babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985
  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. * Represents 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: 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. private static _UpReadOnly;
  2448. private static _ZeroReadOnly;
  2449. /** @hidden */
  2450. _x: number;
  2451. /** @hidden */
  2452. _y: number;
  2453. /** @hidden */
  2454. _z: number;
  2455. /** @hidden */
  2456. _isDirty: boolean;
  2457. /** Gets or sets the x coordinate */
  2458. get x(): number;
  2459. set x(value: number);
  2460. /** Gets or sets the y coordinate */
  2461. get y(): number;
  2462. set y(value: number);
  2463. /** Gets or sets the z coordinate */
  2464. get z(): number;
  2465. set z(value: number);
  2466. /**
  2467. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2468. * @param x defines the first coordinates (on X axis)
  2469. * @param y defines the second coordinates (on Y axis)
  2470. * @param z defines the third coordinates (on Z axis)
  2471. */
  2472. constructor(x?: number, y?: number, z?: number);
  2473. /**
  2474. * Creates a string representation of the Vector3
  2475. * @returns a string with the Vector3 coordinates.
  2476. */
  2477. toString(): string;
  2478. /**
  2479. * Gets the class name
  2480. * @returns the string "Vector3"
  2481. */
  2482. getClassName(): string;
  2483. /**
  2484. * Creates the Vector3 hash code
  2485. * @returns a number which tends to be unique between Vector3 instances
  2486. */
  2487. getHashCode(): number;
  2488. /**
  2489. * Creates an array containing three elements : the coordinates of the Vector3
  2490. * @returns a new array of numbers
  2491. */
  2492. asArray(): number[];
  2493. /**
  2494. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2495. * @param array defines the destination array
  2496. * @param index defines the offset in the destination array
  2497. * @returns the current Vector3
  2498. */
  2499. toArray(array: FloatArray, index?: number): Vector3;
  2500. /**
  2501. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2502. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2503. */
  2504. toQuaternion(): Quaternion;
  2505. /**
  2506. * Adds the given vector to the current Vector3
  2507. * @param otherVector defines the second operand
  2508. * @returns the current updated Vector3
  2509. */
  2510. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Adds the given coordinates to the current Vector3
  2513. * @param x defines the x coordinate of the operand
  2514. * @param y defines the y coordinate of the operand
  2515. * @param z defines the z coordinate of the operand
  2516. * @returns the current updated Vector3
  2517. */
  2518. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2519. /**
  2520. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2521. * @param otherVector defines the second operand
  2522. * @returns the resulting Vector3
  2523. */
  2524. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2525. /**
  2526. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2527. * @param otherVector defines the second operand
  2528. * @param result defines the Vector3 object where to store the result
  2529. * @returns the current Vector3
  2530. */
  2531. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2532. /**
  2533. * Subtract the given vector from the current Vector3
  2534. * @param otherVector defines the second operand
  2535. * @returns the current updated Vector3
  2536. */
  2537. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2538. /**
  2539. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2540. * @param otherVector defines the second operand
  2541. * @returns the resulting Vector3
  2542. */
  2543. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2544. /**
  2545. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2546. * @param otherVector defines the second operand
  2547. * @param result defines the Vector3 object where to store the result
  2548. * @returns the current Vector3
  2549. */
  2550. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2551. /**
  2552. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2553. * @param x defines the x coordinate of the operand
  2554. * @param y defines the y coordinate of the operand
  2555. * @param z defines the z coordinate of the operand
  2556. * @returns the resulting Vector3
  2557. */
  2558. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2559. /**
  2560. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2561. * @param x defines the x coordinate of the operand
  2562. * @param y defines the y coordinate of the operand
  2563. * @param z defines the z coordinate of the operand
  2564. * @param result defines the Vector3 object where to store the result
  2565. * @returns the current Vector3
  2566. */
  2567. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2568. /**
  2569. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2570. * @returns a new Vector3
  2571. */
  2572. negate(): Vector3;
  2573. /**
  2574. * Negate this vector in place
  2575. * @returns this
  2576. */
  2577. negateInPlace(): Vector3;
  2578. /**
  2579. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2580. * @param result defines the Vector3 object where to store the result
  2581. * @returns the current Vector3
  2582. */
  2583. negateToRef(result: Vector3): Vector3;
  2584. /**
  2585. * Multiplies the Vector3 coordinates by the float "scale"
  2586. * @param scale defines the multiplier factor
  2587. * @returns the current updated Vector3
  2588. */
  2589. scaleInPlace(scale: number): Vector3;
  2590. /**
  2591. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2592. * @param scale defines the multiplier factor
  2593. * @returns a new Vector3
  2594. */
  2595. scale(scale: number): Vector3;
  2596. /**
  2597. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2598. * @param scale defines the multiplier factor
  2599. * @param result defines the Vector3 object where to store the result
  2600. * @returns the current Vector3
  2601. */
  2602. scaleToRef(scale: number, result: Vector3): Vector3;
  2603. /**
  2604. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2605. * @param scale defines the scale factor
  2606. * @param result defines the Vector3 object where to store the result
  2607. * @returns the unmodified current Vector3
  2608. */
  2609. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2610. /**
  2611. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2612. * @param origin defines the origin of the projection ray
  2613. * @param plane defines the plane to project to
  2614. * @returns the projected vector3
  2615. */
  2616. projectOnPlane(plane: Plane, origin: 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. * @param result defines the Vector3 where to store the result
  2622. */
  2623. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2624. /**
  2625. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2626. * @param otherVector defines the second operand
  2627. * @returns true if both vectors are equals
  2628. */
  2629. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2630. /**
  2631. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2632. * @param otherVector defines the second operand
  2633. * @param epsilon defines the minimal distance to define values as equals
  2634. * @returns true if both vectors are distant less than epsilon
  2635. */
  2636. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2637. /**
  2638. * Returns true if the current Vector3 coordinates equals the given floats
  2639. * @param x defines the x coordinate of the operand
  2640. * @param y defines the y coordinate of the operand
  2641. * @param z defines the z coordinate of the operand
  2642. * @returns true if both vectors are equals
  2643. */
  2644. equalsToFloats(x: number, y: number, z: number): boolean;
  2645. /**
  2646. * Multiplies the current Vector3 coordinates by the given ones
  2647. * @param otherVector defines the second operand
  2648. * @returns the current updated Vector3
  2649. */
  2650. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2651. /**
  2652. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2653. * @param otherVector defines the second operand
  2654. * @returns the new Vector3
  2655. */
  2656. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2657. /**
  2658. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2659. * @param otherVector defines the second operand
  2660. * @param result defines the Vector3 object where to store the result
  2661. * @returns the current Vector3
  2662. */
  2663. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2664. /**
  2665. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2666. * @param x defines the x coordinate of the operand
  2667. * @param y defines the y coordinate of the operand
  2668. * @param z defines the z coordinate of the operand
  2669. * @returns the new Vector3
  2670. */
  2671. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2672. /**
  2673. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2674. * @param otherVector defines the second operand
  2675. * @returns the new Vector3
  2676. */
  2677. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2678. /**
  2679. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2680. * @param otherVector defines the second operand
  2681. * @param result defines the Vector3 object where to store the result
  2682. * @returns the current Vector3
  2683. */
  2684. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2685. /**
  2686. * Divides the current Vector3 coordinates by the given ones.
  2687. * @param otherVector defines the second operand
  2688. * @returns the current updated Vector3
  2689. */
  2690. divideInPlace(otherVector: Vector3): Vector3;
  2691. /**
  2692. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2693. * @param other defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2699. * @param other defines the second operand
  2700. * @returns the current updated Vector3
  2701. */
  2702. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2705. * @param x defines the x coordinate of the operand
  2706. * @param y defines the y coordinate of the operand
  2707. * @param z defines the z coordinate of the operand
  2708. * @returns the current updated Vector3
  2709. */
  2710. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2711. /**
  2712. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2713. * @param x defines the x coordinate of the operand
  2714. * @param y defines the y coordinate of the operand
  2715. * @param z defines the z coordinate of the operand
  2716. * @returns the current updated Vector3
  2717. */
  2718. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2719. /**
  2720. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2721. * Check if is non uniform within a certain amount of decimal places to account for this
  2722. * @param epsilon the amount the values can differ
  2723. * @returns if the the vector is non uniform to a certain number of decimal places
  2724. */
  2725. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2726. /**
  2727. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2728. */
  2729. get isNonUniform(): boolean;
  2730. /**
  2731. * Gets a new Vector3 from current Vector3 floored values
  2732. * @returns a new Vector3
  2733. */
  2734. floor(): Vector3;
  2735. /**
  2736. * Gets a new Vector3 from current Vector3 floored values
  2737. * @returns a new Vector3
  2738. */
  2739. fract(): Vector3;
  2740. /**
  2741. * Gets the length of the Vector3
  2742. * @returns the length of the Vector3
  2743. */
  2744. length(): number;
  2745. /**
  2746. * Gets the squared length of the Vector3
  2747. * @returns squared length of the Vector3
  2748. */
  2749. lengthSquared(): number;
  2750. /**
  2751. * Normalize the current Vector3.
  2752. * Please note that this is an in place operation.
  2753. * @returns the current updated Vector3
  2754. */
  2755. normalize(): Vector3;
  2756. /**
  2757. * Reorders the x y z properties of the vector in place
  2758. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2759. * @returns the current updated vector
  2760. */
  2761. reorderInPlace(order: string): this;
  2762. /**
  2763. * Rotates the vector around 0,0,0 by a quaternion
  2764. * @param quaternion the rotation quaternion
  2765. * @param result vector to store the result
  2766. * @returns the resulting vector
  2767. */
  2768. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2769. /**
  2770. * Rotates a vector around a given point
  2771. * @param quaternion the rotation quaternion
  2772. * @param point the point to rotate around
  2773. * @param result vector to store the result
  2774. * @returns the resulting vector
  2775. */
  2776. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2777. /**
  2778. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2779. * The cross product is then orthogonal to both current and "other"
  2780. * @param other defines the right operand
  2781. * @returns the cross product
  2782. */
  2783. cross(other: Vector3): Vector3;
  2784. /**
  2785. * Normalize the current Vector3 with the given input length.
  2786. * Please note that this is an in place operation.
  2787. * @param len the length of the vector
  2788. * @returns the current updated Vector3
  2789. */
  2790. normalizeFromLength(len: number): Vector3;
  2791. /**
  2792. * Normalize the current Vector3 to a new vector
  2793. * @returns the new Vector3
  2794. */
  2795. normalizeToNew(): Vector3;
  2796. /**
  2797. * Normalize the current Vector3 to the reference
  2798. * @param reference define the Vector3 to update
  2799. * @returns the updated Vector3
  2800. */
  2801. normalizeToRef(reference: Vector3): Vector3;
  2802. /**
  2803. * Creates a new Vector3 copied from the current Vector3
  2804. * @returns the new Vector3
  2805. */
  2806. clone(): Vector3;
  2807. /**
  2808. * Copies the given vector coordinates to the current Vector3 ones
  2809. * @param source defines the source Vector3
  2810. * @returns the current updated Vector3
  2811. */
  2812. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2813. /**
  2814. * Copies the given floats to the current Vector3 coordinates
  2815. * @param x defines the x coordinate of the operand
  2816. * @param y defines the y coordinate of the operand
  2817. * @param z defines the z coordinate of the operand
  2818. * @returns the current updated Vector3
  2819. */
  2820. copyFromFloats(x: number, y: number, z: number): Vector3;
  2821. /**
  2822. * Copies the given floats to the current Vector3 coordinates
  2823. * @param x defines the x coordinate of the operand
  2824. * @param y defines the y coordinate of the operand
  2825. * @param z defines the z coordinate of the operand
  2826. * @returns the current updated Vector3
  2827. */
  2828. set(x: number, y: number, z: number): Vector3;
  2829. /**
  2830. * Copies the given float to the current Vector3 coordinates
  2831. * @param v defines the x, y and z coordinates of the operand
  2832. * @returns the current updated Vector3
  2833. */
  2834. setAll(v: number): Vector3;
  2835. /**
  2836. * Get the clip factor between two vectors
  2837. * @param vector0 defines the first operand
  2838. * @param vector1 defines the second operand
  2839. * @param axis defines the axis to use
  2840. * @param size defines the size along the axis
  2841. * @returns the clip factor
  2842. */
  2843. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2844. /**
  2845. * Get angle between two vectors
  2846. * @param vector0 angle between vector0 and vector1
  2847. * @param vector1 angle between vector0 and vector1
  2848. * @param normal direction of the normal
  2849. * @return the angle between vector0 and vector1
  2850. */
  2851. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2852. /**
  2853. * Returns a new Vector3 set from the index "offset" of the given array
  2854. * @param array defines the source array
  2855. * @param offset defines the offset in the source array
  2856. * @returns the new Vector3
  2857. */
  2858. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2859. /**
  2860. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2861. * @param array defines the source array
  2862. * @param offset defines the offset in the source array
  2863. * @returns the new Vector3
  2864. * @deprecated Please use FromArray instead.
  2865. */
  2866. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2867. /**
  2868. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2869. * @param array defines the source array
  2870. * @param offset defines the offset in the source array
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2874. /**
  2875. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  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. * @deprecated Please use FromArrayToRef instead.
  2880. */
  2881. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2882. /**
  2883. * Sets the given vector "result" with the given floats.
  2884. * @param x defines the x coordinate of the source
  2885. * @param y defines the y coordinate of the source
  2886. * @param z defines the z coordinate of the source
  2887. * @param result defines the Vector3 where to store the result
  2888. */
  2889. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2890. /**
  2891. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2892. * @returns a new empty Vector3
  2893. */
  2894. static Zero(): Vector3;
  2895. /**
  2896. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2897. * @returns a new unit Vector3
  2898. */
  2899. static One(): Vector3;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2902. * @returns a new up Vector3
  2903. */
  2904. static Up(): Vector3;
  2905. /**
  2906. * Gets a up Vector3 that must not be updated
  2907. */
  2908. static get UpReadOnly(): DeepImmutable<Vector3>;
  2909. /**
  2910. * Gets a zero Vector3 that must not be updated
  2911. */
  2912. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2913. /**
  2914. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2915. * @returns a new down Vector3
  2916. */
  2917. static Down(): Vector3;
  2918. /**
  2919. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2920. * @param rightHandedSystem is the scene right-handed (negative z)
  2921. * @returns a new forward Vector3
  2922. */
  2923. static Forward(rightHandedSystem?: boolean): Vector3;
  2924. /**
  2925. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2926. * @param rightHandedSystem is the scene right-handed (negative-z)
  2927. * @returns a new forward Vector3
  2928. */
  2929. static Backward(rightHandedSystem?: boolean): Vector3;
  2930. /**
  2931. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2932. * @returns a new right Vector3
  2933. */
  2934. static Right(): Vector3;
  2935. /**
  2936. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2937. * @returns a new left Vector3
  2938. */
  2939. static Left(): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2942. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2943. * @param vector defines the Vector3 to transform
  2944. * @param transformation defines the transformation matrix
  2945. * @returns the transformed Vector3
  2946. */
  2947. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2950. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2951. * @param vector defines the Vector3 to transform
  2952. * @param transformation defines the transformation matrix
  2953. * @param result defines the Vector3 where to store the result
  2954. */
  2955. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2956. /**
  2957. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2958. * This method computes tranformed coordinates only, not transformed direction vectors
  2959. * @param x define the x coordinate of the source vector
  2960. * @param y define the y coordinate of the source vector
  2961. * @param z define the z coordinate of the source vector
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2968. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2969. * @param vector defines the Vector3 to transform
  2970. * @param transformation defines the transformation matrix
  2971. * @returns the new Vector3
  2972. */
  2973. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2976. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2977. * @param vector defines the Vector3 to transform
  2978. * @param transformation defines the transformation matrix
  2979. * @param result defines the Vector3 where to store the result
  2980. */
  2981. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2982. /**
  2983. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2984. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2985. * @param x define the x coordinate of the source vector
  2986. * @param y define the y coordinate of the source vector
  2987. * @param z define the z coordinate of the source vector
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2994. * @param value1 defines the first control point
  2995. * @param value2 defines the second control point
  2996. * @param value3 defines the third control point
  2997. * @param value4 defines the fourth control point
  2998. * @param amount defines the amount on the spline to use
  2999. * @returns the new Vector3
  3000. */
  3001. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3002. /**
  3003. * 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"
  3004. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3005. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3006. * @param value defines the current value
  3007. * @param min defines the lower range value
  3008. * @param max defines the upper range value
  3009. * @returns the new Vector3
  3010. */
  3011. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * 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"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @param result defines the Vector3 where to store the result
  3020. */
  3021. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3022. /**
  3023. * Checks if a given vector is inside a specific range
  3024. * @param v defines the vector to test
  3025. * @param min defines the minimum range
  3026. * @param max defines the maximum range
  3027. */
  3028. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3029. /**
  3030. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3031. * @param value1 defines the first control point
  3032. * @param tangent1 defines the first tangent vector
  3033. * @param value2 defines the second control point
  3034. * @param tangent2 defines the second tangent vector
  3035. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3036. * @returns the new Vector3
  3037. */
  3038. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3041. * @param start defines the start value
  3042. * @param end defines the end value
  3043. * @param amount max defines amount between both (between 0 and 1)
  3044. * @returns the new Vector3
  3045. */
  3046. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3047. /**
  3048. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3049. * @param start defines the start value
  3050. * @param end defines the end value
  3051. * @param amount max defines amount between both (between 0 and 1)
  3052. * @param result defines the Vector3 where to store the result
  3053. */
  3054. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3055. /**
  3056. * Returns the dot product (float) between the vectors "left" and "right"
  3057. * @param left defines the left operand
  3058. * @param right defines the right operand
  3059. * @returns the dot product
  3060. */
  3061. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3062. /**
  3063. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3064. * The cross product is then orthogonal to both "left" and "right"
  3065. * @param left defines the left operand
  3066. * @param right defines the right operand
  3067. * @returns the cross product
  3068. */
  3069. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3070. /**
  3071. * Sets the given vector "result" with the cross product of "left" and "right"
  3072. * The cross product is then orthogonal to both "left" and "right"
  3073. * @param left defines the left operand
  3074. * @param right defines the right operand
  3075. * @param result defines the Vector3 where to store the result
  3076. */
  3077. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3078. /**
  3079. * Returns a new Vector3 as the normalization of the given vector
  3080. * @param vector defines the Vector3 to normalize
  3081. * @returns the new Vector3
  3082. */
  3083. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3084. /**
  3085. * Sets the given vector "result" with the normalization of the given first vector
  3086. * @param vector defines the Vector3 to normalize
  3087. * @param result defines the Vector3 where to store the result
  3088. */
  3089. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3090. /**
  3091. * Project a Vector3 onto screen space
  3092. * @param vector defines the Vector3 to project
  3093. * @param world defines the world matrix to use
  3094. * @param transform defines the transform (view x projection) matrix to use
  3095. * @param viewport defines the screen viewport to use
  3096. * @returns the new Vector3
  3097. */
  3098. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3099. /** @hidden */
  3100. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3101. /**
  3102. * Unproject from screen space to object space
  3103. * @param source defines the screen space Vector3 to use
  3104. * @param viewportWidth defines the current width of the viewport
  3105. * @param viewportHeight defines the current height of the viewport
  3106. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3107. * @param transform defines the transform (view x projection) matrix to use
  3108. * @returns the new Vector3
  3109. */
  3110. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param view defines the view matrix to use
  3118. * @param projection defines the projection matrix to use
  3119. * @returns the new Vector3
  3120. */
  3121. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3122. /**
  3123. * Unproject from screen space to object space
  3124. * @param source defines the screen space Vector3 to use
  3125. * @param viewportWidth defines the current width of the viewport
  3126. * @param viewportHeight defines the current height of the viewport
  3127. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3128. * @param view defines the view matrix to use
  3129. * @param projection defines the projection matrix to use
  3130. * @param result defines the Vector3 where to store the result
  3131. */
  3132. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3133. /**
  3134. * Unproject from screen space to object space
  3135. * @param sourceX defines the screen space x coordinate to use
  3136. * @param sourceY defines the screen space y coordinate to use
  3137. * @param sourceZ defines the screen space z coordinate to use
  3138. * @param viewportWidth defines the current width of the viewport
  3139. * @param viewportHeight defines the current height of the viewport
  3140. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3141. * @param view defines the view matrix to use
  3142. * @param projection defines the projection matrix to use
  3143. * @param result defines the Vector3 where to store the result
  3144. */
  3145. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3146. /**
  3147. * Gets the minimal coordinate values between two Vector3
  3148. * @param left defines the first operand
  3149. * @param right defines the second operand
  3150. * @returns the new Vector3
  3151. */
  3152. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3153. /**
  3154. * Gets the maximal 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 Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3160. /**
  3161. * Returns the distance between the vectors "value1" and "value2"
  3162. * @param value1 defines the first operand
  3163. * @param value2 defines the second operand
  3164. * @returns the distance
  3165. */
  3166. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3167. /**
  3168. * Returns the squared distance between the vectors "value1" and "value2"
  3169. * @param value1 defines the first operand
  3170. * @param value2 defines the second operand
  3171. * @returns the squared distance
  3172. */
  3173. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3174. /**
  3175. * Returns a new Vector3 located at the center between "value1" and "value2"
  3176. * @param value1 defines the first operand
  3177. * @param value2 defines the second operand
  3178. * @returns the new Vector3
  3179. */
  3180. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3181. /**
  3182. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3183. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3184. * to something in order to rotate it from its local system to the given target system
  3185. * Note: axis1, axis2 and axis3 are normalized during this operation
  3186. * @param axis1 defines the first axis
  3187. * @param axis2 defines the second axis
  3188. * @param axis3 defines the third axis
  3189. * @returns a new Vector3
  3190. */
  3191. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3192. /**
  3193. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3194. * @param axis1 defines the first axis
  3195. * @param axis2 defines the second axis
  3196. * @param axis3 defines the third axis
  3197. * @param ref defines the Vector3 where to store the result
  3198. */
  3199. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3200. }
  3201. /**
  3202. * Vector4 class created for EulerAngle class conversion to Quaternion
  3203. */
  3204. export class Vector4 {
  3205. /** x value of the vector */
  3206. x: number;
  3207. /** y value of the vector */
  3208. y: number;
  3209. /** z value of the vector */
  3210. z: number;
  3211. /** w value of the vector */
  3212. w: number;
  3213. /**
  3214. * Creates a Vector4 object from the given floats.
  3215. * @param x x value of the vector
  3216. * @param y y value of the vector
  3217. * @param z z value of the vector
  3218. * @param w w value of the vector
  3219. */
  3220. constructor(
  3221. /** x value of the vector */
  3222. x: number,
  3223. /** y value of the vector */
  3224. y: number,
  3225. /** z value of the vector */
  3226. z: number,
  3227. /** w value of the vector */
  3228. w: number);
  3229. /**
  3230. * Returns the string with the Vector4 coordinates.
  3231. * @returns a string containing all the vector values
  3232. */
  3233. toString(): string;
  3234. /**
  3235. * Returns the string "Vector4".
  3236. * @returns "Vector4"
  3237. */
  3238. getClassName(): string;
  3239. /**
  3240. * Returns the Vector4 hash code.
  3241. * @returns a unique hash code
  3242. */
  3243. getHashCode(): number;
  3244. /**
  3245. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3246. * @returns the resulting array
  3247. */
  3248. asArray(): number[];
  3249. /**
  3250. * Populates the given array from the given index with the Vector4 coordinates.
  3251. * @param array array to populate
  3252. * @param index index of the array to start at (default: 0)
  3253. * @returns the Vector4.
  3254. */
  3255. toArray(array: FloatArray, index?: number): Vector4;
  3256. /**
  3257. * Adds the given vector to the current Vector4.
  3258. * @param otherVector the vector to add
  3259. * @returns the updated Vector4.
  3260. */
  3261. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3264. * @param otherVector the vector to add
  3265. * @returns the resulting vector
  3266. */
  3267. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3268. /**
  3269. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3270. * @param otherVector the vector to add
  3271. * @param result the vector to store the result
  3272. * @returns the current Vector4.
  3273. */
  3274. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3275. /**
  3276. * Subtract in place the given vector from the current Vector4.
  3277. * @param otherVector the vector to subtract
  3278. * @returns the updated Vector4.
  3279. */
  3280. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3283. * @param otherVector the vector to add
  3284. * @returns the new vector with the result
  3285. */
  3286. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3287. /**
  3288. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3289. * @param otherVector the vector to subtract
  3290. * @param result the vector to store the result
  3291. * @returns the current Vector4.
  3292. */
  3293. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3294. /**
  3295. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3296. */
  3297. /**
  3298. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3299. * @param x value to subtract
  3300. * @param y value to subtract
  3301. * @param z value to subtract
  3302. * @param w value to subtract
  3303. * @returns new vector containing the result
  3304. */
  3305. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3306. /**
  3307. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3308. * @param x value to subtract
  3309. * @param y value to subtract
  3310. * @param z value to subtract
  3311. * @param w value to subtract
  3312. * @param result the vector to store the result in
  3313. * @returns the current Vector4.
  3314. */
  3315. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3316. /**
  3317. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3318. * @returns a new vector with the negated values
  3319. */
  3320. negate(): Vector4;
  3321. /**
  3322. * Negate this vector in place
  3323. * @returns this
  3324. */
  3325. negateInPlace(): Vector4;
  3326. /**
  3327. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3328. * @param result defines the Vector3 object where to store the result
  3329. * @returns the current Vector4
  3330. */
  3331. negateToRef(result: Vector4): Vector4;
  3332. /**
  3333. * Multiplies the current Vector4 coordinates by scale (float).
  3334. * @param scale the number to scale with
  3335. * @returns the updated Vector4.
  3336. */
  3337. scaleInPlace(scale: number): Vector4;
  3338. /**
  3339. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3340. * @param scale the number to scale with
  3341. * @returns a new vector with the result
  3342. */
  3343. scale(scale: number): Vector4;
  3344. /**
  3345. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3346. * @param scale the number to scale with
  3347. * @param result a vector to store the result in
  3348. * @returns the current Vector4.
  3349. */
  3350. scaleToRef(scale: number, result: Vector4): Vector4;
  3351. /**
  3352. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3353. * @param scale defines the scale factor
  3354. * @param result defines the Vector4 object where to store the result
  3355. * @returns the unmodified current Vector4
  3356. */
  3357. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3358. /**
  3359. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3360. * @param otherVector the vector to compare against
  3361. * @returns true if they are equal
  3362. */
  3363. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3364. /**
  3365. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3366. * @param otherVector vector to compare against
  3367. * @param epsilon (Default: very small number)
  3368. * @returns true if they are equal
  3369. */
  3370. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3371. /**
  3372. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3373. * @param x x value to compare against
  3374. * @param y y value to compare against
  3375. * @param z z value to compare against
  3376. * @param w w value to compare against
  3377. * @returns true if equal
  3378. */
  3379. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3380. /**
  3381. * Multiplies in place the current Vector4 by the given one.
  3382. * @param otherVector vector to multiple with
  3383. * @returns the updated Vector4.
  3384. */
  3385. multiplyInPlace(otherVector: Vector4): Vector4;
  3386. /**
  3387. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3388. * @param otherVector vector to multiple with
  3389. * @returns resulting new vector
  3390. */
  3391. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3392. /**
  3393. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3394. * @param otherVector vector to multiple with
  3395. * @param result vector to store the result
  3396. * @returns the current Vector4.
  3397. */
  3398. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3399. /**
  3400. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3401. * @param x x value multiply with
  3402. * @param y y value multiply with
  3403. * @param z z value multiply with
  3404. * @param w w value multiply with
  3405. * @returns resulting new vector
  3406. */
  3407. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3408. /**
  3409. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3410. * @param otherVector vector to devide with
  3411. * @returns resulting new vector
  3412. */
  3413. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3414. /**
  3415. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3416. * @param otherVector vector to devide with
  3417. * @param result vector to store the result
  3418. * @returns the current Vector4.
  3419. */
  3420. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3421. /**
  3422. * Divides the current Vector3 coordinates by the given ones.
  3423. * @param otherVector vector to devide with
  3424. * @returns the updated Vector3.
  3425. */
  3426. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3427. /**
  3428. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3429. * @param other defines the second operand
  3430. * @returns the current updated Vector4
  3431. */
  3432. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3435. * @param other defines the second operand
  3436. * @returns the current updated Vector4
  3437. */
  3438. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3439. /**
  3440. * Gets a new Vector4 from current Vector4 floored values
  3441. * @returns a new Vector4
  3442. */
  3443. floor(): Vector4;
  3444. /**
  3445. * Gets a new Vector4 from current Vector3 floored values
  3446. * @returns a new Vector4
  3447. */
  3448. fract(): Vector4;
  3449. /**
  3450. * Returns the Vector4 length (float).
  3451. * @returns the length
  3452. */
  3453. length(): number;
  3454. /**
  3455. * Returns the Vector4 squared length (float).
  3456. * @returns the length squared
  3457. */
  3458. lengthSquared(): number;
  3459. /**
  3460. * Normalizes in place the Vector4.
  3461. * @returns the updated Vector4.
  3462. */
  3463. normalize(): Vector4;
  3464. /**
  3465. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3466. * @returns this converted to a new vector3
  3467. */
  3468. toVector3(): Vector3;
  3469. /**
  3470. * Returns a new Vector4 copied from the current one.
  3471. * @returns the new cloned vector
  3472. */
  3473. clone(): Vector4;
  3474. /**
  3475. * Updates the current Vector4 with the given one coordinates.
  3476. * @param source the source vector to copy from
  3477. * @returns the updated Vector4.
  3478. */
  3479. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the current Vector4 coordinates with the given floats.
  3482. * @param x float to copy from
  3483. * @param y float to copy from
  3484. * @param z float to copy from
  3485. * @param w float to copy from
  3486. * @returns the updated Vector4.
  3487. */
  3488. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3489. /**
  3490. * Updates the current Vector4 coordinates with the given floats.
  3491. * @param x float to set from
  3492. * @param y float to set from
  3493. * @param z float to set from
  3494. * @param w float to set from
  3495. * @returns the updated Vector4.
  3496. */
  3497. set(x: number, y: number, z: number, w: number): Vector4;
  3498. /**
  3499. * Copies the given float to the current Vector3 coordinates
  3500. * @param v defines the x, y, z and w coordinates of the operand
  3501. * @returns the current updated Vector3
  3502. */
  3503. setAll(v: number): Vector4;
  3504. /**
  3505. * Returns a new Vector4 set from the starting index of the given array.
  3506. * @param array the array to pull values from
  3507. * @param offset the offset into the array to start at
  3508. * @returns the new vector
  3509. */
  3510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3511. /**
  3512. * Updates the given vector "result" 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. * @param result the vector to store the result in
  3516. */
  3517. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3518. /**
  3519. * Updates the given vector "result" from the starting index of the given Float32Array.
  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 FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3525. /**
  3526. * Updates the given vector "result" coordinates from the given floats.
  3527. * @param x float to set from
  3528. * @param y float to set from
  3529. * @param z float to set from
  3530. * @param w float to set from
  3531. * @param result the vector to the floats in
  3532. */
  3533. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3534. /**
  3535. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3536. * @returns the new vector
  3537. */
  3538. static Zero(): Vector4;
  3539. /**
  3540. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3541. * @returns the new vector
  3542. */
  3543. static One(): Vector4;
  3544. /**
  3545. * Returns a new normalized Vector4 from the given one.
  3546. * @param vector the vector to normalize
  3547. * @returns the vector
  3548. */
  3549. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3550. /**
  3551. * Updates the given vector "result" from the normalization of the given one.
  3552. * @param vector the vector to normalize
  3553. * @param result the vector to store the result in
  3554. */
  3555. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3556. /**
  3557. * Returns a vector with the minimum values from the left and right vectors
  3558. * @param left left vector to minimize
  3559. * @param right right vector to minimize
  3560. * @returns a new vector with the minimum of the left and right vector values
  3561. */
  3562. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3563. /**
  3564. * Returns a vector with the maximum values from the left and right vectors
  3565. * @param left left vector to maximize
  3566. * @param right right vector to maximize
  3567. * @returns a new vector with the maximum of the left and right vector values
  3568. */
  3569. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3570. /**
  3571. * Returns the distance (float) between the vectors "value1" and "value2".
  3572. * @param value1 value to calulate the distance between
  3573. * @param value2 value to calulate the distance between
  3574. * @return the distance between the two vectors
  3575. */
  3576. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3577. /**
  3578. * Returns the squared 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 squared
  3582. */
  3583. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3584. /**
  3585. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3586. * @param value1 value to calulate the center between
  3587. * @param value2 value to calulate the center between
  3588. * @return the center between the two vectors
  3589. */
  3590. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3591. /**
  3592. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3593. * This methods computes transformed normalized direction vectors only.
  3594. * @param vector the vector to transform
  3595. * @param transformation the transformation matrix to apply
  3596. * @returns the new vector
  3597. */
  3598. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3599. /**
  3600. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3601. * This methods computes transformed normalized direction vectors only.
  3602. * @param vector the vector to transform
  3603. * @param transformation the transformation matrix to apply
  3604. * @param result the vector to store the result in
  3605. */
  3606. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3607. /**
  3608. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3609. * This methods computes transformed normalized direction vectors only.
  3610. * @param x value to transform
  3611. * @param y value to transform
  3612. * @param z value to transform
  3613. * @param w value to transform
  3614. * @param transformation the transformation matrix to apply
  3615. * @param result the vector to store the results in
  3616. */
  3617. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3618. /**
  3619. * Creates a new Vector4 from a Vector3
  3620. * @param source defines the source data
  3621. * @param w defines the 4th component (default is 0)
  3622. * @returns a new Vector4
  3623. */
  3624. static FromVector3(source: Vector3, w?: number): Vector4;
  3625. }
  3626. /**
  3627. * Class used to store quaternion data
  3628. * @see https://en.wikipedia.org/wiki/Quaternion
  3629. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3630. */
  3631. export class Quaternion {
  3632. /** @hidden */
  3633. _x: number;
  3634. /** @hidden */
  3635. _y: number;
  3636. /** @hidden */
  3637. _z: number;
  3638. /** @hidden */
  3639. _w: number;
  3640. /** @hidden */
  3641. _isDirty: boolean;
  3642. /** Gets or sets the x coordinate */
  3643. get x(): number;
  3644. set x(value: number);
  3645. /** Gets or sets the y coordinate */
  3646. get y(): number;
  3647. set y(value: number);
  3648. /** Gets or sets the z coordinate */
  3649. get z(): number;
  3650. set z(value: number);
  3651. /** Gets or sets the w coordinate */
  3652. get w(): number;
  3653. set w(value: number);
  3654. /**
  3655. * Creates a new Quaternion from the given floats
  3656. * @param x defines the first component (0 by default)
  3657. * @param y defines the second component (0 by default)
  3658. * @param z defines the third component (0 by default)
  3659. * @param w defines the fourth component (1.0 by default)
  3660. */
  3661. constructor(x?: number, y?: number, z?: number, w?: number);
  3662. /**
  3663. * Gets a string representation for the current quaternion
  3664. * @returns a string with the Quaternion coordinates
  3665. */
  3666. toString(): string;
  3667. /**
  3668. * Gets the class name of the quaternion
  3669. * @returns the string "Quaternion"
  3670. */
  3671. getClassName(): string;
  3672. /**
  3673. * Gets a hash code for this quaternion
  3674. * @returns the quaternion hash code
  3675. */
  3676. getHashCode(): number;
  3677. /**
  3678. * Copy the quaternion to an array
  3679. * @returns a new array populated with 4 elements from the quaternion coordinates
  3680. */
  3681. asArray(): number[];
  3682. /**
  3683. * Check if two quaternions are equals
  3684. * @param otherQuaternion defines the second operand
  3685. * @return true if the current quaternion and the given one coordinates are strictly equals
  3686. */
  3687. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3688. /**
  3689. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3690. * @param otherQuaternion defines the other quaternion
  3691. * @param epsilon defines the minimal distance to consider equality
  3692. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3693. */
  3694. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3695. /**
  3696. * Clone the current quaternion
  3697. * @returns a new quaternion copied from the current one
  3698. */
  3699. clone(): Quaternion;
  3700. /**
  3701. * Copy a quaternion to the current one
  3702. * @param other defines the other quaternion
  3703. * @returns the updated current quaternion
  3704. */
  3705. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3706. /**
  3707. * Updates the current quaternion with the given float coordinates
  3708. * @param x defines the x coordinate
  3709. * @param y defines the y coordinate
  3710. * @param z defines the z coordinate
  3711. * @param w defines the w coordinate
  3712. * @returns the updated current quaternion
  3713. */
  3714. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3715. /**
  3716. * Updates the current quaternion from the given float coordinates
  3717. * @param x defines the x coordinate
  3718. * @param y defines the y coordinate
  3719. * @param z defines the z coordinate
  3720. * @param w defines the w coordinate
  3721. * @returns the updated current quaternion
  3722. */
  3723. set(x: number, y: number, z: number, w: number): Quaternion;
  3724. /**
  3725. * Adds two quaternions
  3726. * @param other defines the second operand
  3727. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3728. */
  3729. add(other: DeepImmutable<Quaternion>): Quaternion;
  3730. /**
  3731. * Add a quaternion to the current one
  3732. * @param other defines the quaternion to add
  3733. * @returns the current quaternion
  3734. */
  3735. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3736. /**
  3737. * Subtract two quaternions
  3738. * @param other defines the second operand
  3739. * @returns a new quaternion as the subtraction result of the given one from the current one
  3740. */
  3741. subtract(other: Quaternion): Quaternion;
  3742. /**
  3743. * Multiplies the current quaternion by a scale factor
  3744. * @param value defines the scale factor
  3745. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3746. */
  3747. scale(value: number): Quaternion;
  3748. /**
  3749. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3750. * @param scale defines the scale factor
  3751. * @param result defines the Quaternion object where to store the result
  3752. * @returns the unmodified current quaternion
  3753. */
  3754. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3755. /**
  3756. * Multiplies in place the current quaternion by a scale factor
  3757. * @param value defines the scale factor
  3758. * @returns the current modified quaternion
  3759. */
  3760. scaleInPlace(value: number): Quaternion;
  3761. /**
  3762. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3763. * @param scale defines the scale factor
  3764. * @param result defines the Quaternion object where to store the result
  3765. * @returns the unmodified current quaternion
  3766. */
  3767. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3768. /**
  3769. * Multiplies two quaternions
  3770. * @param q1 defines the second operand
  3771. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3772. */
  3773. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3774. /**
  3775. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3776. * @param q1 defines the second operand
  3777. * @param result defines the target quaternion
  3778. * @returns the current quaternion
  3779. */
  3780. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3781. /**
  3782. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3783. * @param q1 defines the second operand
  3784. * @returns the currentupdated quaternion
  3785. */
  3786. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3787. /**
  3788. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3789. * @param ref defines the target quaternion
  3790. * @returns the current quaternion
  3791. */
  3792. conjugateToRef(ref: Quaternion): Quaternion;
  3793. /**
  3794. * Conjugates in place (1-q) the current quaternion
  3795. * @returns the current updated quaternion
  3796. */
  3797. conjugateInPlace(): Quaternion;
  3798. /**
  3799. * Conjugates in place (1-q) the current quaternion
  3800. * @returns a new quaternion
  3801. */
  3802. conjugate(): Quaternion;
  3803. /**
  3804. * Gets length of current quaternion
  3805. * @returns the quaternion length (float)
  3806. */
  3807. length(): number;
  3808. /**
  3809. * Normalize in place the current quaternion
  3810. * @returns the current updated quaternion
  3811. */
  3812. normalize(): Quaternion;
  3813. /**
  3814. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3815. * @param order is a reserved parameter and is ignore for now
  3816. * @returns a new Vector3 containing the Euler angles
  3817. */
  3818. toEulerAngles(order?: string): Vector3;
  3819. /**
  3820. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3821. * @param result defines the vector which will be filled with the Euler angles
  3822. * @param order is a reserved parameter and is ignore for now
  3823. * @returns the current unchanged quaternion
  3824. */
  3825. toEulerAnglesToRef(result: Vector3): Quaternion;
  3826. /**
  3827. * Updates the given rotation matrix with the current quaternion values
  3828. * @param result defines the target matrix
  3829. * @returns the current unchanged quaternion
  3830. */
  3831. toRotationMatrix(result: Matrix): Quaternion;
  3832. /**
  3833. * Updates the current quaternion from the given rotation matrix values
  3834. * @param matrix defines the source matrix
  3835. * @returns the current updated quaternion
  3836. */
  3837. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3838. /**
  3839. * Creates a new quaternion from a rotation matrix
  3840. * @param matrix defines the source matrix
  3841. * @returns a new quaternion created from the given rotation matrix values
  3842. */
  3843. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3844. /**
  3845. * Updates the given quaternion with the given rotation matrix values
  3846. * @param matrix defines the source matrix
  3847. * @param result defines the target quaternion
  3848. */
  3849. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3850. /**
  3851. * Returns the dot product (float) between the quaternions "left" and "right"
  3852. * @param left defines the left operand
  3853. * @param right defines the right operand
  3854. * @returns the dot product
  3855. */
  3856. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3857. /**
  3858. * Checks if the two quaternions are close to each other
  3859. * @param quat0 defines the first quaternion to check
  3860. * @param quat1 defines the second quaternion to check
  3861. * @returns true if the two quaternions are close to each other
  3862. */
  3863. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3864. /**
  3865. * Creates an empty quaternion
  3866. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3867. */
  3868. static Zero(): Quaternion;
  3869. /**
  3870. * Inverse a given quaternion
  3871. * @param q defines the source quaternion
  3872. * @returns a new quaternion as the inverted current quaternion
  3873. */
  3874. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3875. /**
  3876. * Inverse a given quaternion
  3877. * @param q defines the source quaternion
  3878. * @param result the quaternion the result will be stored in
  3879. * @returns the result quaternion
  3880. */
  3881. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3882. /**
  3883. * Creates an identity quaternion
  3884. * @returns the identity quaternion
  3885. */
  3886. static Identity(): Quaternion;
  3887. /**
  3888. * Gets a boolean indicating if the given quaternion is identity
  3889. * @param quaternion defines the quaternion to check
  3890. * @returns true if the quaternion is identity
  3891. */
  3892. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3893. /**
  3894. * Creates a quaternion from a rotation around an axis
  3895. * @param axis defines the axis to use
  3896. * @param angle defines the angle to use
  3897. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3898. */
  3899. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3900. /**
  3901. * Creates a rotation around an axis and stores it into the given quaternion
  3902. * @param axis defines the axis to use
  3903. * @param angle defines the angle to use
  3904. * @param result defines the target quaternion
  3905. * @returns the target quaternion
  3906. */
  3907. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3908. /**
  3909. * Creates a new quaternion from data stored into an array
  3910. * @param array defines the data source
  3911. * @param offset defines the offset in the source array where the data starts
  3912. * @returns a new quaternion
  3913. */
  3914. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3915. /**
  3916. * Updates the given quaternion "result" from the starting index of the given array.
  3917. * @param array the array to pull values from
  3918. * @param offset the offset into the array to start at
  3919. * @param result the quaternion to store the result in
  3920. */
  3921. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3922. /**
  3923. * Create a quaternion from Euler rotation angles
  3924. * @param x Pitch
  3925. * @param y Yaw
  3926. * @param z Roll
  3927. * @returns the new Quaternion
  3928. */
  3929. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3930. /**
  3931. * Updates a quaternion from Euler rotation angles
  3932. * @param x Pitch
  3933. * @param y Yaw
  3934. * @param z Roll
  3935. * @param result the quaternion to store the result
  3936. * @returns the updated quaternion
  3937. */
  3938. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3939. /**
  3940. * Create a quaternion from Euler rotation vector
  3941. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3942. * @returns the new Quaternion
  3943. */
  3944. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3945. /**
  3946. * Updates a quaternion from Euler rotation vector
  3947. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3948. * @param result the quaternion to store the result
  3949. * @returns the updated quaternion
  3950. */
  3951. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3952. /**
  3953. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3954. * @param yaw defines the rotation around Y axis
  3955. * @param pitch defines the rotation around X axis
  3956. * @param roll defines the rotation around Z axis
  3957. * @returns the new quaternion
  3958. */
  3959. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3960. /**
  3961. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3962. * @param yaw defines the rotation around Y axis
  3963. * @param pitch defines the rotation around X axis
  3964. * @param roll defines the rotation around Z axis
  3965. * @param result defines the target quaternion
  3966. */
  3967. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3968. /**
  3969. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3970. * @param alpha defines the rotation around first axis
  3971. * @param beta defines the rotation around second axis
  3972. * @param gamma defines the rotation around third axis
  3973. * @returns the new quaternion
  3974. */
  3975. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3976. /**
  3977. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3978. * @param alpha defines the rotation around first axis
  3979. * @param beta defines the rotation around second axis
  3980. * @param gamma defines the rotation around third axis
  3981. * @param result defines the target quaternion
  3982. */
  3983. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3984. /**
  3985. * 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)
  3986. * @param axis1 defines the first axis
  3987. * @param axis2 defines the second axis
  3988. * @param axis3 defines the third axis
  3989. * @returns the new quaternion
  3990. */
  3991. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3992. /**
  3993. * 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
  3994. * @param axis1 defines the first axis
  3995. * @param axis2 defines the second axis
  3996. * @param axis3 defines the third axis
  3997. * @param ref defines the target quaternion
  3998. */
  3999. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4000. /**
  4001. * Interpolates between two quaternions
  4002. * @param left defines first quaternion
  4003. * @param right defines second quaternion
  4004. * @param amount defines the gradient to use
  4005. * @returns the new interpolated quaternion
  4006. */
  4007. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4008. /**
  4009. * Interpolates between two quaternions and stores it into a target quaternion
  4010. * @param left defines first quaternion
  4011. * @param right defines second quaternion
  4012. * @param amount defines the gradient to use
  4013. * @param result defines the target quaternion
  4014. */
  4015. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4016. /**
  4017. * Interpolate between two quaternions using Hermite interpolation
  4018. * @param value1 defines first quaternion
  4019. * @param tangent1 defines the incoming tangent
  4020. * @param value2 defines second quaternion
  4021. * @param tangent2 defines the outgoing tangent
  4022. * @param amount defines the target quaternion
  4023. * @returns the new interpolated quaternion
  4024. */
  4025. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4026. }
  4027. /**
  4028. * Class used to store matrix data (4x4)
  4029. */
  4030. export class Matrix {
  4031. private static _updateFlagSeed;
  4032. private static _identityReadOnly;
  4033. private _isIdentity;
  4034. private _isIdentityDirty;
  4035. private _isIdentity3x2;
  4036. private _isIdentity3x2Dirty;
  4037. /**
  4038. * Gets the update flag of the matrix which is an unique number for the matrix.
  4039. * It will be incremented every time the matrix data change.
  4040. * You can use it to speed the comparison between two versions of the same matrix.
  4041. */
  4042. updateFlag: number;
  4043. private readonly _m;
  4044. /**
  4045. * Gets the internal data of the matrix
  4046. */
  4047. get m(): DeepImmutable<Float32Array>;
  4048. /** @hidden */
  4049. _markAsUpdated(): void;
  4050. /** @hidden */
  4051. private _updateIdentityStatus;
  4052. /**
  4053. * Creates an empty matrix (filled with zeros)
  4054. */
  4055. constructor();
  4056. /**
  4057. * Check if the current matrix is identity
  4058. * @returns true is the matrix is the identity matrix
  4059. */
  4060. isIdentity(): boolean;
  4061. /**
  4062. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4063. * @returns true is the matrix is the identity matrix
  4064. */
  4065. isIdentityAs3x2(): boolean;
  4066. /**
  4067. * Gets the determinant of the matrix
  4068. * @returns the matrix determinant
  4069. */
  4070. determinant(): number;
  4071. /**
  4072. * Returns the matrix as a Float32Array
  4073. * @returns the matrix underlying array
  4074. */
  4075. toArray(): DeepImmutable<Float32Array>;
  4076. /**
  4077. * Returns the matrix as a Float32Array
  4078. * @returns the matrix underlying array.
  4079. */
  4080. asArray(): DeepImmutable<Float32Array>;
  4081. /**
  4082. * Inverts the current matrix in place
  4083. * @returns the current inverted matrix
  4084. */
  4085. invert(): Matrix;
  4086. /**
  4087. * Sets all the matrix elements to zero
  4088. * @returns the current matrix
  4089. */
  4090. reset(): Matrix;
  4091. /**
  4092. * Adds the current matrix with a second one
  4093. * @param other defines the matrix to add
  4094. * @returns a new matrix as the addition of the current matrix and the given one
  4095. */
  4096. add(other: DeepImmutable<Matrix>): Matrix;
  4097. /**
  4098. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4099. * @param other defines the matrix to add
  4100. * @param result defines the target matrix
  4101. * @returns the current matrix
  4102. */
  4103. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4104. /**
  4105. * Adds in place the given matrix to the current matrix
  4106. * @param other defines the second operand
  4107. * @returns the current updated matrix
  4108. */
  4109. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4110. /**
  4111. * Sets the given matrix to the current inverted Matrix
  4112. * @param other defines the target matrix
  4113. * @returns the unmodified current matrix
  4114. */
  4115. invertToRef(other: Matrix): Matrix;
  4116. /**
  4117. * add a value at the specified position in the current Matrix
  4118. * @param index the index of the value within the matrix. between 0 and 15.
  4119. * @param value the value to be added
  4120. * @returns the current updated matrix
  4121. */
  4122. addAtIndex(index: number, value: number): Matrix;
  4123. /**
  4124. * mutiply the specified position in the current Matrix by a value
  4125. * @param index the index of the value within the matrix. between 0 and 15.
  4126. * @param value the value to be added
  4127. * @returns the current updated matrix
  4128. */
  4129. multiplyAtIndex(index: number, value: number): Matrix;
  4130. /**
  4131. * Inserts the translation vector (using 3 floats) in the current matrix
  4132. * @param x defines the 1st component of the translation
  4133. * @param y defines the 2nd component of the translation
  4134. * @param z defines the 3rd component of the translation
  4135. * @returns the current updated matrix
  4136. */
  4137. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4138. /**
  4139. * Adds the translation vector (using 3 floats) in the current matrix
  4140. * @param x defines the 1st component of the translation
  4141. * @param y defines the 2nd component of the translation
  4142. * @param z defines the 3rd component of the translation
  4143. * @returns the current updated matrix
  4144. */
  4145. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4146. /**
  4147. * Inserts the translation vector in the current matrix
  4148. * @param vector3 defines the translation to insert
  4149. * @returns the current updated matrix
  4150. */
  4151. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4152. /**
  4153. * Gets the translation value of the current matrix
  4154. * @returns a new Vector3 as the extracted translation from the matrix
  4155. */
  4156. getTranslation(): Vector3;
  4157. /**
  4158. * Fill a Vector3 with the extracted translation from the matrix
  4159. * @param result defines the Vector3 where to store the translation
  4160. * @returns the current matrix
  4161. */
  4162. getTranslationToRef(result: Vector3): Matrix;
  4163. /**
  4164. * Remove rotation and scaling part from the matrix
  4165. * @returns the updated matrix
  4166. */
  4167. removeRotationAndScaling(): Matrix;
  4168. /**
  4169. * Multiply two matrices
  4170. * @param other defines the second operand
  4171. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4172. */
  4173. multiply(other: DeepImmutable<Matrix>): Matrix;
  4174. /**
  4175. * Copy the current matrix from the given one
  4176. * @param other defines the source matrix
  4177. * @returns the current updated matrix
  4178. */
  4179. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4180. /**
  4181. * Populates the given array from the starting index with the current matrix values
  4182. * @param array defines the target array
  4183. * @param offset defines the offset in the target array where to start storing values
  4184. * @returns the current matrix
  4185. */
  4186. copyToArray(array: Float32Array, offset?: number): Matrix;
  4187. /**
  4188. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4189. * @param other defines the second operand
  4190. * @param result defines the matrix where to store the multiplication
  4191. * @returns the current matrix
  4192. */
  4193. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4194. /**
  4195. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4196. * @param other defines the second operand
  4197. * @param result defines the array where to store the multiplication
  4198. * @param offset defines the offset in the target array where to start storing values
  4199. * @returns the current matrix
  4200. */
  4201. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4202. /**
  4203. * Check equality between this matrix and a second one
  4204. * @param value defines the second matrix to compare
  4205. * @returns true is the current matrix and the given one values are strictly equal
  4206. */
  4207. equals(value: DeepImmutable<Matrix>): boolean;
  4208. /**
  4209. * Clone the current matrix
  4210. * @returns a new matrix from the current matrix
  4211. */
  4212. clone(): Matrix;
  4213. /**
  4214. * Returns the name of the current matrix class
  4215. * @returns the string "Matrix"
  4216. */
  4217. getClassName(): string;
  4218. /**
  4219. * Gets the hash code of the current matrix
  4220. * @returns the hash code
  4221. */
  4222. getHashCode(): number;
  4223. /**
  4224. * Decomposes the current Matrix into a translation, rotation and scaling components
  4225. * @param scale defines the scale vector3 given as a reference to update
  4226. * @param rotation defines the rotation quaternion given as a reference to update
  4227. * @param translation defines the translation vector3 given as a reference to update
  4228. * @returns true if operation was successful
  4229. */
  4230. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4231. /**
  4232. * Gets specific row of the matrix
  4233. * @param index defines the number of the row to get
  4234. * @returns the index-th row of the current matrix as a new Vector4
  4235. */
  4236. getRow(index: number): Nullable<Vector4>;
  4237. /**
  4238. * Sets the index-th row of the current matrix to the vector4 values
  4239. * @param index defines the number of the row to set
  4240. * @param row defines the target vector4
  4241. * @returns the updated current matrix
  4242. */
  4243. setRow(index: number, row: Vector4): Matrix;
  4244. /**
  4245. * Compute the transpose of the matrix
  4246. * @returns the new transposed matrix
  4247. */
  4248. transpose(): Matrix;
  4249. /**
  4250. * Compute the transpose of the matrix and store it in a given matrix
  4251. * @param result defines the target matrix
  4252. * @returns the current matrix
  4253. */
  4254. transposeToRef(result: Matrix): Matrix;
  4255. /**
  4256. * Sets the index-th row of the current matrix with the given 4 x float values
  4257. * @param index defines the row index
  4258. * @param x defines the x component to set
  4259. * @param y defines the y component to set
  4260. * @param z defines the z component to set
  4261. * @param w defines the w component to set
  4262. * @returns the updated current matrix
  4263. */
  4264. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4265. /**
  4266. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4267. * @param scale defines the scale factor
  4268. * @returns a new matrix
  4269. */
  4270. scale(scale: number): Matrix;
  4271. /**
  4272. * Scale the current matrix values by a factor to a given result matrix
  4273. * @param scale defines the scale factor
  4274. * @param result defines the matrix to store the result
  4275. * @returns the current matrix
  4276. */
  4277. scaleToRef(scale: number, result: Matrix): Matrix;
  4278. /**
  4279. * Scale the current matrix values by a factor and add the result to a given matrix
  4280. * @param scale defines the scale factor
  4281. * @param result defines the Matrix to store the result
  4282. * @returns the current matrix
  4283. */
  4284. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4285. /**
  4286. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4287. * @param ref matrix to store the result
  4288. */
  4289. toNormalMatrix(ref: Matrix): void;
  4290. /**
  4291. * Gets only rotation part of the current matrix
  4292. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4293. */
  4294. getRotationMatrix(): Matrix;
  4295. /**
  4296. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4297. * @param result defines the target matrix to store data to
  4298. * @returns the current matrix
  4299. */
  4300. getRotationMatrixToRef(result: Matrix): Matrix;
  4301. /**
  4302. * Toggles model matrix from being right handed to left handed in place and vice versa
  4303. */
  4304. toggleModelMatrixHandInPlace(): void;
  4305. /**
  4306. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4307. */
  4308. toggleProjectionMatrixHandInPlace(): void;
  4309. /**
  4310. * Creates a matrix from an array
  4311. * @param array defines the source array
  4312. * @param offset defines an offset in the source array
  4313. * @returns a new Matrix set from the starting index of the given array
  4314. */
  4315. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4316. /**
  4317. * Copy the content of an array into a given matrix
  4318. * @param array defines the source array
  4319. * @param offset defines an offset in the source array
  4320. * @param result defines the target matrix
  4321. */
  4322. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4323. /**
  4324. * Stores an array into a matrix after having multiplied each component by a given factor
  4325. * @param array defines the source array
  4326. * @param offset defines the offset in the source array
  4327. * @param scale defines the scaling factor
  4328. * @param result defines the target matrix
  4329. */
  4330. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4331. /**
  4332. * Gets an identity matrix that must not be updated
  4333. */
  4334. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4335. /**
  4336. * Stores a list of values (16) inside a given matrix
  4337. * @param initialM11 defines 1st value of 1st row
  4338. * @param initialM12 defines 2nd value of 1st row
  4339. * @param initialM13 defines 3rd value of 1st row
  4340. * @param initialM14 defines 4th value of 1st row
  4341. * @param initialM21 defines 1st value of 2nd row
  4342. * @param initialM22 defines 2nd value of 2nd row
  4343. * @param initialM23 defines 3rd value of 2nd row
  4344. * @param initialM24 defines 4th value of 2nd row
  4345. * @param initialM31 defines 1st value of 3rd row
  4346. * @param initialM32 defines 2nd value of 3rd row
  4347. * @param initialM33 defines 3rd value of 3rd row
  4348. * @param initialM34 defines 4th value of 3rd row
  4349. * @param initialM41 defines 1st value of 4th row
  4350. * @param initialM42 defines 2nd value of 4th row
  4351. * @param initialM43 defines 3rd value of 4th row
  4352. * @param initialM44 defines 4th value of 4th row
  4353. * @param result defines the target matrix
  4354. */
  4355. 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;
  4356. /**
  4357. * Creates new matrix from a list of values (16)
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @returns the new matrix
  4375. */
  4376. 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;
  4377. /**
  4378. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4379. * @param scale defines the scale vector3
  4380. * @param rotation defines the rotation quaternion
  4381. * @param translation defines the translation vector3
  4382. * @returns a new matrix
  4383. */
  4384. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4385. /**
  4386. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4387. * @param scale defines the scale vector3
  4388. * @param rotation defines the rotation quaternion
  4389. * @param translation defines the translation vector3
  4390. * @param result defines the target matrix
  4391. */
  4392. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4393. /**
  4394. * Creates a new identity matrix
  4395. * @returns a new identity matrix
  4396. */
  4397. static Identity(): Matrix;
  4398. /**
  4399. * Creates a new identity matrix and stores the result in a given matrix
  4400. * @param result defines the target matrix
  4401. */
  4402. static IdentityToRef(result: Matrix): void;
  4403. /**
  4404. * Creates a new zero matrix
  4405. * @returns a new zero matrix
  4406. */
  4407. static Zero(): Matrix;
  4408. /**
  4409. * Creates a new rotation matrix for "angle" radians around the X axis
  4410. * @param angle defines the angle (in radians) to use
  4411. * @return the new matrix
  4412. */
  4413. static RotationX(angle: number): Matrix;
  4414. /**
  4415. * Creates a new matrix as the invert of a given matrix
  4416. * @param source defines the source matrix
  4417. * @returns the new matrix
  4418. */
  4419. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4420. /**
  4421. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4422. * @param angle defines the angle (in radians) to use
  4423. * @param result defines the target matrix
  4424. */
  4425. static RotationXToRef(angle: number, result: Matrix): void;
  4426. /**
  4427. * Creates a new rotation matrix for "angle" radians around the Y axis
  4428. * @param angle defines the angle (in radians) to use
  4429. * @return the new matrix
  4430. */
  4431. static RotationY(angle: number): Matrix;
  4432. /**
  4433. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4434. * @param angle defines the angle (in radians) to use
  4435. * @param result defines the target matrix
  4436. */
  4437. static RotationYToRef(angle: number, result: Matrix): void;
  4438. /**
  4439. * Creates a new rotation matrix for "angle" radians around the Z axis
  4440. * @param angle defines the angle (in radians) to use
  4441. * @return the new matrix
  4442. */
  4443. static RotationZ(angle: number): Matrix;
  4444. /**
  4445. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4446. * @param angle defines the angle (in radians) to use
  4447. * @param result defines the target matrix
  4448. */
  4449. static RotationZToRef(angle: number, result: Matrix): void;
  4450. /**
  4451. * Creates a new rotation matrix for "angle" radians around the given axis
  4452. * @param axis defines the axis to use
  4453. * @param angle defines the angle (in radians) to use
  4454. * @return the new matrix
  4455. */
  4456. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4457. /**
  4458. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4459. * @param axis defines the axis to use
  4460. * @param angle defines the angle (in radians) to use
  4461. * @param result defines the target matrix
  4462. */
  4463. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4464. /**
  4465. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4466. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4467. * @param from defines the vector to align
  4468. * @param to defines the vector to align to
  4469. * @param result defines the target matrix
  4470. */
  4471. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4472. /**
  4473. * Creates a rotation matrix
  4474. * @param yaw defines the yaw angle in radians (Y axis)
  4475. * @param pitch defines the pitch angle in radians (X axis)
  4476. * @param roll defines the roll angle in radians (X axis)
  4477. * @returns the new rotation matrix
  4478. */
  4479. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4480. /**
  4481. * Creates a rotation matrix and stores it in a given matrix
  4482. * @param yaw defines the yaw angle in radians (Y axis)
  4483. * @param pitch defines the pitch angle in radians (X axis)
  4484. * @param roll defines the roll angle in radians (X axis)
  4485. * @param result defines the target matrix
  4486. */
  4487. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4488. /**
  4489. * Creates a scaling matrix
  4490. * @param x defines the scale factor on X axis
  4491. * @param y defines the scale factor on Y axis
  4492. * @param z defines the scale factor on Z axis
  4493. * @returns the new matrix
  4494. */
  4495. static Scaling(x: number, y: number, z: number): Matrix;
  4496. /**
  4497. * Creates a scaling matrix and stores it in a given matrix
  4498. * @param x defines the scale factor on X axis
  4499. * @param y defines the scale factor on Y axis
  4500. * @param z defines the scale factor on Z axis
  4501. * @param result defines the target matrix
  4502. */
  4503. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4504. /**
  4505. * Creates a translation matrix
  4506. * @param x defines the translation on X axis
  4507. * @param y defines the translation on Y axis
  4508. * @param z defines the translationon Z axis
  4509. * @returns the new matrix
  4510. */
  4511. static Translation(x: number, y: number, z: number): Matrix;
  4512. /**
  4513. * Creates a translation matrix and stores it in a given matrix
  4514. * @param x defines the translation on X axis
  4515. * @param y defines the translation on Y axis
  4516. * @param z defines the translationon Z axis
  4517. * @param result defines the target matrix
  4518. */
  4519. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4520. /**
  4521. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4522. * @param startValue defines the start value
  4523. * @param endValue defines the end value
  4524. * @param gradient defines the gradient factor
  4525. * @returns the new matrix
  4526. */
  4527. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4528. /**
  4529. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4530. * @param startValue defines the start value
  4531. * @param endValue defines the end value
  4532. * @param gradient defines the gradient factor
  4533. * @param result defines the Matrix object where to store data
  4534. */
  4535. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4536. /**
  4537. * Builds a new matrix whose values are computed by:
  4538. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4539. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4540. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4541. * @param startValue defines the first matrix
  4542. * @param endValue defines the second matrix
  4543. * @param gradient defines the gradient between the two matrices
  4544. * @returns the new matrix
  4545. */
  4546. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4547. /**
  4548. * Update a matrix to values which are computed by:
  4549. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4550. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4551. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4552. * @param startValue defines the first matrix
  4553. * @param endValue defines the second matrix
  4554. * @param gradient defines the gradient between the two matrices
  4555. * @param result defines the target matrix
  4556. */
  4557. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4558. /**
  4559. * 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"
  4560. * This function works in left handed mode
  4561. * @param eye defines the final position of the entity
  4562. * @param target defines where the entity should look at
  4563. * @param up defines the up vector for the entity
  4564. * @returns the new matrix
  4565. */
  4566. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4567. /**
  4568. * 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".
  4569. * This function works in left handed mode
  4570. * @param eye defines the final position of the entity
  4571. * @param target defines where the entity should look at
  4572. * @param up defines the up vector for the entity
  4573. * @param result defines the target matrix
  4574. */
  4575. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4576. /**
  4577. * 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"
  4578. * This function works in right handed mode
  4579. * @param eye defines the final position of the entity
  4580. * @param target defines where the entity should look at
  4581. * @param up defines the up vector for the entity
  4582. * @returns the new matrix
  4583. */
  4584. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4585. /**
  4586. * 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".
  4587. * This function works in right handed mode
  4588. * @param eye defines the final position of the entity
  4589. * @param target defines where the entity should look at
  4590. * @param up defines the up vector for the entity
  4591. * @param result defines the target matrix
  4592. */
  4593. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4594. /**
  4595. * Create a left-handed orthographic projection matrix
  4596. * @param width defines the viewport width
  4597. * @param height defines the viewport height
  4598. * @param znear defines the near clip plane
  4599. * @param zfar defines the far clip plane
  4600. * @returns a new matrix as a left-handed orthographic projection matrix
  4601. */
  4602. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4603. /**
  4604. * Store a left-handed orthographic projection to a given matrix
  4605. * @param width defines the viewport width
  4606. * @param height defines the viewport height
  4607. * @param znear defines the near clip plane
  4608. * @param zfar defines the far clip plane
  4609. * @param result defines the target matrix
  4610. */
  4611. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4612. /**
  4613. * Create a left-handed orthographic projection matrix
  4614. * @param left defines the viewport left coordinate
  4615. * @param right defines the viewport right coordinate
  4616. * @param bottom defines the viewport bottom coordinate
  4617. * @param top defines the viewport top coordinate
  4618. * @param znear defines the near clip plane
  4619. * @param zfar defines the far clip plane
  4620. * @returns a new matrix as a left-handed orthographic projection matrix
  4621. */
  4622. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4623. /**
  4624. * Stores a left-handed orthographic projection into a given matrix
  4625. * @param left defines the viewport left coordinate
  4626. * @param right defines the viewport right coordinate
  4627. * @param bottom defines the viewport bottom coordinate
  4628. * @param top defines the viewport top coordinate
  4629. * @param znear defines the near clip plane
  4630. * @param zfar defines the far clip plane
  4631. * @param result defines the target matrix
  4632. */
  4633. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4634. /**
  4635. * Creates a right-handed orthographic projection matrix
  4636. * @param left defines the viewport left coordinate
  4637. * @param right defines the viewport right coordinate
  4638. * @param bottom defines the viewport bottom coordinate
  4639. * @param top defines the viewport top coordinate
  4640. * @param znear defines the near clip plane
  4641. * @param zfar defines the far clip plane
  4642. * @returns a new matrix as a right-handed orthographic projection matrix
  4643. */
  4644. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4645. /**
  4646. * Stores a right-handed orthographic projection into a given matrix
  4647. * @param left defines the viewport left coordinate
  4648. * @param right defines the viewport right coordinate
  4649. * @param bottom defines the viewport bottom coordinate
  4650. * @param top defines the viewport top coordinate
  4651. * @param znear defines the near clip plane
  4652. * @param zfar defines the far clip plane
  4653. * @param result defines the target matrix
  4654. */
  4655. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4656. /**
  4657. * Creates a left-handed perspective projection matrix
  4658. * @param width defines the viewport width
  4659. * @param height defines the viewport height
  4660. * @param znear defines the near clip plane
  4661. * @param zfar defines the far clip plane
  4662. * @returns a new matrix as a left-handed perspective projection matrix
  4663. */
  4664. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4665. /**
  4666. * Creates a left-handed perspective projection matrix
  4667. * @param fov defines the horizontal field of view
  4668. * @param aspect defines the aspect ratio
  4669. * @param znear defines the near clip plane
  4670. * @param zfar defines the far clip plane
  4671. * @returns a new matrix as a left-handed perspective projection matrix
  4672. */
  4673. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4674. /**
  4675. * Stores a left-handed perspective projection into a given matrix
  4676. * @param fov defines the horizontal field of view
  4677. * @param aspect defines the aspect ratio
  4678. * @param znear defines the near clip plane
  4679. * @param zfar defines the far clip plane
  4680. * @param result defines the target matrix
  4681. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4682. */
  4683. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4684. /**
  4685. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4686. * @param fov defines the horizontal field of view
  4687. * @param aspect defines the aspect ratio
  4688. * @param znear defines the near clip plane
  4689. * @param zfar not used as infinity is used as far clip
  4690. * @param result defines the target matrix
  4691. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4692. */
  4693. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4694. /**
  4695. * Creates a right-handed perspective projection matrix
  4696. * @param fov defines the horizontal field of view
  4697. * @param aspect defines the aspect ratio
  4698. * @param znear defines the near clip plane
  4699. * @param zfar defines the far clip plane
  4700. * @returns a new matrix as a right-handed perspective projection matrix
  4701. */
  4702. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4703. /**
  4704. * Stores a right-handed perspective projection into a given matrix
  4705. * @param fov defines the horizontal field of view
  4706. * @param aspect defines the aspect ratio
  4707. * @param znear defines the near clip plane
  4708. * @param zfar defines the far clip plane
  4709. * @param result defines the target matrix
  4710. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4711. */
  4712. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4713. /**
  4714. * Stores a right-handed perspective projection into a given matrix
  4715. * @param fov defines the horizontal field of view
  4716. * @param aspect defines the aspect ratio
  4717. * @param znear defines the near clip plane
  4718. * @param zfar not used as infinity is used as far clip
  4719. * @param result defines the target matrix
  4720. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4721. */
  4722. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4723. /**
  4724. * Stores a perspective projection for WebVR info a given matrix
  4725. * @param fov defines the field of view
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @param result defines the target matrix
  4729. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4730. */
  4731. static PerspectiveFovWebVRToRef(fov: {
  4732. upDegrees: number;
  4733. downDegrees: number;
  4734. leftDegrees: number;
  4735. rightDegrees: number;
  4736. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4737. /**
  4738. * Computes a complete transformation matrix
  4739. * @param viewport defines the viewport to use
  4740. * @param world defines the world matrix
  4741. * @param view defines the view matrix
  4742. * @param projection defines the projection matrix
  4743. * @param zmin defines the near clip plane
  4744. * @param zmax defines the far clip plane
  4745. * @returns the transformation matrix
  4746. */
  4747. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4748. /**
  4749. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4750. * @param matrix defines the matrix to use
  4751. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4752. */
  4753. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4754. /**
  4755. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4756. * @param matrix defines the matrix to use
  4757. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4758. */
  4759. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4760. /**
  4761. * Compute the transpose of a given matrix
  4762. * @param matrix defines the matrix to transpose
  4763. * @returns the new matrix
  4764. */
  4765. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4766. /**
  4767. * Compute the transpose of a matrix and store it in a target matrix
  4768. * @param matrix defines the matrix to transpose
  4769. * @param result defines the target matrix
  4770. */
  4771. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4772. /**
  4773. * Computes a reflection matrix from a plane
  4774. * @param plane defines the reflection plane
  4775. * @returns a new matrix
  4776. */
  4777. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4778. /**
  4779. * Computes a reflection matrix from a plane
  4780. * @param plane defines the reflection plane
  4781. * @param result defines the target matrix
  4782. */
  4783. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4784. /**
  4785. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4786. * @param xaxis defines the value of the 1st axis
  4787. * @param yaxis defines the value of the 2nd axis
  4788. * @param zaxis defines the value of the 3rd axis
  4789. * @param result defines the target matrix
  4790. */
  4791. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4792. /**
  4793. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4794. * @param quat defines the quaternion to use
  4795. * @param result defines the target matrix
  4796. */
  4797. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4798. }
  4799. /**
  4800. * @hidden
  4801. */
  4802. export class TmpVectors {
  4803. static Vector2: Vector2[];
  4804. static Vector3: Vector3[];
  4805. static Vector4: Vector4[];
  4806. static Quaternion: Quaternion[];
  4807. static Matrix: Matrix[];
  4808. }
  4809. }
  4810. declare module "babylonjs/Maths/math.path" {
  4811. import { DeepImmutable, Nullable } from "babylonjs/types";
  4812. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4813. /**
  4814. * Defines potential orientation for back face culling
  4815. */
  4816. export enum Orientation {
  4817. /**
  4818. * Clockwise
  4819. */
  4820. CW = 0,
  4821. /** Counter clockwise */
  4822. CCW = 1
  4823. }
  4824. /** Class used to represent a Bezier curve */
  4825. export class BezierCurve {
  4826. /**
  4827. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4828. * @param t defines the time
  4829. * @param x1 defines the left coordinate on X axis
  4830. * @param y1 defines the left coordinate on Y axis
  4831. * @param x2 defines the right coordinate on X axis
  4832. * @param y2 defines the right coordinate on Y axis
  4833. * @returns the interpolated value
  4834. */
  4835. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4836. }
  4837. /**
  4838. * Defines angle representation
  4839. */
  4840. export class Angle {
  4841. private _radians;
  4842. /**
  4843. * Creates an Angle object of "radians" radians (float).
  4844. * @param radians the angle in radians
  4845. */
  4846. constructor(radians: number);
  4847. /**
  4848. * Get value in degrees
  4849. * @returns the Angle value in degrees (float)
  4850. */
  4851. degrees(): number;
  4852. /**
  4853. * Get value in radians
  4854. * @returns the Angle value in radians (float)
  4855. */
  4856. radians(): number;
  4857. /**
  4858. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4859. * @param a defines first vector
  4860. * @param b defines second vector
  4861. * @returns a new Angle
  4862. */
  4863. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4864. /**
  4865. * Gets a new Angle object from the given float in radians
  4866. * @param radians defines the angle value in radians
  4867. * @returns a new Angle
  4868. */
  4869. static FromRadians(radians: number): Angle;
  4870. /**
  4871. * Gets a new Angle object from the given float in degrees
  4872. * @param degrees defines the angle value in degrees
  4873. * @returns a new Angle
  4874. */
  4875. static FromDegrees(degrees: number): Angle;
  4876. }
  4877. /**
  4878. * This represents an arc in a 2d space.
  4879. */
  4880. export class Arc2 {
  4881. /** Defines the start point of the arc */
  4882. startPoint: Vector2;
  4883. /** Defines the mid point of the arc */
  4884. midPoint: Vector2;
  4885. /** Defines the end point of the arc */
  4886. endPoint: Vector2;
  4887. /**
  4888. * Defines the center point of the arc.
  4889. */
  4890. centerPoint: Vector2;
  4891. /**
  4892. * Defines the radius of the arc.
  4893. */
  4894. radius: number;
  4895. /**
  4896. * Defines the angle of the arc (from mid point to end point).
  4897. */
  4898. angle: Angle;
  4899. /**
  4900. * Defines the start angle of the arc (from start point to middle point).
  4901. */
  4902. startAngle: Angle;
  4903. /**
  4904. * Defines the orientation of the arc (clock wise/counter clock wise).
  4905. */
  4906. orientation: Orientation;
  4907. /**
  4908. * Creates an Arc object from the three given points : start, middle and end.
  4909. * @param startPoint Defines the start point of the arc
  4910. * @param midPoint Defines the midlle point of the arc
  4911. * @param endPoint Defines the end point of the arc
  4912. */
  4913. constructor(
  4914. /** Defines the start point of the arc */
  4915. startPoint: Vector2,
  4916. /** Defines the mid point of the arc */
  4917. midPoint: Vector2,
  4918. /** Defines the end point of the arc */
  4919. endPoint: Vector2);
  4920. }
  4921. /**
  4922. * Represents a 2D path made up of multiple 2D points
  4923. */
  4924. export class Path2 {
  4925. private _points;
  4926. private _length;
  4927. /**
  4928. * If the path start and end point are the same
  4929. */
  4930. closed: boolean;
  4931. /**
  4932. * Creates a Path2 object from the starting 2D coordinates x and y.
  4933. * @param x the starting points x value
  4934. * @param y the starting points y value
  4935. */
  4936. constructor(x: number, y: number);
  4937. /**
  4938. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4939. * @param x the added points x value
  4940. * @param y the added points y value
  4941. * @returns the updated Path2.
  4942. */
  4943. addLineTo(x: number, y: number): Path2;
  4944. /**
  4945. * 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.
  4946. * @param midX middle point x value
  4947. * @param midY middle point y value
  4948. * @param endX end point x value
  4949. * @param endY end point y value
  4950. * @param numberOfSegments (default: 36)
  4951. * @returns the updated Path2.
  4952. */
  4953. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4954. /**
  4955. * Closes the Path2.
  4956. * @returns the Path2.
  4957. */
  4958. close(): Path2;
  4959. /**
  4960. * Gets the sum of the distance between each sequential point in the path
  4961. * @returns the Path2 total length (float).
  4962. */
  4963. length(): number;
  4964. /**
  4965. * Gets the points which construct the path
  4966. * @returns the Path2 internal array of points.
  4967. */
  4968. getPoints(): Vector2[];
  4969. /**
  4970. * Retreives the point at the distance aways from the starting point
  4971. * @param normalizedLengthPosition the length along the path to retreive the point from
  4972. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4973. */
  4974. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4975. /**
  4976. * Creates a new path starting from an x and y position
  4977. * @param x starting x value
  4978. * @param y starting y value
  4979. * @returns a new Path2 starting at the coordinates (x, y).
  4980. */
  4981. static StartingAt(x: number, y: number): Path2;
  4982. }
  4983. /**
  4984. * Represents a 3D path made up of multiple 3D points
  4985. */
  4986. export class Path3D {
  4987. /**
  4988. * an array of Vector3, the curve axis of the Path3D
  4989. */
  4990. path: Vector3[];
  4991. private _curve;
  4992. private _distances;
  4993. private _tangents;
  4994. private _normals;
  4995. private _binormals;
  4996. private _raw;
  4997. private _alignTangentsWithPath;
  4998. private readonly _pointAtData;
  4999. /**
  5000. * new Path3D(path, normal, raw)
  5001. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5002. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5003. * @param path an array of Vector3, the curve axis of the Path3D
  5004. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5005. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5006. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5007. */
  5008. constructor(
  5009. /**
  5010. * an array of Vector3, the curve axis of the Path3D
  5011. */
  5012. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5013. /**
  5014. * Returns the Path3D array of successive Vector3 designing its curve.
  5015. * @returns the Path3D array of successive Vector3 designing its curve.
  5016. */
  5017. getCurve(): Vector3[];
  5018. /**
  5019. * Returns the Path3D array of successive Vector3 designing its curve.
  5020. * @returns the Path3D array of successive Vector3 designing its curve.
  5021. */
  5022. getPoints(): Vector3[];
  5023. /**
  5024. * @returns the computed length (float) of the path.
  5025. */
  5026. length(): number;
  5027. /**
  5028. * Returns an array populated with tangent vectors on each Path3D curve point.
  5029. * @returns an array populated with tangent vectors on each Path3D curve point.
  5030. */
  5031. getTangents(): Vector3[];
  5032. /**
  5033. * Returns an array populated with normal vectors on each Path3D curve point.
  5034. * @returns an array populated with normal vectors on each Path3D curve point.
  5035. */
  5036. getNormals(): Vector3[];
  5037. /**
  5038. * Returns an array populated with binormal vectors on each Path3D curve point.
  5039. * @returns an array populated with binormal vectors on each Path3D curve point.
  5040. */
  5041. getBinormals(): Vector3[];
  5042. /**
  5043. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5044. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5045. */
  5046. getDistances(): number[];
  5047. /**
  5048. * Returns an interpolated point along this path
  5049. * @param position the position of the point along this path, from 0.0 to 1.0
  5050. * @returns a new Vector3 as the point
  5051. */
  5052. getPointAt(position: number): Vector3;
  5053. /**
  5054. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5055. * @param position the position of the point along this path, from 0.0 to 1.0
  5056. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5057. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5058. */
  5059. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5060. /**
  5061. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5062. * @param position the position of the point along this path, from 0.0 to 1.0
  5063. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5064. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5065. */
  5066. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5067. /**
  5068. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5069. * @param position the position of the point along this path, from 0.0 to 1.0
  5070. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5071. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5072. */
  5073. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5074. /**
  5075. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5076. * @param position the position of the point along this path, from 0.0 to 1.0
  5077. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5078. */
  5079. getDistanceAt(position: number): number;
  5080. /**
  5081. * Returns the array index of the previous point of an interpolated point along this path
  5082. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5083. * @returns the array index
  5084. */
  5085. getPreviousPointIndexAt(position: number): number;
  5086. /**
  5087. * 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)
  5088. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5089. * @returns the sub position
  5090. */
  5091. getSubPositionAt(position: number): number;
  5092. /**
  5093. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5094. * @param target the vector of which to get the closest position to
  5095. * @returns the position of the closest virtual point on this path to the target vector
  5096. */
  5097. getClosestPositionTo(target: Vector3): number;
  5098. /**
  5099. * Returns a sub path (slice) of this path
  5100. * @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
  5101. * @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
  5102. * @returns a sub path (slice) of this path
  5103. */
  5104. slice(start?: number, end?: number): Path3D;
  5105. /**
  5106. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5107. * @param path path which all values are copied into the curves points
  5108. * @param firstNormal which should be projected onto the curve
  5109. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5110. * @returns the same object updated.
  5111. */
  5112. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5113. private _compute;
  5114. private _getFirstNonNullVector;
  5115. private _getLastNonNullVector;
  5116. private _normalVector;
  5117. /**
  5118. * Updates the point at data for an interpolated point along this curve
  5119. * @param position the position of the point along this curve, from 0.0 to 1.0
  5120. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5121. * @returns the (updated) point at data
  5122. */
  5123. private _updatePointAtData;
  5124. /**
  5125. * Updates the point at data from the specified parameters
  5126. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5127. * @param point the interpolated point
  5128. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5129. */
  5130. private _setPointAtData;
  5131. /**
  5132. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5133. */
  5134. private _updateInterpolationMatrix;
  5135. }
  5136. /**
  5137. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5138. * A Curve3 is designed from a series of successive Vector3.
  5139. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5140. */
  5141. export class Curve3 {
  5142. private _points;
  5143. private _length;
  5144. /**
  5145. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5146. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5147. * @param v1 (Vector3) the control point
  5148. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5149. * @param nbPoints (integer) the wanted number of points in the curve
  5150. * @returns the created Curve3
  5151. */
  5152. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5153. /**
  5154. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5155. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5156. * @param v1 (Vector3) the first control point
  5157. * @param v2 (Vector3) the second control point
  5158. * @param v3 (Vector3) the end point of the Cubic Bezier
  5159. * @param nbPoints (integer) the wanted number of points in the curve
  5160. * @returns the created Curve3
  5161. */
  5162. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5163. /**
  5164. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5165. * @param p1 (Vector3) the origin point of the Hermite Spline
  5166. * @param t1 (Vector3) the tangent vector at the origin point
  5167. * @param p2 (Vector3) the end point of the Hermite Spline
  5168. * @param t2 (Vector3) the tangent vector at the end point
  5169. * @param nbPoints (integer) the wanted number of points in the curve
  5170. * @returns the created Curve3
  5171. */
  5172. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5173. /**
  5174. * Returns a Curve3 object along a CatmullRom Spline curve :
  5175. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5176. * @param nbPoints (integer) the wanted number of points between each curve control points
  5177. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5178. * @returns the created Curve3
  5179. */
  5180. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5181. /**
  5182. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5183. * A Curve3 is designed from a series of successive Vector3.
  5184. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5185. * @param points points which make up the curve
  5186. */
  5187. constructor(points: Vector3[]);
  5188. /**
  5189. * @returns the Curve3 stored array of successive Vector3
  5190. */
  5191. getPoints(): Vector3[];
  5192. /**
  5193. * @returns the computed length (float) of the curve.
  5194. */
  5195. length(): number;
  5196. /**
  5197. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5198. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5199. * curveA and curveB keep unchanged.
  5200. * @param curve the curve to continue from this curve
  5201. * @returns the newly constructed curve
  5202. */
  5203. continue(curve: DeepImmutable<Curve3>): Curve3;
  5204. private _computeLength;
  5205. }
  5206. }
  5207. declare module "babylonjs/Animations/easing" {
  5208. /**
  5209. * This represents the main contract an easing function should follow.
  5210. * Easing functions are used throughout the animation system.
  5211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5212. */
  5213. export interface IEasingFunction {
  5214. /**
  5215. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5216. * of the easing function.
  5217. * The link below provides some of the most common examples of easing functions.
  5218. * @see https://easings.net/
  5219. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5220. * @returns the corresponding value on the curve defined by the easing function
  5221. */
  5222. ease(gradient: number): number;
  5223. }
  5224. /**
  5225. * Base class used for every default easing function.
  5226. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5227. */
  5228. export class EasingFunction implements IEasingFunction {
  5229. /**
  5230. * Interpolation follows the mathematical formula associated with the easing function.
  5231. */
  5232. static readonly EASINGMODE_EASEIN: number;
  5233. /**
  5234. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5235. */
  5236. static readonly EASINGMODE_EASEOUT: number;
  5237. /**
  5238. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5239. */
  5240. static readonly EASINGMODE_EASEINOUT: number;
  5241. private _easingMode;
  5242. /**
  5243. * Sets the easing mode of the current function.
  5244. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5245. */
  5246. setEasingMode(easingMode: number): void;
  5247. /**
  5248. * Gets the current easing mode.
  5249. * @returns the easing mode
  5250. */
  5251. getEasingMode(): number;
  5252. /**
  5253. * @hidden
  5254. */
  5255. easeInCore(gradient: number): number;
  5256. /**
  5257. * Given an input gradient between 0 and 1, this returns the corresponding value
  5258. * of the easing function.
  5259. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5260. * @returns the corresponding value on the curve defined by the easing function
  5261. */
  5262. ease(gradient: number): number;
  5263. }
  5264. /**
  5265. * Easing function with a circle shape (see link below).
  5266. * @see https://easings.net/#easeInCirc
  5267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5268. */
  5269. export class CircleEase extends EasingFunction implements IEasingFunction {
  5270. /** @hidden */
  5271. easeInCore(gradient: number): number;
  5272. }
  5273. /**
  5274. * Easing function with a ease back shape (see link below).
  5275. * @see https://easings.net/#easeInBack
  5276. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5277. */
  5278. export class BackEase extends EasingFunction implements IEasingFunction {
  5279. /** Defines the amplitude of the function */
  5280. amplitude: number;
  5281. /**
  5282. * Instantiates a back ease easing
  5283. * @see https://easings.net/#easeInBack
  5284. * @param amplitude Defines the amplitude of the function
  5285. */
  5286. constructor(
  5287. /** Defines the amplitude of the function */
  5288. amplitude?: number);
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a bouncing shape (see link below).
  5294. * @see https://easings.net/#easeInBounce
  5295. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BounceEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the number of bounces */
  5299. bounces: number;
  5300. /** Defines the amplitude of the bounce */
  5301. bounciness: number;
  5302. /**
  5303. * Instantiates a bounce easing
  5304. * @see https://easings.net/#easeInBounce
  5305. * @param bounces Defines the number of bounces
  5306. * @param bounciness Defines the amplitude of the bounce
  5307. */
  5308. constructor(
  5309. /** Defines the number of bounces */
  5310. bounces?: number,
  5311. /** Defines the amplitude of the bounce */
  5312. bounciness?: number);
  5313. /** @hidden */
  5314. easeInCore(gradient: number): number;
  5315. }
  5316. /**
  5317. * Easing function with a power of 3 shape (see link below).
  5318. * @see https://easings.net/#easeInCubic
  5319. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5320. */
  5321. export class CubicEase extends EasingFunction implements IEasingFunction {
  5322. /** @hidden */
  5323. easeInCore(gradient: number): number;
  5324. }
  5325. /**
  5326. * Easing function with an elastic shape (see link below).
  5327. * @see https://easings.net/#easeInElastic
  5328. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5329. */
  5330. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5331. /** Defines the number of oscillations*/
  5332. oscillations: number;
  5333. /** Defines the amplitude of the oscillations*/
  5334. springiness: number;
  5335. /**
  5336. * Instantiates an elastic easing function
  5337. * @see https://easings.net/#easeInElastic
  5338. * @param oscillations Defines the number of oscillations
  5339. * @param springiness Defines the amplitude of the oscillations
  5340. */
  5341. constructor(
  5342. /** Defines the number of oscillations*/
  5343. oscillations?: number,
  5344. /** Defines the amplitude of the oscillations*/
  5345. springiness?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with an exponential shape (see link below).
  5351. * @see https://easings.net/#easeInExpo
  5352. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the exponent of the function */
  5356. exponent: number;
  5357. /**
  5358. * Instantiates an exponential easing function
  5359. * @see https://easings.net/#easeInExpo
  5360. * @param exponent Defines the exponent of the function
  5361. */
  5362. constructor(
  5363. /** Defines the exponent of the function */
  5364. exponent?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a power shape (see link below).
  5370. * @see https://easings.net/#easeInQuad
  5371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class PowerEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the power of the function */
  5375. power: number;
  5376. /**
  5377. * Instantiates an power base easing function
  5378. * @see https://easings.net/#easeInQuad
  5379. * @param power Defines the power of the function
  5380. */
  5381. constructor(
  5382. /** Defines the power of the function */
  5383. power?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power of 2 shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5393. /** @hidden */
  5394. easeInCore(gradient: number): number;
  5395. }
  5396. /**
  5397. * Easing function with a power of 4 shape (see link below).
  5398. * @see https://easings.net/#easeInQuart
  5399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5400. */
  5401. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5402. /** @hidden */
  5403. easeInCore(gradient: number): number;
  5404. }
  5405. /**
  5406. * Easing function with a power of 5 shape (see link below).
  5407. * @see https://easings.net/#easeInQuint
  5408. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5409. */
  5410. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5411. /** @hidden */
  5412. easeInCore(gradient: number): number;
  5413. }
  5414. /**
  5415. * Easing function with a sin shape (see link below).
  5416. * @see https://easings.net/#easeInSine
  5417. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5418. */
  5419. export class SineEase extends EasingFunction implements IEasingFunction {
  5420. /** @hidden */
  5421. easeInCore(gradient: number): number;
  5422. }
  5423. /**
  5424. * Easing function with a bezier shape (see link below).
  5425. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5426. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5427. */
  5428. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5429. /** Defines the x component of the start tangent in the bezier curve */
  5430. x1: number;
  5431. /** Defines the y component of the start tangent in the bezier curve */
  5432. y1: number;
  5433. /** Defines the x component of the end tangent in the bezier curve */
  5434. x2: number;
  5435. /** Defines the y component of the end tangent in the bezier curve */
  5436. y2: number;
  5437. /**
  5438. * Instantiates a bezier function
  5439. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5440. * @param x1 Defines the x component of the start tangent in the bezier curve
  5441. * @param y1 Defines the y component of the start tangent in the bezier curve
  5442. * @param x2 Defines the x component of the end tangent in the bezier curve
  5443. * @param y2 Defines the y component of the end tangent in the bezier curve
  5444. */
  5445. constructor(
  5446. /** Defines the x component of the start tangent in the bezier curve */
  5447. x1?: number,
  5448. /** Defines the y component of the start tangent in the bezier curve */
  5449. y1?: number,
  5450. /** Defines the x component of the end tangent in the bezier curve */
  5451. x2?: number,
  5452. /** Defines the y component of the end tangent in the bezier curve */
  5453. y2?: number);
  5454. /** @hidden */
  5455. easeInCore(gradient: number): number;
  5456. }
  5457. }
  5458. declare module "babylonjs/Maths/math.color" {
  5459. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5460. /**
  5461. * Class used to hold a RBG color
  5462. */
  5463. export class Color3 {
  5464. /**
  5465. * Defines the red component (between 0 and 1, default is 0)
  5466. */
  5467. r: number;
  5468. /**
  5469. * Defines the green component (between 0 and 1, default is 0)
  5470. */
  5471. g: number;
  5472. /**
  5473. * Defines the blue component (between 0 and 1, default is 0)
  5474. */
  5475. b: number;
  5476. /**
  5477. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5478. * @param r defines the red component (between 0 and 1, default is 0)
  5479. * @param g defines the green component (between 0 and 1, default is 0)
  5480. * @param b defines the blue component (between 0 and 1, default is 0)
  5481. */
  5482. constructor(
  5483. /**
  5484. * Defines the red component (between 0 and 1, default is 0)
  5485. */
  5486. r?: number,
  5487. /**
  5488. * Defines the green component (between 0 and 1, default is 0)
  5489. */
  5490. g?: number,
  5491. /**
  5492. * Defines the blue component (between 0 and 1, default is 0)
  5493. */
  5494. b?: number);
  5495. /**
  5496. * Creates a string with the Color3 current values
  5497. * @returns the string representation of the Color3 object
  5498. */
  5499. toString(): string;
  5500. /**
  5501. * Returns the string "Color3"
  5502. * @returns "Color3"
  5503. */
  5504. getClassName(): string;
  5505. /**
  5506. * Compute the Color3 hash code
  5507. * @returns an unique number that can be used to hash Color3 objects
  5508. */
  5509. getHashCode(): number;
  5510. /**
  5511. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5512. * @param array defines the array where to store the r,g,b components
  5513. * @param index defines an optional index in the target array to define where to start storing values
  5514. * @returns the current Color3 object
  5515. */
  5516. toArray(array: FloatArray, index?: number): Color3;
  5517. /**
  5518. * Returns a new Color4 object from the current Color3 and the given alpha
  5519. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5520. * @returns a new Color4 object
  5521. */
  5522. toColor4(alpha?: number): Color4;
  5523. /**
  5524. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5525. * @returns the new array
  5526. */
  5527. asArray(): number[];
  5528. /**
  5529. * Returns the luminance value
  5530. * @returns a float value
  5531. */
  5532. toLuminance(): number;
  5533. /**
  5534. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5535. * @param otherColor defines the second operand
  5536. * @returns the new Color3 object
  5537. */
  5538. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5539. /**
  5540. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5541. * @param otherColor defines the second operand
  5542. * @param result defines the Color3 object where to store the result
  5543. * @returns the current Color3
  5544. */
  5545. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5546. /**
  5547. * Determines equality between Color3 objects
  5548. * @param otherColor defines the second operand
  5549. * @returns true if the rgb values are equal to the given ones
  5550. */
  5551. equals(otherColor: DeepImmutable<Color3>): boolean;
  5552. /**
  5553. * Determines equality between the current Color3 object and a set of r,b,g values
  5554. * @param r defines the red component to check
  5555. * @param g defines the green component to check
  5556. * @param b defines the blue component to check
  5557. * @returns true if the rgb values are equal to the given ones
  5558. */
  5559. equalsFloats(r: number, g: number, b: number): boolean;
  5560. /**
  5561. * Multiplies in place each rgb value by scale
  5562. * @param scale defines the scaling factor
  5563. * @returns the updated Color3
  5564. */
  5565. scale(scale: number): Color3;
  5566. /**
  5567. * Multiplies the rgb values by scale and stores the result into "result"
  5568. * @param scale defines the scaling factor
  5569. * @param result defines the Color3 object where to store the result
  5570. * @returns the unmodified current Color3
  5571. */
  5572. scaleToRef(scale: number, result: Color3): Color3;
  5573. /**
  5574. * Scale the current Color3 values by a factor and add the result to a given Color3
  5575. * @param scale defines the scale factor
  5576. * @param result defines color to store the result into
  5577. * @returns the unmodified current Color3
  5578. */
  5579. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5580. /**
  5581. * Clamps the rgb values by the min and max values and stores the result into "result"
  5582. * @param min defines minimum clamping value (default is 0)
  5583. * @param max defines maximum clamping value (default is 1)
  5584. * @param result defines color to store the result into
  5585. * @returns the original Color3
  5586. */
  5587. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5588. /**
  5589. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5590. * @param otherColor defines the second operand
  5591. * @returns the new Color3
  5592. */
  5593. add(otherColor: DeepImmutable<Color3>): Color3;
  5594. /**
  5595. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5596. * @param otherColor defines the second operand
  5597. * @param result defines Color3 object to store the result into
  5598. * @returns the unmodified current Color3
  5599. */
  5600. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5601. /**
  5602. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5603. * @param otherColor defines the second operand
  5604. * @returns the new Color3
  5605. */
  5606. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5607. /**
  5608. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5609. * @param otherColor defines the second operand
  5610. * @param result defines Color3 object to store the result into
  5611. * @returns the unmodified current Color3
  5612. */
  5613. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5614. /**
  5615. * Copy the current object
  5616. * @returns a new Color3 copied the current one
  5617. */
  5618. clone(): Color3;
  5619. /**
  5620. * Copies the rgb values from the source in the current Color3
  5621. * @param source defines the source Color3 object
  5622. * @returns the updated Color3 object
  5623. */
  5624. copyFrom(source: DeepImmutable<Color3>): Color3;
  5625. /**
  5626. * Updates the Color3 rgb values from the given floats
  5627. * @param r defines the red component to read from
  5628. * @param g defines the green component to read from
  5629. * @param b defines the blue component to read from
  5630. * @returns the current Color3 object
  5631. */
  5632. copyFromFloats(r: number, g: number, b: number): Color3;
  5633. /**
  5634. * Updates the Color3 rgb values from the given floats
  5635. * @param r defines the red component to read from
  5636. * @param g defines the green component to read from
  5637. * @param b defines the blue component to read from
  5638. * @returns the current Color3 object
  5639. */
  5640. set(r: number, g: number, b: number): Color3;
  5641. /**
  5642. * Compute the Color3 hexadecimal code as a string
  5643. * @returns a string containing the hexadecimal representation of the Color3 object
  5644. */
  5645. toHexString(): string;
  5646. /**
  5647. * Computes a new Color3 converted from the current one to linear space
  5648. * @returns a new Color3 object
  5649. */
  5650. toLinearSpace(): Color3;
  5651. /**
  5652. * Converts current color in rgb space to HSV values
  5653. * @returns a new color3 representing the HSV values
  5654. */
  5655. toHSV(): Color3;
  5656. /**
  5657. * Converts current color in rgb space to HSV values
  5658. * @param result defines the Color3 where to store the HSV values
  5659. */
  5660. toHSVToRef(result: Color3): void;
  5661. /**
  5662. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5663. * @param convertedColor defines the Color3 object where to store the linear space version
  5664. * @returns the unmodified Color3
  5665. */
  5666. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5667. /**
  5668. * Computes a new Color3 converted from the current one to gamma space
  5669. * @returns a new Color3 object
  5670. */
  5671. toGammaSpace(): Color3;
  5672. /**
  5673. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5674. * @param convertedColor defines the Color3 object where to store the gamma space version
  5675. * @returns the unmodified Color3
  5676. */
  5677. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5678. private static _BlackReadOnly;
  5679. /**
  5680. * Convert Hue, saturation and value to a Color3 (RGB)
  5681. * @param hue defines the hue
  5682. * @param saturation defines the saturation
  5683. * @param value defines the value
  5684. * @param result defines the Color3 where to store the RGB values
  5685. */
  5686. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5687. /**
  5688. * Creates a new Color3 from the string containing valid hexadecimal values
  5689. * @param hex defines a string containing valid hexadecimal values
  5690. * @returns a new Color3 object
  5691. */
  5692. static FromHexString(hex: string): Color3;
  5693. /**
  5694. * Creates a new Color3 from the starting index of the given array
  5695. * @param array defines the source array
  5696. * @param offset defines an offset in the source array
  5697. * @returns a new Color3 object
  5698. */
  5699. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5700. /**
  5701. * Creates a new Color3 from integer values (< 256)
  5702. * @param r defines the red component to read from (value between 0 and 255)
  5703. * @param g defines the green component to read from (value between 0 and 255)
  5704. * @param b defines the blue component to read from (value between 0 and 255)
  5705. * @returns a new Color3 object
  5706. */
  5707. static FromInts(r: number, g: number, b: number): Color3;
  5708. /**
  5709. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5710. * @param start defines the start Color3 value
  5711. * @param end defines the end Color3 value
  5712. * @param amount defines the gradient value between start and end
  5713. * @returns a new Color3 object
  5714. */
  5715. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5716. /**
  5717. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5718. * @param left defines the start value
  5719. * @param right defines the end value
  5720. * @param amount defines the gradient factor
  5721. * @param result defines the Color3 object where to store the result
  5722. */
  5723. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5724. /**
  5725. * Returns a Color3 value containing a red color
  5726. * @returns a new Color3 object
  5727. */
  5728. static Red(): Color3;
  5729. /**
  5730. * Returns a Color3 value containing a green color
  5731. * @returns a new Color3 object
  5732. */
  5733. static Green(): Color3;
  5734. /**
  5735. * Returns a Color3 value containing a blue color
  5736. * @returns a new Color3 object
  5737. */
  5738. static Blue(): Color3;
  5739. /**
  5740. * Returns a Color3 value containing a black color
  5741. * @returns a new Color3 object
  5742. */
  5743. static Black(): Color3;
  5744. /**
  5745. * Gets a Color3 value containing a black color that must not be updated
  5746. */
  5747. static get BlackReadOnly(): DeepImmutable<Color3>;
  5748. /**
  5749. * Returns a Color3 value containing a white color
  5750. * @returns a new Color3 object
  5751. */
  5752. static White(): Color3;
  5753. /**
  5754. * Returns a Color3 value containing a purple color
  5755. * @returns a new Color3 object
  5756. */
  5757. static Purple(): Color3;
  5758. /**
  5759. * Returns a Color3 value containing a magenta color
  5760. * @returns a new Color3 object
  5761. */
  5762. static Magenta(): Color3;
  5763. /**
  5764. * Returns a Color3 value containing a yellow color
  5765. * @returns a new Color3 object
  5766. */
  5767. static Yellow(): Color3;
  5768. /**
  5769. * Returns a Color3 value containing a gray color
  5770. * @returns a new Color3 object
  5771. */
  5772. static Gray(): Color3;
  5773. /**
  5774. * Returns a Color3 value containing a teal color
  5775. * @returns a new Color3 object
  5776. */
  5777. static Teal(): Color3;
  5778. /**
  5779. * Returns a Color3 value containing a random color
  5780. * @returns a new Color3 object
  5781. */
  5782. static Random(): Color3;
  5783. }
  5784. /**
  5785. * Class used to hold a RBGA color
  5786. */
  5787. export class Color4 {
  5788. /**
  5789. * Defines the red component (between 0 and 1, default is 0)
  5790. */
  5791. r: number;
  5792. /**
  5793. * Defines the green component (between 0 and 1, default is 0)
  5794. */
  5795. g: number;
  5796. /**
  5797. * Defines the blue component (between 0 and 1, default is 0)
  5798. */
  5799. b: number;
  5800. /**
  5801. * Defines the alpha component (between 0 and 1, default is 1)
  5802. */
  5803. a: number;
  5804. /**
  5805. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5806. * @param r defines the red component (between 0 and 1, default is 0)
  5807. * @param g defines the green component (between 0 and 1, default is 0)
  5808. * @param b defines the blue component (between 0 and 1, default is 0)
  5809. * @param a defines the alpha component (between 0 and 1, default is 1)
  5810. */
  5811. constructor(
  5812. /**
  5813. * Defines the red component (between 0 and 1, default is 0)
  5814. */
  5815. r?: number,
  5816. /**
  5817. * Defines the green component (between 0 and 1, default is 0)
  5818. */
  5819. g?: number,
  5820. /**
  5821. * Defines the blue component (between 0 and 1, default is 0)
  5822. */
  5823. b?: number,
  5824. /**
  5825. * Defines the alpha component (between 0 and 1, default is 1)
  5826. */
  5827. a?: number);
  5828. /**
  5829. * Adds in place the given Color4 values to the current Color4 object
  5830. * @param right defines the second operand
  5831. * @returns the current updated Color4 object
  5832. */
  5833. addInPlace(right: DeepImmutable<Color4>): Color4;
  5834. /**
  5835. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5836. * @returns the new array
  5837. */
  5838. asArray(): number[];
  5839. /**
  5840. * Stores from the starting index in the given array the Color4 successive values
  5841. * @param array defines the array where to store the r,g,b components
  5842. * @param index defines an optional index in the target array to define where to start storing values
  5843. * @returns the current Color4 object
  5844. */
  5845. toArray(array: number[], index?: number): Color4;
  5846. /**
  5847. * Determines equality between Color4 objects
  5848. * @param otherColor defines the second operand
  5849. * @returns true if the rgba values are equal to the given ones
  5850. */
  5851. equals(otherColor: DeepImmutable<Color4>): boolean;
  5852. /**
  5853. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5854. * @param right defines the second operand
  5855. * @returns a new Color4 object
  5856. */
  5857. add(right: DeepImmutable<Color4>): Color4;
  5858. /**
  5859. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5860. * @param right defines the second operand
  5861. * @returns a new Color4 object
  5862. */
  5863. subtract(right: DeepImmutable<Color4>): Color4;
  5864. /**
  5865. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5866. * @param right defines the second operand
  5867. * @param result defines the Color4 object where to store the result
  5868. * @returns the current Color4 object
  5869. */
  5870. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5871. /**
  5872. * Creates a new Color4 with the current Color4 values multiplied by scale
  5873. * @param scale defines the scaling factor to apply
  5874. * @returns a new Color4 object
  5875. */
  5876. scale(scale: number): Color4;
  5877. /**
  5878. * Multiplies the current Color4 values by scale and stores the result in "result"
  5879. * @param scale defines the scaling factor to apply
  5880. * @param result defines the Color4 object where to store the result
  5881. * @returns the current unmodified Color4
  5882. */
  5883. scaleToRef(scale: number, result: Color4): Color4;
  5884. /**
  5885. * Scale the current Color4 values by a factor and add the result to a given Color4
  5886. * @param scale defines the scale factor
  5887. * @param result defines the Color4 object where to store the result
  5888. * @returns the unmodified current Color4
  5889. */
  5890. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5891. /**
  5892. * Clamps the rgb values by the min and max values and stores the result into "result"
  5893. * @param min defines minimum clamping value (default is 0)
  5894. * @param max defines maximum clamping value (default is 1)
  5895. * @param result defines color to store the result into.
  5896. * @returns the cuurent Color4
  5897. */
  5898. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5899. /**
  5900. * Multipy an Color4 value by another and return a new Color4 object
  5901. * @param color defines the Color4 value to multiply by
  5902. * @returns a new Color4 object
  5903. */
  5904. multiply(color: Color4): Color4;
  5905. /**
  5906. * Multipy a Color4 value by another and push the result in a reference value
  5907. * @param color defines the Color4 value to multiply by
  5908. * @param result defines the Color4 to fill the result in
  5909. * @returns the result Color4
  5910. */
  5911. multiplyToRef(color: Color4, result: Color4): Color4;
  5912. /**
  5913. * Creates a string with the Color4 current values
  5914. * @returns the string representation of the Color4 object
  5915. */
  5916. toString(): string;
  5917. /**
  5918. * Returns the string "Color4"
  5919. * @returns "Color4"
  5920. */
  5921. getClassName(): string;
  5922. /**
  5923. * Compute the Color4 hash code
  5924. * @returns an unique number that can be used to hash Color4 objects
  5925. */
  5926. getHashCode(): number;
  5927. /**
  5928. * Creates a new Color4 copied from the current one
  5929. * @returns a new Color4 object
  5930. */
  5931. clone(): Color4;
  5932. /**
  5933. * Copies the given Color4 values into the current one
  5934. * @param source defines the source Color4 object
  5935. * @returns the current updated Color4 object
  5936. */
  5937. copyFrom(source: Color4): Color4;
  5938. /**
  5939. * Copies the given float values into the current one
  5940. * @param r defines the red component to read from
  5941. * @param g defines the green component to read from
  5942. * @param b defines the blue component to read from
  5943. * @param a defines the alpha component to read from
  5944. * @returns the current updated Color4 object
  5945. */
  5946. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5947. /**
  5948. * Copies the given float values into the current one
  5949. * @param r defines the red component to read from
  5950. * @param g defines the green component to read from
  5951. * @param b defines the blue component to read from
  5952. * @param a defines the alpha component to read from
  5953. * @returns the current updated Color4 object
  5954. */
  5955. set(r: number, g: number, b: number, a: number): Color4;
  5956. /**
  5957. * Compute the Color4 hexadecimal code as a string
  5958. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5959. * @returns a string containing the hexadecimal representation of the Color4 object
  5960. */
  5961. toHexString(returnAsColor3?: boolean): string;
  5962. /**
  5963. * Computes a new Color4 converted from the current one to linear space
  5964. * @returns a new Color4 object
  5965. */
  5966. toLinearSpace(): Color4;
  5967. /**
  5968. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5969. * @param convertedColor defines the Color4 object where to store the linear space version
  5970. * @returns the unmodified Color4
  5971. */
  5972. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5973. /**
  5974. * Computes a new Color4 converted from the current one to gamma space
  5975. * @returns a new Color4 object
  5976. */
  5977. toGammaSpace(): Color4;
  5978. /**
  5979. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5980. * @param convertedColor defines the Color4 object where to store the gamma space version
  5981. * @returns the unmodified Color4
  5982. */
  5983. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5984. /**
  5985. * Creates a new Color4 from the string containing valid hexadecimal values
  5986. * @param hex defines a string containing valid hexadecimal values
  5987. * @returns a new Color4 object
  5988. */
  5989. static FromHexString(hex: string): Color4;
  5990. /**
  5991. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5992. * @param left defines the start value
  5993. * @param right defines the end value
  5994. * @param amount defines the gradient factor
  5995. * @returns a new Color4 object
  5996. */
  5997. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5998. /**
  5999. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6000. * @param left defines the start value
  6001. * @param right defines the end value
  6002. * @param amount defines the gradient factor
  6003. * @param result defines the Color4 object where to store data
  6004. */
  6005. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6006. /**
  6007. * Creates a new Color4 from a Color3 and an alpha value
  6008. * @param color3 defines the source Color3 to read from
  6009. * @param alpha defines the alpha component (1.0 by default)
  6010. * @returns a new Color4 object
  6011. */
  6012. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6013. /**
  6014. * Creates a new Color4 from the starting index element of the given array
  6015. * @param array defines the source array to read from
  6016. * @param offset defines the offset in the source array
  6017. * @returns a new Color4 object
  6018. */
  6019. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6020. /**
  6021. * Creates a new Color3 from integer values (< 256)
  6022. * @param r defines the red component to read from (value between 0 and 255)
  6023. * @param g defines the green component to read from (value between 0 and 255)
  6024. * @param b defines the blue component to read from (value between 0 and 255)
  6025. * @param a defines the alpha component to read from (value between 0 and 255)
  6026. * @returns a new Color3 object
  6027. */
  6028. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6029. /**
  6030. * Check the content of a given array and convert it to an array containing RGBA data
  6031. * If the original array was already containing count * 4 values then it is returned directly
  6032. * @param colors defines the array to check
  6033. * @param count defines the number of RGBA data to expect
  6034. * @returns an array containing count * 4 values (RGBA)
  6035. */
  6036. static CheckColors4(colors: number[], count: number): number[];
  6037. }
  6038. /**
  6039. * @hidden
  6040. */
  6041. export class TmpColors {
  6042. static Color3: Color3[];
  6043. static Color4: Color4[];
  6044. }
  6045. }
  6046. declare module "babylonjs/Animations/animationKey" {
  6047. /**
  6048. * Defines an interface which represents an animation key frame
  6049. */
  6050. export interface IAnimationKey {
  6051. /**
  6052. * Frame of the key frame
  6053. */
  6054. frame: number;
  6055. /**
  6056. * Value at the specifies key frame
  6057. */
  6058. value: any;
  6059. /**
  6060. * The input tangent for the cubic hermite spline
  6061. */
  6062. inTangent?: any;
  6063. /**
  6064. * The output tangent for the cubic hermite spline
  6065. */
  6066. outTangent?: any;
  6067. /**
  6068. * The animation interpolation type
  6069. */
  6070. interpolation?: AnimationKeyInterpolation;
  6071. }
  6072. /**
  6073. * Enum for the animation key frame interpolation type
  6074. */
  6075. export enum AnimationKeyInterpolation {
  6076. /**
  6077. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6078. */
  6079. STEP = 1
  6080. }
  6081. }
  6082. declare module "babylonjs/Animations/animationRange" {
  6083. /**
  6084. * Represents the range of an animation
  6085. */
  6086. export class AnimationRange {
  6087. /**The name of the animation range**/
  6088. name: string;
  6089. /**The starting frame of the animation */
  6090. from: number;
  6091. /**The ending frame of the animation*/
  6092. to: number;
  6093. /**
  6094. * Initializes the range of an animation
  6095. * @param name The name of the animation range
  6096. * @param from The starting frame of the animation
  6097. * @param to The ending frame of the animation
  6098. */
  6099. constructor(
  6100. /**The name of the animation range**/
  6101. name: string,
  6102. /**The starting frame of the animation */
  6103. from: number,
  6104. /**The ending frame of the animation*/
  6105. to: number);
  6106. /**
  6107. * Makes a copy of the animation range
  6108. * @returns A copy of the animation range
  6109. */
  6110. clone(): AnimationRange;
  6111. }
  6112. }
  6113. declare module "babylonjs/Animations/animationEvent" {
  6114. /**
  6115. * Composed of a frame, and an action function
  6116. */
  6117. export class AnimationEvent {
  6118. /** The frame for which the event is triggered **/
  6119. frame: number;
  6120. /** The event to perform when triggered **/
  6121. action: (currentFrame: number) => void;
  6122. /** Specifies if the event should be triggered only once**/
  6123. onlyOnce?: boolean | undefined;
  6124. /**
  6125. * Specifies if the animation event is done
  6126. */
  6127. isDone: boolean;
  6128. /**
  6129. * Initializes the animation event
  6130. * @param frame The frame for which the event is triggered
  6131. * @param action The event to perform when triggered
  6132. * @param onlyOnce Specifies if the event should be triggered only once
  6133. */
  6134. constructor(
  6135. /** The frame for which the event is triggered **/
  6136. frame: number,
  6137. /** The event to perform when triggered **/
  6138. action: (currentFrame: number) => void,
  6139. /** Specifies if the event should be triggered only once**/
  6140. onlyOnce?: boolean | undefined);
  6141. /** @hidden */
  6142. _clone(): AnimationEvent;
  6143. }
  6144. }
  6145. declare module "babylonjs/Behaviors/behavior" {
  6146. import { Nullable } from "babylonjs/types";
  6147. /**
  6148. * Interface used to define a behavior
  6149. */
  6150. export interface Behavior<T> {
  6151. /** gets or sets behavior's name */
  6152. name: string;
  6153. /**
  6154. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6155. */
  6156. init(): void;
  6157. /**
  6158. * Called when the behavior is attached to a target
  6159. * @param target defines the target where the behavior is attached to
  6160. */
  6161. attach(target: T): void;
  6162. /**
  6163. * Called when the behavior is detached from its target
  6164. */
  6165. detach(): void;
  6166. }
  6167. /**
  6168. * Interface implemented by classes supporting behaviors
  6169. */
  6170. export interface IBehaviorAware<T> {
  6171. /**
  6172. * Attach a behavior
  6173. * @param behavior defines the behavior to attach
  6174. * @returns the current host
  6175. */
  6176. addBehavior(behavior: Behavior<T>): T;
  6177. /**
  6178. * Remove a behavior from the current object
  6179. * @param behavior defines the behavior to detach
  6180. * @returns the current host
  6181. */
  6182. removeBehavior(behavior: Behavior<T>): T;
  6183. /**
  6184. * Gets a behavior using its name to search
  6185. * @param name defines the name to search
  6186. * @returns the behavior or null if not found
  6187. */
  6188. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6189. }
  6190. }
  6191. declare module "babylonjs/Misc/smartArray" {
  6192. /**
  6193. * Defines an array and its length.
  6194. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6195. */
  6196. export interface ISmartArrayLike<T> {
  6197. /**
  6198. * The data of the array.
  6199. */
  6200. data: Array<T>;
  6201. /**
  6202. * The active length of the array.
  6203. */
  6204. length: number;
  6205. }
  6206. /**
  6207. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6208. */
  6209. export class SmartArray<T> implements ISmartArrayLike<T> {
  6210. /**
  6211. * The full set of data from the array.
  6212. */
  6213. data: Array<T>;
  6214. /**
  6215. * The active length of the array.
  6216. */
  6217. length: number;
  6218. protected _id: number;
  6219. /**
  6220. * Instantiates a Smart Array.
  6221. * @param capacity defines the default capacity of the array.
  6222. */
  6223. constructor(capacity: number);
  6224. /**
  6225. * Pushes a value at the end of the active data.
  6226. * @param value defines the object to push in the array.
  6227. */
  6228. push(value: T): void;
  6229. /**
  6230. * Iterates over the active data and apply the lambda to them.
  6231. * @param func defines the action to apply on each value.
  6232. */
  6233. forEach(func: (content: T) => void): void;
  6234. /**
  6235. * Sorts the full sets of data.
  6236. * @param compareFn defines the comparison function to apply.
  6237. */
  6238. sort(compareFn: (a: T, b: T) => number): void;
  6239. /**
  6240. * Resets the active data to an empty array.
  6241. */
  6242. reset(): void;
  6243. /**
  6244. * Releases all the data from the array as well as the array.
  6245. */
  6246. dispose(): void;
  6247. /**
  6248. * Concats the active data with a given array.
  6249. * @param array defines the data to concatenate with.
  6250. */
  6251. concat(array: any): void;
  6252. /**
  6253. * Returns the position of a value in the active data.
  6254. * @param value defines the value to find the index for
  6255. * @returns the index if found in the active data otherwise -1
  6256. */
  6257. indexOf(value: T): number;
  6258. /**
  6259. * Returns whether an element is part of the active data.
  6260. * @param value defines the value to look for
  6261. * @returns true if found in the active data otherwise false
  6262. */
  6263. contains(value: T): boolean;
  6264. private static _GlobalId;
  6265. }
  6266. /**
  6267. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6268. * The data in this array can only be present once
  6269. */
  6270. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6271. private _duplicateId;
  6272. /**
  6273. * Pushes a value at the end of the active data.
  6274. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6275. * @param value defines the object to push in the array.
  6276. */
  6277. push(value: T): void;
  6278. /**
  6279. * Pushes a value at the end of the active data.
  6280. * If the data is already present, it won t be added again
  6281. * @param value defines the object to push in the array.
  6282. * @returns true if added false if it was already present
  6283. */
  6284. pushNoDuplicate(value: T): boolean;
  6285. /**
  6286. * Resets the active data to an empty array.
  6287. */
  6288. reset(): void;
  6289. /**
  6290. * Concats the active data with a given array.
  6291. * This ensures no dupplicate will be present in the result.
  6292. * @param array defines the data to concatenate with.
  6293. */
  6294. concatWithNoDuplicate(array: any): void;
  6295. }
  6296. }
  6297. declare module "babylonjs/Cameras/cameraInputsManager" {
  6298. import { Nullable } from "babylonjs/types";
  6299. import { Camera } from "babylonjs/Cameras/camera";
  6300. /**
  6301. * @ignore
  6302. * This is a list of all the different input types that are available in the application.
  6303. * Fo instance: ArcRotateCameraGamepadInput...
  6304. */
  6305. export var CameraInputTypes: {};
  6306. /**
  6307. * This is the contract to implement in order to create a new input class.
  6308. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6309. */
  6310. export interface ICameraInput<TCamera extends Camera> {
  6311. /**
  6312. * Defines the camera the input is attached to.
  6313. */
  6314. camera: Nullable<TCamera>;
  6315. /**
  6316. * Gets the class name of the current intput.
  6317. * @returns the class name
  6318. */
  6319. getClassName(): string;
  6320. /**
  6321. * Get the friendly name associated with the input class.
  6322. * @returns the input friendly name
  6323. */
  6324. getSimpleName(): string;
  6325. /**
  6326. * Attach the input controls to a specific dom element to get the input from.
  6327. * @param element Defines the element the controls should be listened from
  6328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6329. */
  6330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6331. /**
  6332. * Detach the current controls from the specified dom element.
  6333. * @param element Defines the element to stop listening the inputs from
  6334. */
  6335. detachControl(element: Nullable<HTMLElement>): void;
  6336. /**
  6337. * Update the current camera state depending on the inputs that have been used this frame.
  6338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6339. */
  6340. checkInputs?: () => void;
  6341. }
  6342. /**
  6343. * Represents a map of input types to input instance or input index to input instance.
  6344. */
  6345. export interface CameraInputsMap<TCamera extends Camera> {
  6346. /**
  6347. * Accessor to the input by input type.
  6348. */
  6349. [name: string]: ICameraInput<TCamera>;
  6350. /**
  6351. * Accessor to the input by input index.
  6352. */
  6353. [idx: number]: ICameraInput<TCamera>;
  6354. }
  6355. /**
  6356. * This represents the input manager used within a camera.
  6357. * It helps dealing with all the different kind of input attached to a camera.
  6358. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6359. */
  6360. export class CameraInputsManager<TCamera extends Camera> {
  6361. /**
  6362. * Defines the list of inputs attahed to the camera.
  6363. */
  6364. attached: CameraInputsMap<TCamera>;
  6365. /**
  6366. * Defines the dom element the camera is collecting inputs from.
  6367. * This is null if the controls have not been attached.
  6368. */
  6369. attachedElement: Nullable<HTMLElement>;
  6370. /**
  6371. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. noPreventDefault: boolean;
  6374. /**
  6375. * Defined the camera the input manager belongs to.
  6376. */
  6377. camera: TCamera;
  6378. /**
  6379. * Update the current camera state depending on the inputs that have been used this frame.
  6380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6381. */
  6382. checkInputs: () => void;
  6383. /**
  6384. * Instantiate a new Camera Input Manager.
  6385. * @param camera Defines the camera the input manager blongs to
  6386. */
  6387. constructor(camera: TCamera);
  6388. /**
  6389. * Add an input method to a camera
  6390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6391. * @param input camera input method
  6392. */
  6393. add(input: ICameraInput<TCamera>): void;
  6394. /**
  6395. * Remove a specific input method from a camera
  6396. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6397. * @param inputToRemove camera input method
  6398. */
  6399. remove(inputToRemove: ICameraInput<TCamera>): void;
  6400. /**
  6401. * Remove a specific input type from a camera
  6402. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6403. * @param inputType the type of the input to remove
  6404. */
  6405. removeByType(inputType: string): void;
  6406. private _addCheckInputs;
  6407. /**
  6408. * Attach the input controls to the currently attached dom element to listen the events from.
  6409. * @param input Defines the input to attach
  6410. */
  6411. attachInput(input: ICameraInput<TCamera>): void;
  6412. /**
  6413. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6414. * @param element Defines the dom element to collect the events from
  6415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6416. */
  6417. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6418. /**
  6419. * Detach the current manager inputs controls from a specific dom element.
  6420. * @param element Defines the dom element to collect the events from
  6421. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6422. */
  6423. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6424. /**
  6425. * Rebuild the dynamic inputCheck function from the current list of
  6426. * defined inputs in the manager.
  6427. */
  6428. rebuildInputCheck(): void;
  6429. /**
  6430. * Remove all attached input methods from a camera
  6431. */
  6432. clear(): void;
  6433. /**
  6434. * Serialize the current input manager attached to a camera.
  6435. * This ensures than once parsed,
  6436. * the input associated to the camera will be identical to the current ones
  6437. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6438. */
  6439. serialize(serializedCamera: any): void;
  6440. /**
  6441. * Parses an input manager serialized JSON to restore the previous list of inputs
  6442. * and states associated to a camera.
  6443. * @param parsedCamera Defines the JSON to parse
  6444. */
  6445. parse(parsedCamera: any): void;
  6446. }
  6447. }
  6448. declare module "babylonjs/Meshes/buffer" {
  6449. import { Nullable, DataArray } from "babylonjs/types";
  6450. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6451. /**
  6452. * Class used to store data that will be store in GPU memory
  6453. */
  6454. export class Buffer {
  6455. private _engine;
  6456. private _buffer;
  6457. /** @hidden */
  6458. _data: Nullable<DataArray>;
  6459. private _updatable;
  6460. private _instanced;
  6461. private _divisor;
  6462. /**
  6463. * Gets the byte stride.
  6464. */
  6465. readonly byteStride: number;
  6466. /**
  6467. * Constructor
  6468. * @param engine the engine
  6469. * @param data the data to use for this buffer
  6470. * @param updatable whether the data is updatable
  6471. * @param stride the stride (optional)
  6472. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6473. * @param instanced whether the buffer is instanced (optional)
  6474. * @param useBytes set to true if the stride in in bytes (optional)
  6475. * @param divisor sets an optional divisor for instances (1 by default)
  6476. */
  6477. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6478. /**
  6479. * Create a new VertexBuffer based on the current buffer
  6480. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6481. * @param offset defines offset in the buffer (0 by default)
  6482. * @param size defines the size in floats of attributes (position is 3 for instance)
  6483. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6484. * @param instanced defines if the vertex buffer contains indexed data
  6485. * @param useBytes defines if the offset and stride are in bytes *
  6486. * @param divisor sets an optional divisor for instances (1 by default)
  6487. * @returns the new vertex buffer
  6488. */
  6489. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6490. /**
  6491. * Gets a boolean indicating if the Buffer is updatable?
  6492. * @returns true if the buffer is updatable
  6493. */
  6494. isUpdatable(): boolean;
  6495. /**
  6496. * Gets current buffer's data
  6497. * @returns a DataArray or null
  6498. */
  6499. getData(): Nullable<DataArray>;
  6500. /**
  6501. * Gets underlying native buffer
  6502. * @returns underlying native buffer
  6503. */
  6504. getBuffer(): Nullable<DataBuffer>;
  6505. /**
  6506. * Gets the stride in float32 units (i.e. byte stride / 4).
  6507. * May not be an integer if the byte stride is not divisible by 4.
  6508. * @returns the stride in float32 units
  6509. * @deprecated Please use byteStride instead.
  6510. */
  6511. getStrideSize(): number;
  6512. /**
  6513. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6514. * @param data defines the data to store
  6515. */
  6516. create(data?: Nullable<DataArray>): void;
  6517. /** @hidden */
  6518. _rebuild(): void;
  6519. /**
  6520. * Update current buffer data
  6521. * @param data defines the data to store
  6522. */
  6523. update(data: DataArray): void;
  6524. /**
  6525. * Updates the data directly.
  6526. * @param data the new data
  6527. * @param offset the new offset
  6528. * @param vertexCount the vertex count (optional)
  6529. * @param useBytes set to true if the offset is in bytes
  6530. */
  6531. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6532. /**
  6533. * Release all resources
  6534. */
  6535. dispose(): void;
  6536. }
  6537. /**
  6538. * Specialized buffer used to store vertex data
  6539. */
  6540. export class VertexBuffer {
  6541. /** @hidden */
  6542. _buffer: Buffer;
  6543. private _kind;
  6544. private _size;
  6545. private _ownsBuffer;
  6546. private _instanced;
  6547. private _instanceDivisor;
  6548. /**
  6549. * The byte type.
  6550. */
  6551. static readonly BYTE: number;
  6552. /**
  6553. * The unsigned byte type.
  6554. */
  6555. static readonly UNSIGNED_BYTE: number;
  6556. /**
  6557. * The short type.
  6558. */
  6559. static readonly SHORT: number;
  6560. /**
  6561. * The unsigned short type.
  6562. */
  6563. static readonly UNSIGNED_SHORT: number;
  6564. /**
  6565. * The integer type.
  6566. */
  6567. static readonly INT: number;
  6568. /**
  6569. * The unsigned integer type.
  6570. */
  6571. static readonly UNSIGNED_INT: number;
  6572. /**
  6573. * The float type.
  6574. */
  6575. static readonly FLOAT: number;
  6576. /**
  6577. * Gets or sets the instance divisor when in instanced mode
  6578. */
  6579. get instanceDivisor(): number;
  6580. set instanceDivisor(value: number);
  6581. /**
  6582. * Gets the byte stride.
  6583. */
  6584. readonly byteStride: number;
  6585. /**
  6586. * Gets the byte offset.
  6587. */
  6588. readonly byteOffset: number;
  6589. /**
  6590. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6591. */
  6592. readonly normalized: boolean;
  6593. /**
  6594. * Gets the data type of each component in the array.
  6595. */
  6596. readonly type: number;
  6597. /**
  6598. * Constructor
  6599. * @param engine the engine
  6600. * @param data the data to use for this vertex buffer
  6601. * @param kind the vertex buffer kind
  6602. * @param updatable whether the data is updatable
  6603. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6604. * @param stride the stride (optional)
  6605. * @param instanced whether the buffer is instanced (optional)
  6606. * @param offset the offset of the data (optional)
  6607. * @param size the number of components (optional)
  6608. * @param type the type of the component (optional)
  6609. * @param normalized whether the data contains normalized data (optional)
  6610. * @param useBytes set to true if stride and offset are in bytes (optional)
  6611. * @param divisor defines the instance divisor to use (1 by default)
  6612. */
  6613. 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);
  6614. /** @hidden */
  6615. _rebuild(): void;
  6616. /**
  6617. * Returns the kind of the VertexBuffer (string)
  6618. * @returns a string
  6619. */
  6620. getKind(): string;
  6621. /**
  6622. * Gets a boolean indicating if the VertexBuffer is updatable?
  6623. * @returns true if the buffer is updatable
  6624. */
  6625. isUpdatable(): boolean;
  6626. /**
  6627. * Gets current buffer's data
  6628. * @returns a DataArray or null
  6629. */
  6630. getData(): Nullable<DataArray>;
  6631. /**
  6632. * Gets underlying native buffer
  6633. * @returns underlying native buffer
  6634. */
  6635. getBuffer(): Nullable<DataBuffer>;
  6636. /**
  6637. * Gets the stride in float32 units (i.e. byte stride / 4).
  6638. * May not be an integer if the byte stride is not divisible by 4.
  6639. * @returns the stride in float32 units
  6640. * @deprecated Please use byteStride instead.
  6641. */
  6642. getStrideSize(): number;
  6643. /**
  6644. * Returns the offset as a multiple of the type byte length.
  6645. * @returns the offset in bytes
  6646. * @deprecated Please use byteOffset instead.
  6647. */
  6648. getOffset(): number;
  6649. /**
  6650. * Returns the number of components per vertex attribute (integer)
  6651. * @returns the size in float
  6652. */
  6653. getSize(): number;
  6654. /**
  6655. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6656. * @returns true if this buffer is instanced
  6657. */
  6658. getIsInstanced(): boolean;
  6659. /**
  6660. * Returns the instancing divisor, zero for non-instanced (integer).
  6661. * @returns a number
  6662. */
  6663. getInstanceDivisor(): number;
  6664. /**
  6665. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6666. * @param data defines the data to store
  6667. */
  6668. create(data?: DataArray): void;
  6669. /**
  6670. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6671. * This function will create a new buffer if the current one is not updatable
  6672. * @param data defines the data to store
  6673. */
  6674. update(data: DataArray): void;
  6675. /**
  6676. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6677. * Returns the directly updated WebGLBuffer.
  6678. * @param data the new data
  6679. * @param offset the new offset
  6680. * @param useBytes set to true if the offset is in bytes
  6681. */
  6682. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6683. /**
  6684. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6685. */
  6686. dispose(): void;
  6687. /**
  6688. * Enumerates each value of this vertex buffer as numbers.
  6689. * @param count the number of values to enumerate
  6690. * @param callback the callback function called for each value
  6691. */
  6692. forEach(count: number, callback: (value: number, index: number) => void): void;
  6693. /**
  6694. * Positions
  6695. */
  6696. static readonly PositionKind: string;
  6697. /**
  6698. * Normals
  6699. */
  6700. static readonly NormalKind: string;
  6701. /**
  6702. * Tangents
  6703. */
  6704. static readonly TangentKind: string;
  6705. /**
  6706. * Texture coordinates
  6707. */
  6708. static readonly UVKind: string;
  6709. /**
  6710. * Texture coordinates 2
  6711. */
  6712. static readonly UV2Kind: string;
  6713. /**
  6714. * Texture coordinates 3
  6715. */
  6716. static readonly UV3Kind: string;
  6717. /**
  6718. * Texture coordinates 4
  6719. */
  6720. static readonly UV4Kind: string;
  6721. /**
  6722. * Texture coordinates 5
  6723. */
  6724. static readonly UV5Kind: string;
  6725. /**
  6726. * Texture coordinates 6
  6727. */
  6728. static readonly UV6Kind: string;
  6729. /**
  6730. * Colors
  6731. */
  6732. static readonly ColorKind: string;
  6733. /**
  6734. * Matrix indices (for bones)
  6735. */
  6736. static readonly MatricesIndicesKind: string;
  6737. /**
  6738. * Matrix weights (for bones)
  6739. */
  6740. static readonly MatricesWeightsKind: string;
  6741. /**
  6742. * Additional matrix indices (for bones)
  6743. */
  6744. static readonly MatricesIndicesExtraKind: string;
  6745. /**
  6746. * Additional matrix weights (for bones)
  6747. */
  6748. static readonly MatricesWeightsExtraKind: string;
  6749. /**
  6750. * Deduces the stride given a kind.
  6751. * @param kind The kind string to deduce
  6752. * @returns The deduced stride
  6753. */
  6754. static DeduceStride(kind: string): number;
  6755. /**
  6756. * Gets the byte length of the given type.
  6757. * @param type the type
  6758. * @returns the number of bytes
  6759. */
  6760. static GetTypeByteLength(type: number): number;
  6761. /**
  6762. * Enumerates each value of the given parameters as numbers.
  6763. * @param data the data to enumerate
  6764. * @param byteOffset the byte offset of the data
  6765. * @param byteStride the byte stride of the data
  6766. * @param componentCount the number of components per element
  6767. * @param componentType the type of the component
  6768. * @param count the number of values to enumerate
  6769. * @param normalized whether the data is normalized
  6770. * @param callback the callback function called for each value
  6771. */
  6772. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6773. private static _GetFloatValue;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/intersectionInfo" {
  6777. import { Nullable } from "babylonjs/types";
  6778. /**
  6779. * @hidden
  6780. */
  6781. export class IntersectionInfo {
  6782. bu: Nullable<number>;
  6783. bv: Nullable<number>;
  6784. distance: number;
  6785. faceId: number;
  6786. subMeshId: number;
  6787. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6788. }
  6789. }
  6790. declare module "babylonjs/Culling/boundingSphere" {
  6791. import { DeepImmutable } from "babylonjs/types";
  6792. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6793. import { Plane } from "babylonjs/Maths/math.plane";
  6794. /**
  6795. * Class used to store bounding sphere information
  6796. */
  6797. export class BoundingSphere {
  6798. /**
  6799. * Gets the center of the bounding sphere in local space
  6800. */
  6801. readonly center: Vector3;
  6802. /**
  6803. * Radius of the bounding sphere in local space
  6804. */
  6805. radius: number;
  6806. /**
  6807. * Gets the center of the bounding sphere in world space
  6808. */
  6809. readonly centerWorld: Vector3;
  6810. /**
  6811. * Radius of the bounding sphere in world space
  6812. */
  6813. radiusWorld: number;
  6814. /**
  6815. * Gets the minimum vector in local space
  6816. */
  6817. readonly minimum: Vector3;
  6818. /**
  6819. * Gets the maximum vector in local space
  6820. */
  6821. readonly maximum: Vector3;
  6822. private _worldMatrix;
  6823. private static readonly TmpVector3;
  6824. /**
  6825. * Creates a new bounding sphere
  6826. * @param min defines the minimum vector (in local space)
  6827. * @param max defines the maximum vector (in local space)
  6828. * @param worldMatrix defines the new world matrix
  6829. */
  6830. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6831. /**
  6832. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6833. * @param min defines the new minimum vector (in local space)
  6834. * @param max defines the new maximum vector (in local space)
  6835. * @param worldMatrix defines the new world matrix
  6836. */
  6837. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6838. /**
  6839. * Scale the current bounding sphere by applying a scale factor
  6840. * @param factor defines the scale factor to apply
  6841. * @returns the current bounding box
  6842. */
  6843. scale(factor: number): BoundingSphere;
  6844. /**
  6845. * Gets the world matrix of the bounding box
  6846. * @returns a matrix
  6847. */
  6848. getWorldMatrix(): DeepImmutable<Matrix>;
  6849. /** @hidden */
  6850. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6851. /**
  6852. * Tests if the bounding sphere is intersecting the frustum planes
  6853. * @param frustumPlanes defines the frustum planes to test
  6854. * @returns true if there is an intersection
  6855. */
  6856. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6857. /**
  6858. * Tests if the bounding sphere center is in between the frustum planes.
  6859. * Used for optimistic fast inclusion.
  6860. * @param frustumPlanes defines the frustum planes to test
  6861. * @returns true if the sphere center is in between the frustum planes
  6862. */
  6863. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6864. /**
  6865. * Tests if a point is inside the bounding sphere
  6866. * @param point defines the point to test
  6867. * @returns true if the point is inside the bounding sphere
  6868. */
  6869. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6870. /**
  6871. * Checks if two sphere intersct
  6872. * @param sphere0 sphere 0
  6873. * @param sphere1 sphere 1
  6874. * @returns true if the speres intersect
  6875. */
  6876. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingBox" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6882. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6883. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6884. import { Plane } from "babylonjs/Maths/math.plane";
  6885. /**
  6886. * Class used to store bounding box information
  6887. */
  6888. export class BoundingBox implements ICullable {
  6889. /**
  6890. * Gets the 8 vectors representing the bounding box in local space
  6891. */
  6892. readonly vectors: Vector3[];
  6893. /**
  6894. * Gets the center of the bounding box in local space
  6895. */
  6896. readonly center: Vector3;
  6897. /**
  6898. * Gets the center of the bounding box in world space
  6899. */
  6900. readonly centerWorld: Vector3;
  6901. /**
  6902. * Gets the extend size in local space
  6903. */
  6904. readonly extendSize: Vector3;
  6905. /**
  6906. * Gets the extend size in world space
  6907. */
  6908. readonly extendSizeWorld: Vector3;
  6909. /**
  6910. * Gets the OBB (object bounding box) directions
  6911. */
  6912. readonly directions: Vector3[];
  6913. /**
  6914. * Gets the 8 vectors representing the bounding box in world space
  6915. */
  6916. readonly vectorsWorld: Vector3[];
  6917. /**
  6918. * Gets the minimum vector in world space
  6919. */
  6920. readonly minimumWorld: Vector3;
  6921. /**
  6922. * Gets the maximum vector in world space
  6923. */
  6924. readonly maximumWorld: Vector3;
  6925. /**
  6926. * Gets the minimum vector in local space
  6927. */
  6928. readonly minimum: Vector3;
  6929. /**
  6930. * Gets the maximum vector in local space
  6931. */
  6932. readonly maximum: Vector3;
  6933. private _worldMatrix;
  6934. private static readonly TmpVector3;
  6935. /**
  6936. * @hidden
  6937. */
  6938. _tag: number;
  6939. /**
  6940. * Creates a new bounding box
  6941. * @param min defines the minimum vector (in local space)
  6942. * @param max defines the maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6946. /**
  6947. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6948. * @param min defines the new minimum vector (in local space)
  6949. * @param max defines the new maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6953. /**
  6954. * Scale the current bounding box by applying a scale factor
  6955. * @param factor defines the scale factor to apply
  6956. * @returns the current bounding box
  6957. */
  6958. scale(factor: number): BoundingBox;
  6959. /**
  6960. * Gets the world matrix of the bounding box
  6961. * @returns a matrix
  6962. */
  6963. getWorldMatrix(): DeepImmutable<Matrix>;
  6964. /** @hidden */
  6965. _update(world: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Tests if the bounding box is intersecting the frustum planes
  6968. * @param frustumPlanes defines the frustum planes to test
  6969. * @returns true if there is an intersection
  6970. */
  6971. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6972. /**
  6973. * Tests if the bounding box is entirely inside the frustum planes
  6974. * @param frustumPlanes defines the frustum planes to test
  6975. * @returns true if there is an inclusion
  6976. */
  6977. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6978. /**
  6979. * Tests if a point is inside the bounding box
  6980. * @param point defines the point to test
  6981. * @returns true if the point is inside the bounding box
  6982. */
  6983. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6984. /**
  6985. * Tests if the bounding box intersects with a bounding sphere
  6986. * @param sphere defines the sphere to test
  6987. * @returns true if there is an intersection
  6988. */
  6989. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6990. /**
  6991. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6992. * @param min defines the min vector to use
  6993. * @param max defines the max vector to use
  6994. * @returns true if there is an intersection
  6995. */
  6996. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6997. /**
  6998. * Tests if two bounding boxes are intersections
  6999. * @param box0 defines the first box to test
  7000. * @param box1 defines the second box to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7004. /**
  7005. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7006. * @param minPoint defines the minimum vector of the bounding box
  7007. * @param maxPoint defines the maximum vector of the bounding box
  7008. * @param sphereCenter defines the sphere center
  7009. * @param sphereRadius defines the sphere radius
  7010. * @returns true if there is an intersection
  7011. */
  7012. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7013. /**
  7014. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7015. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7016. * @param frustumPlanes defines the frustum planes to test
  7017. * @return true if there is an inclusion
  7018. */
  7019. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7020. /**
  7021. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7022. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7023. * @param frustumPlanes defines the frustum planes to test
  7024. * @return true if there is an intersection
  7025. */
  7026. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7027. }
  7028. }
  7029. declare module "babylonjs/Collisions/collider" {
  7030. import { Nullable, IndicesArray } from "babylonjs/types";
  7031. import { Vector3 } from "babylonjs/Maths/math.vector";
  7032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7033. import { Plane } from "babylonjs/Maths/math.plane";
  7034. /** @hidden */
  7035. export class Collider {
  7036. /** Define if a collision was found */
  7037. collisionFound: boolean;
  7038. /**
  7039. * Define last intersection point in local space
  7040. */
  7041. intersectionPoint: Vector3;
  7042. /**
  7043. * Define last collided mesh
  7044. */
  7045. collidedMesh: Nullable<AbstractMesh>;
  7046. private _collisionPoint;
  7047. private _planeIntersectionPoint;
  7048. private _tempVector;
  7049. private _tempVector2;
  7050. private _tempVector3;
  7051. private _tempVector4;
  7052. private _edge;
  7053. private _baseToVertex;
  7054. private _destinationPoint;
  7055. private _slidePlaneNormal;
  7056. private _displacementVector;
  7057. /** @hidden */
  7058. _radius: Vector3;
  7059. /** @hidden */
  7060. _retry: number;
  7061. private _velocity;
  7062. private _basePoint;
  7063. private _epsilon;
  7064. /** @hidden */
  7065. _velocityWorldLength: number;
  7066. /** @hidden */
  7067. _basePointWorld: Vector3;
  7068. private _velocityWorld;
  7069. private _normalizedVelocity;
  7070. /** @hidden */
  7071. _initialVelocity: Vector3;
  7072. /** @hidden */
  7073. _initialPosition: Vector3;
  7074. private _nearestDistance;
  7075. private _collisionMask;
  7076. get collisionMask(): number;
  7077. set collisionMask(mask: number);
  7078. /**
  7079. * Gets the plane normal used to compute the sliding response (in local space)
  7080. */
  7081. get slidePlaneNormal(): Vector3;
  7082. /** @hidden */
  7083. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7084. /** @hidden */
  7085. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7086. /** @hidden */
  7087. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7088. /** @hidden */
  7089. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7090. /** @hidden */
  7091. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7092. /** @hidden */
  7093. _getResponse(pos: Vector3, vel: Vector3): void;
  7094. }
  7095. }
  7096. declare module "babylonjs/Culling/boundingInfo" {
  7097. import { DeepImmutable } from "babylonjs/types";
  7098. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7099. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7100. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7101. import { Plane } from "babylonjs/Maths/math.plane";
  7102. import { Collider } from "babylonjs/Collisions/collider";
  7103. /**
  7104. * Interface for cullable objects
  7105. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7106. */
  7107. export interface ICullable {
  7108. /**
  7109. * Checks if the object or part of the object is in the frustum
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isInFrustum(frustumPlanes: Plane[]): boolean;
  7114. /**
  7115. * Checks if a cullable object (mesh...) is in the camera frustum
  7116. * Unlike isInFrustum this cheks the full bounding box
  7117. * @param frustumPlanes Camera near/planes
  7118. * @returns true if the object is in frustum otherwise false
  7119. */
  7120. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7121. }
  7122. /**
  7123. * Info for a bounding data of a mesh
  7124. */
  7125. export class BoundingInfo implements ICullable {
  7126. /**
  7127. * Bounding box for the mesh
  7128. */
  7129. readonly boundingBox: BoundingBox;
  7130. /**
  7131. * Bounding sphere for the mesh
  7132. */
  7133. readonly boundingSphere: BoundingSphere;
  7134. private _isLocked;
  7135. private static readonly TmpVector3;
  7136. /**
  7137. * Constructs bounding info
  7138. * @param minimum min vector of the bounding box/sphere
  7139. * @param maximum max vector of the bounding box/sphere
  7140. * @param worldMatrix defines the new world matrix
  7141. */
  7142. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7143. /**
  7144. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7145. * @param min defines the new minimum vector (in local space)
  7146. * @param max defines the new maximum vector (in local space)
  7147. * @param worldMatrix defines the new world matrix
  7148. */
  7149. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7150. /**
  7151. * min vector of the bounding box/sphere
  7152. */
  7153. get minimum(): Vector3;
  7154. /**
  7155. * max vector of the bounding box/sphere
  7156. */
  7157. get maximum(): Vector3;
  7158. /**
  7159. * If the info is locked and won't be updated to avoid perf overhead
  7160. */
  7161. get isLocked(): boolean;
  7162. set isLocked(value: boolean);
  7163. /**
  7164. * Updates the bounding sphere and box
  7165. * @param world world matrix to be used to update
  7166. */
  7167. update(world: DeepImmutable<Matrix>): void;
  7168. /**
  7169. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7170. * @param center New center of the bounding info
  7171. * @param extend New extend of the bounding info
  7172. * @returns the current bounding info
  7173. */
  7174. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7175. /**
  7176. * Scale the current bounding info by applying a scale factor
  7177. * @param factor defines the scale factor to apply
  7178. * @returns the current bounding info
  7179. */
  7180. scale(factor: number): BoundingInfo;
  7181. /**
  7182. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7183. * @param frustumPlanes defines the frustum to test
  7184. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7185. * @returns true if the bounding info is in the frustum planes
  7186. */
  7187. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7188. /**
  7189. * Gets the world distance between the min and max points of the bounding box
  7190. */
  7191. get diagonalLength(): number;
  7192. /**
  7193. * Checks if a cullable object (mesh...) is in the camera frustum
  7194. * Unlike isInFrustum this cheks the full bounding box
  7195. * @param frustumPlanes Camera near/planes
  7196. * @returns true if the object is in frustum otherwise false
  7197. */
  7198. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7199. /** @hidden */
  7200. _checkCollision(collider: Collider): boolean;
  7201. /**
  7202. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7203. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7204. * @param point the point to check intersection with
  7205. * @returns if the point intersects
  7206. */
  7207. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7208. /**
  7209. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7210. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7211. * @param boundingInfo the bounding info to check intersection with
  7212. * @param precise if the intersection should be done using OBB
  7213. * @returns if the bounding info intersects
  7214. */
  7215. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7216. }
  7217. }
  7218. declare module "babylonjs/Maths/math.functions" {
  7219. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7220. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7221. /**
  7222. * Extracts minimum and maximum values from a list of indexed positions
  7223. * @param positions defines the positions to use
  7224. * @param indices defines the indices to the positions
  7225. * @param indexStart defines the start index
  7226. * @param indexCount defines the end index
  7227. * @param bias defines bias value to add to the result
  7228. * @return minimum and maximum values
  7229. */
  7230. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7231. minimum: Vector3;
  7232. maximum: Vector3;
  7233. };
  7234. /**
  7235. * Extracts minimum and maximum values from a list of positions
  7236. * @param positions defines the positions to use
  7237. * @param start defines the start index in the positions array
  7238. * @param count defines the number of positions to handle
  7239. * @param bias defines bias value to add to the result
  7240. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7241. * @return minimum and maximum values
  7242. */
  7243. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7244. minimum: Vector3;
  7245. maximum: Vector3;
  7246. };
  7247. }
  7248. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7249. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7250. /** @hidden */
  7251. export class WebGLDataBuffer extends DataBuffer {
  7252. private _buffer;
  7253. constructor(resource: WebGLBuffer);
  7254. get underlyingResource(): any;
  7255. }
  7256. }
  7257. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7258. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7259. import { Nullable } from "babylonjs/types";
  7260. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7261. /** @hidden */
  7262. export class WebGLPipelineContext implements IPipelineContext {
  7263. engine: ThinEngine;
  7264. program: Nullable<WebGLProgram>;
  7265. context?: WebGLRenderingContext;
  7266. vertexShader?: WebGLShader;
  7267. fragmentShader?: WebGLShader;
  7268. isParallelCompiled: boolean;
  7269. onCompiled?: () => void;
  7270. transformFeedback?: WebGLTransformFeedback | null;
  7271. vertexCompilationError: Nullable<string>;
  7272. fragmentCompilationError: Nullable<string>;
  7273. programLinkError: Nullable<string>;
  7274. programValidationError: Nullable<string>;
  7275. get isAsync(): boolean;
  7276. get isReady(): boolean;
  7277. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7278. _getVertexShaderCode(): string | null;
  7279. _getFragmentShaderCode(): string | null;
  7280. }
  7281. }
  7282. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7283. import { FloatArray, Nullable } from "babylonjs/types";
  7284. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7285. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7286. module "babylonjs/Engines/thinEngine" {
  7287. interface ThinEngine {
  7288. /**
  7289. * Create an uniform buffer
  7290. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7291. * @param elements defines the content of the uniform buffer
  7292. * @returns the webGL uniform buffer
  7293. */
  7294. createUniformBuffer(elements: FloatArray): DataBuffer;
  7295. /**
  7296. * Create a dynamic uniform buffer
  7297. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7298. * @param elements defines the content of the uniform buffer
  7299. * @returns the webGL uniform buffer
  7300. */
  7301. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7302. /**
  7303. * Update an existing uniform buffer
  7304. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7305. * @param uniformBuffer defines the target uniform buffer
  7306. * @param elements defines the content to update
  7307. * @param offset defines the offset in the uniform buffer where update should start
  7308. * @param count defines the size of the data to update
  7309. */
  7310. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7311. /**
  7312. * Bind an uniform buffer to the current webGL context
  7313. * @param buffer defines the buffer to bind
  7314. */
  7315. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7316. /**
  7317. * Bind a buffer to the current webGL context at a given location
  7318. * @param buffer defines the buffer to bind
  7319. * @param location defines the index where to bind the buffer
  7320. */
  7321. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7322. /**
  7323. * Bind a specific block at a given index in a specific shader program
  7324. * @param pipelineContext defines the pipeline context to use
  7325. * @param blockName defines the block name
  7326. * @param index defines the index where to bind the block
  7327. */
  7328. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7329. }
  7330. }
  7331. }
  7332. declare module "babylonjs/Materials/uniformBuffer" {
  7333. import { Nullable, FloatArray } from "babylonjs/types";
  7334. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7335. import { Engine } from "babylonjs/Engines/engine";
  7336. import { Effect } from "babylonjs/Materials/effect";
  7337. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7338. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7339. import { Color3 } from "babylonjs/Maths/math.color";
  7340. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7341. /**
  7342. * Uniform buffer objects.
  7343. *
  7344. * Handles blocks of uniform on the GPU.
  7345. *
  7346. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7347. *
  7348. * For more information, please refer to :
  7349. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7350. */
  7351. export class UniformBuffer {
  7352. private _engine;
  7353. private _buffer;
  7354. private _data;
  7355. private _bufferData;
  7356. private _dynamic?;
  7357. private _uniformLocations;
  7358. private _uniformSizes;
  7359. private _uniformLocationPointer;
  7360. private _needSync;
  7361. private _noUBO;
  7362. private _currentEffect;
  7363. /** @hidden */
  7364. _alreadyBound: boolean;
  7365. private static _MAX_UNIFORM_SIZE;
  7366. private static _tempBuffer;
  7367. /**
  7368. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7373. /**
  7374. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7379. /**
  7380. * Lambda to Update a single float in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateFloat: (name: string, x: number) => void;
  7385. /**
  7386. * Lambda to Update a vec2 of float in a uniform buffer.
  7387. * This is dynamic to allow compat with webgl 1 and 2.
  7388. * You will need to pass the name of the uniform as well as the value.
  7389. */
  7390. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7391. /**
  7392. * Lambda to Update a vec3 of float in a uniform buffer.
  7393. * This is dynamic to allow compat with webgl 1 and 2.
  7394. * You will need to pass the name of the uniform as well as the value.
  7395. */
  7396. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7397. /**
  7398. * Lambda to Update a vec4 of float in a uniform buffer.
  7399. * This is dynamic to allow compat with webgl 1 and 2.
  7400. * You will need to pass the name of the uniform as well as the value.
  7401. */
  7402. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7403. /**
  7404. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7405. * This is dynamic to allow compat with webgl 1 and 2.
  7406. * You will need to pass the name of the uniform as well as the value.
  7407. */
  7408. updateMatrix: (name: string, mat: Matrix) => void;
  7409. /**
  7410. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7411. * This is dynamic to allow compat with webgl 1 and 2.
  7412. * You will need to pass the name of the uniform as well as the value.
  7413. */
  7414. updateVector3: (name: string, vector: Vector3) => void;
  7415. /**
  7416. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7417. * This is dynamic to allow compat with webgl 1 and 2.
  7418. * You will need to pass the name of the uniform as well as the value.
  7419. */
  7420. updateVector4: (name: string, vector: Vector4) => void;
  7421. /**
  7422. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7423. * This is dynamic to allow compat with webgl 1 and 2.
  7424. * You will need to pass the name of the uniform as well as the value.
  7425. */
  7426. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7427. /**
  7428. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7429. * This is dynamic to allow compat with webgl 1 and 2.
  7430. * You will need to pass the name of the uniform as well as the value.
  7431. */
  7432. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7433. /**
  7434. * Instantiates a new Uniform buffer objects.
  7435. *
  7436. * Handles blocks of uniform on the GPU.
  7437. *
  7438. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7439. *
  7440. * For more information, please refer to :
  7441. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7442. * @param engine Define the engine the buffer is associated with
  7443. * @param data Define the data contained in the buffer
  7444. * @param dynamic Define if the buffer is updatable
  7445. */
  7446. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7447. /**
  7448. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7449. * or just falling back on setUniformXXX calls.
  7450. */
  7451. get useUbo(): boolean;
  7452. /**
  7453. * Indicates if the WebGL underlying uniform buffer is in sync
  7454. * with the javascript cache data.
  7455. */
  7456. get isSync(): boolean;
  7457. /**
  7458. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7459. * Also, a dynamic UniformBuffer will disable cache verification and always
  7460. * update the underlying WebGL uniform buffer to the GPU.
  7461. * @returns if Dynamic, otherwise false
  7462. */
  7463. isDynamic(): boolean;
  7464. /**
  7465. * The data cache on JS side.
  7466. * @returns the underlying data as a float array
  7467. */
  7468. getData(): Float32Array;
  7469. /**
  7470. * The underlying WebGL Uniform buffer.
  7471. * @returns the webgl buffer
  7472. */
  7473. getBuffer(): Nullable<DataBuffer>;
  7474. /**
  7475. * std140 layout specifies how to align data within an UBO structure.
  7476. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7477. * for specs.
  7478. */
  7479. private _fillAlignment;
  7480. /**
  7481. * Adds an uniform in the buffer.
  7482. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7483. * for the layout to be correct !
  7484. * @param name Name of the uniform, as used in the uniform block in the shader.
  7485. * @param size Data size, or data directly.
  7486. */
  7487. addUniform(name: string, size: number | number[]): void;
  7488. /**
  7489. * Adds a Matrix 4x4 to the uniform buffer.
  7490. * @param name Name of the uniform, as used in the uniform block in the shader.
  7491. * @param mat A 4x4 matrix.
  7492. */
  7493. addMatrix(name: string, mat: Matrix): void;
  7494. /**
  7495. * Adds a vec2 to the uniform buffer.
  7496. * @param name Name of the uniform, as used in the uniform block in the shader.
  7497. * @param x Define the x component value of the vec2
  7498. * @param y Define the y component value of the vec2
  7499. */
  7500. addFloat2(name: string, x: number, y: number): void;
  7501. /**
  7502. * Adds a vec3 to the uniform buffer.
  7503. * @param name Name of the uniform, as used in the uniform block in the shader.
  7504. * @param x Define the x component value of the vec3
  7505. * @param y Define the y component value of the vec3
  7506. * @param z Define the z component value of the vec3
  7507. */
  7508. addFloat3(name: string, x: number, y: number, z: number): void;
  7509. /**
  7510. * Adds a vec3 to the uniform buffer.
  7511. * @param name Name of the uniform, as used in the uniform block in the shader.
  7512. * @param color Define the vec3 from a Color
  7513. */
  7514. addColor3(name: string, color: Color3): void;
  7515. /**
  7516. * Adds a vec4 to the uniform buffer.
  7517. * @param name Name of the uniform, as used in the uniform block in the shader.
  7518. * @param color Define the rgb components from a Color
  7519. * @param alpha Define the a component of the vec4
  7520. */
  7521. addColor4(name: string, color: Color3, alpha: number): void;
  7522. /**
  7523. * Adds a vec3 to the uniform buffer.
  7524. * @param name Name of the uniform, as used in the uniform block in the shader.
  7525. * @param vector Define the vec3 components from a Vector
  7526. */
  7527. addVector3(name: string, vector: Vector3): void;
  7528. /**
  7529. * Adds a Matrix 3x3 to the uniform buffer.
  7530. * @param name Name of the uniform, as used in the uniform block in the shader.
  7531. */
  7532. addMatrix3x3(name: string): void;
  7533. /**
  7534. * Adds a Matrix 2x2 to the uniform buffer.
  7535. * @param name Name of the uniform, as used in the uniform block in the shader.
  7536. */
  7537. addMatrix2x2(name: string): void;
  7538. /**
  7539. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7540. */
  7541. create(): void;
  7542. /** @hidden */
  7543. _rebuild(): void;
  7544. /**
  7545. * Updates the WebGL Uniform Buffer on the GPU.
  7546. * If the `dynamic` flag is set to true, no cache comparison is done.
  7547. * Otherwise, the buffer will be updated only if the cache differs.
  7548. */
  7549. update(): void;
  7550. /**
  7551. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7552. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7553. * @param data Define the flattened data
  7554. * @param size Define the size of the data.
  7555. */
  7556. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7557. private _valueCache;
  7558. private _cacheMatrix;
  7559. private _updateMatrix3x3ForUniform;
  7560. private _updateMatrix3x3ForEffect;
  7561. private _updateMatrix2x2ForEffect;
  7562. private _updateMatrix2x2ForUniform;
  7563. private _updateFloatForEffect;
  7564. private _updateFloatForUniform;
  7565. private _updateFloat2ForEffect;
  7566. private _updateFloat2ForUniform;
  7567. private _updateFloat3ForEffect;
  7568. private _updateFloat3ForUniform;
  7569. private _updateFloat4ForEffect;
  7570. private _updateFloat4ForUniform;
  7571. private _updateMatrixForEffect;
  7572. private _updateMatrixForUniform;
  7573. private _updateVector3ForEffect;
  7574. private _updateVector3ForUniform;
  7575. private _updateVector4ForEffect;
  7576. private _updateVector4ForUniform;
  7577. private _updateColor3ForEffect;
  7578. private _updateColor3ForUniform;
  7579. private _updateColor4ForEffect;
  7580. private _updateColor4ForUniform;
  7581. /**
  7582. * Sets a sampler uniform on the effect.
  7583. * @param name Define the name of the sampler.
  7584. * @param texture Define the texture to set in the sampler
  7585. */
  7586. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7587. /**
  7588. * Directly updates the value of the uniform in the cache AND on the GPU.
  7589. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7590. * @param data Define the flattened data
  7591. */
  7592. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7593. /**
  7594. * Binds this uniform buffer to an effect.
  7595. * @param effect Define the effect to bind the buffer to
  7596. * @param name Name of the uniform block in the shader.
  7597. */
  7598. bindToEffect(effect: Effect, name: string): void;
  7599. /**
  7600. * Disposes the uniform buffer.
  7601. */
  7602. dispose(): void;
  7603. }
  7604. }
  7605. declare module "babylonjs/Misc/iInspectable" {
  7606. /**
  7607. * Enum that determines the text-wrapping mode to use.
  7608. */
  7609. export enum InspectableType {
  7610. /**
  7611. * Checkbox for booleans
  7612. */
  7613. Checkbox = 0,
  7614. /**
  7615. * Sliders for numbers
  7616. */
  7617. Slider = 1,
  7618. /**
  7619. * Vector3
  7620. */
  7621. Vector3 = 2,
  7622. /**
  7623. * Quaternions
  7624. */
  7625. Quaternion = 3,
  7626. /**
  7627. * Color3
  7628. */
  7629. Color3 = 4,
  7630. /**
  7631. * String
  7632. */
  7633. String = 5
  7634. }
  7635. /**
  7636. * Interface used to define custom inspectable properties.
  7637. * This interface is used by the inspector to display custom property grids
  7638. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7639. */
  7640. export interface IInspectable {
  7641. /**
  7642. * Gets the label to display
  7643. */
  7644. label: string;
  7645. /**
  7646. * Gets the name of the property to edit
  7647. */
  7648. propertyName: string;
  7649. /**
  7650. * Gets the type of the editor to use
  7651. */
  7652. type: InspectableType;
  7653. /**
  7654. * Gets the minimum value of the property when using in "slider" mode
  7655. */
  7656. min?: number;
  7657. /**
  7658. * Gets the maximum value of the property when using in "slider" mode
  7659. */
  7660. max?: number;
  7661. /**
  7662. * Gets the setp to use when using in "slider" mode
  7663. */
  7664. step?: number;
  7665. }
  7666. }
  7667. declare module "babylonjs/Misc/timingTools" {
  7668. /**
  7669. * Class used to provide helper for timing
  7670. */
  7671. export class TimingTools {
  7672. /**
  7673. * Polyfill for setImmediate
  7674. * @param action defines the action to execute after the current execution block
  7675. */
  7676. static SetImmediate(action: () => void): void;
  7677. }
  7678. }
  7679. declare module "babylonjs/Misc/instantiationTools" {
  7680. /**
  7681. * Class used to enable instatition of objects by class name
  7682. */
  7683. export class InstantiationTools {
  7684. /**
  7685. * Use this object to register external classes like custom textures or material
  7686. * to allow the laoders to instantiate them
  7687. */
  7688. static RegisteredExternalClasses: {
  7689. [key: string]: Object;
  7690. };
  7691. /**
  7692. * Tries to instantiate a new object from a given class name
  7693. * @param className defines the class name to instantiate
  7694. * @returns the new object or null if the system was not able to do the instantiation
  7695. */
  7696. static Instantiate(className: string): any;
  7697. }
  7698. }
  7699. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7700. /**
  7701. * Define options used to create a depth texture
  7702. */
  7703. export class DepthTextureCreationOptions {
  7704. /** Specifies whether or not a stencil should be allocated in the texture */
  7705. generateStencil?: boolean;
  7706. /** Specifies whether or not bilinear filtering is enable on the texture */
  7707. bilinearFiltering?: boolean;
  7708. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7709. comparisonFunction?: number;
  7710. /** Specifies if the created texture is a cube texture */
  7711. isCube?: boolean;
  7712. }
  7713. }
  7714. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7715. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7716. import { Nullable } from "babylonjs/types";
  7717. import { Scene } from "babylonjs/scene";
  7718. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7719. module "babylonjs/Engines/thinEngine" {
  7720. interface ThinEngine {
  7721. /**
  7722. * Creates a depth stencil cube texture.
  7723. * This is only available in WebGL 2.
  7724. * @param size The size of face edge in the cube texture.
  7725. * @param options The options defining the cube texture.
  7726. * @returns The cube texture
  7727. */
  7728. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7729. /**
  7730. * Creates a cube texture
  7731. * @param rootUrl defines the url where the files to load is located
  7732. * @param scene defines the current scene
  7733. * @param files defines the list of files to load (1 per face)
  7734. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7735. * @param onLoad defines an optional callback raised when the texture is loaded
  7736. * @param onError defines an optional callback raised if there is an issue to load the texture
  7737. * @param format defines the format of the data
  7738. * @param forcedExtension defines the extension to use to pick the right loader
  7739. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7740. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7741. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7742. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7743. * @returns the cube texture as an InternalTexture
  7744. */
  7745. 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;
  7746. /**
  7747. * Creates a cube texture
  7748. * @param rootUrl defines the url where the files to load is located
  7749. * @param scene defines the current scene
  7750. * @param files defines the list of files to load (1 per face)
  7751. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7752. * @param onLoad defines an optional callback raised when the texture is loaded
  7753. * @param onError defines an optional callback raised if there is an issue to load the texture
  7754. * @param format defines the format of the data
  7755. * @param forcedExtension defines the extension to use to pick the right loader
  7756. * @returns the cube texture as an InternalTexture
  7757. */
  7758. 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;
  7759. /**
  7760. * Creates a cube texture
  7761. * @param rootUrl defines the url where the files to load is located
  7762. * @param scene defines the current scene
  7763. * @param files defines the list of files to load (1 per face)
  7764. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7765. * @param onLoad defines an optional callback raised when the texture is loaded
  7766. * @param onError defines an optional callback raised if there is an issue to load the texture
  7767. * @param format defines the format of the data
  7768. * @param forcedExtension defines the extension to use to pick the right loader
  7769. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7770. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7771. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7772. * @returns the cube texture as an InternalTexture
  7773. */
  7774. 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;
  7775. /** @hidden */
  7776. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7779. /** @hidden */
  7780. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /** @hidden */
  7782. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7783. /**
  7784. * @hidden
  7785. */
  7786. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7787. }
  7788. }
  7789. }
  7790. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7791. import { Nullable } from "babylonjs/types";
  7792. import { Scene } from "babylonjs/scene";
  7793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7795. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7796. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7797. import { Observable } from "babylonjs/Misc/observable";
  7798. /**
  7799. * Class for creating a cube texture
  7800. */
  7801. export class CubeTexture extends BaseTexture {
  7802. private _delayedOnLoad;
  7803. /**
  7804. * Observable triggered once the texture has been loaded.
  7805. */
  7806. onLoadObservable: Observable<CubeTexture>;
  7807. /**
  7808. * The url of the texture
  7809. */
  7810. url: string;
  7811. /**
  7812. * Gets or sets the center of the bounding box associated with the cube texture.
  7813. * It must define where the camera used to render the texture was set
  7814. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7815. */
  7816. boundingBoxPosition: Vector3;
  7817. private _boundingBoxSize;
  7818. /**
  7819. * Gets or sets the size of the bounding box associated with the cube texture
  7820. * When defined, the cubemap will switch to local mode
  7821. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7822. * @example https://www.babylonjs-playground.com/#RNASML
  7823. */
  7824. set boundingBoxSize(value: Vector3);
  7825. /**
  7826. * Returns the bounding box size
  7827. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7828. */
  7829. get boundingBoxSize(): Vector3;
  7830. protected _rotationY: number;
  7831. /**
  7832. * Sets texture matrix rotation angle around Y axis in radians.
  7833. */
  7834. set rotationY(value: number);
  7835. /**
  7836. * Gets texture matrix rotation angle around Y axis radians.
  7837. */
  7838. get rotationY(): number;
  7839. /**
  7840. * Are mip maps generated for this texture or not.
  7841. */
  7842. get noMipmap(): boolean;
  7843. private _noMipmap;
  7844. private _files;
  7845. protected _forcedExtension: Nullable<string>;
  7846. private _extensions;
  7847. private _textureMatrix;
  7848. private _format;
  7849. private _createPolynomials;
  7850. /**
  7851. * Creates a cube texture from an array of image urls
  7852. * @param files defines an array of image urls
  7853. * @param scene defines the hosting scene
  7854. * @param noMipmap specifies if mip maps are not used
  7855. * @returns a cube texture
  7856. */
  7857. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7858. /**
  7859. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7860. * @param url defines the url of the prefiltered texture
  7861. * @param scene defines the scene the texture is attached to
  7862. * @param forcedExtension defines the extension of the file if different from the url
  7863. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7864. * @return the prefiltered texture
  7865. */
  7866. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7867. /**
  7868. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7869. * as prefiltered data.
  7870. * @param rootUrl defines the url of the texture or the root name of the six images
  7871. * @param null defines the scene or engine the texture is attached to
  7872. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7873. * @param noMipmap defines if mipmaps should be created or not
  7874. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7875. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7876. * @param onError defines a callback triggered in case of error during load
  7877. * @param format defines the internal format to use for the texture once loaded
  7878. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7879. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7880. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7881. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7882. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7883. * @return the cube texture
  7884. */
  7885. 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);
  7886. /**
  7887. * Get the current class name of the texture useful for serialization or dynamic coding.
  7888. * @returns "CubeTexture"
  7889. */
  7890. getClassName(): string;
  7891. /**
  7892. * Update the url (and optional buffer) of this texture if url was null during construction.
  7893. * @param url the url of the texture
  7894. * @param forcedExtension defines the extension to use
  7895. * @param onLoad callback called when the texture is loaded (defaults to null)
  7896. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7897. */
  7898. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7899. /**
  7900. * Delays loading of the cube texture
  7901. * @param forcedExtension defines the extension to use
  7902. */
  7903. delayLoad(forcedExtension?: string): void;
  7904. /**
  7905. * Returns the reflection texture matrix
  7906. * @returns the reflection texture matrix
  7907. */
  7908. getReflectionTextureMatrix(): Matrix;
  7909. /**
  7910. * Sets the reflection texture matrix
  7911. * @param value Reflection texture matrix
  7912. */
  7913. setReflectionTextureMatrix(value: Matrix): void;
  7914. /**
  7915. * Parses text to create a cube texture
  7916. * @param parsedTexture define the serialized text to read from
  7917. * @param scene defines the hosting scene
  7918. * @param rootUrl defines the root url of the cube texture
  7919. * @returns a cube texture
  7920. */
  7921. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7922. /**
  7923. * Makes a clone, or deep copy, of the cube texture
  7924. * @returns a new cube texture
  7925. */
  7926. clone(): CubeTexture;
  7927. }
  7928. }
  7929. declare module "babylonjs/Materials/materialDefines" {
  7930. /**
  7931. * Manages the defines for the Material
  7932. */
  7933. export class MaterialDefines {
  7934. /** @hidden */
  7935. protected _keys: string[];
  7936. private _isDirty;
  7937. /** @hidden */
  7938. _renderId: number;
  7939. /** @hidden */
  7940. _areLightsDirty: boolean;
  7941. /** @hidden */
  7942. _areLightsDisposed: boolean;
  7943. /** @hidden */
  7944. _areAttributesDirty: boolean;
  7945. /** @hidden */
  7946. _areTexturesDirty: boolean;
  7947. /** @hidden */
  7948. _areFresnelDirty: boolean;
  7949. /** @hidden */
  7950. _areMiscDirty: boolean;
  7951. /** @hidden */
  7952. _areImageProcessingDirty: boolean;
  7953. /** @hidden */
  7954. _normals: boolean;
  7955. /** @hidden */
  7956. _uvs: boolean;
  7957. /** @hidden */
  7958. _needNormals: boolean;
  7959. /** @hidden */
  7960. _needUVs: boolean;
  7961. [id: string]: any;
  7962. /**
  7963. * Specifies if the material needs to be re-calculated
  7964. */
  7965. get isDirty(): boolean;
  7966. /**
  7967. * Marks the material to indicate that it has been re-calculated
  7968. */
  7969. markAsProcessed(): void;
  7970. /**
  7971. * Marks the material to indicate that it needs to be re-calculated
  7972. */
  7973. markAsUnprocessed(): void;
  7974. /**
  7975. * Marks the material to indicate all of its defines need to be re-calculated
  7976. */
  7977. markAllAsDirty(): void;
  7978. /**
  7979. * Marks the material to indicate that image processing needs to be re-calculated
  7980. */
  7981. markAsImageProcessingDirty(): void;
  7982. /**
  7983. * Marks the material to indicate the lights need to be re-calculated
  7984. * @param disposed Defines whether the light is dirty due to dispose or not
  7985. */
  7986. markAsLightDirty(disposed?: boolean): void;
  7987. /**
  7988. * Marks the attribute state as changed
  7989. */
  7990. markAsAttributesDirty(): void;
  7991. /**
  7992. * Marks the texture state as changed
  7993. */
  7994. markAsTexturesDirty(): void;
  7995. /**
  7996. * Marks the fresnel state as changed
  7997. */
  7998. markAsFresnelDirty(): void;
  7999. /**
  8000. * Marks the misc state as changed
  8001. */
  8002. markAsMiscDirty(): void;
  8003. /**
  8004. * Rebuilds the material defines
  8005. */
  8006. rebuild(): void;
  8007. /**
  8008. * Specifies if two material defines are equal
  8009. * @param other - A material define instance to compare to
  8010. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8011. */
  8012. isEqual(other: MaterialDefines): boolean;
  8013. /**
  8014. * Clones this instance's defines to another instance
  8015. * @param other - material defines to clone values to
  8016. */
  8017. cloneTo(other: MaterialDefines): void;
  8018. /**
  8019. * Resets the material define values
  8020. */
  8021. reset(): void;
  8022. /**
  8023. * Converts the material define values to a string
  8024. * @returns - String of material define information
  8025. */
  8026. toString(): string;
  8027. }
  8028. }
  8029. declare module "babylonjs/Materials/colorCurves" {
  8030. import { Effect } from "babylonjs/Materials/effect";
  8031. /**
  8032. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8033. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8034. * 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;
  8035. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8036. */
  8037. export class ColorCurves {
  8038. private _dirty;
  8039. private _tempColor;
  8040. private _globalCurve;
  8041. private _highlightsCurve;
  8042. private _midtonesCurve;
  8043. private _shadowsCurve;
  8044. private _positiveCurve;
  8045. private _negativeCurve;
  8046. private _globalHue;
  8047. private _globalDensity;
  8048. private _globalSaturation;
  8049. private _globalExposure;
  8050. /**
  8051. * Gets the global Hue value.
  8052. * 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).
  8053. */
  8054. get globalHue(): number;
  8055. /**
  8056. * Sets the global Hue value.
  8057. * 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).
  8058. */
  8059. set globalHue(value: number);
  8060. /**
  8061. * Gets the global Density value.
  8062. * 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.
  8063. * Values less than zero provide a filter of opposite hue.
  8064. */
  8065. get globalDensity(): number;
  8066. /**
  8067. * Sets the global Density value.
  8068. * 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.
  8069. * Values less than zero provide a filter of opposite hue.
  8070. */
  8071. set globalDensity(value: number);
  8072. /**
  8073. * Gets the global Saturation value.
  8074. * 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.
  8075. */
  8076. get globalSaturation(): number;
  8077. /**
  8078. * Sets the global Saturation value.
  8079. * 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.
  8080. */
  8081. set globalSaturation(value: number);
  8082. /**
  8083. * Gets the global Exposure value.
  8084. * 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.
  8085. */
  8086. get globalExposure(): number;
  8087. /**
  8088. * Sets the global Exposure value.
  8089. * 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.
  8090. */
  8091. set globalExposure(value: number);
  8092. private _highlightsHue;
  8093. private _highlightsDensity;
  8094. private _highlightsSaturation;
  8095. private _highlightsExposure;
  8096. /**
  8097. * Gets the highlights Hue value.
  8098. * 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).
  8099. */
  8100. get highlightsHue(): number;
  8101. /**
  8102. * Sets the highlights Hue value.
  8103. * 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).
  8104. */
  8105. set highlightsHue(value: number);
  8106. /**
  8107. * Gets the highlights Density value.
  8108. * 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.
  8109. * Values less than zero provide a filter of opposite hue.
  8110. */
  8111. get highlightsDensity(): number;
  8112. /**
  8113. * Sets the highlights Density value.
  8114. * 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.
  8115. * Values less than zero provide a filter of opposite hue.
  8116. */
  8117. set highlightsDensity(value: number);
  8118. /**
  8119. * Gets the highlights Saturation value.
  8120. * 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.
  8121. */
  8122. get highlightsSaturation(): number;
  8123. /**
  8124. * Sets the highlights Saturation value.
  8125. * 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.
  8126. */
  8127. set highlightsSaturation(value: number);
  8128. /**
  8129. * Gets the highlights Exposure value.
  8130. * 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.
  8131. */
  8132. get highlightsExposure(): number;
  8133. /**
  8134. * Sets the highlights Exposure value.
  8135. * 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.
  8136. */
  8137. set highlightsExposure(value: number);
  8138. private _midtonesHue;
  8139. private _midtonesDensity;
  8140. private _midtonesSaturation;
  8141. private _midtonesExposure;
  8142. /**
  8143. * Gets the midtones Hue value.
  8144. * 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).
  8145. */
  8146. get midtonesHue(): number;
  8147. /**
  8148. * Sets the midtones Hue value.
  8149. * 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).
  8150. */
  8151. set midtonesHue(value: number);
  8152. /**
  8153. * Gets the midtones Density value.
  8154. * 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.
  8155. * Values less than zero provide a filter of opposite hue.
  8156. */
  8157. get midtonesDensity(): number;
  8158. /**
  8159. * Sets the midtones Density value.
  8160. * 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.
  8161. * Values less than zero provide a filter of opposite hue.
  8162. */
  8163. set midtonesDensity(value: number);
  8164. /**
  8165. * Gets the midtones Saturation value.
  8166. * 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.
  8167. */
  8168. get midtonesSaturation(): number;
  8169. /**
  8170. * Sets the midtones Saturation value.
  8171. * 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.
  8172. */
  8173. set midtonesSaturation(value: number);
  8174. /**
  8175. * Gets the midtones Exposure value.
  8176. * 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.
  8177. */
  8178. get midtonesExposure(): number;
  8179. /**
  8180. * Sets the midtones Exposure value.
  8181. * 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.
  8182. */
  8183. set midtonesExposure(value: number);
  8184. private _shadowsHue;
  8185. private _shadowsDensity;
  8186. private _shadowsSaturation;
  8187. private _shadowsExposure;
  8188. /**
  8189. * Gets the shadows Hue value.
  8190. * 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).
  8191. */
  8192. get shadowsHue(): number;
  8193. /**
  8194. * Sets the shadows Hue value.
  8195. * 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).
  8196. */
  8197. set shadowsHue(value: number);
  8198. /**
  8199. * Gets the shadows Density value.
  8200. * 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.
  8201. * Values less than zero provide a filter of opposite hue.
  8202. */
  8203. get shadowsDensity(): number;
  8204. /**
  8205. * Sets the shadows Density value.
  8206. * 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.
  8207. * Values less than zero provide a filter of opposite hue.
  8208. */
  8209. set shadowsDensity(value: number);
  8210. /**
  8211. * Gets the shadows Saturation value.
  8212. * 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.
  8213. */
  8214. get shadowsSaturation(): number;
  8215. /**
  8216. * Sets the shadows Saturation value.
  8217. * 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.
  8218. */
  8219. set shadowsSaturation(value: number);
  8220. /**
  8221. * Gets the shadows Exposure value.
  8222. * 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.
  8223. */
  8224. get shadowsExposure(): number;
  8225. /**
  8226. * Sets the shadows Exposure value.
  8227. * 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.
  8228. */
  8229. set shadowsExposure(value: number);
  8230. /**
  8231. * Returns the class name
  8232. * @returns The class name
  8233. */
  8234. getClassName(): string;
  8235. /**
  8236. * Binds the color curves to the shader.
  8237. * @param colorCurves The color curve to bind
  8238. * @param effect The effect to bind to
  8239. * @param positiveUniform The positive uniform shader parameter
  8240. * @param neutralUniform The neutral uniform shader parameter
  8241. * @param negativeUniform The negative uniform shader parameter
  8242. */
  8243. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8244. /**
  8245. * Prepare the list of uniforms associated with the ColorCurves effects.
  8246. * @param uniformsList The list of uniforms used in the effect
  8247. */
  8248. static PrepareUniforms(uniformsList: string[]): void;
  8249. /**
  8250. * Returns color grading data based on a hue, density, saturation and exposure value.
  8251. * @param filterHue The hue of the color filter.
  8252. * @param filterDensity The density of the color filter.
  8253. * @param saturation The saturation.
  8254. * @param exposure The exposure.
  8255. * @param result The result data container.
  8256. */
  8257. private getColorGradingDataToRef;
  8258. /**
  8259. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8260. * @param value The input slider value in range [-100,100].
  8261. * @returns Adjusted value.
  8262. */
  8263. private static applyColorGradingSliderNonlinear;
  8264. /**
  8265. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8266. * @param hue The hue (H) input.
  8267. * @param saturation The saturation (S) input.
  8268. * @param brightness The brightness (B) input.
  8269. * @result An RGBA color represented as Vector4.
  8270. */
  8271. private static fromHSBToRef;
  8272. /**
  8273. * Returns a value clamped between min and max
  8274. * @param value The value to clamp
  8275. * @param min The minimum of value
  8276. * @param max The maximum of value
  8277. * @returns The clamped value.
  8278. */
  8279. private static clamp;
  8280. /**
  8281. * Clones the current color curve instance.
  8282. * @return The cloned curves
  8283. */
  8284. clone(): ColorCurves;
  8285. /**
  8286. * Serializes the current color curve instance to a json representation.
  8287. * @return a JSON representation
  8288. */
  8289. serialize(): any;
  8290. /**
  8291. * Parses the color curve from a json representation.
  8292. * @param source the JSON source to parse
  8293. * @return The parsed curves
  8294. */
  8295. static Parse(source: any): ColorCurves;
  8296. }
  8297. }
  8298. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8299. import { Observable } from "babylonjs/Misc/observable";
  8300. import { Nullable } from "babylonjs/types";
  8301. import { Color4 } from "babylonjs/Maths/math.color";
  8302. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8303. import { Effect } from "babylonjs/Materials/effect";
  8304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8305. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8306. /**
  8307. * Interface to follow in your material defines to integrate easily the
  8308. * Image proccessing functions.
  8309. * @hidden
  8310. */
  8311. export interface IImageProcessingConfigurationDefines {
  8312. IMAGEPROCESSING: boolean;
  8313. VIGNETTE: boolean;
  8314. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8315. VIGNETTEBLENDMODEOPAQUE: boolean;
  8316. TONEMAPPING: boolean;
  8317. TONEMAPPING_ACES: boolean;
  8318. CONTRAST: boolean;
  8319. EXPOSURE: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. }
  8327. /**
  8328. * @hidden
  8329. */
  8330. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8331. IMAGEPROCESSING: boolean;
  8332. VIGNETTE: boolean;
  8333. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8334. VIGNETTEBLENDMODEOPAQUE: boolean;
  8335. TONEMAPPING: boolean;
  8336. TONEMAPPING_ACES: boolean;
  8337. CONTRAST: boolean;
  8338. COLORCURVES: boolean;
  8339. COLORGRADING: boolean;
  8340. COLORGRADING3D: boolean;
  8341. SAMPLER3DGREENDEPTH: boolean;
  8342. SAMPLER3DBGRMAP: boolean;
  8343. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8344. EXPOSURE: boolean;
  8345. constructor();
  8346. }
  8347. /**
  8348. * This groups together the common properties used for image processing either in direct forward pass
  8349. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8350. * or not.
  8351. */
  8352. export class ImageProcessingConfiguration {
  8353. /**
  8354. * Default tone mapping applied in BabylonJS.
  8355. */
  8356. static readonly TONEMAPPING_STANDARD: number;
  8357. /**
  8358. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8359. * to other engines rendering to increase portability.
  8360. */
  8361. static readonly TONEMAPPING_ACES: number;
  8362. /**
  8363. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8364. */
  8365. colorCurves: Nullable<ColorCurves>;
  8366. private _colorCurvesEnabled;
  8367. /**
  8368. * Gets wether the color curves effect is enabled.
  8369. */
  8370. get colorCurvesEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color curves effect is enabled.
  8373. */
  8374. set colorCurvesEnabled(value: boolean);
  8375. private _colorGradingTexture;
  8376. /**
  8377. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8378. */
  8379. get colorGradingTexture(): Nullable<BaseTexture>;
  8380. /**
  8381. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8382. */
  8383. set colorGradingTexture(value: Nullable<BaseTexture>);
  8384. private _colorGradingEnabled;
  8385. /**
  8386. * Gets wether the color grading effect is enabled.
  8387. */
  8388. get colorGradingEnabled(): boolean;
  8389. /**
  8390. * Sets wether the color grading effect is enabled.
  8391. */
  8392. set colorGradingEnabled(value: boolean);
  8393. private _colorGradingWithGreenDepth;
  8394. /**
  8395. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8396. */
  8397. get colorGradingWithGreenDepth(): boolean;
  8398. /**
  8399. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8400. */
  8401. set colorGradingWithGreenDepth(value: boolean);
  8402. private _colorGradingBGR;
  8403. /**
  8404. * Gets wether the color grading texture contains BGR values.
  8405. */
  8406. get colorGradingBGR(): boolean;
  8407. /**
  8408. * Sets wether the color grading texture contains BGR values.
  8409. */
  8410. set colorGradingBGR(value: boolean);
  8411. /** @hidden */
  8412. _exposure: number;
  8413. /**
  8414. * Gets the Exposure used in the effect.
  8415. */
  8416. get exposure(): number;
  8417. /**
  8418. * Sets the Exposure used in the effect.
  8419. */
  8420. set exposure(value: number);
  8421. private _toneMappingEnabled;
  8422. /**
  8423. * Gets wether the tone mapping effect is enabled.
  8424. */
  8425. get toneMappingEnabled(): boolean;
  8426. /**
  8427. * Sets wether the tone mapping effect is enabled.
  8428. */
  8429. set toneMappingEnabled(value: boolean);
  8430. private _toneMappingType;
  8431. /**
  8432. * Gets the type of tone mapping effect.
  8433. */
  8434. get toneMappingType(): number;
  8435. /**
  8436. * Sets the type of tone mapping effect used in BabylonJS.
  8437. */
  8438. set toneMappingType(value: number);
  8439. protected _contrast: number;
  8440. /**
  8441. * Gets the contrast used in the effect.
  8442. */
  8443. get contrast(): number;
  8444. /**
  8445. * Sets the contrast used in the effect.
  8446. */
  8447. set contrast(value: number);
  8448. /**
  8449. * Vignette stretch size.
  8450. */
  8451. vignetteStretch: number;
  8452. /**
  8453. * Vignette centre X Offset.
  8454. */
  8455. vignetteCentreX: number;
  8456. /**
  8457. * Vignette centre Y Offset.
  8458. */
  8459. vignetteCentreY: number;
  8460. /**
  8461. * Vignette weight or intensity of the vignette effect.
  8462. */
  8463. vignetteWeight: number;
  8464. /**
  8465. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8466. * if vignetteEnabled is set to true.
  8467. */
  8468. vignetteColor: Color4;
  8469. /**
  8470. * Camera field of view used by the Vignette effect.
  8471. */
  8472. vignetteCameraFov: number;
  8473. private _vignetteBlendMode;
  8474. /**
  8475. * Gets the vignette blend mode allowing different kind of effect.
  8476. */
  8477. get vignetteBlendMode(): number;
  8478. /**
  8479. * Sets the vignette blend mode allowing different kind of effect.
  8480. */
  8481. set vignetteBlendMode(value: number);
  8482. private _vignetteEnabled;
  8483. /**
  8484. * Gets wether the vignette effect is enabled.
  8485. */
  8486. get vignetteEnabled(): boolean;
  8487. /**
  8488. * Sets wether the vignette effect is enabled.
  8489. */
  8490. set vignetteEnabled(value: boolean);
  8491. private _applyByPostProcess;
  8492. /**
  8493. * Gets wether the image processing is applied through a post process or not.
  8494. */
  8495. get applyByPostProcess(): boolean;
  8496. /**
  8497. * Sets wether the image processing is applied through a post process or not.
  8498. */
  8499. set applyByPostProcess(value: boolean);
  8500. private _isEnabled;
  8501. /**
  8502. * Gets wether the image processing is enabled or not.
  8503. */
  8504. get isEnabled(): boolean;
  8505. /**
  8506. * Sets wether the image processing is enabled or not.
  8507. */
  8508. set isEnabled(value: boolean);
  8509. /**
  8510. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8511. */
  8512. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8513. /**
  8514. * Method called each time the image processing information changes requires to recompile the effect.
  8515. */
  8516. protected _updateParameters(): void;
  8517. /**
  8518. * Gets the current class name.
  8519. * @return "ImageProcessingConfiguration"
  8520. */
  8521. getClassName(): string;
  8522. /**
  8523. * Prepare the list of uniforms associated with the Image Processing effects.
  8524. * @param uniforms The list of uniforms used in the effect
  8525. * @param defines the list of defines currently in use
  8526. */
  8527. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8528. /**
  8529. * Prepare the list of samplers associated with the Image Processing effects.
  8530. * @param samplersList The list of uniforms used in the effect
  8531. * @param defines the list of defines currently in use
  8532. */
  8533. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8534. /**
  8535. * Prepare the list of defines associated to the shader.
  8536. * @param defines the list of defines to complete
  8537. * @param forPostProcess Define if we are currently in post process mode or not
  8538. */
  8539. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8540. /**
  8541. * Returns true if all the image processing information are ready.
  8542. * @returns True if ready, otherwise, false
  8543. */
  8544. isReady(): boolean;
  8545. /**
  8546. * Binds the image processing to the shader.
  8547. * @param effect The effect to bind to
  8548. * @param overrideAspectRatio Override the aspect ratio of the effect
  8549. */
  8550. bind(effect: Effect, overrideAspectRatio?: number): void;
  8551. /**
  8552. * Clones the current image processing instance.
  8553. * @return The cloned image processing
  8554. */
  8555. clone(): ImageProcessingConfiguration;
  8556. /**
  8557. * Serializes the current image processing instance to a json representation.
  8558. * @return a JSON representation
  8559. */
  8560. serialize(): any;
  8561. /**
  8562. * Parses the image processing from a json representation.
  8563. * @param source the JSON source to parse
  8564. * @return The parsed image processing
  8565. */
  8566. static Parse(source: any): ImageProcessingConfiguration;
  8567. private static _VIGNETTEMODE_MULTIPLY;
  8568. private static _VIGNETTEMODE_OPAQUE;
  8569. /**
  8570. * Used to apply the vignette as a mix with the pixel color.
  8571. */
  8572. static get VIGNETTEMODE_MULTIPLY(): number;
  8573. /**
  8574. * Used to apply the vignette as a replacement of the pixel color.
  8575. */
  8576. static get VIGNETTEMODE_OPAQUE(): number;
  8577. }
  8578. }
  8579. declare module "babylonjs/Shaders/postprocess.vertex" {
  8580. /** @hidden */
  8581. export var postprocessVertexShader: {
  8582. name: string;
  8583. shader: string;
  8584. };
  8585. }
  8586. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8588. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8589. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8590. module "babylonjs/Engines/thinEngine" {
  8591. interface ThinEngine {
  8592. /**
  8593. * Creates a new render target texture
  8594. * @param size defines the size of the texture
  8595. * @param options defines the options used to create the texture
  8596. * @returns a new render target texture stored in an InternalTexture
  8597. */
  8598. createRenderTargetTexture(size: number | {
  8599. width: number;
  8600. height: number;
  8601. layers?: number;
  8602. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8603. /**
  8604. * Creates a depth stencil texture.
  8605. * This is only available in WebGL 2 or with the depth texture extension available.
  8606. * @param size The size of face edge in the texture.
  8607. * @param options The options defining the texture.
  8608. * @returns The texture
  8609. */
  8610. createDepthStencilTexture(size: number | {
  8611. width: number;
  8612. height: number;
  8613. layers?: number;
  8614. }, options: DepthTextureCreationOptions): InternalTexture;
  8615. /** @hidden */
  8616. _createDepthStencilTexture(size: number | {
  8617. width: number;
  8618. height: number;
  8619. layers?: number;
  8620. }, options: DepthTextureCreationOptions): InternalTexture;
  8621. }
  8622. }
  8623. }
  8624. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8625. /**
  8626. * Defines the kind of connection point for node based material
  8627. */
  8628. export enum NodeMaterialBlockConnectionPointTypes {
  8629. /** Float */
  8630. Float = 1,
  8631. /** Int */
  8632. Int = 2,
  8633. /** Vector2 */
  8634. Vector2 = 4,
  8635. /** Vector3 */
  8636. Vector3 = 8,
  8637. /** Vector4 */
  8638. Vector4 = 16,
  8639. /** Color3 */
  8640. Color3 = 32,
  8641. /** Color4 */
  8642. Color4 = 64,
  8643. /** Matrix */
  8644. Matrix = 128,
  8645. /** Custom object */
  8646. Object = 256,
  8647. /** Detect type based on connection */
  8648. AutoDetect = 1024,
  8649. /** Output type that will be defined by input type */
  8650. BasedOnInput = 2048
  8651. }
  8652. }
  8653. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8654. /**
  8655. * Enum used to define the target of a block
  8656. */
  8657. export enum NodeMaterialBlockTargets {
  8658. /** Vertex shader */
  8659. Vertex = 1,
  8660. /** Fragment shader */
  8661. Fragment = 2,
  8662. /** Neutral */
  8663. Neutral = 4,
  8664. /** Vertex and Fragment */
  8665. VertexAndFragment = 3
  8666. }
  8667. }
  8668. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8669. /**
  8670. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8671. */
  8672. export enum NodeMaterialBlockConnectionPointMode {
  8673. /** Value is an uniform */
  8674. Uniform = 0,
  8675. /** Value is a mesh attribute */
  8676. Attribute = 1,
  8677. /** Value is a varying between vertex and fragment shaders */
  8678. Varying = 2,
  8679. /** Mode is undefined */
  8680. Undefined = 3
  8681. }
  8682. }
  8683. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8684. /**
  8685. * Enum used to define system values e.g. values automatically provided by the system
  8686. */
  8687. export enum NodeMaterialSystemValues {
  8688. /** World */
  8689. World = 1,
  8690. /** View */
  8691. View = 2,
  8692. /** Projection */
  8693. Projection = 3,
  8694. /** ViewProjection */
  8695. ViewProjection = 4,
  8696. /** WorldView */
  8697. WorldView = 5,
  8698. /** WorldViewProjection */
  8699. WorldViewProjection = 6,
  8700. /** CameraPosition */
  8701. CameraPosition = 7,
  8702. /** Fog Color */
  8703. FogColor = 8,
  8704. /** Delta time */
  8705. DeltaTime = 9
  8706. }
  8707. }
  8708. declare module "babylonjs/Maths/math.axis" {
  8709. import { Vector3 } from "babylonjs/Maths/math.vector";
  8710. /** Defines supported spaces */
  8711. export enum Space {
  8712. /** Local (object) space */
  8713. LOCAL = 0,
  8714. /** World space */
  8715. WORLD = 1,
  8716. /** Bone space */
  8717. BONE = 2
  8718. }
  8719. /** Defines the 3 main axes */
  8720. export class Axis {
  8721. /** X axis */
  8722. static X: Vector3;
  8723. /** Y axis */
  8724. static Y: Vector3;
  8725. /** Z axis */
  8726. static Z: Vector3;
  8727. }
  8728. }
  8729. declare module "babylonjs/Maths/math.frustum" {
  8730. import { Matrix } from "babylonjs/Maths/math.vector";
  8731. import { DeepImmutable } from "babylonjs/types";
  8732. import { Plane } from "babylonjs/Maths/math.plane";
  8733. /**
  8734. * Represents a camera frustum
  8735. */
  8736. export class Frustum {
  8737. /**
  8738. * Gets the planes representing the frustum
  8739. * @param transform matrix to be applied to the returned planes
  8740. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8741. */
  8742. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8743. /**
  8744. * Gets the near frustum plane transformed by the transform matrix
  8745. * @param transform transformation matrix to be applied to the resulting frustum plane
  8746. * @param frustumPlane the resuling frustum plane
  8747. */
  8748. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8749. /**
  8750. * Gets the far frustum plane transformed by the transform matrix
  8751. * @param transform transformation matrix to be applied to the resulting frustum plane
  8752. * @param frustumPlane the resuling frustum plane
  8753. */
  8754. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8755. /**
  8756. * Gets the left frustum plane transformed by the transform matrix
  8757. * @param transform transformation matrix to be applied to the resulting frustum plane
  8758. * @param frustumPlane the resuling frustum plane
  8759. */
  8760. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8761. /**
  8762. * Gets the right frustum plane transformed by the transform matrix
  8763. * @param transform transformation matrix to be applied to the resulting frustum plane
  8764. * @param frustumPlane the resuling frustum plane
  8765. */
  8766. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8767. /**
  8768. * Gets the top frustum plane transformed by the transform matrix
  8769. * @param transform transformation matrix to be applied to the resulting frustum plane
  8770. * @param frustumPlane the resuling frustum plane
  8771. */
  8772. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8773. /**
  8774. * Gets the bottom frustum plane transformed by the transform matrix
  8775. * @param transform transformation matrix to be applied to the resulting frustum plane
  8776. * @param frustumPlane the resuling frustum plane
  8777. */
  8778. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8779. /**
  8780. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8781. * @param transform transformation matrix to be applied to the resulting frustum planes
  8782. * @param frustumPlanes the resuling frustum planes
  8783. */
  8784. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8785. }
  8786. }
  8787. declare module "babylonjs/Maths/math.size" {
  8788. /**
  8789. * Interface for the size containing width and height
  8790. */
  8791. export interface ISize {
  8792. /**
  8793. * Width
  8794. */
  8795. width: number;
  8796. /**
  8797. * Heighht
  8798. */
  8799. height: number;
  8800. }
  8801. /**
  8802. * Size containing widht and height
  8803. */
  8804. export class Size implements ISize {
  8805. /**
  8806. * Width
  8807. */
  8808. width: number;
  8809. /**
  8810. * Height
  8811. */
  8812. height: number;
  8813. /**
  8814. * Creates a Size object from the given width and height (floats).
  8815. * @param width width of the new size
  8816. * @param height height of the new size
  8817. */
  8818. constructor(width: number, height: number);
  8819. /**
  8820. * Returns a string with the Size width and height
  8821. * @returns a string with the Size width and height
  8822. */
  8823. toString(): string;
  8824. /**
  8825. * "Size"
  8826. * @returns the string "Size"
  8827. */
  8828. getClassName(): string;
  8829. /**
  8830. * Returns the Size hash code.
  8831. * @returns a hash code for a unique width and height
  8832. */
  8833. getHashCode(): number;
  8834. /**
  8835. * Updates the current size from the given one.
  8836. * @param src the given size
  8837. */
  8838. copyFrom(src: Size): void;
  8839. /**
  8840. * Updates in place the current Size from the given floats.
  8841. * @param width width of the new size
  8842. * @param height height of the new size
  8843. * @returns the updated Size.
  8844. */
  8845. copyFromFloats(width: number, height: number): Size;
  8846. /**
  8847. * Updates in place the current Size from the given floats.
  8848. * @param width width to set
  8849. * @param height height to set
  8850. * @returns the updated Size.
  8851. */
  8852. set(width: number, height: number): Size;
  8853. /**
  8854. * Multiplies the width and height by numbers
  8855. * @param w factor to multiple the width by
  8856. * @param h factor to multiple the height by
  8857. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8858. */
  8859. multiplyByFloats(w: number, h: number): Size;
  8860. /**
  8861. * Clones the size
  8862. * @returns a new Size copied from the given one.
  8863. */
  8864. clone(): Size;
  8865. /**
  8866. * True if the current Size and the given one width and height are strictly equal.
  8867. * @param other the other size to compare against
  8868. * @returns True if the current Size and the given one width and height are strictly equal.
  8869. */
  8870. equals(other: Size): boolean;
  8871. /**
  8872. * The surface of the Size : width * height (float).
  8873. */
  8874. get surface(): number;
  8875. /**
  8876. * Create a new size of zero
  8877. * @returns a new Size set to (0.0, 0.0)
  8878. */
  8879. static Zero(): Size;
  8880. /**
  8881. * Sums the width and height of two sizes
  8882. * @param otherSize size to add to this size
  8883. * @returns a new Size set as the addition result of the current Size and the given one.
  8884. */
  8885. add(otherSize: Size): Size;
  8886. /**
  8887. * Subtracts the width and height of two
  8888. * @param otherSize size to subtract to this size
  8889. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8890. */
  8891. subtract(otherSize: Size): Size;
  8892. /**
  8893. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8894. * @param start starting size to lerp between
  8895. * @param end end size to lerp between
  8896. * @param amount amount to lerp between the start and end values
  8897. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8898. */
  8899. static Lerp(start: Size, end: Size, amount: number): Size;
  8900. }
  8901. }
  8902. declare module "babylonjs/Maths/math.vertexFormat" {
  8903. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8904. /**
  8905. * Contains position and normal vectors for a vertex
  8906. */
  8907. export class PositionNormalVertex {
  8908. /** the position of the vertex (defaut: 0,0,0) */
  8909. position: Vector3;
  8910. /** the normal of the vertex (defaut: 0,1,0) */
  8911. normal: Vector3;
  8912. /**
  8913. * Creates a PositionNormalVertex
  8914. * @param position the position of the vertex (defaut: 0,0,0)
  8915. * @param normal the normal of the vertex (defaut: 0,1,0)
  8916. */
  8917. constructor(
  8918. /** the position of the vertex (defaut: 0,0,0) */
  8919. position?: Vector3,
  8920. /** the normal of the vertex (defaut: 0,1,0) */
  8921. normal?: Vector3);
  8922. /**
  8923. * Clones the PositionNormalVertex
  8924. * @returns the cloned PositionNormalVertex
  8925. */
  8926. clone(): PositionNormalVertex;
  8927. }
  8928. /**
  8929. * Contains position, normal and uv vectors for a vertex
  8930. */
  8931. export class PositionNormalTextureVertex {
  8932. /** the position of the vertex (defaut: 0,0,0) */
  8933. position: Vector3;
  8934. /** the normal of the vertex (defaut: 0,1,0) */
  8935. normal: Vector3;
  8936. /** the uv of the vertex (default: 0,0) */
  8937. uv: Vector2;
  8938. /**
  8939. * Creates a PositionNormalTextureVertex
  8940. * @param position the position of the vertex (defaut: 0,0,0)
  8941. * @param normal the normal of the vertex (defaut: 0,1,0)
  8942. * @param uv the uv of the vertex (default: 0,0)
  8943. */
  8944. constructor(
  8945. /** the position of the vertex (defaut: 0,0,0) */
  8946. position?: Vector3,
  8947. /** the normal of the vertex (defaut: 0,1,0) */
  8948. normal?: Vector3,
  8949. /** the uv of the vertex (default: 0,0) */
  8950. uv?: Vector2);
  8951. /**
  8952. * Clones the PositionNormalTextureVertex
  8953. * @returns the cloned PositionNormalTextureVertex
  8954. */
  8955. clone(): PositionNormalTextureVertex;
  8956. }
  8957. }
  8958. declare module "babylonjs/Maths/math" {
  8959. export * from "babylonjs/Maths/math.axis";
  8960. export * from "babylonjs/Maths/math.color";
  8961. export * from "babylonjs/Maths/math.constants";
  8962. export * from "babylonjs/Maths/math.frustum";
  8963. export * from "babylonjs/Maths/math.path";
  8964. export * from "babylonjs/Maths/math.plane";
  8965. export * from "babylonjs/Maths/math.size";
  8966. export * from "babylonjs/Maths/math.vector";
  8967. export * from "babylonjs/Maths/math.vertexFormat";
  8968. export * from "babylonjs/Maths/math.viewport";
  8969. }
  8970. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8971. /**
  8972. * Enum defining the type of animations supported by InputBlock
  8973. */
  8974. export enum AnimatedInputBlockTypes {
  8975. /** No animation */
  8976. None = 0,
  8977. /** Time based animation. Will only work for floats */
  8978. Time = 1
  8979. }
  8980. }
  8981. declare module "babylonjs/Lights/shadowLight" {
  8982. import { Camera } from "babylonjs/Cameras/camera";
  8983. import { Scene } from "babylonjs/scene";
  8984. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8986. import { Light } from "babylonjs/Lights/light";
  8987. /**
  8988. * Interface describing all the common properties and methods a shadow light needs to implement.
  8989. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8990. * as well as binding the different shadow properties to the effects.
  8991. */
  8992. export interface IShadowLight extends Light {
  8993. /**
  8994. * The light id in the scene (used in scene.findLighById for instance)
  8995. */
  8996. id: string;
  8997. /**
  8998. * The position the shdow will be casted from.
  8999. */
  9000. position: Vector3;
  9001. /**
  9002. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9003. */
  9004. direction: Vector3;
  9005. /**
  9006. * The transformed position. Position of the light in world space taking parenting in account.
  9007. */
  9008. transformedPosition: Vector3;
  9009. /**
  9010. * The transformed direction. Direction of the light in world space taking parenting in account.
  9011. */
  9012. transformedDirection: Vector3;
  9013. /**
  9014. * The friendly name of the light in the scene.
  9015. */
  9016. name: string;
  9017. /**
  9018. * Defines the shadow projection clipping minimum z value.
  9019. */
  9020. shadowMinZ: number;
  9021. /**
  9022. * Defines the shadow projection clipping maximum z value.
  9023. */
  9024. shadowMaxZ: number;
  9025. /**
  9026. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9027. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9028. */
  9029. computeTransformedInformation(): boolean;
  9030. /**
  9031. * Gets the scene the light belongs to.
  9032. * @returns The scene
  9033. */
  9034. getScene(): Scene;
  9035. /**
  9036. * Callback defining a custom Projection Matrix Builder.
  9037. * This can be used to override the default projection matrix computation.
  9038. */
  9039. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9040. /**
  9041. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9042. * @param matrix The materix to updated with the projection information
  9043. * @param viewMatrix The transform matrix of the light
  9044. * @param renderList The list of mesh to render in the map
  9045. * @returns The current light
  9046. */
  9047. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9048. /**
  9049. * Gets the current depth scale used in ESM.
  9050. * @returns The scale
  9051. */
  9052. getDepthScale(): number;
  9053. /**
  9054. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9055. * @returns true if a cube texture needs to be use
  9056. */
  9057. needCube(): boolean;
  9058. /**
  9059. * Detects if the projection matrix requires to be recomputed this frame.
  9060. * @returns true if it requires to be recomputed otherwise, false.
  9061. */
  9062. needProjectionMatrixCompute(): boolean;
  9063. /**
  9064. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9065. */
  9066. forceProjectionMatrixCompute(): void;
  9067. /**
  9068. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9069. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9070. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9071. */
  9072. getShadowDirection(faceIndex?: number): Vector3;
  9073. /**
  9074. * Gets the minZ used for shadow according to both the scene and the light.
  9075. * @param activeCamera The camera we are returning the min for
  9076. * @returns the depth min z
  9077. */
  9078. getDepthMinZ(activeCamera: Camera): number;
  9079. /**
  9080. * Gets the maxZ used for shadow according to both the scene and the light.
  9081. * @param activeCamera The camera we are returning the max for
  9082. * @returns the depth max z
  9083. */
  9084. getDepthMaxZ(activeCamera: Camera): number;
  9085. }
  9086. /**
  9087. * Base implementation IShadowLight
  9088. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9089. */
  9090. export abstract class ShadowLight extends Light implements IShadowLight {
  9091. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9092. protected _position: Vector3;
  9093. protected _setPosition(value: Vector3): void;
  9094. /**
  9095. * Sets the position the shadow will be casted from. Also use as the light position for both
  9096. * point and spot lights.
  9097. */
  9098. get position(): Vector3;
  9099. /**
  9100. * Sets the position the shadow will be casted from. Also use as the light position for both
  9101. * point and spot lights.
  9102. */
  9103. set position(value: Vector3);
  9104. protected _direction: Vector3;
  9105. protected _setDirection(value: Vector3): void;
  9106. /**
  9107. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9108. * Also use as the light direction on spot and directional lights.
  9109. */
  9110. get direction(): Vector3;
  9111. /**
  9112. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9113. * Also use as the light direction on spot and directional lights.
  9114. */
  9115. set direction(value: Vector3);
  9116. protected _shadowMinZ: number;
  9117. /**
  9118. * Gets the shadow projection clipping minimum z value.
  9119. */
  9120. get shadowMinZ(): number;
  9121. /**
  9122. * Sets the shadow projection clipping minimum z value.
  9123. */
  9124. set shadowMinZ(value: number);
  9125. protected _shadowMaxZ: number;
  9126. /**
  9127. * Sets the shadow projection clipping maximum z value.
  9128. */
  9129. get shadowMaxZ(): number;
  9130. /**
  9131. * Gets the shadow projection clipping maximum z value.
  9132. */
  9133. set shadowMaxZ(value: number);
  9134. /**
  9135. * Callback defining a custom Projection Matrix Builder.
  9136. * This can be used to override the default projection matrix computation.
  9137. */
  9138. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9139. /**
  9140. * The transformed position. Position of the light in world space taking parenting in account.
  9141. */
  9142. transformedPosition: Vector3;
  9143. /**
  9144. * The transformed direction. Direction of the light in world space taking parenting in account.
  9145. */
  9146. transformedDirection: Vector3;
  9147. private _needProjectionMatrixCompute;
  9148. /**
  9149. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9150. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9151. */
  9152. computeTransformedInformation(): boolean;
  9153. /**
  9154. * Return the depth scale used for the shadow map.
  9155. * @returns the depth scale.
  9156. */
  9157. getDepthScale(): number;
  9158. /**
  9159. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9160. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9161. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9162. */
  9163. getShadowDirection(faceIndex?: number): Vector3;
  9164. /**
  9165. * Returns the ShadowLight absolute position in the World.
  9166. * @returns the position vector in world space
  9167. */
  9168. getAbsolutePosition(): Vector3;
  9169. /**
  9170. * Sets the ShadowLight direction toward the passed target.
  9171. * @param target The point to target in local space
  9172. * @returns the updated ShadowLight direction
  9173. */
  9174. setDirectionToTarget(target: Vector3): Vector3;
  9175. /**
  9176. * Returns the light rotation in euler definition.
  9177. * @returns the x y z rotation in local space.
  9178. */
  9179. getRotation(): Vector3;
  9180. /**
  9181. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9182. * @returns true if a cube texture needs to be use
  9183. */
  9184. needCube(): boolean;
  9185. /**
  9186. * Detects if the projection matrix requires to be recomputed this frame.
  9187. * @returns true if it requires to be recomputed otherwise, false.
  9188. */
  9189. needProjectionMatrixCompute(): boolean;
  9190. /**
  9191. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9192. */
  9193. forceProjectionMatrixCompute(): void;
  9194. /** @hidden */
  9195. _initCache(): void;
  9196. /** @hidden */
  9197. _isSynchronized(): boolean;
  9198. /**
  9199. * Computes the world matrix of the node
  9200. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9201. * @returns the world matrix
  9202. */
  9203. computeWorldMatrix(force?: boolean): Matrix;
  9204. /**
  9205. * Gets the minZ used for shadow according to both the scene and the light.
  9206. * @param activeCamera The camera we are returning the min for
  9207. * @returns the depth min z
  9208. */
  9209. getDepthMinZ(activeCamera: Camera): number;
  9210. /**
  9211. * Gets the maxZ used for shadow according to both the scene and the light.
  9212. * @param activeCamera The camera we are returning the max for
  9213. * @returns the depth max z
  9214. */
  9215. getDepthMaxZ(activeCamera: Camera): number;
  9216. /**
  9217. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9218. * @param matrix The materix to updated with the projection information
  9219. * @param viewMatrix The transform matrix of the light
  9220. * @param renderList The list of mesh to render in the map
  9221. * @returns The current light
  9222. */
  9223. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9224. }
  9225. }
  9226. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9227. /** @hidden */
  9228. export var packingFunctions: {
  9229. name: string;
  9230. shader: string;
  9231. };
  9232. }
  9233. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9234. /** @hidden */
  9235. export var bayerDitherFunctions: {
  9236. name: string;
  9237. shader: string;
  9238. };
  9239. }
  9240. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9241. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9242. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9243. /** @hidden */
  9244. export var shadowMapFragmentDeclaration: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9250. /** @hidden */
  9251. export var clipPlaneFragmentDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9257. /** @hidden */
  9258. export var clipPlaneFragment: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9264. /** @hidden */
  9265. export var shadowMapFragment: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9271. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9272. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9274. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9275. /** @hidden */
  9276. export var shadowMapPixelShader: {
  9277. name: string;
  9278. shader: string;
  9279. };
  9280. }
  9281. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9282. /** @hidden */
  9283. export var bonesDeclaration: {
  9284. name: string;
  9285. shader: string;
  9286. };
  9287. }
  9288. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9289. /** @hidden */
  9290. export var morphTargetsVertexGlobalDeclaration: {
  9291. name: string;
  9292. shader: string;
  9293. };
  9294. }
  9295. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9296. /** @hidden */
  9297. export var morphTargetsVertexDeclaration: {
  9298. name: string;
  9299. shader: string;
  9300. };
  9301. }
  9302. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9303. /** @hidden */
  9304. export var instancesDeclaration: {
  9305. name: string;
  9306. shader: string;
  9307. };
  9308. }
  9309. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9310. /** @hidden */
  9311. export var helperFunctions: {
  9312. name: string;
  9313. shader: string;
  9314. };
  9315. }
  9316. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9317. /** @hidden */
  9318. export var shadowMapVertexDeclaration: {
  9319. name: string;
  9320. shader: string;
  9321. };
  9322. }
  9323. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9324. /** @hidden */
  9325. export var clipPlaneVertexDeclaration: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9331. /** @hidden */
  9332. export var morphTargetsVertex: {
  9333. name: string;
  9334. shader: string;
  9335. };
  9336. }
  9337. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9338. /** @hidden */
  9339. export var instancesVertex: {
  9340. name: string;
  9341. shader: string;
  9342. };
  9343. }
  9344. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9345. /** @hidden */
  9346. export var bonesVertex: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9352. /** @hidden */
  9353. export var shadowMapVertexNormalBias: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9359. /** @hidden */
  9360. export var shadowMapVertexMetric: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9366. /** @hidden */
  9367. export var clipPlaneVertex: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9373. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9374. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9376. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9377. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9378. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9379. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9380. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9381. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9382. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9383. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9384. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9385. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9386. /** @hidden */
  9387. export var shadowMapVertexShader: {
  9388. name: string;
  9389. shader: string;
  9390. };
  9391. }
  9392. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9393. /** @hidden */
  9394. export var depthBoxBlurPixelShader: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9400. /** @hidden */
  9401. export var shadowMapFragmentSoftTransparentShadow: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module "babylonjs/Materials/effectFallbacks" {
  9407. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9408. import { Effect } from "babylonjs/Materials/effect";
  9409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9410. /**
  9411. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9412. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9413. */
  9414. export class EffectFallbacks implements IEffectFallbacks {
  9415. private _defines;
  9416. private _currentRank;
  9417. private _maxRank;
  9418. private _mesh;
  9419. /**
  9420. * Removes the fallback from the bound mesh.
  9421. */
  9422. unBindMesh(): void;
  9423. /**
  9424. * Adds a fallback on the specified property.
  9425. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9426. * @param define The name of the define in the shader
  9427. */
  9428. addFallback(rank: number, define: string): void;
  9429. /**
  9430. * Sets the mesh to use CPU skinning when needing to fallback.
  9431. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9432. * @param mesh The mesh to use the fallbacks.
  9433. */
  9434. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9435. /**
  9436. * Checks to see if more fallbacks are still availible.
  9437. */
  9438. get hasMoreFallbacks(): boolean;
  9439. /**
  9440. * Removes the defines that should be removed when falling back.
  9441. * @param currentDefines defines the current define statements for the shader.
  9442. * @param effect defines the current effect we try to compile
  9443. * @returns The resulting defines with defines of the current rank removed.
  9444. */
  9445. reduce(currentDefines: string, effect: Effect): string;
  9446. }
  9447. }
  9448. declare module "babylonjs/Actions/action" {
  9449. import { Observable } from "babylonjs/Misc/observable";
  9450. import { Condition } from "babylonjs/Actions/condition";
  9451. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9452. import { ActionManager } from "babylonjs/Actions/actionManager";
  9453. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9454. /**
  9455. * Interface used to define Action
  9456. */
  9457. export interface IAction {
  9458. /**
  9459. * Trigger for the action
  9460. */
  9461. trigger: number;
  9462. /** Options of the trigger */
  9463. triggerOptions: any;
  9464. /**
  9465. * Gets the trigger parameters
  9466. * @returns the trigger parameters
  9467. */
  9468. getTriggerParameter(): any;
  9469. /**
  9470. * Internal only - executes current action event
  9471. * @hidden
  9472. */
  9473. _executeCurrent(evt?: ActionEvent): void;
  9474. /**
  9475. * Serialize placeholder for child classes
  9476. * @param parent of child
  9477. * @returns the serialized object
  9478. */
  9479. serialize(parent: any): any;
  9480. /**
  9481. * Internal only
  9482. * @hidden
  9483. */
  9484. _prepare(): void;
  9485. /**
  9486. * Internal only - manager for action
  9487. * @hidden
  9488. */
  9489. _actionManager: AbstractActionManager;
  9490. /**
  9491. * Adds action to chain of actions, may be a DoNothingAction
  9492. * @param action defines the next action to execute
  9493. * @returns The action passed in
  9494. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9495. */
  9496. then(action: IAction): IAction;
  9497. }
  9498. /**
  9499. * The action to be carried out following a trigger
  9500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9501. */
  9502. export class Action implements IAction {
  9503. /** the trigger, with or without parameters, for the action */
  9504. triggerOptions: any;
  9505. /**
  9506. * Trigger for the action
  9507. */
  9508. trigger: number;
  9509. /**
  9510. * Internal only - manager for action
  9511. * @hidden
  9512. */
  9513. _actionManager: ActionManager;
  9514. private _nextActiveAction;
  9515. private _child;
  9516. private _condition?;
  9517. private _triggerParameter;
  9518. /**
  9519. * An event triggered prior to action being executed.
  9520. */
  9521. onBeforeExecuteObservable: Observable<Action>;
  9522. /**
  9523. * Creates a new Action
  9524. * @param triggerOptions the trigger, with or without parameters, for the action
  9525. * @param condition an optional determinant of action
  9526. */
  9527. constructor(
  9528. /** the trigger, with or without parameters, for the action */
  9529. triggerOptions: any, condition?: Condition);
  9530. /**
  9531. * Internal only
  9532. * @hidden
  9533. */
  9534. _prepare(): void;
  9535. /**
  9536. * Gets the trigger parameters
  9537. * @returns the trigger parameters
  9538. */
  9539. getTriggerParameter(): any;
  9540. /**
  9541. * Internal only - executes current action event
  9542. * @hidden
  9543. */
  9544. _executeCurrent(evt?: ActionEvent): void;
  9545. /**
  9546. * Execute placeholder for child classes
  9547. * @param evt optional action event
  9548. */
  9549. execute(evt?: ActionEvent): void;
  9550. /**
  9551. * Skips to next active action
  9552. */
  9553. skipToNextActiveAction(): void;
  9554. /**
  9555. * Adds action to chain of actions, may be a DoNothingAction
  9556. * @param action defines the next action to execute
  9557. * @returns The action passed in
  9558. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9559. */
  9560. then(action: Action): Action;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getProperty(propertyPath: string): string;
  9566. /**
  9567. * Internal only
  9568. * @hidden
  9569. */
  9570. _getEffectiveTarget(target: any, propertyPath: string): any;
  9571. /**
  9572. * Serialize placeholder for child classes
  9573. * @param parent of child
  9574. * @returns the serialized object
  9575. */
  9576. serialize(parent: any): any;
  9577. /**
  9578. * Internal only called by serialize
  9579. * @hidden
  9580. */
  9581. protected _serialize(serializedAction: any, parent?: any): any;
  9582. /**
  9583. * Internal only
  9584. * @hidden
  9585. */
  9586. static _SerializeValueAsString: (value: any) => string;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  9592. name: string;
  9593. targetType: string;
  9594. value: string;
  9595. };
  9596. }
  9597. }
  9598. declare module "babylonjs/Actions/condition" {
  9599. import { ActionManager } from "babylonjs/Actions/actionManager";
  9600. /**
  9601. * A Condition applied to an Action
  9602. */
  9603. export class Condition {
  9604. /**
  9605. * Internal only - manager for action
  9606. * @hidden
  9607. */
  9608. _actionManager: ActionManager;
  9609. /**
  9610. * Internal only
  9611. * @hidden
  9612. */
  9613. _evaluationId: number;
  9614. /**
  9615. * Internal only
  9616. * @hidden
  9617. */
  9618. _currentResult: boolean;
  9619. /**
  9620. * Creates a new Condition
  9621. * @param actionManager the manager of the action the condition is applied to
  9622. */
  9623. constructor(actionManager: ActionManager);
  9624. /**
  9625. * Check if the current condition is valid
  9626. * @returns a boolean
  9627. */
  9628. isValid(): boolean;
  9629. /**
  9630. * Internal only
  9631. * @hidden
  9632. */
  9633. _getProperty(propertyPath: string): string;
  9634. /**
  9635. * Internal only
  9636. * @hidden
  9637. */
  9638. _getEffectiveTarget(target: any, propertyPath: string): any;
  9639. /**
  9640. * Serialize placeholder for child classes
  9641. * @returns the serialized object
  9642. */
  9643. serialize(): any;
  9644. /**
  9645. * Internal only
  9646. * @hidden
  9647. */
  9648. protected _serialize(serializedCondition: any): any;
  9649. }
  9650. /**
  9651. * Defines specific conditional operators as extensions of Condition
  9652. */
  9653. export class ValueCondition extends Condition {
  9654. /** path to specify the property of the target the conditional operator uses */
  9655. propertyPath: string;
  9656. /** the value compared by the conditional operator against the current value of the property */
  9657. value: any;
  9658. /** the conditional operator, default ValueCondition.IsEqual */
  9659. operator: number;
  9660. /**
  9661. * Internal only
  9662. * @hidden
  9663. */
  9664. private static _IsEqual;
  9665. /**
  9666. * Internal only
  9667. * @hidden
  9668. */
  9669. private static _IsDifferent;
  9670. /**
  9671. * Internal only
  9672. * @hidden
  9673. */
  9674. private static _IsGreater;
  9675. /**
  9676. * Internal only
  9677. * @hidden
  9678. */
  9679. private static _IsLesser;
  9680. /**
  9681. * returns the number for IsEqual
  9682. */
  9683. static get IsEqual(): number;
  9684. /**
  9685. * Returns the number for IsDifferent
  9686. */
  9687. static get IsDifferent(): number;
  9688. /**
  9689. * Returns the number for IsGreater
  9690. */
  9691. static get IsGreater(): number;
  9692. /**
  9693. * Returns the number for IsLesser
  9694. */
  9695. static get IsLesser(): number;
  9696. /**
  9697. * Internal only The action manager for the condition
  9698. * @hidden
  9699. */
  9700. _actionManager: ActionManager;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. private _target;
  9706. /**
  9707. * Internal only
  9708. * @hidden
  9709. */
  9710. private _effectiveTarget;
  9711. /**
  9712. * Internal only
  9713. * @hidden
  9714. */
  9715. private _property;
  9716. /**
  9717. * Creates a new ValueCondition
  9718. * @param actionManager manager for the action the condition applies to
  9719. * @param target for the action
  9720. * @param propertyPath path to specify the property of the target the conditional operator uses
  9721. * @param value the value compared by the conditional operator against the current value of the property
  9722. * @param operator the conditional operator, default ValueCondition.IsEqual
  9723. */
  9724. constructor(actionManager: ActionManager, target: any,
  9725. /** path to specify the property of the target the conditional operator uses */
  9726. propertyPath: string,
  9727. /** the value compared by the conditional operator against the current value of the property */
  9728. value: any,
  9729. /** the conditional operator, default ValueCondition.IsEqual */
  9730. operator?: number);
  9731. /**
  9732. * Compares the given value with the property value for the specified conditional operator
  9733. * @returns the result of the comparison
  9734. */
  9735. isValid(): boolean;
  9736. /**
  9737. * Serialize the ValueCondition into a JSON compatible object
  9738. * @returns serialization object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Gets the name of the conditional operator for the ValueCondition
  9743. * @param operator the conditional operator
  9744. * @returns the name
  9745. */
  9746. static GetOperatorName(operator: number): string;
  9747. }
  9748. /**
  9749. * Defines a predicate condition as an extension of Condition
  9750. */
  9751. export class PredicateCondition extends Condition {
  9752. /** defines the predicate function used to validate the condition */
  9753. predicate: () => boolean;
  9754. /**
  9755. * Internal only - manager for action
  9756. * @hidden
  9757. */
  9758. _actionManager: ActionManager;
  9759. /**
  9760. * Creates a new PredicateCondition
  9761. * @param actionManager manager for the action the condition applies to
  9762. * @param predicate defines the predicate function used to validate the condition
  9763. */
  9764. constructor(actionManager: ActionManager,
  9765. /** defines the predicate function used to validate the condition */
  9766. predicate: () => boolean);
  9767. /**
  9768. * @returns the validity of the predicate condition
  9769. */
  9770. isValid(): boolean;
  9771. }
  9772. /**
  9773. * Defines a state condition as an extension of Condition
  9774. */
  9775. export class StateCondition extends Condition {
  9776. /** Value to compare with target state */
  9777. value: string;
  9778. /**
  9779. * Internal only - manager for action
  9780. * @hidden
  9781. */
  9782. _actionManager: ActionManager;
  9783. /**
  9784. * Internal only
  9785. * @hidden
  9786. */
  9787. private _target;
  9788. /**
  9789. * Creates a new StateCondition
  9790. * @param actionManager manager for the action the condition applies to
  9791. * @param target of the condition
  9792. * @param value to compare with target state
  9793. */
  9794. constructor(actionManager: ActionManager, target: any,
  9795. /** Value to compare with target state */
  9796. value: string);
  9797. /**
  9798. * Gets a boolean indicating if the current condition is met
  9799. * @returns the validity of the state
  9800. */
  9801. isValid(): boolean;
  9802. /**
  9803. * Serialize the StateCondition into a JSON compatible object
  9804. * @returns serialization object
  9805. */
  9806. serialize(): any;
  9807. }
  9808. }
  9809. declare module "babylonjs/Actions/directActions" {
  9810. import { Action } from "babylonjs/Actions/action";
  9811. import { Condition } from "babylonjs/Actions/condition";
  9812. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9813. /**
  9814. * This defines an action responsible to toggle a boolean once triggered.
  9815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9816. */
  9817. export class SwitchBooleanAction extends Action {
  9818. /**
  9819. * The path to the boolean property in the target object
  9820. */
  9821. propertyPath: string;
  9822. private _target;
  9823. private _effectiveTarget;
  9824. private _property;
  9825. /**
  9826. * Instantiate the action
  9827. * @param triggerOptions defines the trigger options
  9828. * @param target defines the object containing the boolean
  9829. * @param propertyPath defines the path to the boolean property in the target object
  9830. * @param condition defines the trigger related conditions
  9831. */
  9832. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9833. /** @hidden */
  9834. _prepare(): void;
  9835. /**
  9836. * Execute the action toggle the boolean value.
  9837. */
  9838. execute(): void;
  9839. /**
  9840. * Serializes the actions and its related information.
  9841. * @param parent defines the object to serialize in
  9842. * @returns the serialized object
  9843. */
  9844. serialize(parent: any): any;
  9845. }
  9846. /**
  9847. * This defines an action responsible to set a the state field of the target
  9848. * to a desired value once triggered.
  9849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9850. */
  9851. export class SetStateAction extends Action {
  9852. /**
  9853. * The value to store in the state field.
  9854. */
  9855. value: string;
  9856. private _target;
  9857. /**
  9858. * Instantiate the action
  9859. * @param triggerOptions defines the trigger options
  9860. * @param target defines the object containing the state property
  9861. * @param value defines the value to store in the state field
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9865. /**
  9866. * Execute the action and store the value on the target state property.
  9867. */
  9868. execute(): void;
  9869. /**
  9870. * Serializes the actions and its related information.
  9871. * @param parent defines the object to serialize in
  9872. * @returns the serialized object
  9873. */
  9874. serialize(parent: any): any;
  9875. }
  9876. /**
  9877. * This defines an action responsible to set a property of the target
  9878. * to a desired value once triggered.
  9879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9880. */
  9881. export class SetValueAction extends Action {
  9882. /**
  9883. * The path of the property to set in the target.
  9884. */
  9885. propertyPath: string;
  9886. /**
  9887. * The value to set in the property
  9888. */
  9889. value: any;
  9890. private _target;
  9891. private _effectiveTarget;
  9892. private _property;
  9893. /**
  9894. * Instantiate the action
  9895. * @param triggerOptions defines the trigger options
  9896. * @param target defines the object containing the property
  9897. * @param propertyPath defines the path of the property to set in the target
  9898. * @param value defines the value to set in the property
  9899. * @param condition defines the trigger related conditions
  9900. */
  9901. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9902. /** @hidden */
  9903. _prepare(): void;
  9904. /**
  9905. * Execute the action and set the targetted property to the desired value.
  9906. */
  9907. execute(): void;
  9908. /**
  9909. * Serializes the actions and its related information.
  9910. * @param parent defines the object to serialize in
  9911. * @returns the serialized object
  9912. */
  9913. serialize(parent: any): any;
  9914. }
  9915. /**
  9916. * This defines an action responsible to increment the target value
  9917. * to a desired value once triggered.
  9918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9919. */
  9920. export class IncrementValueAction extends Action {
  9921. /**
  9922. * The path of the property to increment in the target.
  9923. */
  9924. propertyPath: string;
  9925. /**
  9926. * The value we should increment the property by.
  9927. */
  9928. value: any;
  9929. private _target;
  9930. private _effectiveTarget;
  9931. private _property;
  9932. /**
  9933. * Instantiate the action
  9934. * @param triggerOptions defines the trigger options
  9935. * @param target defines the object containing the property
  9936. * @param propertyPath defines the path of the property to increment in the target
  9937. * @param value defines the value value we should increment the property by
  9938. * @param condition defines the trigger related conditions
  9939. */
  9940. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9941. /** @hidden */
  9942. _prepare(): void;
  9943. /**
  9944. * Execute the action and increment the target of the value amount.
  9945. */
  9946. execute(): void;
  9947. /**
  9948. * Serializes the actions and its related information.
  9949. * @param parent defines the object to serialize in
  9950. * @returns the serialized object
  9951. */
  9952. serialize(parent: any): any;
  9953. }
  9954. /**
  9955. * This defines an action responsible to start an animation once triggered.
  9956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9957. */
  9958. export class PlayAnimationAction extends Action {
  9959. /**
  9960. * Where the animation should start (animation frame)
  9961. */
  9962. from: number;
  9963. /**
  9964. * Where the animation should stop (animation frame)
  9965. */
  9966. to: number;
  9967. /**
  9968. * Define if the animation should loop or stop after the first play.
  9969. */
  9970. loop?: boolean;
  9971. private _target;
  9972. /**
  9973. * Instantiate the action
  9974. * @param triggerOptions defines the trigger options
  9975. * @param target defines the target animation or animation name
  9976. * @param from defines from where the animation should start (animation frame)
  9977. * @param end defines where the animation should stop (animation frame)
  9978. * @param loop defines if the animation should loop or stop after the first play
  9979. * @param condition defines the trigger related conditions
  9980. */
  9981. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9982. /** @hidden */
  9983. _prepare(): void;
  9984. /**
  9985. * Execute the action and play the animation.
  9986. */
  9987. execute(): void;
  9988. /**
  9989. * Serializes the actions and its related information.
  9990. * @param parent defines the object to serialize in
  9991. * @returns the serialized object
  9992. */
  9993. serialize(parent: any): any;
  9994. }
  9995. /**
  9996. * This defines an action responsible to stop an animation once triggered.
  9997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9998. */
  9999. export class StopAnimationAction extends Action {
  10000. private _target;
  10001. /**
  10002. * Instantiate the action
  10003. * @param triggerOptions defines the trigger options
  10004. * @param target defines the target animation or animation name
  10005. * @param condition defines the trigger related conditions
  10006. */
  10007. constructor(triggerOptions: any, target: any, condition?: Condition);
  10008. /** @hidden */
  10009. _prepare(): void;
  10010. /**
  10011. * Execute the action and stop the animation.
  10012. */
  10013. execute(): void;
  10014. /**
  10015. * Serializes the actions and its related information.
  10016. * @param parent defines the object to serialize in
  10017. * @returns the serialized object
  10018. */
  10019. serialize(parent: any): any;
  10020. }
  10021. /**
  10022. * This defines an action responsible that does nothing once triggered.
  10023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10024. */
  10025. export class DoNothingAction extends Action {
  10026. /**
  10027. * Instantiate the action
  10028. * @param triggerOptions defines the trigger options
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions?: any, condition?: Condition);
  10032. /**
  10033. * Execute the action and do nothing.
  10034. */
  10035. execute(): void;
  10036. /**
  10037. * Serializes the actions and its related information.
  10038. * @param parent defines the object to serialize in
  10039. * @returns the serialized object
  10040. */
  10041. serialize(parent: any): any;
  10042. }
  10043. /**
  10044. * This defines an action responsible to trigger several actions once triggered.
  10045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10046. */
  10047. export class CombineAction extends Action {
  10048. /**
  10049. * The list of aggregated animations to run.
  10050. */
  10051. children: Action[];
  10052. /**
  10053. * Instantiate the action
  10054. * @param triggerOptions defines the trigger options
  10055. * @param children defines the list of aggregated animations to run
  10056. * @param condition defines the trigger related conditions
  10057. */
  10058. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10059. /** @hidden */
  10060. _prepare(): void;
  10061. /**
  10062. * Execute the action and executes all the aggregated actions.
  10063. */
  10064. execute(evt: ActionEvent): void;
  10065. /**
  10066. * Serializes the actions and its related information.
  10067. * @param parent defines the object to serialize in
  10068. * @returns the serialized object
  10069. */
  10070. serialize(parent: any): any;
  10071. }
  10072. /**
  10073. * This defines an action responsible to run code (external event) once triggered.
  10074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10075. */
  10076. export class ExecuteCodeAction extends Action {
  10077. /**
  10078. * The callback function to run.
  10079. */
  10080. func: (evt: ActionEvent) => void;
  10081. /**
  10082. * Instantiate the action
  10083. * @param triggerOptions defines the trigger options
  10084. * @param func defines the callback function to run
  10085. * @param condition defines the trigger related conditions
  10086. */
  10087. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10088. /**
  10089. * Execute the action and run the attached code.
  10090. */
  10091. execute(evt: ActionEvent): void;
  10092. }
  10093. /**
  10094. * This defines an action responsible to set the parent property of the target once triggered.
  10095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10096. */
  10097. export class SetParentAction extends Action {
  10098. private _parent;
  10099. private _target;
  10100. /**
  10101. * Instantiate the action
  10102. * @param triggerOptions defines the trigger options
  10103. * @param target defines the target containing the parent property
  10104. * @param parent defines from where the animation should start (animation frame)
  10105. * @param condition defines the trigger related conditions
  10106. */
  10107. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10108. /** @hidden */
  10109. _prepare(): void;
  10110. /**
  10111. * Execute the action and set the parent property.
  10112. */
  10113. execute(): void;
  10114. /**
  10115. * Serializes the actions and its related information.
  10116. * @param parent defines the object to serialize in
  10117. * @returns the serialized object
  10118. */
  10119. serialize(parent: any): any;
  10120. }
  10121. }
  10122. declare module "babylonjs/Actions/actionManager" {
  10123. import { Nullable } from "babylonjs/types";
  10124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10125. import { Scene } from "babylonjs/scene";
  10126. import { IAction } from "babylonjs/Actions/action";
  10127. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10128. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10129. /**
  10130. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10131. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10133. */
  10134. export class ActionManager extends AbstractActionManager {
  10135. /**
  10136. * Nothing
  10137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10138. */
  10139. static readonly NothingTrigger: number;
  10140. /**
  10141. * On pick
  10142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10143. */
  10144. static readonly OnPickTrigger: number;
  10145. /**
  10146. * On left pick
  10147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10148. */
  10149. static readonly OnLeftPickTrigger: number;
  10150. /**
  10151. * On right pick
  10152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10153. */
  10154. static readonly OnRightPickTrigger: number;
  10155. /**
  10156. * On center pick
  10157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10158. */
  10159. static readonly OnCenterPickTrigger: number;
  10160. /**
  10161. * On pick down
  10162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10163. */
  10164. static readonly OnPickDownTrigger: number;
  10165. /**
  10166. * On double pick
  10167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10168. */
  10169. static readonly OnDoublePickTrigger: number;
  10170. /**
  10171. * On pick up
  10172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10173. */
  10174. static readonly OnPickUpTrigger: number;
  10175. /**
  10176. * On pick out.
  10177. * This trigger will only be raised if you also declared a OnPickDown
  10178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10179. */
  10180. static readonly OnPickOutTrigger: number;
  10181. /**
  10182. * On long press
  10183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10184. */
  10185. static readonly OnLongPressTrigger: number;
  10186. /**
  10187. * On pointer over
  10188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10189. */
  10190. static readonly OnPointerOverTrigger: number;
  10191. /**
  10192. * On pointer out
  10193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10194. */
  10195. static readonly OnPointerOutTrigger: number;
  10196. /**
  10197. * On every frame
  10198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10199. */
  10200. static readonly OnEveryFrameTrigger: number;
  10201. /**
  10202. * On intersection enter
  10203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10204. */
  10205. static readonly OnIntersectionEnterTrigger: number;
  10206. /**
  10207. * On intersection exit
  10208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10209. */
  10210. static readonly OnIntersectionExitTrigger: number;
  10211. /**
  10212. * On key down
  10213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10214. */
  10215. static readonly OnKeyDownTrigger: number;
  10216. /**
  10217. * On key up
  10218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10219. */
  10220. static readonly OnKeyUpTrigger: number;
  10221. private _scene;
  10222. /**
  10223. * Creates a new action manager
  10224. * @param scene defines the hosting scene
  10225. */
  10226. constructor(scene: Scene);
  10227. /**
  10228. * Releases all associated resources
  10229. */
  10230. dispose(): void;
  10231. /**
  10232. * Gets hosting scene
  10233. * @returns the hosting scene
  10234. */
  10235. getScene(): Scene;
  10236. /**
  10237. * Does this action manager handles actions of any of the given triggers
  10238. * @param triggers defines the triggers to be tested
  10239. * @return a boolean indicating whether one (or more) of the triggers is handled
  10240. */
  10241. hasSpecificTriggers(triggers: number[]): boolean;
  10242. /**
  10243. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10244. * speed.
  10245. * @param triggerA defines the trigger to be tested
  10246. * @param triggerB defines the trigger to be tested
  10247. * @return a boolean indicating whether one (or more) of the triggers is handled
  10248. */
  10249. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10250. /**
  10251. * Does this action manager handles actions of a given trigger
  10252. * @param trigger defines the trigger to be tested
  10253. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10254. * @return whether the trigger is handled
  10255. */
  10256. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10257. /**
  10258. * Does this action manager has pointer triggers
  10259. */
  10260. get hasPointerTriggers(): boolean;
  10261. /**
  10262. * Does this action manager has pick triggers
  10263. */
  10264. get hasPickTriggers(): boolean;
  10265. /**
  10266. * Registers an action to this action manager
  10267. * @param action defines the action to be registered
  10268. * @return the action amended (prepared) after registration
  10269. */
  10270. registerAction(action: IAction): Nullable<IAction>;
  10271. /**
  10272. * Unregisters an action to this action manager
  10273. * @param action defines the action to be unregistered
  10274. * @return a boolean indicating whether the action has been unregistered
  10275. */
  10276. unregisterAction(action: IAction): Boolean;
  10277. /**
  10278. * Process a specific trigger
  10279. * @param trigger defines the trigger to process
  10280. * @param evt defines the event details to be processed
  10281. */
  10282. processTrigger(trigger: number, evt?: IActionEvent): void;
  10283. /** @hidden */
  10284. _getEffectiveTarget(target: any, propertyPath: string): any;
  10285. /** @hidden */
  10286. _getProperty(propertyPath: string): string;
  10287. /**
  10288. * Serialize this manager to a JSON object
  10289. * @param name defines the property name to store this manager
  10290. * @returns a JSON representation of this manager
  10291. */
  10292. serialize(name: string): any;
  10293. /**
  10294. * Creates a new ActionManager from a JSON data
  10295. * @param parsedActions defines the JSON data to read from
  10296. * @param object defines the hosting mesh
  10297. * @param scene defines the hosting scene
  10298. */
  10299. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10300. /**
  10301. * Get a trigger name by index
  10302. * @param trigger defines the trigger index
  10303. * @returns a trigger name
  10304. */
  10305. static GetTriggerName(trigger: number): string;
  10306. }
  10307. }
  10308. declare module "babylonjs/Sprites/sprite" {
  10309. import { Vector3 } from "babylonjs/Maths/math.vector";
  10310. import { Nullable } from "babylonjs/types";
  10311. import { ActionManager } from "babylonjs/Actions/actionManager";
  10312. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10313. import { Color4 } from "babylonjs/Maths/math.color";
  10314. import { Observable } from "babylonjs/Misc/observable";
  10315. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10316. import { Animation } from "babylonjs/Animations/animation";
  10317. /**
  10318. * Class used to represent a sprite
  10319. * @see http://doc.babylonjs.com/babylon101/sprites
  10320. */
  10321. export class Sprite implements IAnimatable {
  10322. /** defines the name */
  10323. name: string;
  10324. /** Gets or sets the current world position */
  10325. position: Vector3;
  10326. /** Gets or sets the main color */
  10327. color: Color4;
  10328. /** Gets or sets the width */
  10329. width: number;
  10330. /** Gets or sets the height */
  10331. height: number;
  10332. /** Gets or sets rotation angle */
  10333. angle: number;
  10334. /** Gets or sets the cell index in the sprite sheet */
  10335. cellIndex: number;
  10336. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10337. cellRef: string;
  10338. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10339. invertU: boolean;
  10340. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10341. invertV: boolean;
  10342. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10343. disposeWhenFinishedAnimating: boolean;
  10344. /** Gets the list of attached animations */
  10345. animations: Nullable<Array<Animation>>;
  10346. /** Gets or sets a boolean indicating if the sprite can be picked */
  10347. isPickable: boolean;
  10348. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10349. useAlphaForPicking: boolean;
  10350. /** @hidden */
  10351. _xOffset: number;
  10352. /** @hidden */
  10353. _yOffset: number;
  10354. /** @hidden */
  10355. _xSize: number;
  10356. /** @hidden */
  10357. _ySize: number;
  10358. /**
  10359. * Gets or sets the associated action manager
  10360. */
  10361. actionManager: Nullable<ActionManager>;
  10362. /**
  10363. * An event triggered when the control has been disposed
  10364. */
  10365. onDisposeObservable: Observable<Sprite>;
  10366. private _animationStarted;
  10367. private _loopAnimation;
  10368. private _fromIndex;
  10369. private _toIndex;
  10370. private _delay;
  10371. private _direction;
  10372. private _manager;
  10373. private _time;
  10374. private _onAnimationEnd;
  10375. /**
  10376. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10377. */
  10378. isVisible: boolean;
  10379. /**
  10380. * Gets or sets the sprite size
  10381. */
  10382. get size(): number;
  10383. set size(value: number);
  10384. /**
  10385. * Returns a boolean indicating if the animation is started
  10386. */
  10387. get animationStarted(): boolean;
  10388. /**
  10389. * Gets or sets the unique id of the sprite
  10390. */
  10391. uniqueId: number;
  10392. /**
  10393. * Gets the manager of this sprite
  10394. */
  10395. get manager(): ISpriteManager;
  10396. /**
  10397. * Creates a new Sprite
  10398. * @param name defines the name
  10399. * @param manager defines the manager
  10400. */
  10401. constructor(
  10402. /** defines the name */
  10403. name: string, manager: ISpriteManager);
  10404. /**
  10405. * Returns the string "Sprite"
  10406. * @returns "Sprite"
  10407. */
  10408. getClassName(): string;
  10409. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10410. get fromIndex(): number;
  10411. set fromIndex(value: number);
  10412. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10413. get toIndex(): number;
  10414. set toIndex(value: number);
  10415. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10416. get loopAnimation(): boolean;
  10417. set loopAnimation(value: boolean);
  10418. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10419. get delay(): number;
  10420. set delay(value: number);
  10421. /**
  10422. * Starts an animation
  10423. * @param from defines the initial key
  10424. * @param to defines the end key
  10425. * @param loop defines if the animation must loop
  10426. * @param delay defines the start delay (in ms)
  10427. * @param onAnimationEnd defines a callback to call when animation ends
  10428. */
  10429. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10430. /** Stops current animation (if any) */
  10431. stopAnimation(): void;
  10432. /** @hidden */
  10433. _animate(deltaTime: number): void;
  10434. /** Release associated resources */
  10435. dispose(): void;
  10436. /**
  10437. * Serializes the sprite to a JSON object
  10438. * @returns the JSON object
  10439. */
  10440. serialize(): any;
  10441. /**
  10442. * Parses a JSON object to create a new sprite
  10443. * @param parsedSprite The JSON object to parse
  10444. * @param manager defines the hosting manager
  10445. * @returns the new sprite
  10446. */
  10447. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10448. }
  10449. }
  10450. declare module "babylonjs/Collisions/pickingInfo" {
  10451. import { Nullable } from "babylonjs/types";
  10452. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10454. import { Sprite } from "babylonjs/Sprites/sprite";
  10455. import { Ray } from "babylonjs/Culling/ray";
  10456. /**
  10457. * Information about the result of picking within a scene
  10458. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10459. */
  10460. export class PickingInfo {
  10461. /** @hidden */
  10462. _pickingUnavailable: boolean;
  10463. /**
  10464. * If the pick collided with an object
  10465. */
  10466. hit: boolean;
  10467. /**
  10468. * Distance away where the pick collided
  10469. */
  10470. distance: number;
  10471. /**
  10472. * The location of pick collision
  10473. */
  10474. pickedPoint: Nullable<Vector3>;
  10475. /**
  10476. * The mesh corresponding the the pick collision
  10477. */
  10478. pickedMesh: Nullable<AbstractMesh>;
  10479. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10480. bu: number;
  10481. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10482. bv: number;
  10483. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10484. faceId: number;
  10485. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10486. subMeshFaceId: number;
  10487. /** Id of the the submesh that was picked */
  10488. subMeshId: number;
  10489. /** If a sprite was picked, this will be the sprite the pick collided with */
  10490. pickedSprite: Nullable<Sprite>;
  10491. /**
  10492. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10493. */
  10494. originMesh: Nullable<AbstractMesh>;
  10495. /**
  10496. * The ray that was used to perform the picking.
  10497. */
  10498. ray: Nullable<Ray>;
  10499. /**
  10500. * Gets the normal correspodning to the face the pick collided with
  10501. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10502. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10503. * @returns The normal correspodning to the face the pick collided with
  10504. */
  10505. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10506. /**
  10507. * Gets the texture coordinates of where the pick occured
  10508. * @returns the vector containing the coordnates of the texture
  10509. */
  10510. getTextureCoordinates(): Nullable<Vector2>;
  10511. }
  10512. }
  10513. declare module "babylonjs/Culling/ray" {
  10514. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10515. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10517. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10518. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10519. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10520. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10521. import { Plane } from "babylonjs/Maths/math.plane";
  10522. /**
  10523. * Class representing a ray with position and direction
  10524. */
  10525. export class Ray {
  10526. /** origin point */
  10527. origin: Vector3;
  10528. /** direction */
  10529. direction: Vector3;
  10530. /** length of the ray */
  10531. length: number;
  10532. private static readonly TmpVector3;
  10533. private _tmpRay;
  10534. /**
  10535. * Creates a new ray
  10536. * @param origin origin point
  10537. * @param direction direction
  10538. * @param length length of the ray
  10539. */
  10540. constructor(
  10541. /** origin point */
  10542. origin: Vector3,
  10543. /** direction */
  10544. direction: Vector3,
  10545. /** length of the ray */
  10546. length?: number);
  10547. /**
  10548. * Checks if the ray intersects a box
  10549. * This does not account for the ray lenght by design to improve perfs.
  10550. * @param minimum bound of the box
  10551. * @param maximum bound of the box
  10552. * @param intersectionTreshold extra extend to be added to the box in all direction
  10553. * @returns if the box was hit
  10554. */
  10555. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10556. /**
  10557. * Checks if the ray intersects a box
  10558. * This does not account for the ray lenght by design to improve perfs.
  10559. * @param box the bounding box to check
  10560. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10561. * @returns if the box was hit
  10562. */
  10563. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10564. /**
  10565. * If the ray hits a sphere
  10566. * @param sphere the bounding sphere to check
  10567. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10568. * @returns true if it hits the sphere
  10569. */
  10570. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10571. /**
  10572. * If the ray hits a triange
  10573. * @param vertex0 triangle vertex
  10574. * @param vertex1 triangle vertex
  10575. * @param vertex2 triangle vertex
  10576. * @returns intersection information if hit
  10577. */
  10578. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10579. /**
  10580. * Checks if ray intersects a plane
  10581. * @param plane the plane to check
  10582. * @returns the distance away it was hit
  10583. */
  10584. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10585. /**
  10586. * Calculate the intercept of a ray on a given axis
  10587. * @param axis to check 'x' | 'y' | 'z'
  10588. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10589. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10590. */
  10591. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10592. /**
  10593. * Checks if ray intersects a mesh
  10594. * @param mesh the mesh to check
  10595. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10596. * @returns picking info of the intersecton
  10597. */
  10598. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10599. /**
  10600. * Checks if ray intersects a mesh
  10601. * @param meshes the meshes to check
  10602. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10603. * @param results array to store result in
  10604. * @returns Array of picking infos
  10605. */
  10606. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10607. private _comparePickingInfo;
  10608. private static smallnum;
  10609. private static rayl;
  10610. /**
  10611. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10612. * @param sega the first point of the segment to test the intersection against
  10613. * @param segb the second point of the segment to test the intersection against
  10614. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10615. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10616. */
  10617. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10618. /**
  10619. * Update the ray from viewport position
  10620. * @param x position
  10621. * @param y y position
  10622. * @param viewportWidth viewport width
  10623. * @param viewportHeight viewport height
  10624. * @param world world matrix
  10625. * @param view view matrix
  10626. * @param projection projection matrix
  10627. * @returns this ray updated
  10628. */
  10629. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10630. /**
  10631. * Creates a ray with origin and direction of 0,0,0
  10632. * @returns the new ray
  10633. */
  10634. static Zero(): Ray;
  10635. /**
  10636. * Creates a new ray from screen space and viewport
  10637. * @param x position
  10638. * @param y y position
  10639. * @param viewportWidth viewport width
  10640. * @param viewportHeight viewport height
  10641. * @param world world matrix
  10642. * @param view view matrix
  10643. * @param projection projection matrix
  10644. * @returns new ray
  10645. */
  10646. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10647. /**
  10648. * 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
  10649. * transformed to the given world matrix.
  10650. * @param origin The origin point
  10651. * @param end The end point
  10652. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10653. * @returns the new ray
  10654. */
  10655. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10656. /**
  10657. * Transforms a ray by a matrix
  10658. * @param ray ray to transform
  10659. * @param matrix matrix to apply
  10660. * @returns the resulting new ray
  10661. */
  10662. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10663. /**
  10664. * Transforms a ray by a matrix
  10665. * @param ray ray to transform
  10666. * @param matrix matrix to apply
  10667. * @param result ray to store result in
  10668. */
  10669. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10670. /**
  10671. * Unproject a ray from screen space to object space
  10672. * @param sourceX defines the screen space x coordinate to use
  10673. * @param sourceY defines the screen space y coordinate to use
  10674. * @param viewportWidth defines the current width of the viewport
  10675. * @param viewportHeight defines the current height of the viewport
  10676. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10677. * @param view defines the view matrix to use
  10678. * @param projection defines the projection matrix to use
  10679. */
  10680. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10681. }
  10682. /**
  10683. * Type used to define predicate used to select faces when a mesh intersection is detected
  10684. */
  10685. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10686. module "babylonjs/scene" {
  10687. interface Scene {
  10688. /** @hidden */
  10689. _tempPickingRay: Nullable<Ray>;
  10690. /** @hidden */
  10691. _cachedRayForTransform: Ray;
  10692. /** @hidden */
  10693. _pickWithRayInverseMatrix: Matrix;
  10694. /** @hidden */
  10695. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10696. /** @hidden */
  10697. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10698. }
  10699. }
  10700. }
  10701. declare module "babylonjs/sceneComponent" {
  10702. import { Scene } from "babylonjs/scene";
  10703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10704. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10705. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10706. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10707. import { Nullable } from "babylonjs/types";
  10708. import { Camera } from "babylonjs/Cameras/camera";
  10709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10710. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10711. import { AbstractScene } from "babylonjs/abstractScene";
  10712. import { Mesh } from "babylonjs/Meshes/mesh";
  10713. /**
  10714. * Groups all the scene component constants in one place to ease maintenance.
  10715. * @hidden
  10716. */
  10717. export class SceneComponentConstants {
  10718. static readonly NAME_EFFECTLAYER: string;
  10719. static readonly NAME_LAYER: string;
  10720. static readonly NAME_LENSFLARESYSTEM: string;
  10721. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10722. static readonly NAME_PARTICLESYSTEM: string;
  10723. static readonly NAME_GAMEPAD: string;
  10724. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10725. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10726. static readonly NAME_DEPTHRENDERER: string;
  10727. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10728. static readonly NAME_SPRITE: string;
  10729. static readonly NAME_OUTLINERENDERER: string;
  10730. static readonly NAME_PROCEDURALTEXTURE: string;
  10731. static readonly NAME_SHADOWGENERATOR: string;
  10732. static readonly NAME_OCTREE: string;
  10733. static readonly NAME_PHYSICSENGINE: string;
  10734. static readonly NAME_AUDIO: string;
  10735. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10736. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10737. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10739. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10740. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10741. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10742. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10743. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10744. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10745. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10746. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10747. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10748. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10749. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10750. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10751. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10752. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10753. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10754. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10755. static readonly STEP_AFTERRENDER_AUDIO: number;
  10756. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10759. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10760. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10761. static readonly STEP_POINTERMOVE_SPRITE: number;
  10762. static readonly STEP_POINTERDOWN_SPRITE: number;
  10763. static readonly STEP_POINTERUP_SPRITE: number;
  10764. }
  10765. /**
  10766. * This represents a scene component.
  10767. *
  10768. * This is used to decouple the dependency the scene is having on the different workloads like
  10769. * layers, post processes...
  10770. */
  10771. export interface ISceneComponent {
  10772. /**
  10773. * The name of the component. Each component must have a unique name.
  10774. */
  10775. name: string;
  10776. /**
  10777. * The scene the component belongs to.
  10778. */
  10779. scene: Scene;
  10780. /**
  10781. * Register the component to one instance of a scene.
  10782. */
  10783. register(): void;
  10784. /**
  10785. * Rebuilds the elements related to this component in case of
  10786. * context lost for instance.
  10787. */
  10788. rebuild(): void;
  10789. /**
  10790. * Disposes the component and the associated ressources.
  10791. */
  10792. dispose(): void;
  10793. }
  10794. /**
  10795. * This represents a SERIALIZABLE scene component.
  10796. *
  10797. * This extends Scene Component to add Serialization methods on top.
  10798. */
  10799. export interface ISceneSerializableComponent extends ISceneComponent {
  10800. /**
  10801. * Adds all the elements from the container to the scene
  10802. * @param container the container holding the elements
  10803. */
  10804. addFromContainer(container: AbstractScene): void;
  10805. /**
  10806. * Removes all the elements in the container from the scene
  10807. * @param container contains the elements to remove
  10808. * @param dispose if the removed element should be disposed (default: false)
  10809. */
  10810. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10811. /**
  10812. * Serializes the component data to the specified json object
  10813. * @param serializationObject The object to serialize to
  10814. */
  10815. serialize(serializationObject: any): void;
  10816. }
  10817. /**
  10818. * Strong typing of a Mesh related stage step action
  10819. */
  10820. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10821. /**
  10822. * Strong typing of a Evaluate Sub Mesh related stage step action
  10823. */
  10824. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10825. /**
  10826. * Strong typing of a Active Mesh related stage step action
  10827. */
  10828. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10829. /**
  10830. * Strong typing of a Camera related stage step action
  10831. */
  10832. export type CameraStageAction = (camera: Camera) => void;
  10833. /**
  10834. * Strong typing of a Camera Frame buffer related stage step action
  10835. */
  10836. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10837. /**
  10838. * Strong typing of a Render Target related stage step action
  10839. */
  10840. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10841. /**
  10842. * Strong typing of a RenderingGroup related stage step action
  10843. */
  10844. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10845. /**
  10846. * Strong typing of a Mesh Render related stage step action
  10847. */
  10848. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10849. /**
  10850. * Strong typing of a simple stage step action
  10851. */
  10852. export type SimpleStageAction = () => void;
  10853. /**
  10854. * Strong typing of a render target action.
  10855. */
  10856. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10857. /**
  10858. * Strong typing of a pointer move action.
  10859. */
  10860. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10861. /**
  10862. * Strong typing of a pointer up/down action.
  10863. */
  10864. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10865. /**
  10866. * Representation of a stage in the scene (Basically a list of ordered steps)
  10867. * @hidden
  10868. */
  10869. export class Stage<T extends Function> extends Array<{
  10870. index: number;
  10871. component: ISceneComponent;
  10872. action: T;
  10873. }> {
  10874. /**
  10875. * Hide ctor from the rest of the world.
  10876. * @param items The items to add.
  10877. */
  10878. private constructor();
  10879. /**
  10880. * Creates a new Stage.
  10881. * @returns A new instance of a Stage
  10882. */
  10883. static Create<T extends Function>(): Stage<T>;
  10884. /**
  10885. * Registers a step in an ordered way in the targeted stage.
  10886. * @param index Defines the position to register the step in
  10887. * @param component Defines the component attached to the step
  10888. * @param action Defines the action to launch during the step
  10889. */
  10890. registerStep(index: number, component: ISceneComponent, action: T): void;
  10891. /**
  10892. * Clears all the steps from the stage.
  10893. */
  10894. clear(): void;
  10895. }
  10896. }
  10897. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10898. import { Nullable } from "babylonjs/types";
  10899. import { Observable } from "babylonjs/Misc/observable";
  10900. import { Scene } from "babylonjs/scene";
  10901. import { Sprite } from "babylonjs/Sprites/sprite";
  10902. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10903. import { Ray } from "babylonjs/Culling/ray";
  10904. import { Camera } from "babylonjs/Cameras/camera";
  10905. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10906. import { ISceneComponent } from "babylonjs/sceneComponent";
  10907. module "babylonjs/scene" {
  10908. interface Scene {
  10909. /** @hidden */
  10910. _pointerOverSprite: Nullable<Sprite>;
  10911. /** @hidden */
  10912. _pickedDownSprite: Nullable<Sprite>;
  10913. /** @hidden */
  10914. _tempSpritePickingRay: Nullable<Ray>;
  10915. /**
  10916. * All of the sprite managers added to this scene
  10917. * @see http://doc.babylonjs.com/babylon101/sprites
  10918. */
  10919. spriteManagers: Array<ISpriteManager>;
  10920. /**
  10921. * An event triggered when sprites rendering is about to start
  10922. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10923. */
  10924. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10925. /**
  10926. * An event triggered when sprites rendering is done
  10927. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10928. */
  10929. onAfterSpritesRenderingObservable: Observable<Scene>;
  10930. /** @hidden */
  10931. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10932. /** Launch a ray to try to pick a sprite in the scene
  10933. * @param x position on screen
  10934. * @param y position on screen
  10935. * @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
  10936. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10937. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10938. * @returns a PickingInfo
  10939. */
  10940. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10941. /** Use the given ray to pick a sprite in the scene
  10942. * @param ray The ray (in world space) to use to pick meshes
  10943. * @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
  10944. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10945. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10946. * @returns a PickingInfo
  10947. */
  10948. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10949. /** @hidden */
  10950. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10951. /** Launch a ray to try to pick sprites in the scene
  10952. * @param x position on screen
  10953. * @param y position on screen
  10954. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10955. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10956. * @returns a PickingInfo array
  10957. */
  10958. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10959. /** Use the given ray to pick sprites in the scene
  10960. * @param ray The ray (in world space) to use to pick meshes
  10961. * @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
  10962. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10963. * @returns a PickingInfo array
  10964. */
  10965. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10966. /**
  10967. * Force the sprite under the pointer
  10968. * @param sprite defines the sprite to use
  10969. */
  10970. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10971. /**
  10972. * Gets the sprite under the pointer
  10973. * @returns a Sprite or null if no sprite is under the pointer
  10974. */
  10975. getPointerOverSprite(): Nullable<Sprite>;
  10976. }
  10977. }
  10978. /**
  10979. * Defines the sprite scene component responsible to manage sprites
  10980. * in a given scene.
  10981. */
  10982. export class SpriteSceneComponent implements ISceneComponent {
  10983. /**
  10984. * The component name helpfull to identify the component in the list of scene components.
  10985. */
  10986. readonly name: string;
  10987. /**
  10988. * The scene the component belongs to.
  10989. */
  10990. scene: Scene;
  10991. /** @hidden */
  10992. private _spritePredicate;
  10993. /**
  10994. * Creates a new instance of the component for the given scene
  10995. * @param scene Defines the scene to register the component in
  10996. */
  10997. constructor(scene: Scene);
  10998. /**
  10999. * Registers the component in a given scene
  11000. */
  11001. register(): void;
  11002. /**
  11003. * Rebuilds the elements related to this component in case of
  11004. * context lost for instance.
  11005. */
  11006. rebuild(): void;
  11007. /**
  11008. * Disposes the component and the associated ressources.
  11009. */
  11010. dispose(): void;
  11011. private _pickSpriteButKeepRay;
  11012. private _pointerMove;
  11013. private _pointerDown;
  11014. private _pointerUp;
  11015. }
  11016. }
  11017. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11018. /** @hidden */
  11019. export var fogFragmentDeclaration: {
  11020. name: string;
  11021. shader: string;
  11022. };
  11023. }
  11024. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11025. /** @hidden */
  11026. export var fogFragment: {
  11027. name: string;
  11028. shader: string;
  11029. };
  11030. }
  11031. declare module "babylonjs/Shaders/sprites.fragment" {
  11032. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11033. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11034. /** @hidden */
  11035. export var spritesPixelShader: {
  11036. name: string;
  11037. shader: string;
  11038. };
  11039. }
  11040. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11041. /** @hidden */
  11042. export var fogVertexDeclaration: {
  11043. name: string;
  11044. shader: string;
  11045. };
  11046. }
  11047. declare module "babylonjs/Shaders/sprites.vertex" {
  11048. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11049. /** @hidden */
  11050. export var spritesVertexShader: {
  11051. name: string;
  11052. shader: string;
  11053. };
  11054. }
  11055. declare module "babylonjs/Sprites/spriteManager" {
  11056. import { IDisposable, Scene } from "babylonjs/scene";
  11057. import { Nullable } from "babylonjs/types";
  11058. import { Observable } from "babylonjs/Misc/observable";
  11059. import { Sprite } from "babylonjs/Sprites/sprite";
  11060. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11061. import { Camera } from "babylonjs/Cameras/camera";
  11062. import { Texture } from "babylonjs/Materials/Textures/texture";
  11063. import "babylonjs/Shaders/sprites.fragment";
  11064. import "babylonjs/Shaders/sprites.vertex";
  11065. import { Ray } from "babylonjs/Culling/ray";
  11066. /**
  11067. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11068. */
  11069. export interface ISpriteManager extends IDisposable {
  11070. /**
  11071. * Gets manager's name
  11072. */
  11073. name: string;
  11074. /**
  11075. * Restricts the camera to viewing objects with the same layerMask.
  11076. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11077. */
  11078. layerMask: number;
  11079. /**
  11080. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11081. */
  11082. isPickable: boolean;
  11083. /**
  11084. * Gets the hosting scene
  11085. */
  11086. scene: Scene;
  11087. /**
  11088. * Specifies the rendering group id for this mesh (0 by default)
  11089. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11090. */
  11091. renderingGroupId: number;
  11092. /**
  11093. * Defines the list of sprites managed by the manager.
  11094. */
  11095. sprites: Array<Sprite>;
  11096. /**
  11097. * Gets or sets the spritesheet texture
  11098. */
  11099. texture: Texture;
  11100. /** Defines the default width of a cell in the spritesheet */
  11101. cellWidth: number;
  11102. /** Defines the default height of a cell in the spritesheet */
  11103. cellHeight: number;
  11104. /**
  11105. * Tests the intersection of a sprite with a specific ray.
  11106. * @param ray The ray we are sending to test the collision
  11107. * @param camera The camera space we are sending rays in
  11108. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11109. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11110. * @returns picking info or null.
  11111. */
  11112. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11113. /**
  11114. * Intersects the sprites with a ray
  11115. * @param ray defines the ray to intersect with
  11116. * @param camera defines the current active camera
  11117. * @param predicate defines a predicate used to select candidate sprites
  11118. * @returns null if no hit or a PickingInfo array
  11119. */
  11120. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11121. /**
  11122. * Renders the list of sprites on screen.
  11123. */
  11124. render(): void;
  11125. }
  11126. /**
  11127. * Class used to manage multiple sprites on the same spritesheet
  11128. * @see http://doc.babylonjs.com/babylon101/sprites
  11129. */
  11130. export class SpriteManager implements ISpriteManager {
  11131. /** defines the manager's name */
  11132. name: string;
  11133. /** Define the Url to load snippets */
  11134. static SnippetUrl: string;
  11135. /** Snippet ID if the manager was created from the snippet server */
  11136. snippetId: string;
  11137. /** Gets the list of sprites */
  11138. sprites: Sprite[];
  11139. /** Gets or sets the rendering group id (0 by default) */
  11140. renderingGroupId: number;
  11141. /** Gets or sets camera layer mask */
  11142. layerMask: number;
  11143. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11144. fogEnabled: boolean;
  11145. /** Gets or sets a boolean indicating if the sprites are pickable */
  11146. isPickable: boolean;
  11147. /** Defines the default width of a cell in the spritesheet */
  11148. cellWidth: number;
  11149. /** Defines the default height of a cell in the spritesheet */
  11150. cellHeight: number;
  11151. /** Associative array from JSON sprite data file */
  11152. private _cellData;
  11153. /** Array of sprite names from JSON sprite data file */
  11154. private _spriteMap;
  11155. /** True when packed cell data from JSON file is ready*/
  11156. private _packedAndReady;
  11157. private _textureContent;
  11158. /**
  11159. * An event triggered when the manager is disposed.
  11160. */
  11161. onDisposeObservable: Observable<SpriteManager>;
  11162. private _onDisposeObserver;
  11163. /**
  11164. * Callback called when the manager is disposed
  11165. */
  11166. set onDispose(callback: () => void);
  11167. private _capacity;
  11168. private _fromPacked;
  11169. private _spriteTexture;
  11170. private _epsilon;
  11171. private _scene;
  11172. private _vertexData;
  11173. private _buffer;
  11174. private _vertexBuffers;
  11175. private _indexBuffer;
  11176. private _effectBase;
  11177. private _effectFog;
  11178. /**
  11179. * Gets or sets the unique id of the sprite
  11180. */
  11181. uniqueId: number;
  11182. /**
  11183. * Gets the array of sprites
  11184. */
  11185. get children(): Sprite[];
  11186. /**
  11187. * Gets the hosting scene
  11188. */
  11189. get scene(): Scene;
  11190. /**
  11191. * Gets the capacity of the manager
  11192. */
  11193. get capacity(): number;
  11194. /**
  11195. * Gets or sets the spritesheet texture
  11196. */
  11197. get texture(): Texture;
  11198. set texture(value: Texture);
  11199. private _blendMode;
  11200. /**
  11201. * Blend mode use to render the particle, it can be any of
  11202. * the static Constants.ALPHA_x properties provided in this class.
  11203. * Default value is Constants.ALPHA_COMBINE
  11204. */
  11205. get blendMode(): number;
  11206. set blendMode(blendMode: number);
  11207. /** Disables writing to the depth buffer when rendering the sprites.
  11208. * It can be handy to disable depth writing when using textures without alpha channel
  11209. * and setting some specific blend modes.
  11210. */
  11211. disableDepthWrite: boolean;
  11212. /**
  11213. * Creates a new sprite manager
  11214. * @param name defines the manager's name
  11215. * @param imgUrl defines the sprite sheet url
  11216. * @param capacity defines the maximum allowed number of sprites
  11217. * @param cellSize defines the size of a sprite cell
  11218. * @param scene defines the hosting scene
  11219. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11220. * @param samplingMode defines the smapling mode to use with spritesheet
  11221. * @param fromPacked set to false; do not alter
  11222. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11223. */
  11224. constructor(
  11225. /** defines the manager's name */
  11226. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11227. /**
  11228. * Returns the string "SpriteManager"
  11229. * @returns "SpriteManager"
  11230. */
  11231. getClassName(): string;
  11232. private _makePacked;
  11233. private _appendSpriteVertex;
  11234. private _checkTextureAlpha;
  11235. /**
  11236. * Intersects the sprites with a ray
  11237. * @param ray defines the ray to intersect with
  11238. * @param camera defines the current active camera
  11239. * @param predicate defines a predicate used to select candidate sprites
  11240. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11241. * @returns null if no hit or a PickingInfo
  11242. */
  11243. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11244. /**
  11245. * Intersects the sprites with a ray
  11246. * @param ray defines the ray to intersect with
  11247. * @param camera defines the current active camera
  11248. * @param predicate defines a predicate used to select candidate sprites
  11249. * @returns null if no hit or a PickingInfo array
  11250. */
  11251. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11252. /**
  11253. * Render all child sprites
  11254. */
  11255. render(): void;
  11256. /**
  11257. * Release associated resources
  11258. */
  11259. dispose(): void;
  11260. /**
  11261. * Serializes the sprite manager to a JSON object
  11262. * @param serializeTexture defines if the texture must be serialized as well
  11263. * @returns the JSON object
  11264. */
  11265. serialize(serializeTexture?: boolean): any;
  11266. /**
  11267. * Parses a JSON object to create a new sprite manager.
  11268. * @param parsedManager The JSON object to parse
  11269. * @param scene The scene to create the sprite managerin
  11270. * @param rootUrl The root url to use to load external dependencies like texture
  11271. * @returns the new sprite manager
  11272. */
  11273. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11274. /**
  11275. * Creates a sprite manager from a snippet saved in a remote file
  11276. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11277. * @param url defines the url to load from
  11278. * @param scene defines the hosting scene
  11279. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11280. * @returns a promise that will resolve to the new sprite manager
  11281. */
  11282. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11283. /**
  11284. * Creates a sprite manager from a snippet saved by the sprite editor
  11285. * @param snippetId defines the snippet to load
  11286. * @param scene defines the hosting scene
  11287. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11288. * @returns a promise that will resolve to the new sprite manager
  11289. */
  11290. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11291. }
  11292. }
  11293. declare module "babylonjs/Misc/gradients" {
  11294. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11295. /** Interface used by value gradients (color, factor, ...) */
  11296. export interface IValueGradient {
  11297. /**
  11298. * Gets or sets the gradient value (between 0 and 1)
  11299. */
  11300. gradient: number;
  11301. }
  11302. /** Class used to store color4 gradient */
  11303. export class ColorGradient implements IValueGradient {
  11304. /**
  11305. * Gets or sets the gradient value (between 0 and 1)
  11306. */
  11307. gradient: number;
  11308. /**
  11309. * Gets or sets first associated color
  11310. */
  11311. color1: Color4;
  11312. /**
  11313. * Gets or sets second associated color
  11314. */
  11315. color2?: Color4 | undefined;
  11316. /**
  11317. * Creates a new color4 gradient
  11318. * @param gradient gets or sets the gradient value (between 0 and 1)
  11319. * @param color1 gets or sets first associated color
  11320. * @param color2 gets or sets first second color
  11321. */
  11322. constructor(
  11323. /**
  11324. * Gets or sets the gradient value (between 0 and 1)
  11325. */
  11326. gradient: number,
  11327. /**
  11328. * Gets or sets first associated color
  11329. */
  11330. color1: Color4,
  11331. /**
  11332. * Gets or sets second associated color
  11333. */
  11334. color2?: Color4 | undefined);
  11335. /**
  11336. * Will get a color picked randomly between color1 and color2.
  11337. * If color2 is undefined then color1 will be used
  11338. * @param result defines the target Color4 to store the result in
  11339. */
  11340. getColorToRef(result: Color4): void;
  11341. }
  11342. /** Class used to store color 3 gradient */
  11343. export class Color3Gradient implements IValueGradient {
  11344. /**
  11345. * Gets or sets the gradient value (between 0 and 1)
  11346. */
  11347. gradient: number;
  11348. /**
  11349. * Gets or sets the associated color
  11350. */
  11351. color: Color3;
  11352. /**
  11353. * Creates a new color3 gradient
  11354. * @param gradient gets or sets the gradient value (between 0 and 1)
  11355. * @param color gets or sets associated color
  11356. */
  11357. constructor(
  11358. /**
  11359. * Gets or sets the gradient value (between 0 and 1)
  11360. */
  11361. gradient: number,
  11362. /**
  11363. * Gets or sets the associated color
  11364. */
  11365. color: Color3);
  11366. }
  11367. /** Class used to store factor gradient */
  11368. export class FactorGradient implements IValueGradient {
  11369. /**
  11370. * Gets or sets the gradient value (between 0 and 1)
  11371. */
  11372. gradient: number;
  11373. /**
  11374. * Gets or sets first associated factor
  11375. */
  11376. factor1: number;
  11377. /**
  11378. * Gets or sets second associated factor
  11379. */
  11380. factor2?: number | undefined;
  11381. /**
  11382. * Creates a new factor gradient
  11383. * @param gradient gets or sets the gradient value (between 0 and 1)
  11384. * @param factor1 gets or sets first associated factor
  11385. * @param factor2 gets or sets second associated factor
  11386. */
  11387. constructor(
  11388. /**
  11389. * Gets or sets the gradient value (between 0 and 1)
  11390. */
  11391. gradient: number,
  11392. /**
  11393. * Gets or sets first associated factor
  11394. */
  11395. factor1: number,
  11396. /**
  11397. * Gets or sets second associated factor
  11398. */
  11399. factor2?: number | undefined);
  11400. /**
  11401. * Will get a number picked randomly between factor1 and factor2.
  11402. * If factor2 is undefined then factor1 will be used
  11403. * @returns the picked number
  11404. */
  11405. getFactor(): number;
  11406. }
  11407. /**
  11408. * Helper used to simplify some generic gradient tasks
  11409. */
  11410. export class GradientHelper {
  11411. /**
  11412. * Gets the current gradient from an array of IValueGradient
  11413. * @param ratio defines the current ratio to get
  11414. * @param gradients defines the array of IValueGradient
  11415. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11416. */
  11417. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11418. }
  11419. }
  11420. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  11421. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11422. import { Nullable } from "babylonjs/types";
  11423. module "babylonjs/Engines/thinEngine" {
  11424. interface ThinEngine {
  11425. /**
  11426. * Creates a dynamic texture
  11427. * @param width defines the width of the texture
  11428. * @param height defines the height of the texture
  11429. * @param generateMipMaps defines if the engine should generate the mip levels
  11430. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11431. * @returns the dynamic texture inside an InternalTexture
  11432. */
  11433. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11434. /**
  11435. * Update the content of a dynamic texture
  11436. * @param texture defines the texture to update
  11437. * @param canvas defines the canvas containing the source
  11438. * @param invertY defines if data must be stored with Y axis inverted
  11439. * @param premulAlpha defines if alpha is stored as premultiplied
  11440. * @param format defines the format of the data
  11441. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11442. */
  11443. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11444. }
  11445. }
  11446. }
  11447. declare module "babylonjs/Misc/canvasGenerator" {
  11448. /**
  11449. * Helper class used to generate a canvas to manipulate images
  11450. */
  11451. export class CanvasGenerator {
  11452. /**
  11453. * Create a new canvas (or offscreen canvas depending on the context)
  11454. * @param width defines the expected width
  11455. * @param height defines the expected height
  11456. * @return a new canvas or offscreen canvas
  11457. */
  11458. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11459. }
  11460. }
  11461. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  11462. import { Scene } from "babylonjs/scene";
  11463. import { Texture } from "babylonjs/Materials/Textures/texture";
  11464. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  11465. /**
  11466. * A class extending Texture allowing drawing on a texture
  11467. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11468. */
  11469. export class DynamicTexture extends Texture {
  11470. private _generateMipMaps;
  11471. private _canvas;
  11472. private _context;
  11473. /**
  11474. * Creates a DynamicTexture
  11475. * @param name defines the name of the texture
  11476. * @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
  11477. * @param scene defines the scene where you want the texture
  11478. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11479. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11480. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11481. */
  11482. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11483. /**
  11484. * Get the current class name of the texture useful for serialization or dynamic coding.
  11485. * @returns "DynamicTexture"
  11486. */
  11487. getClassName(): string;
  11488. /**
  11489. * Gets the current state of canRescale
  11490. */
  11491. get canRescale(): boolean;
  11492. private _recreate;
  11493. /**
  11494. * Scales the texture
  11495. * @param ratio the scale factor to apply to both width and height
  11496. */
  11497. scale(ratio: number): void;
  11498. /**
  11499. * Resizes the texture
  11500. * @param width the new width
  11501. * @param height the new height
  11502. */
  11503. scaleTo(width: number, height: number): void;
  11504. /**
  11505. * Gets the context of the canvas used by the texture
  11506. * @returns the canvas context of the dynamic texture
  11507. */
  11508. getContext(): CanvasRenderingContext2D;
  11509. /**
  11510. * Clears the texture
  11511. */
  11512. clear(): void;
  11513. /**
  11514. * Updates the texture
  11515. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11516. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11517. */
  11518. update(invertY?: boolean, premulAlpha?: boolean): void;
  11519. /**
  11520. * Draws text onto the texture
  11521. * @param text defines the text to be drawn
  11522. * @param x defines the placement of the text from the left
  11523. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11524. * @param font defines the font to be used with font-style, font-size, font-name
  11525. * @param color defines the color used for the text
  11526. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11527. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11528. * @param update defines whether texture is immediately update (default is true)
  11529. */
  11530. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11531. /**
  11532. * Clones the texture
  11533. * @returns the clone of the texture.
  11534. */
  11535. clone(): DynamicTexture;
  11536. /**
  11537. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11538. * @returns a serialized dynamic texture object
  11539. */
  11540. serialize(): any;
  11541. private _IsCanvasElement;
  11542. /** @hidden */
  11543. _rebuild(): void;
  11544. }
  11545. }
  11546. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11547. import { Nullable } from "babylonjs/types";
  11548. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11549. import { Scene } from "babylonjs/scene";
  11550. module "babylonjs/Engines/thinEngine" {
  11551. interface ThinEngine {
  11552. /**
  11553. * Creates a raw texture
  11554. * @param data defines the data to store in the texture
  11555. * @param width defines the width of the texture
  11556. * @param height defines the height of the texture
  11557. * @param format defines the format of the data
  11558. * @param generateMipMaps defines if the engine should generate the mip levels
  11559. * @param invertY defines if data must be stored with Y axis inverted
  11560. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11561. * @param compression defines the compression used (null by default)
  11562. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11563. * @returns the raw texture inside an InternalTexture
  11564. */
  11565. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11566. /**
  11567. * Update a raw texture
  11568. * @param texture defines the texture to update
  11569. * @param data defines the data to store in the texture
  11570. * @param format defines the format of the data
  11571. * @param invertY defines if data must be stored with Y axis inverted
  11572. */
  11573. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11574. /**
  11575. * Update a raw texture
  11576. * @param texture defines the texture to update
  11577. * @param data defines the data to store in the texture
  11578. * @param format defines the format of the data
  11579. * @param invertY defines if data must be stored with Y axis inverted
  11580. * @param compression defines the compression used (null by default)
  11581. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11582. */
  11583. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11584. /**
  11585. * Creates a new raw cube texture
  11586. * @param data defines the array of data to use to create each face
  11587. * @param size defines the size of the textures
  11588. * @param format defines the format of the data
  11589. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11590. * @param generateMipMaps defines if the engine should generate the mip levels
  11591. * @param invertY defines if data must be stored with Y axis inverted
  11592. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11593. * @param compression defines the compression used (null by default)
  11594. * @returns the cube texture as an InternalTexture
  11595. */
  11596. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11597. /**
  11598. * Update a raw cube texture
  11599. * @param texture defines the texture to udpdate
  11600. * @param data defines the data to store
  11601. * @param format defines the data format
  11602. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11603. * @param invertY defines if data must be stored with Y axis inverted
  11604. */
  11605. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11606. /**
  11607. * Update a raw cube texture
  11608. * @param texture defines the texture to udpdate
  11609. * @param data defines the data to store
  11610. * @param format defines the data format
  11611. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11612. * @param invertY defines if data must be stored with Y axis inverted
  11613. * @param compression defines the compression used (null by default)
  11614. */
  11615. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11616. /**
  11617. * Update a raw cube texture
  11618. * @param texture defines the texture to udpdate
  11619. * @param data defines the data to store
  11620. * @param format defines the data format
  11621. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11622. * @param invertY defines if data must be stored with Y axis inverted
  11623. * @param compression defines the compression used (null by default)
  11624. * @param level defines which level of the texture to update
  11625. */
  11626. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11627. /**
  11628. * Creates a new raw cube texture from a specified url
  11629. * @param url defines the url where the data is located
  11630. * @param scene defines the current scene
  11631. * @param size defines the size of the textures
  11632. * @param format defines the format of the data
  11633. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11634. * @param noMipmap defines if the engine should avoid generating the mip levels
  11635. * @param callback defines a callback used to extract texture data from loaded data
  11636. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11637. * @param onLoad defines a callback called when texture is loaded
  11638. * @param onError defines a callback called if there is an error
  11639. * @returns the cube texture as an InternalTexture
  11640. */
  11641. 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;
  11642. /**
  11643. * Creates a new raw cube texture from a specified url
  11644. * @param url defines the url where the data is located
  11645. * @param scene defines the current scene
  11646. * @param size defines the size of the textures
  11647. * @param format defines the format of the data
  11648. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11649. * @param noMipmap defines if the engine should avoid generating the mip levels
  11650. * @param callback defines a callback used to extract texture data from loaded data
  11651. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11652. * @param onLoad defines a callback called when texture is loaded
  11653. * @param onError defines a callback called if there is an error
  11654. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11655. * @param invertY defines if data must be stored with Y axis inverted
  11656. * @returns the cube texture as an InternalTexture
  11657. */
  11658. 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;
  11659. /**
  11660. * Creates a new raw 3D texture
  11661. * @param data defines the data used to create the texture
  11662. * @param width defines the width of the texture
  11663. * @param height defines the height of the texture
  11664. * @param depth defines the depth of the texture
  11665. * @param format defines the format of the texture
  11666. * @param generateMipMaps defines if the engine must generate mip levels
  11667. * @param invertY defines if data must be stored with Y axis inverted
  11668. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11669. * @param compression defines the compressed used (can be null)
  11670. * @param textureType defines the compressed used (can be null)
  11671. * @returns a new raw 3D texture (stored in an InternalTexture)
  11672. */
  11673. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11674. /**
  11675. * Update a raw 3D texture
  11676. * @param texture defines the texture to update
  11677. * @param data defines the data to store
  11678. * @param format defines the data format
  11679. * @param invertY defines if data must be stored with Y axis inverted
  11680. */
  11681. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11682. /**
  11683. * Update a raw 3D texture
  11684. * @param texture defines the texture to update
  11685. * @param data defines the data to store
  11686. * @param format defines the data format
  11687. * @param invertY defines if data must be stored with Y axis inverted
  11688. * @param compression defines the used compression (can be null)
  11689. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11690. */
  11691. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11692. /**
  11693. * Creates a new raw 2D array texture
  11694. * @param data defines the data used to create the texture
  11695. * @param width defines the width of the texture
  11696. * @param height defines the height of the texture
  11697. * @param depth defines the number of layers of the texture
  11698. * @param format defines the format of the texture
  11699. * @param generateMipMaps defines if the engine must generate mip levels
  11700. * @param invertY defines if data must be stored with Y axis inverted
  11701. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11702. * @param compression defines the compressed used (can be null)
  11703. * @param textureType defines the compressed used (can be null)
  11704. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11705. */
  11706. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11707. /**
  11708. * Update a raw 2D array texture
  11709. * @param texture defines the texture to update
  11710. * @param data defines the data to store
  11711. * @param format defines the data format
  11712. * @param invertY defines if data must be stored with Y axis inverted
  11713. */
  11714. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11715. /**
  11716. * Update a raw 2D array texture
  11717. * @param texture defines the texture to update
  11718. * @param data defines the data to store
  11719. * @param format defines the data format
  11720. * @param invertY defines if data must be stored with Y axis inverted
  11721. * @param compression defines the used compression (can be null)
  11722. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11723. */
  11724. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11725. }
  11726. }
  11727. }
  11728. declare module "babylonjs/Materials/Textures/rawTexture" {
  11729. import { Scene } from "babylonjs/scene";
  11730. import { Texture } from "babylonjs/Materials/Textures/texture";
  11731. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11732. /**
  11733. * Raw texture can help creating a texture directly from an array of data.
  11734. * This can be super useful if you either get the data from an uncompressed source or
  11735. * if you wish to create your texture pixel by pixel.
  11736. */
  11737. export class RawTexture extends Texture {
  11738. /**
  11739. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11740. */
  11741. format: number;
  11742. /**
  11743. * Instantiates a new RawTexture.
  11744. * Raw texture can help creating a texture directly from an array of data.
  11745. * This can be super useful if you either get the data from an uncompressed source or
  11746. * if you wish to create your texture pixel by pixel.
  11747. * @param data define the array of data to use to create the texture
  11748. * @param width define the width of the texture
  11749. * @param height define the height of the texture
  11750. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11751. * @param scene define the scene the texture belongs to
  11752. * @param generateMipMaps define whether mip maps should be generated or not
  11753. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11754. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11755. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11756. */
  11757. constructor(data: ArrayBufferView, width: number, height: number,
  11758. /**
  11759. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11760. */
  11761. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11762. /**
  11763. * Updates the texture underlying data.
  11764. * @param data Define the new data of the texture
  11765. */
  11766. update(data: ArrayBufferView): void;
  11767. /**
  11768. * Creates a luminance texture from some data.
  11769. * @param data Define the texture data
  11770. * @param width Define the width of the texture
  11771. * @param height Define the height of the texture
  11772. * @param scene Define the scene the texture belongs to
  11773. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11774. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11775. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11776. * @returns the luminance texture
  11777. */
  11778. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11779. /**
  11780. * Creates a luminance alpha texture from some data.
  11781. * @param data Define the texture data
  11782. * @param width Define the width of the texture
  11783. * @param height Define the height of the texture
  11784. * @param scene Define the scene the texture belongs to
  11785. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11786. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11787. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11788. * @returns the luminance alpha texture
  11789. */
  11790. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11791. /**
  11792. * Creates an alpha texture from some data.
  11793. * @param data Define the texture data
  11794. * @param width Define the width of the texture
  11795. * @param height Define the height of the texture
  11796. * @param scene Define the scene the texture belongs to
  11797. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11798. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11799. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11800. * @returns the alpha texture
  11801. */
  11802. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11803. /**
  11804. * Creates a RGB texture from some data.
  11805. * @param data Define the texture data
  11806. * @param width Define the width of the texture
  11807. * @param height Define the height of the texture
  11808. * @param scene Define the scene the texture belongs to
  11809. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11810. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11811. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11812. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11813. * @returns the RGB alpha texture
  11814. */
  11815. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11816. /**
  11817. * Creates a RGBA texture from some data.
  11818. * @param data Define the texture data
  11819. * @param width Define the width of the texture
  11820. * @param height Define the height of the texture
  11821. * @param scene Define the scene the texture belongs to
  11822. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11823. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11824. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11825. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11826. * @returns the RGBA texture
  11827. */
  11828. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11829. /**
  11830. * Creates a R texture from some data.
  11831. * @param data Define the texture data
  11832. * @param width Define the width of the texture
  11833. * @param height Define the height of the texture
  11834. * @param scene Define the scene the texture belongs to
  11835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11838. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11839. * @returns the R texture
  11840. */
  11841. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11842. }
  11843. }
  11844. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11845. import { Scene } from "babylonjs/scene";
  11846. import { ISceneComponent } from "babylonjs/sceneComponent";
  11847. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11848. module "babylonjs/abstractScene" {
  11849. interface AbstractScene {
  11850. /**
  11851. * The list of procedural textures added to the scene
  11852. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11853. */
  11854. proceduralTextures: Array<ProceduralTexture>;
  11855. }
  11856. }
  11857. /**
  11858. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11859. * in a given scene.
  11860. */
  11861. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11862. /**
  11863. * The component name helpfull to identify the component in the list of scene components.
  11864. */
  11865. readonly name: string;
  11866. /**
  11867. * The scene the component belongs to.
  11868. */
  11869. scene: Scene;
  11870. /**
  11871. * Creates a new instance of the component for the given scene
  11872. * @param scene Defines the scene to register the component in
  11873. */
  11874. constructor(scene: Scene);
  11875. /**
  11876. * Registers the component in a given scene
  11877. */
  11878. register(): void;
  11879. /**
  11880. * Rebuilds the elements related to this component in case of
  11881. * context lost for instance.
  11882. */
  11883. rebuild(): void;
  11884. /**
  11885. * Disposes the component and the associated ressources.
  11886. */
  11887. dispose(): void;
  11888. private _beforeClear;
  11889. }
  11890. }
  11891. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11892. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11893. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11894. module "babylonjs/Engines/thinEngine" {
  11895. interface ThinEngine {
  11896. /**
  11897. * Creates a new render target cube texture
  11898. * @param size defines the size of the texture
  11899. * @param options defines the options used to create the texture
  11900. * @returns a new render target cube texture stored in an InternalTexture
  11901. */
  11902. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11903. }
  11904. }
  11905. }
  11906. declare module "babylonjs/Shaders/procedural.vertex" {
  11907. /** @hidden */
  11908. export var proceduralVertexShader: {
  11909. name: string;
  11910. shader: string;
  11911. };
  11912. }
  11913. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11914. import { Observable } from "babylonjs/Misc/observable";
  11915. import { Nullable } from "babylonjs/types";
  11916. import { Scene } from "babylonjs/scene";
  11917. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11918. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11919. import { Effect } from "babylonjs/Materials/effect";
  11920. import { Texture } from "babylonjs/Materials/Textures/texture";
  11921. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11922. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11923. import "babylonjs/Shaders/procedural.vertex";
  11924. /**
  11925. * 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.
  11926. * This is the base class of any Procedural texture and contains most of the shareable code.
  11927. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11928. */
  11929. export class ProceduralTexture extends Texture {
  11930. isCube: boolean;
  11931. /**
  11932. * Define if the texture is enabled or not (disabled texture will not render)
  11933. */
  11934. isEnabled: boolean;
  11935. /**
  11936. * Define if the texture must be cleared before rendering (default is true)
  11937. */
  11938. autoClear: boolean;
  11939. /**
  11940. * Callback called when the texture is generated
  11941. */
  11942. onGenerated: () => void;
  11943. /**
  11944. * Event raised when the texture is generated
  11945. */
  11946. onGeneratedObservable: Observable<ProceduralTexture>;
  11947. /** @hidden */
  11948. _generateMipMaps: boolean;
  11949. /** @hidden **/
  11950. _effect: Effect;
  11951. /** @hidden */
  11952. _textures: {
  11953. [key: string]: Texture;
  11954. };
  11955. /** @hidden */
  11956. protected _fallbackTexture: Nullable<Texture>;
  11957. private _size;
  11958. private _currentRefreshId;
  11959. private _frameId;
  11960. private _refreshRate;
  11961. private _vertexBuffers;
  11962. private _indexBuffer;
  11963. private _uniforms;
  11964. private _samplers;
  11965. private _fragment;
  11966. private _floats;
  11967. private _ints;
  11968. private _floatsArrays;
  11969. private _colors3;
  11970. private _colors4;
  11971. private _vectors2;
  11972. private _vectors3;
  11973. private _matrices;
  11974. private _fallbackTextureUsed;
  11975. private _fullEngine;
  11976. private _cachedDefines;
  11977. private _contentUpdateId;
  11978. private _contentData;
  11979. /**
  11980. * Instantiates a new procedural texture.
  11981. * 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.
  11982. * This is the base class of any Procedural texture and contains most of the shareable code.
  11983. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11984. * @param name Define the name of the texture
  11985. * @param size Define the size of the texture to create
  11986. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11987. * @param scene Define the scene the texture belongs to
  11988. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11989. * @param generateMipMaps Define if the texture should creates mip maps or not
  11990. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11991. */
  11992. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11993. /**
  11994. * The effect that is created when initializing the post process.
  11995. * @returns The created effect corresponding the the postprocess.
  11996. */
  11997. getEffect(): Effect;
  11998. /**
  11999. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12000. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12001. */
  12002. getContent(): Nullable<ArrayBufferView>;
  12003. private _createIndexBuffer;
  12004. /** @hidden */
  12005. _rebuild(): void;
  12006. /**
  12007. * Resets the texture in order to recreate its associated resources.
  12008. * This can be called in case of context loss
  12009. */
  12010. reset(): void;
  12011. protected _getDefines(): string;
  12012. /**
  12013. * Is the texture ready to be used ? (rendered at least once)
  12014. * @returns true if ready, otherwise, false.
  12015. */
  12016. isReady(): boolean;
  12017. /**
  12018. * Resets the refresh counter of the texture and start bak from scratch.
  12019. * Could be useful to regenerate the texture if it is setup to render only once.
  12020. */
  12021. resetRefreshCounter(): void;
  12022. /**
  12023. * Set the fragment shader to use in order to render the texture.
  12024. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12025. */
  12026. setFragment(fragment: any): void;
  12027. /**
  12028. * Define the refresh rate of the texture or the rendering frequency.
  12029. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12030. */
  12031. get refreshRate(): number;
  12032. set refreshRate(value: number);
  12033. /** @hidden */
  12034. _shouldRender(): boolean;
  12035. /**
  12036. * Get the size the texture is rendering at.
  12037. * @returns the size (texture is always squared)
  12038. */
  12039. getRenderSize(): number;
  12040. /**
  12041. * Resize the texture to new value.
  12042. * @param size Define the new size the texture should have
  12043. * @param generateMipMaps Define whether the new texture should create mip maps
  12044. */
  12045. resize(size: number, generateMipMaps: boolean): void;
  12046. private _checkUniform;
  12047. /**
  12048. * Set a texture in the shader program used to render.
  12049. * @param name Define the name of the uniform samplers as defined in the shader
  12050. * @param texture Define the texture to bind to this sampler
  12051. * @return the texture itself allowing "fluent" like uniform updates
  12052. */
  12053. setTexture(name: string, texture: Texture): ProceduralTexture;
  12054. /**
  12055. * Set a float in the shader.
  12056. * @param name Define the name of the uniform as defined in the shader
  12057. * @param value Define the value to give to the uniform
  12058. * @return the texture itself allowing "fluent" like uniform updates
  12059. */
  12060. setFloat(name: string, value: number): ProceduralTexture;
  12061. /**
  12062. * Set a int in the shader.
  12063. * @param name Define the name of the uniform as defined in the shader
  12064. * @param value Define the value to give to the uniform
  12065. * @return the texture itself allowing "fluent" like uniform updates
  12066. */
  12067. setInt(name: string, value: number): ProceduralTexture;
  12068. /**
  12069. * Set an array of floats in the shader.
  12070. * @param name Define the name of the uniform as defined in the shader
  12071. * @param value Define the value to give to the uniform
  12072. * @return the texture itself allowing "fluent" like uniform updates
  12073. */
  12074. setFloats(name: string, value: number[]): ProceduralTexture;
  12075. /**
  12076. * Set a vec3 in the shader from a Color3.
  12077. * @param name Define the name of the uniform as defined in the shader
  12078. * @param value Define the value to give to the uniform
  12079. * @return the texture itself allowing "fluent" like uniform updates
  12080. */
  12081. setColor3(name: string, value: Color3): ProceduralTexture;
  12082. /**
  12083. * Set a vec4 in the shader from a Color4.
  12084. * @param name Define the name of the uniform as defined in the shader
  12085. * @param value Define the value to give to the uniform
  12086. * @return the texture itself allowing "fluent" like uniform updates
  12087. */
  12088. setColor4(name: string, value: Color4): ProceduralTexture;
  12089. /**
  12090. * Set a vec2 in the shader from a Vector2.
  12091. * @param name Define the name of the uniform as defined in the shader
  12092. * @param value Define the value to give to the uniform
  12093. * @return the texture itself allowing "fluent" like uniform updates
  12094. */
  12095. setVector2(name: string, value: Vector2): ProceduralTexture;
  12096. /**
  12097. * Set a vec3 in the shader from a Vector3.
  12098. * @param name Define the name of the uniform as defined in the shader
  12099. * @param value Define the value to give to the uniform
  12100. * @return the texture itself allowing "fluent" like uniform updates
  12101. */
  12102. setVector3(name: string, value: Vector3): ProceduralTexture;
  12103. /**
  12104. * Set a mat4 in the shader from a MAtrix.
  12105. * @param name Define the name of the uniform as defined in the shader
  12106. * @param value Define the value to give to the uniform
  12107. * @return the texture itself allowing "fluent" like uniform updates
  12108. */
  12109. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12110. /**
  12111. * Render the texture to its associated render target.
  12112. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12113. */
  12114. render(useCameraPostProcess?: boolean): void;
  12115. /**
  12116. * Clone the texture.
  12117. * @returns the cloned texture
  12118. */
  12119. clone(): ProceduralTexture;
  12120. /**
  12121. * Dispose the texture and release its asoociated resources.
  12122. */
  12123. dispose(): void;
  12124. }
  12125. }
  12126. declare module "babylonjs/Particles/baseParticleSystem" {
  12127. import { Nullable } from "babylonjs/types";
  12128. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12130. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12131. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12132. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12133. import { Scene } from "babylonjs/scene";
  12134. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12135. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12136. import { Texture } from "babylonjs/Materials/Textures/texture";
  12137. import { Color4 } from "babylonjs/Maths/math.color";
  12138. import { Animation } from "babylonjs/Animations/animation";
  12139. /**
  12140. * This represents the base class for particle system in Babylon.
  12141. * 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.
  12142. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12143. * @example https://doc.babylonjs.com/babylon101/particles
  12144. */
  12145. export class BaseParticleSystem {
  12146. /**
  12147. * Source color is added to the destination color without alpha affecting the result
  12148. */
  12149. static BLENDMODE_ONEONE: number;
  12150. /**
  12151. * Blend current color and particle color using particle’s alpha
  12152. */
  12153. static BLENDMODE_STANDARD: number;
  12154. /**
  12155. * Add current color and particle color multiplied by particle’s alpha
  12156. */
  12157. static BLENDMODE_ADD: number;
  12158. /**
  12159. * Multiply current color with particle color
  12160. */
  12161. static BLENDMODE_MULTIPLY: number;
  12162. /**
  12163. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12164. */
  12165. static BLENDMODE_MULTIPLYADD: number;
  12166. /**
  12167. * List of animations used by the particle system.
  12168. */
  12169. animations: Animation[];
  12170. /**
  12171. * Gets or sets the unique id of the particle system
  12172. */
  12173. uniqueId: number;
  12174. /**
  12175. * The id of the Particle system.
  12176. */
  12177. id: string;
  12178. /**
  12179. * The friendly name of the Particle system.
  12180. */
  12181. name: string;
  12182. /**
  12183. * Snippet ID if the particle system was created from the snippet server
  12184. */
  12185. snippetId: string;
  12186. /**
  12187. * The rendering group used by the Particle system to chose when to render.
  12188. */
  12189. renderingGroupId: number;
  12190. /**
  12191. * The emitter represents the Mesh or position we are attaching the particle system to.
  12192. */
  12193. emitter: Nullable<AbstractMesh | Vector3>;
  12194. /**
  12195. * The maximum number of particles to emit per frame
  12196. */
  12197. emitRate: number;
  12198. /**
  12199. * If you want to launch only a few particles at once, that can be done, as well.
  12200. */
  12201. manualEmitCount: number;
  12202. /**
  12203. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12204. */
  12205. updateSpeed: number;
  12206. /**
  12207. * The amount of time the particle system is running (depends of the overall update speed).
  12208. */
  12209. targetStopDuration: number;
  12210. /**
  12211. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12212. */
  12213. disposeOnStop: boolean;
  12214. /**
  12215. * Minimum power of emitting particles.
  12216. */
  12217. minEmitPower: number;
  12218. /**
  12219. * Maximum power of emitting particles.
  12220. */
  12221. maxEmitPower: number;
  12222. /**
  12223. * Minimum life time of emitting particles.
  12224. */
  12225. minLifeTime: number;
  12226. /**
  12227. * Maximum life time of emitting particles.
  12228. */
  12229. maxLifeTime: number;
  12230. /**
  12231. * Minimum Size of emitting particles.
  12232. */
  12233. minSize: number;
  12234. /**
  12235. * Maximum Size of emitting particles.
  12236. */
  12237. maxSize: number;
  12238. /**
  12239. * Minimum scale of emitting particles on X axis.
  12240. */
  12241. minScaleX: number;
  12242. /**
  12243. * Maximum scale of emitting particles on X axis.
  12244. */
  12245. maxScaleX: number;
  12246. /**
  12247. * Minimum scale of emitting particles on Y axis.
  12248. */
  12249. minScaleY: number;
  12250. /**
  12251. * Maximum scale of emitting particles on Y axis.
  12252. */
  12253. maxScaleY: number;
  12254. /**
  12255. * Gets or sets the minimal initial rotation in radians.
  12256. */
  12257. minInitialRotation: number;
  12258. /**
  12259. * Gets or sets the maximal initial rotation in radians.
  12260. */
  12261. maxInitialRotation: number;
  12262. /**
  12263. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12264. */
  12265. minAngularSpeed: number;
  12266. /**
  12267. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12268. */
  12269. maxAngularSpeed: number;
  12270. /**
  12271. * The texture used to render each particle. (this can be a spritesheet)
  12272. */
  12273. particleTexture: Nullable<Texture>;
  12274. /**
  12275. * The layer mask we are rendering the particles through.
  12276. */
  12277. layerMask: number;
  12278. /**
  12279. * This can help using your own shader to render the particle system.
  12280. * The according effect will be created
  12281. */
  12282. customShader: any;
  12283. /**
  12284. * By default particle system starts as soon as they are created. This prevents the
  12285. * automatic start to happen and let you decide when to start emitting particles.
  12286. */
  12287. preventAutoStart: boolean;
  12288. private _noiseTexture;
  12289. /**
  12290. * Gets or sets a texture used to add random noise to particle positions
  12291. */
  12292. get noiseTexture(): Nullable<ProceduralTexture>;
  12293. set noiseTexture(value: Nullable<ProceduralTexture>);
  12294. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12295. noiseStrength: Vector3;
  12296. /**
  12297. * Callback triggered when the particle animation is ending.
  12298. */
  12299. onAnimationEnd: Nullable<() => void>;
  12300. /**
  12301. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12302. */
  12303. blendMode: number;
  12304. /**
  12305. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12306. * to override the particles.
  12307. */
  12308. forceDepthWrite: boolean;
  12309. /** 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 */
  12310. preWarmCycles: number;
  12311. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12312. preWarmStepOffset: number;
  12313. /**
  12314. * 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)
  12315. */
  12316. spriteCellChangeSpeed: number;
  12317. /**
  12318. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12319. */
  12320. startSpriteCellID: number;
  12321. /**
  12322. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12323. */
  12324. endSpriteCellID: number;
  12325. /**
  12326. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12327. */
  12328. spriteCellWidth: number;
  12329. /**
  12330. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12331. */
  12332. spriteCellHeight: number;
  12333. /**
  12334. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12335. */
  12336. spriteRandomStartCell: boolean;
  12337. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12338. translationPivot: Vector2;
  12339. /** @hidden */
  12340. protected _isAnimationSheetEnabled: boolean;
  12341. /**
  12342. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12343. */
  12344. beginAnimationOnStart: boolean;
  12345. /**
  12346. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12347. */
  12348. beginAnimationFrom: number;
  12349. /**
  12350. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12351. */
  12352. beginAnimationTo: number;
  12353. /**
  12354. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12355. */
  12356. beginAnimationLoop: boolean;
  12357. /**
  12358. * Gets or sets a world offset applied to all particles
  12359. */
  12360. worldOffset: Vector3;
  12361. /**
  12362. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12363. */
  12364. get isAnimationSheetEnabled(): boolean;
  12365. set isAnimationSheetEnabled(value: boolean);
  12366. /**
  12367. * Get hosting scene
  12368. * @returns the scene
  12369. */
  12370. getScene(): Scene;
  12371. /**
  12372. * You can use gravity if you want to give an orientation to your particles.
  12373. */
  12374. gravity: Vector3;
  12375. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12376. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12377. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12378. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12379. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12380. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12381. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12382. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12383. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12384. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12385. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12386. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12387. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12388. /**
  12389. * Defines the delay in milliseconds before starting the system (0 by default)
  12390. */
  12391. startDelay: number;
  12392. /**
  12393. * Gets the current list of drag gradients.
  12394. * You must use addDragGradient and removeDragGradient to udpate this list
  12395. * @returns the list of drag gradients
  12396. */
  12397. getDragGradients(): Nullable<Array<FactorGradient>>;
  12398. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12399. limitVelocityDamping: number;
  12400. /**
  12401. * Gets the current list of limit velocity gradients.
  12402. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12403. * @returns the list of limit velocity gradients
  12404. */
  12405. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12406. /**
  12407. * Gets the current list of color gradients.
  12408. * You must use addColorGradient and removeColorGradient to udpate this list
  12409. * @returns the list of color gradients
  12410. */
  12411. getColorGradients(): Nullable<Array<ColorGradient>>;
  12412. /**
  12413. * Gets the current list of size gradients.
  12414. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12415. * @returns the list of size gradients
  12416. */
  12417. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12418. /**
  12419. * Gets the current list of color remap gradients.
  12420. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12421. * @returns the list of color remap gradients
  12422. */
  12423. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12424. /**
  12425. * Gets the current list of alpha remap gradients.
  12426. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12427. * @returns the list of alpha remap gradients
  12428. */
  12429. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12430. /**
  12431. * Gets the current list of life time gradients.
  12432. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12433. * @returns the list of life time gradients
  12434. */
  12435. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12436. /**
  12437. * Gets the current list of angular speed gradients.
  12438. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12439. * @returns the list of angular speed gradients
  12440. */
  12441. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12442. /**
  12443. * Gets the current list of velocity gradients.
  12444. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12445. * @returns the list of velocity gradients
  12446. */
  12447. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12448. /**
  12449. * Gets the current list of start size gradients.
  12450. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12451. * @returns the list of start size gradients
  12452. */
  12453. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12454. /**
  12455. * Gets the current list of emit rate gradients.
  12456. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12457. * @returns the list of emit rate gradients
  12458. */
  12459. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12460. /**
  12461. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12462. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12463. */
  12464. get direction1(): Vector3;
  12465. set direction1(value: Vector3);
  12466. /**
  12467. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12468. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12469. */
  12470. get direction2(): Vector3;
  12471. set direction2(value: Vector3);
  12472. /**
  12473. * 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.
  12474. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12475. */
  12476. get minEmitBox(): Vector3;
  12477. set minEmitBox(value: Vector3);
  12478. /**
  12479. * 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.
  12480. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12481. */
  12482. get maxEmitBox(): Vector3;
  12483. set maxEmitBox(value: Vector3);
  12484. /**
  12485. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12486. */
  12487. color1: Color4;
  12488. /**
  12489. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12490. */
  12491. color2: Color4;
  12492. /**
  12493. * Color the particle will have at the end of its lifetime
  12494. */
  12495. colorDead: Color4;
  12496. /**
  12497. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12498. */
  12499. textureMask: Color4;
  12500. /**
  12501. * The particle emitter type defines the emitter used by the particle system.
  12502. * It can be for example box, sphere, or cone...
  12503. */
  12504. particleEmitterType: IParticleEmitterType;
  12505. /** @hidden */
  12506. _isSubEmitter: boolean;
  12507. /**
  12508. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12509. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12510. */
  12511. billboardMode: number;
  12512. protected _isBillboardBased: boolean;
  12513. /**
  12514. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12515. */
  12516. get isBillboardBased(): boolean;
  12517. set isBillboardBased(value: boolean);
  12518. /**
  12519. * The scene the particle system belongs to.
  12520. */
  12521. protected _scene: Scene;
  12522. /**
  12523. * Local cache of defines for image processing.
  12524. */
  12525. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12526. /**
  12527. * Default configuration related to image processing available in the standard Material.
  12528. */
  12529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12530. /**
  12531. * Gets the image processing configuration used either in this material.
  12532. */
  12533. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12534. /**
  12535. * Sets the Default image processing configuration used either in the this material.
  12536. *
  12537. * If sets to null, the scene one is in use.
  12538. */
  12539. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12540. /**
  12541. * Attaches a new image processing configuration to the Standard Material.
  12542. * @param configuration
  12543. */
  12544. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12545. /** @hidden */
  12546. protected _reset(): void;
  12547. /** @hidden */
  12548. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12549. /**
  12550. * Instantiates a particle system.
  12551. * 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.
  12552. * @param name The name of the particle system
  12553. */
  12554. constructor(name: string);
  12555. /**
  12556. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12557. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12558. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12559. * @returns the emitter
  12560. */
  12561. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12562. /**
  12563. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12564. * @param radius The radius of the hemisphere to emit from
  12565. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12566. * @returns the emitter
  12567. */
  12568. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12569. /**
  12570. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12571. * @param radius The radius of the sphere to emit from
  12572. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12573. * @returns the emitter
  12574. */
  12575. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12576. /**
  12577. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12578. * @param radius The radius of the sphere to emit from
  12579. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12580. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12581. * @returns the emitter
  12582. */
  12583. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12584. /**
  12585. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12586. * @param radius The radius of the emission cylinder
  12587. * @param height The height of the emission cylinder
  12588. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12589. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12590. * @returns the emitter
  12591. */
  12592. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12593. /**
  12594. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12595. * @param radius The radius of the cylinder to emit from
  12596. * @param height The height of the emission cylinder
  12597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12598. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12599. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12600. * @returns the emitter
  12601. */
  12602. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12603. /**
  12604. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12605. * @param radius The radius of the cone to emit from
  12606. * @param angle The base angle of the cone
  12607. * @returns the emitter
  12608. */
  12609. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12610. /**
  12611. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12614. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12615. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12616. * @returns the emitter
  12617. */
  12618. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12619. }
  12620. }
  12621. declare module "babylonjs/Particles/subEmitter" {
  12622. import { Scene } from "babylonjs/scene";
  12623. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12624. /**
  12625. * Type of sub emitter
  12626. */
  12627. export enum SubEmitterType {
  12628. /**
  12629. * Attached to the particle over it's lifetime
  12630. */
  12631. ATTACHED = 0,
  12632. /**
  12633. * Created when the particle dies
  12634. */
  12635. END = 1
  12636. }
  12637. /**
  12638. * Sub emitter class used to emit particles from an existing particle
  12639. */
  12640. export class SubEmitter {
  12641. /**
  12642. * the particle system to be used by the sub emitter
  12643. */
  12644. particleSystem: ParticleSystem;
  12645. /**
  12646. * Type of the submitter (Default: END)
  12647. */
  12648. type: SubEmitterType;
  12649. /**
  12650. * 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)
  12651. * Note: This only is supported when using an emitter of type Mesh
  12652. */
  12653. inheritDirection: boolean;
  12654. /**
  12655. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12656. */
  12657. inheritedVelocityAmount: number;
  12658. /**
  12659. * Creates a sub emitter
  12660. * @param particleSystem the particle system to be used by the sub emitter
  12661. */
  12662. constructor(
  12663. /**
  12664. * the particle system to be used by the sub emitter
  12665. */
  12666. particleSystem: ParticleSystem);
  12667. /**
  12668. * Clones the sub emitter
  12669. * @returns the cloned sub emitter
  12670. */
  12671. clone(): SubEmitter;
  12672. /**
  12673. * Serialize current object to a JSON object
  12674. * @returns the serialized object
  12675. */
  12676. serialize(): any;
  12677. /** @hidden */
  12678. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12679. /**
  12680. * Creates a new SubEmitter from a serialized JSON version
  12681. * @param serializationObject defines the JSON object to read from
  12682. * @param scene defines the hosting scene
  12683. * @param rootUrl defines the rootUrl for data loading
  12684. * @returns a new SubEmitter
  12685. */
  12686. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12687. /** Release associated resources */
  12688. dispose(): void;
  12689. }
  12690. }
  12691. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12692. /** @hidden */
  12693. export var imageProcessingDeclaration: {
  12694. name: string;
  12695. shader: string;
  12696. };
  12697. }
  12698. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12699. /** @hidden */
  12700. export var imageProcessingFunctions: {
  12701. name: string;
  12702. shader: string;
  12703. };
  12704. }
  12705. declare module "babylonjs/Shaders/particles.fragment" {
  12706. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12707. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12708. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12709. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12710. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12711. /** @hidden */
  12712. export var particlesPixelShader: {
  12713. name: string;
  12714. shader: string;
  12715. };
  12716. }
  12717. declare module "babylonjs/Shaders/particles.vertex" {
  12718. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12719. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12720. /** @hidden */
  12721. export var particlesVertexShader: {
  12722. name: string;
  12723. shader: string;
  12724. };
  12725. }
  12726. declare module "babylonjs/Particles/particleSystem" {
  12727. import { Nullable } from "babylonjs/types";
  12728. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12729. import { Observable } from "babylonjs/Misc/observable";
  12730. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12731. import { Effect } from "babylonjs/Materials/effect";
  12732. import { Scene, IDisposable } from "babylonjs/scene";
  12733. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12734. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12735. import { Particle } from "babylonjs/Particles/particle";
  12736. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12737. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12738. import "babylonjs/Shaders/particles.fragment";
  12739. import "babylonjs/Shaders/particles.vertex";
  12740. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12741. /**
  12742. * This represents a particle system in Babylon.
  12743. * 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.
  12744. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12745. * @example https://doc.babylonjs.com/babylon101/particles
  12746. */
  12747. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12748. /**
  12749. * Billboard mode will only apply to Y axis
  12750. */
  12751. static readonly BILLBOARDMODE_Y: number;
  12752. /**
  12753. * Billboard mode will apply to all axes
  12754. */
  12755. static readonly BILLBOARDMODE_ALL: number;
  12756. /**
  12757. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12758. */
  12759. static readonly BILLBOARDMODE_STRETCHED: number;
  12760. /**
  12761. * This function can be defined to provide custom update for active particles.
  12762. * This function will be called instead of regular update (age, position, color, etc.).
  12763. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12764. */
  12765. updateFunction: (particles: Particle[]) => void;
  12766. private _emitterWorldMatrix;
  12767. /**
  12768. * This function can be defined to specify initial direction for every new particle.
  12769. * It by default use the emitterType defined function
  12770. */
  12771. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12772. /**
  12773. * This function can be defined to specify initial position for every new particle.
  12774. * It by default use the emitterType defined function
  12775. */
  12776. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12777. /**
  12778. * @hidden
  12779. */
  12780. _inheritedVelocityOffset: Vector3;
  12781. /**
  12782. * An event triggered when the system is disposed
  12783. */
  12784. onDisposeObservable: Observable<IParticleSystem>;
  12785. private _onDisposeObserver;
  12786. /**
  12787. * Sets a callback that will be triggered when the system is disposed
  12788. */
  12789. set onDispose(callback: () => void);
  12790. private _particles;
  12791. private _epsilon;
  12792. private _capacity;
  12793. private _stockParticles;
  12794. private _newPartsExcess;
  12795. private _vertexData;
  12796. private _vertexBuffer;
  12797. private _vertexBuffers;
  12798. private _spriteBuffer;
  12799. private _indexBuffer;
  12800. private _effect;
  12801. private _customEffect;
  12802. private _cachedDefines;
  12803. private _scaledColorStep;
  12804. private _colorDiff;
  12805. private _scaledDirection;
  12806. private _scaledGravity;
  12807. private _currentRenderId;
  12808. private _alive;
  12809. private _useInstancing;
  12810. private _started;
  12811. private _stopped;
  12812. private _actualFrame;
  12813. private _scaledUpdateSpeed;
  12814. private _vertexBufferSize;
  12815. /** @hidden */
  12816. _currentEmitRateGradient: Nullable<FactorGradient>;
  12817. /** @hidden */
  12818. _currentEmitRate1: number;
  12819. /** @hidden */
  12820. _currentEmitRate2: number;
  12821. /** @hidden */
  12822. _currentStartSizeGradient: Nullable<FactorGradient>;
  12823. /** @hidden */
  12824. _currentStartSize1: number;
  12825. /** @hidden */
  12826. _currentStartSize2: number;
  12827. private readonly _rawTextureWidth;
  12828. private _rampGradientsTexture;
  12829. private _useRampGradients;
  12830. /** Gets or sets a boolean indicating that ramp gradients must be used
  12831. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12832. */
  12833. get useRampGradients(): boolean;
  12834. set useRampGradients(value: boolean);
  12835. /**
  12836. * 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.
  12837. * 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: [])
  12838. */
  12839. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12840. private _subEmitters;
  12841. /**
  12842. * @hidden
  12843. * If the particle systems emitter should be disposed when the particle system is disposed
  12844. */
  12845. _disposeEmitterOnDispose: boolean;
  12846. /**
  12847. * The current active Sub-systems, this property is used by the root particle system only.
  12848. */
  12849. activeSubSystems: Array<ParticleSystem>;
  12850. /**
  12851. * Specifies if the particles are updated in emitter local space or world space
  12852. */
  12853. isLocal: boolean;
  12854. private _rootParticleSystem;
  12855. /**
  12856. * Gets the current list of active particles
  12857. */
  12858. get particles(): Particle[];
  12859. /**
  12860. * Gets the number of particles active at the same time.
  12861. * @returns The number of active particles.
  12862. */
  12863. getActiveCount(): number;
  12864. /**
  12865. * Returns the string "ParticleSystem"
  12866. * @returns a string containing the class name
  12867. */
  12868. getClassName(): string;
  12869. /**
  12870. * Gets a boolean indicating that the system is stopping
  12871. * @returns true if the system is currently stopping
  12872. */
  12873. isStopping(): boolean;
  12874. /**
  12875. * Gets the custom effect used to render the particles
  12876. * @param blendMode Blend mode for which the effect should be retrieved
  12877. * @returns The effect
  12878. */
  12879. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12880. /**
  12881. * Sets the custom effect used to render the particles
  12882. * @param effect The effect to set
  12883. * @param blendMode Blend mode for which the effect should be set
  12884. */
  12885. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12886. /** @hidden */
  12887. private _onBeforeDrawParticlesObservable;
  12888. /**
  12889. * Observable that will be called just before the particles are drawn
  12890. */
  12891. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12892. /**
  12893. * Gets the name of the particle vertex shader
  12894. */
  12895. get vertexShaderName(): string;
  12896. /**
  12897. * Instantiates a particle system.
  12898. * 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.
  12899. * @param name The name of the particle system
  12900. * @param capacity The max number of particles alive at the same time
  12901. * @param scene The scene the particle system belongs to
  12902. * @param customEffect a custom effect used to change the way particles are rendered by default
  12903. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12904. * @param epsilon Offset used to render the particles
  12905. */
  12906. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12907. private _addFactorGradient;
  12908. private _removeFactorGradient;
  12909. /**
  12910. * Adds a new life time gradient
  12911. * @param gradient defines the gradient to use (between 0 and 1)
  12912. * @param factor defines the life time factor to affect to the specified gradient
  12913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12914. * @returns the current particle system
  12915. */
  12916. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12917. /**
  12918. * Remove a specific life time gradient
  12919. * @param gradient defines the gradient to remove
  12920. * @returns the current particle system
  12921. */
  12922. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12923. /**
  12924. * Adds a new size gradient
  12925. * @param gradient defines the gradient to use (between 0 and 1)
  12926. * @param factor defines the size factor to affect to the specified gradient
  12927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12928. * @returns the current particle system
  12929. */
  12930. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12931. /**
  12932. * Remove a specific size gradient
  12933. * @param gradient defines the gradient to remove
  12934. * @returns the current particle system
  12935. */
  12936. removeSizeGradient(gradient: number): IParticleSystem;
  12937. /**
  12938. * Adds a new color remap gradient
  12939. * @param gradient defines the gradient to use (between 0 and 1)
  12940. * @param min defines the color remap minimal range
  12941. * @param max defines the color remap maximal range
  12942. * @returns the current particle system
  12943. */
  12944. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12945. /**
  12946. * Remove a specific color remap gradient
  12947. * @param gradient defines the gradient to remove
  12948. * @returns the current particle system
  12949. */
  12950. removeColorRemapGradient(gradient: number): IParticleSystem;
  12951. /**
  12952. * Adds a new alpha remap gradient
  12953. * @param gradient defines the gradient to use (between 0 and 1)
  12954. * @param min defines the alpha remap minimal range
  12955. * @param max defines the alpha remap maximal range
  12956. * @returns the current particle system
  12957. */
  12958. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12959. /**
  12960. * Remove a specific alpha remap gradient
  12961. * @param gradient defines the gradient to remove
  12962. * @returns the current particle system
  12963. */
  12964. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12965. /**
  12966. * Adds a new angular speed gradient
  12967. * @param gradient defines the gradient to use (between 0 and 1)
  12968. * @param factor defines the angular speed to affect to the specified gradient
  12969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12970. * @returns the current particle system
  12971. */
  12972. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12973. /**
  12974. * Remove a specific angular speed gradient
  12975. * @param gradient defines the gradient to remove
  12976. * @returns the current particle system
  12977. */
  12978. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12979. /**
  12980. * Adds a new velocity gradient
  12981. * @param gradient defines the gradient to use (between 0 and 1)
  12982. * @param factor defines the velocity to affect to the specified gradient
  12983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12984. * @returns the current particle system
  12985. */
  12986. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12987. /**
  12988. * Remove a specific velocity gradient
  12989. * @param gradient defines the gradient to remove
  12990. * @returns the current particle system
  12991. */
  12992. removeVelocityGradient(gradient: number): IParticleSystem;
  12993. /**
  12994. * Adds a new limit velocity gradient
  12995. * @param gradient defines the gradient to use (between 0 and 1)
  12996. * @param factor defines the limit velocity value to affect to the specified gradient
  12997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12998. * @returns the current particle system
  12999. */
  13000. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13001. /**
  13002. * Remove a specific limit velocity gradient
  13003. * @param gradient defines the gradient to remove
  13004. * @returns the current particle system
  13005. */
  13006. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13007. /**
  13008. * Adds a new drag gradient
  13009. * @param gradient defines the gradient to use (between 0 and 1)
  13010. * @param factor defines the drag value to affect to the specified gradient
  13011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13012. * @returns the current particle system
  13013. */
  13014. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13015. /**
  13016. * Remove a specific drag gradient
  13017. * @param gradient defines the gradient to remove
  13018. * @returns the current particle system
  13019. */
  13020. removeDragGradient(gradient: number): IParticleSystem;
  13021. /**
  13022. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13023. * @param gradient defines the gradient to use (between 0 and 1)
  13024. * @param factor defines the emit rate value to affect to the specified gradient
  13025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13026. * @returns the current particle system
  13027. */
  13028. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13029. /**
  13030. * Remove a specific emit rate gradient
  13031. * @param gradient defines the gradient to remove
  13032. * @returns the current particle system
  13033. */
  13034. removeEmitRateGradient(gradient: number): IParticleSystem;
  13035. /**
  13036. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13037. * @param gradient defines the gradient to use (between 0 and 1)
  13038. * @param factor defines the start size value to affect to the specified gradient
  13039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13040. * @returns the current particle system
  13041. */
  13042. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13043. /**
  13044. * Remove a specific start size gradient
  13045. * @param gradient defines the gradient to remove
  13046. * @returns the current particle system
  13047. */
  13048. removeStartSizeGradient(gradient: number): IParticleSystem;
  13049. private _createRampGradientTexture;
  13050. /**
  13051. * Gets the current list of ramp gradients.
  13052. * You must use addRampGradient and removeRampGradient to udpate this list
  13053. * @returns the list of ramp gradients
  13054. */
  13055. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13056. /** Force the system to rebuild all gradients that need to be resync */
  13057. forceRefreshGradients(): void;
  13058. private _syncRampGradientTexture;
  13059. /**
  13060. * Adds a new ramp gradient used to remap particle colors
  13061. * @param gradient defines the gradient to use (between 0 and 1)
  13062. * @param color defines the color to affect to the specified gradient
  13063. * @returns the current particle system
  13064. */
  13065. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13066. /**
  13067. * Remove a specific ramp gradient
  13068. * @param gradient defines the gradient to remove
  13069. * @returns the current particle system
  13070. */
  13071. removeRampGradient(gradient: number): ParticleSystem;
  13072. /**
  13073. * Adds a new color gradient
  13074. * @param gradient defines the gradient to use (between 0 and 1)
  13075. * @param color1 defines the color to affect to the specified gradient
  13076. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13077. * @returns this particle system
  13078. */
  13079. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13080. /**
  13081. * Remove a specific color gradient
  13082. * @param gradient defines the gradient to remove
  13083. * @returns this particle system
  13084. */
  13085. removeColorGradient(gradient: number): IParticleSystem;
  13086. private _fetchR;
  13087. protected _reset(): void;
  13088. private _resetEffect;
  13089. private _createVertexBuffers;
  13090. private _createIndexBuffer;
  13091. /**
  13092. * Gets the maximum number of particles active at the same time.
  13093. * @returns The max number of active particles.
  13094. */
  13095. getCapacity(): number;
  13096. /**
  13097. * Gets whether there are still active particles in the system.
  13098. * @returns True if it is alive, otherwise false.
  13099. */
  13100. isAlive(): boolean;
  13101. /**
  13102. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13103. * @returns True if it has been started, otherwise false.
  13104. */
  13105. isStarted(): boolean;
  13106. private _prepareSubEmitterInternalArray;
  13107. /**
  13108. * Starts the particle system and begins to emit
  13109. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13110. */
  13111. start(delay?: number): void;
  13112. /**
  13113. * Stops the particle system.
  13114. * @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.
  13115. */
  13116. stop(stopSubEmitters?: boolean): void;
  13117. /**
  13118. * Remove all active particles
  13119. */
  13120. reset(): void;
  13121. /**
  13122. * @hidden (for internal use only)
  13123. */
  13124. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13125. /**
  13126. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13127. * Its lifetime will start back at 0.
  13128. */
  13129. recycleParticle: (particle: Particle) => void;
  13130. private _stopSubEmitters;
  13131. private _createParticle;
  13132. private _removeFromRoot;
  13133. private _emitFromParticle;
  13134. private _update;
  13135. /** @hidden */
  13136. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13137. /** @hidden */
  13138. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13139. /**
  13140. * Fill the defines array according to the current settings of the particle system
  13141. * @param defines Array to be updated
  13142. * @param blendMode blend mode to take into account when updating the array
  13143. */
  13144. fillDefines(defines: Array<string>, blendMode: number): void;
  13145. /**
  13146. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13147. * @param uniforms Uniforms array to fill
  13148. * @param attributes Attributes array to fill
  13149. * @param samplers Samplers array to fill
  13150. */
  13151. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13152. /** @hidden */
  13153. private _getEffect;
  13154. /**
  13155. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13156. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13157. */
  13158. animate(preWarmOnly?: boolean): void;
  13159. private _appendParticleVertices;
  13160. /**
  13161. * Rebuilds the particle system.
  13162. */
  13163. rebuild(): void;
  13164. /**
  13165. * Is this system ready to be used/rendered
  13166. * @return true if the system is ready
  13167. */
  13168. isReady(): boolean;
  13169. private _render;
  13170. /**
  13171. * Renders the particle system in its current state.
  13172. * @returns the current number of particles
  13173. */
  13174. render(): number;
  13175. /**
  13176. * Disposes the particle system and free the associated resources
  13177. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13178. */
  13179. dispose(disposeTexture?: boolean): void;
  13180. /**
  13181. * Clones the particle system.
  13182. * @param name The name of the cloned object
  13183. * @param newEmitter The new emitter to use
  13184. * @returns the cloned particle system
  13185. */
  13186. clone(name: string, newEmitter: any): ParticleSystem;
  13187. /**
  13188. * Serializes the particle system to a JSON object
  13189. * @param serializeTexture defines if the texture must be serialized as well
  13190. * @returns the JSON object
  13191. */
  13192. serialize(serializeTexture?: boolean): any;
  13193. /** @hidden */
  13194. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13195. /** @hidden */
  13196. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13197. /**
  13198. * Parses a JSON object to create a particle system.
  13199. * @param parsedParticleSystem The JSON object to parse
  13200. * @param scene The scene to create the particle system in
  13201. * @param rootUrl The root url to use to load external dependencies like texture
  13202. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13203. * @returns the Parsed particle system
  13204. */
  13205. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13206. }
  13207. }
  13208. declare module "babylonjs/Particles/particle" {
  13209. import { Nullable } from "babylonjs/types";
  13210. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13211. import { Color4 } from "babylonjs/Maths/math.color";
  13212. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13213. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13214. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13215. /**
  13216. * A particle represents one of the element emitted by a particle system.
  13217. * This is mainly define by its coordinates, direction, velocity and age.
  13218. */
  13219. export class Particle {
  13220. /**
  13221. * The particle system the particle belongs to.
  13222. */
  13223. particleSystem: ParticleSystem;
  13224. private static _Count;
  13225. /**
  13226. * Unique ID of the particle
  13227. */
  13228. id: number;
  13229. /**
  13230. * The world position of the particle in the scene.
  13231. */
  13232. position: Vector3;
  13233. /**
  13234. * The world direction of the particle in the scene.
  13235. */
  13236. direction: Vector3;
  13237. /**
  13238. * The color of the particle.
  13239. */
  13240. color: Color4;
  13241. /**
  13242. * The color change of the particle per step.
  13243. */
  13244. colorStep: Color4;
  13245. /**
  13246. * Defines how long will the life of the particle be.
  13247. */
  13248. lifeTime: number;
  13249. /**
  13250. * The current age of the particle.
  13251. */
  13252. age: number;
  13253. /**
  13254. * The current size of the particle.
  13255. */
  13256. size: number;
  13257. /**
  13258. * The current scale of the particle.
  13259. */
  13260. scale: Vector2;
  13261. /**
  13262. * The current angle of the particle.
  13263. */
  13264. angle: number;
  13265. /**
  13266. * Defines how fast is the angle changing.
  13267. */
  13268. angularSpeed: number;
  13269. /**
  13270. * Defines the cell index used by the particle to be rendered from a sprite.
  13271. */
  13272. cellIndex: number;
  13273. /**
  13274. * The information required to support color remapping
  13275. */
  13276. remapData: Vector4;
  13277. /** @hidden */
  13278. _randomCellOffset?: number;
  13279. /** @hidden */
  13280. _initialDirection: Nullable<Vector3>;
  13281. /** @hidden */
  13282. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13283. /** @hidden */
  13284. _initialStartSpriteCellID: number;
  13285. /** @hidden */
  13286. _initialEndSpriteCellID: number;
  13287. /** @hidden */
  13288. _currentColorGradient: Nullable<ColorGradient>;
  13289. /** @hidden */
  13290. _currentColor1: Color4;
  13291. /** @hidden */
  13292. _currentColor2: Color4;
  13293. /** @hidden */
  13294. _currentSizeGradient: Nullable<FactorGradient>;
  13295. /** @hidden */
  13296. _currentSize1: number;
  13297. /** @hidden */
  13298. _currentSize2: number;
  13299. /** @hidden */
  13300. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13301. /** @hidden */
  13302. _currentAngularSpeed1: number;
  13303. /** @hidden */
  13304. _currentAngularSpeed2: number;
  13305. /** @hidden */
  13306. _currentVelocityGradient: Nullable<FactorGradient>;
  13307. /** @hidden */
  13308. _currentVelocity1: number;
  13309. /** @hidden */
  13310. _currentVelocity2: number;
  13311. /** @hidden */
  13312. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13313. /** @hidden */
  13314. _currentLimitVelocity1: number;
  13315. /** @hidden */
  13316. _currentLimitVelocity2: number;
  13317. /** @hidden */
  13318. _currentDragGradient: Nullable<FactorGradient>;
  13319. /** @hidden */
  13320. _currentDrag1: number;
  13321. /** @hidden */
  13322. _currentDrag2: number;
  13323. /** @hidden */
  13324. _randomNoiseCoordinates1: Vector3;
  13325. /** @hidden */
  13326. _randomNoiseCoordinates2: Vector3;
  13327. /** @hidden */
  13328. _localPosition?: Vector3;
  13329. /**
  13330. * Creates a new instance Particle
  13331. * @param particleSystem the particle system the particle belongs to
  13332. */
  13333. constructor(
  13334. /**
  13335. * The particle system the particle belongs to.
  13336. */
  13337. particleSystem: ParticleSystem);
  13338. private updateCellInfoFromSystem;
  13339. /**
  13340. * Defines how the sprite cell index is updated for the particle
  13341. */
  13342. updateCellIndex(): void;
  13343. /** @hidden */
  13344. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13345. /** @hidden */
  13346. _inheritParticleInfoToSubEmitters(): void;
  13347. /** @hidden */
  13348. _reset(): void;
  13349. /**
  13350. * Copy the properties of particle to another one.
  13351. * @param other the particle to copy the information to.
  13352. */
  13353. copyTo(other: Particle): void;
  13354. }
  13355. }
  13356. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13357. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13358. import { Effect } from "babylonjs/Materials/effect";
  13359. import { Particle } from "babylonjs/Particles/particle";
  13360. import { Scene } from "babylonjs/scene";
  13361. /**
  13362. * Particle emitter represents a volume emitting particles.
  13363. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13364. */
  13365. export interface IParticleEmitterType {
  13366. /**
  13367. * Called by the particle System when the direction is computed for the created particle.
  13368. * @param worldMatrix is the world matrix of the particle system
  13369. * @param directionToUpdate is the direction vector to update with the result
  13370. * @param particle is the particle we are computed the direction for
  13371. * @param isLocal defines if the direction should be set in local space
  13372. */
  13373. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13374. /**
  13375. * Called by the particle System when the position is computed for the created particle.
  13376. * @param worldMatrix is the world matrix of the particle system
  13377. * @param positionToUpdate is the position vector to update with the result
  13378. * @param particle is the particle we are computed the position for
  13379. * @param isLocal defines if the position should be set in local space
  13380. */
  13381. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13382. /**
  13383. * Clones the current emitter and returns a copy of it
  13384. * @returns the new emitter
  13385. */
  13386. clone(): IParticleEmitterType;
  13387. /**
  13388. * Called by the GPUParticleSystem to setup the update shader
  13389. * @param effect defines the update shader
  13390. */
  13391. applyToShader(effect: Effect): void;
  13392. /**
  13393. * Returns a string to use to update the GPU particles update shader
  13394. * @returns the effect defines string
  13395. */
  13396. getEffectDefines(): string;
  13397. /**
  13398. * Returns a string representing the class name
  13399. * @returns a string containing the class name
  13400. */
  13401. getClassName(): string;
  13402. /**
  13403. * Serializes the particle system to a JSON object.
  13404. * @returns the JSON object
  13405. */
  13406. serialize(): any;
  13407. /**
  13408. * Parse properties from a JSON object
  13409. * @param serializationObject defines the JSON object
  13410. * @param scene defines the hosting scene
  13411. */
  13412. parse(serializationObject: any, scene: Scene): void;
  13413. }
  13414. }
  13415. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13416. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13417. import { Effect } from "babylonjs/Materials/effect";
  13418. import { Particle } from "babylonjs/Particles/particle";
  13419. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13420. /**
  13421. * Particle emitter emitting particles from the inside of a box.
  13422. * It emits the particles randomly between 2 given directions.
  13423. */
  13424. export class BoxParticleEmitter implements IParticleEmitterType {
  13425. /**
  13426. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13427. */
  13428. direction1: Vector3;
  13429. /**
  13430. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13431. */
  13432. direction2: Vector3;
  13433. /**
  13434. * 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.
  13435. */
  13436. minEmitBox: Vector3;
  13437. /**
  13438. * 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.
  13439. */
  13440. maxEmitBox: Vector3;
  13441. /**
  13442. * Creates a new instance BoxParticleEmitter
  13443. */
  13444. constructor();
  13445. /**
  13446. * Called by the particle System when the direction is computed for the created particle.
  13447. * @param worldMatrix is the world matrix of the particle system
  13448. * @param directionToUpdate is the direction vector to update with the result
  13449. * @param particle is the particle we are computed the direction for
  13450. * @param isLocal defines if the direction should be set in local space
  13451. */
  13452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13453. /**
  13454. * Called by the particle System when the position is computed for the created particle.
  13455. * @param worldMatrix is the world matrix of the particle system
  13456. * @param positionToUpdate is the position vector to update with the result
  13457. * @param particle is the particle we are computed the position for
  13458. * @param isLocal defines if the position should be set in local space
  13459. */
  13460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13461. /**
  13462. * Clones the current emitter and returns a copy of it
  13463. * @returns the new emitter
  13464. */
  13465. clone(): BoxParticleEmitter;
  13466. /**
  13467. * Called by the GPUParticleSystem to setup the update shader
  13468. * @param effect defines the update shader
  13469. */
  13470. applyToShader(effect: Effect): void;
  13471. /**
  13472. * Returns a string to use to update the GPU particles update shader
  13473. * @returns a string containng the defines string
  13474. */
  13475. getEffectDefines(): string;
  13476. /**
  13477. * Returns the string "BoxParticleEmitter"
  13478. * @returns a string containing the class name
  13479. */
  13480. getClassName(): string;
  13481. /**
  13482. * Serializes the particle system to a JSON object.
  13483. * @returns the JSON object
  13484. */
  13485. serialize(): any;
  13486. /**
  13487. * Parse properties from a JSON object
  13488. * @param serializationObject defines the JSON object
  13489. */
  13490. parse(serializationObject: any): void;
  13491. }
  13492. }
  13493. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13494. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13495. import { Effect } from "babylonjs/Materials/effect";
  13496. import { Particle } from "babylonjs/Particles/particle";
  13497. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13498. /**
  13499. * Particle emitter emitting particles from the inside of a cone.
  13500. * It emits the particles alongside the cone volume from the base to the particle.
  13501. * The emission direction might be randomized.
  13502. */
  13503. export class ConeParticleEmitter implements IParticleEmitterType {
  13504. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13505. directionRandomizer: number;
  13506. private _radius;
  13507. private _angle;
  13508. private _height;
  13509. /**
  13510. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13511. */
  13512. radiusRange: number;
  13513. /**
  13514. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13515. */
  13516. heightRange: number;
  13517. /**
  13518. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13519. */
  13520. emitFromSpawnPointOnly: boolean;
  13521. /**
  13522. * Gets or sets the radius of the emission cone
  13523. */
  13524. get radius(): number;
  13525. set radius(value: number);
  13526. /**
  13527. * Gets or sets the angle of the emission cone
  13528. */
  13529. get angle(): number;
  13530. set angle(value: number);
  13531. private _buildHeight;
  13532. /**
  13533. * Creates a new instance ConeParticleEmitter
  13534. * @param radius the radius of the emission cone (1 by default)
  13535. * @param angle the cone base angle (PI by default)
  13536. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13537. */
  13538. constructor(radius?: number, angle?: number,
  13539. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13540. directionRandomizer?: number);
  13541. /**
  13542. * Called by the particle System when the direction is computed for the created particle.
  13543. * @param worldMatrix is the world matrix of the particle system
  13544. * @param directionToUpdate is the direction vector to update with the result
  13545. * @param particle is the particle we are computed the direction for
  13546. * @param isLocal defines if the direction should be set in local space
  13547. */
  13548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13549. /**
  13550. * Called by the particle System when the position is computed for the created particle.
  13551. * @param worldMatrix is the world matrix of the particle system
  13552. * @param positionToUpdate is the position vector to update with the result
  13553. * @param particle is the particle we are computed the position for
  13554. * @param isLocal defines if the position should be set in local space
  13555. */
  13556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13557. /**
  13558. * Clones the current emitter and returns a copy of it
  13559. * @returns the new emitter
  13560. */
  13561. clone(): ConeParticleEmitter;
  13562. /**
  13563. * Called by the GPUParticleSystem to setup the update shader
  13564. * @param effect defines the update shader
  13565. */
  13566. applyToShader(effect: Effect): void;
  13567. /**
  13568. * Returns a string to use to update the GPU particles update shader
  13569. * @returns a string containng the defines string
  13570. */
  13571. getEffectDefines(): string;
  13572. /**
  13573. * Returns the string "ConeParticleEmitter"
  13574. * @returns a string containing the class name
  13575. */
  13576. getClassName(): string;
  13577. /**
  13578. * Serializes the particle system to a JSON object.
  13579. * @returns the JSON object
  13580. */
  13581. serialize(): any;
  13582. /**
  13583. * Parse properties from a JSON object
  13584. * @param serializationObject defines the JSON object
  13585. */
  13586. parse(serializationObject: any): void;
  13587. }
  13588. }
  13589. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13590. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13591. import { Effect } from "babylonjs/Materials/effect";
  13592. import { Particle } from "babylonjs/Particles/particle";
  13593. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13594. /**
  13595. * Particle emitter emitting particles from the inside of a cylinder.
  13596. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13597. */
  13598. export class CylinderParticleEmitter implements IParticleEmitterType {
  13599. /**
  13600. * The radius of the emission cylinder.
  13601. */
  13602. radius: number;
  13603. /**
  13604. * The height of the emission cylinder.
  13605. */
  13606. height: number;
  13607. /**
  13608. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13609. */
  13610. radiusRange: number;
  13611. /**
  13612. * How much to randomize the particle direction [0-1].
  13613. */
  13614. directionRandomizer: number;
  13615. /**
  13616. * Creates a new instance CylinderParticleEmitter
  13617. * @param radius the radius of the emission cylinder (1 by default)
  13618. * @param height the height of the emission cylinder (1 by default)
  13619. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13620. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13621. */
  13622. constructor(
  13623. /**
  13624. * The radius of the emission cylinder.
  13625. */
  13626. radius?: number,
  13627. /**
  13628. * The height of the emission cylinder.
  13629. */
  13630. height?: number,
  13631. /**
  13632. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13633. */
  13634. radiusRange?: number,
  13635. /**
  13636. * How much to randomize the particle direction [0-1].
  13637. */
  13638. directionRandomizer?: number);
  13639. /**
  13640. * Called by the particle System when the direction is computed for the created particle.
  13641. * @param worldMatrix is the world matrix of the particle system
  13642. * @param directionToUpdate is the direction vector to update with the result
  13643. * @param particle is the particle we are computed the direction for
  13644. * @param isLocal defines if the direction should be set in local space
  13645. */
  13646. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13647. /**
  13648. * Called by the particle System when the position is computed for the created particle.
  13649. * @param worldMatrix is the world matrix of the particle system
  13650. * @param positionToUpdate is the position vector to update with the result
  13651. * @param particle is the particle we are computed the position for
  13652. * @param isLocal defines if the position should be set in local space
  13653. */
  13654. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13655. /**
  13656. * Clones the current emitter and returns a copy of it
  13657. * @returns the new emitter
  13658. */
  13659. clone(): CylinderParticleEmitter;
  13660. /**
  13661. * Called by the GPUParticleSystem to setup the update shader
  13662. * @param effect defines the update shader
  13663. */
  13664. applyToShader(effect: Effect): void;
  13665. /**
  13666. * Returns a string to use to update the GPU particles update shader
  13667. * @returns a string containng the defines string
  13668. */
  13669. getEffectDefines(): string;
  13670. /**
  13671. * Returns the string "CylinderParticleEmitter"
  13672. * @returns a string containing the class name
  13673. */
  13674. getClassName(): string;
  13675. /**
  13676. * Serializes the particle system to a JSON object.
  13677. * @returns the JSON object
  13678. */
  13679. serialize(): any;
  13680. /**
  13681. * Parse properties from a JSON object
  13682. * @param serializationObject defines the JSON object
  13683. */
  13684. parse(serializationObject: any): void;
  13685. }
  13686. /**
  13687. * Particle emitter emitting particles from the inside of a cylinder.
  13688. * It emits the particles randomly between two vectors.
  13689. */
  13690. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13691. /**
  13692. * The min limit of the emission direction.
  13693. */
  13694. direction1: Vector3;
  13695. /**
  13696. * The max limit of the emission direction.
  13697. */
  13698. direction2: Vector3;
  13699. /**
  13700. * Creates a new instance CylinderDirectedParticleEmitter
  13701. * @param radius the radius of the emission cylinder (1 by default)
  13702. * @param height the height of the emission cylinder (1 by default)
  13703. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13704. * @param direction1 the min limit of the emission direction (up vector by default)
  13705. * @param direction2 the max limit of the emission direction (up vector by default)
  13706. */
  13707. constructor(radius?: number, height?: number, radiusRange?: number,
  13708. /**
  13709. * The min limit of the emission direction.
  13710. */
  13711. direction1?: Vector3,
  13712. /**
  13713. * The max limit of the emission direction.
  13714. */
  13715. direction2?: Vector3);
  13716. /**
  13717. * Called by the particle System when the direction is computed for the created particle.
  13718. * @param worldMatrix is the world matrix of the particle system
  13719. * @param directionToUpdate is the direction vector to update with the result
  13720. * @param particle is the particle we are computed the direction for
  13721. */
  13722. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13723. /**
  13724. * Clones the current emitter and returns a copy of it
  13725. * @returns the new emitter
  13726. */
  13727. clone(): CylinderDirectedParticleEmitter;
  13728. /**
  13729. * Called by the GPUParticleSystem to setup the update shader
  13730. * @param effect defines the update shader
  13731. */
  13732. applyToShader(effect: Effect): void;
  13733. /**
  13734. * Returns a string to use to update the GPU particles update shader
  13735. * @returns a string containng the defines string
  13736. */
  13737. getEffectDefines(): string;
  13738. /**
  13739. * Returns the string "CylinderDirectedParticleEmitter"
  13740. * @returns a string containing the class name
  13741. */
  13742. getClassName(): string;
  13743. /**
  13744. * Serializes the particle system to a JSON object.
  13745. * @returns the JSON object
  13746. */
  13747. serialize(): any;
  13748. /**
  13749. * Parse properties from a JSON object
  13750. * @param serializationObject defines the JSON object
  13751. */
  13752. parse(serializationObject: any): void;
  13753. }
  13754. }
  13755. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13756. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13757. import { Effect } from "babylonjs/Materials/effect";
  13758. import { Particle } from "babylonjs/Particles/particle";
  13759. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13760. /**
  13761. * Particle emitter emitting particles from the inside of a hemisphere.
  13762. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13763. */
  13764. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13765. /**
  13766. * The radius of the emission hemisphere.
  13767. */
  13768. radius: number;
  13769. /**
  13770. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13771. */
  13772. radiusRange: number;
  13773. /**
  13774. * How much to randomize the particle direction [0-1].
  13775. */
  13776. directionRandomizer: number;
  13777. /**
  13778. * Creates a new instance HemisphericParticleEmitter
  13779. * @param radius the radius of the emission hemisphere (1 by default)
  13780. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13781. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13782. */
  13783. constructor(
  13784. /**
  13785. * The radius of the emission hemisphere.
  13786. */
  13787. radius?: number,
  13788. /**
  13789. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13790. */
  13791. radiusRange?: number,
  13792. /**
  13793. * How much to randomize the particle direction [0-1].
  13794. */
  13795. directionRandomizer?: number);
  13796. /**
  13797. * Called by the particle System when the direction is computed for the created particle.
  13798. * @param worldMatrix is the world matrix of the particle system
  13799. * @param directionToUpdate is the direction vector to update with the result
  13800. * @param particle is the particle we are computed the direction for
  13801. * @param isLocal defines if the direction should be set in local space
  13802. */
  13803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13804. /**
  13805. * Called by the particle System when the position is computed for the created particle.
  13806. * @param worldMatrix is the world matrix of the particle system
  13807. * @param positionToUpdate is the position vector to update with the result
  13808. * @param particle is the particle we are computed the position for
  13809. * @param isLocal defines if the position should be set in local space
  13810. */
  13811. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13812. /**
  13813. * Clones the current emitter and returns a copy of it
  13814. * @returns the new emitter
  13815. */
  13816. clone(): HemisphericParticleEmitter;
  13817. /**
  13818. * Called by the GPUParticleSystem to setup the update shader
  13819. * @param effect defines the update shader
  13820. */
  13821. applyToShader(effect: Effect): void;
  13822. /**
  13823. * Returns a string to use to update the GPU particles update shader
  13824. * @returns a string containng the defines string
  13825. */
  13826. getEffectDefines(): string;
  13827. /**
  13828. * Returns the string "HemisphericParticleEmitter"
  13829. * @returns a string containing the class name
  13830. */
  13831. getClassName(): string;
  13832. /**
  13833. * Serializes the particle system to a JSON object.
  13834. * @returns the JSON object
  13835. */
  13836. serialize(): any;
  13837. /**
  13838. * Parse properties from a JSON object
  13839. * @param serializationObject defines the JSON object
  13840. */
  13841. parse(serializationObject: any): void;
  13842. }
  13843. }
  13844. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13845. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13846. import { Effect } from "babylonjs/Materials/effect";
  13847. import { Particle } from "babylonjs/Particles/particle";
  13848. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13849. /**
  13850. * Particle emitter emitting particles from a point.
  13851. * It emits the particles randomly between 2 given directions.
  13852. */
  13853. export class PointParticleEmitter implements IParticleEmitterType {
  13854. /**
  13855. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13856. */
  13857. direction1: Vector3;
  13858. /**
  13859. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13860. */
  13861. direction2: Vector3;
  13862. /**
  13863. * Creates a new instance PointParticleEmitter
  13864. */
  13865. constructor();
  13866. /**
  13867. * Called by the particle System when the direction is computed for the created particle.
  13868. * @param worldMatrix is the world matrix of the particle system
  13869. * @param directionToUpdate is the direction vector to update with the result
  13870. * @param particle is the particle we are computed the direction for
  13871. * @param isLocal defines if the direction should be set in local space
  13872. */
  13873. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13874. /**
  13875. * Called by the particle System when the position is computed for the created particle.
  13876. * @param worldMatrix is the world matrix of the particle system
  13877. * @param positionToUpdate is the position vector to update with the result
  13878. * @param particle is the particle we are computed the position for
  13879. * @param isLocal defines if the position should be set in local space
  13880. */
  13881. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13882. /**
  13883. * Clones the current emitter and returns a copy of it
  13884. * @returns the new emitter
  13885. */
  13886. clone(): PointParticleEmitter;
  13887. /**
  13888. * Called by the GPUParticleSystem to setup the update shader
  13889. * @param effect defines the update shader
  13890. */
  13891. applyToShader(effect: Effect): void;
  13892. /**
  13893. * Returns a string to use to update the GPU particles update shader
  13894. * @returns a string containng the defines string
  13895. */
  13896. getEffectDefines(): string;
  13897. /**
  13898. * Returns the string "PointParticleEmitter"
  13899. * @returns a string containing the class name
  13900. */
  13901. getClassName(): string;
  13902. /**
  13903. * Serializes the particle system to a JSON object.
  13904. * @returns the JSON object
  13905. */
  13906. serialize(): any;
  13907. /**
  13908. * Parse properties from a JSON object
  13909. * @param serializationObject defines the JSON object
  13910. */
  13911. parse(serializationObject: any): void;
  13912. }
  13913. }
  13914. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13915. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13916. import { Effect } from "babylonjs/Materials/effect";
  13917. import { Particle } from "babylonjs/Particles/particle";
  13918. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13919. /**
  13920. * Particle emitter emitting particles from the inside of a sphere.
  13921. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13922. */
  13923. export class SphereParticleEmitter implements IParticleEmitterType {
  13924. /**
  13925. * The radius of the emission sphere.
  13926. */
  13927. radius: number;
  13928. /**
  13929. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13930. */
  13931. radiusRange: number;
  13932. /**
  13933. * How much to randomize the particle direction [0-1].
  13934. */
  13935. directionRandomizer: number;
  13936. /**
  13937. * Creates a new instance SphereParticleEmitter
  13938. * @param radius the radius of the emission sphere (1 by default)
  13939. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13940. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13941. */
  13942. constructor(
  13943. /**
  13944. * The radius of the emission sphere.
  13945. */
  13946. radius?: number,
  13947. /**
  13948. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13949. */
  13950. radiusRange?: number,
  13951. /**
  13952. * How much to randomize the particle direction [0-1].
  13953. */
  13954. directionRandomizer?: number);
  13955. /**
  13956. * Called by the particle System when the direction is computed for the created particle.
  13957. * @param worldMatrix is the world matrix of the particle system
  13958. * @param directionToUpdate is the direction vector to update with the result
  13959. * @param particle is the particle we are computed the direction for
  13960. * @param isLocal defines if the direction should be set in local space
  13961. */
  13962. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13963. /**
  13964. * Called by the particle System when the position is computed for the created particle.
  13965. * @param worldMatrix is the world matrix of the particle system
  13966. * @param positionToUpdate is the position vector to update with the result
  13967. * @param particle is the particle we are computed the position for
  13968. * @param isLocal defines if the position should be set in local space
  13969. */
  13970. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13971. /**
  13972. * Clones the current emitter and returns a copy of it
  13973. * @returns the new emitter
  13974. */
  13975. clone(): SphereParticleEmitter;
  13976. /**
  13977. * Called by the GPUParticleSystem to setup the update shader
  13978. * @param effect defines the update shader
  13979. */
  13980. applyToShader(effect: Effect): void;
  13981. /**
  13982. * Returns a string to use to update the GPU particles update shader
  13983. * @returns a string containng the defines string
  13984. */
  13985. getEffectDefines(): string;
  13986. /**
  13987. * Returns the string "SphereParticleEmitter"
  13988. * @returns a string containing the class name
  13989. */
  13990. getClassName(): string;
  13991. /**
  13992. * Serializes the particle system to a JSON object.
  13993. * @returns the JSON object
  13994. */
  13995. serialize(): any;
  13996. /**
  13997. * Parse properties from a JSON object
  13998. * @param serializationObject defines the JSON object
  13999. */
  14000. parse(serializationObject: any): void;
  14001. }
  14002. /**
  14003. * Particle emitter emitting particles from the inside of a sphere.
  14004. * It emits the particles randomly between two vectors.
  14005. */
  14006. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14007. /**
  14008. * The min limit of the emission direction.
  14009. */
  14010. direction1: Vector3;
  14011. /**
  14012. * The max limit of the emission direction.
  14013. */
  14014. direction2: Vector3;
  14015. /**
  14016. * Creates a new instance SphereDirectedParticleEmitter
  14017. * @param radius the radius of the emission sphere (1 by default)
  14018. * @param direction1 the min limit of the emission direction (up vector by default)
  14019. * @param direction2 the max limit of the emission direction (up vector by default)
  14020. */
  14021. constructor(radius?: number,
  14022. /**
  14023. * The min limit of the emission direction.
  14024. */
  14025. direction1?: Vector3,
  14026. /**
  14027. * The max limit of the emission direction.
  14028. */
  14029. direction2?: Vector3);
  14030. /**
  14031. * Called by the particle System when the direction is computed for the created particle.
  14032. * @param worldMatrix is the world matrix of the particle system
  14033. * @param directionToUpdate is the direction vector to update with the result
  14034. * @param particle is the particle we are computed the direction for
  14035. */
  14036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14037. /**
  14038. * Clones the current emitter and returns a copy of it
  14039. * @returns the new emitter
  14040. */
  14041. clone(): SphereDirectedParticleEmitter;
  14042. /**
  14043. * Called by the GPUParticleSystem to setup the update shader
  14044. * @param effect defines the update shader
  14045. */
  14046. applyToShader(effect: Effect): void;
  14047. /**
  14048. * Returns a string to use to update the GPU particles update shader
  14049. * @returns a string containng the defines string
  14050. */
  14051. getEffectDefines(): string;
  14052. /**
  14053. * Returns the string "SphereDirectedParticleEmitter"
  14054. * @returns a string containing the class name
  14055. */
  14056. getClassName(): string;
  14057. /**
  14058. * Serializes the particle system to a JSON object.
  14059. * @returns the JSON object
  14060. */
  14061. serialize(): any;
  14062. /**
  14063. * Parse properties from a JSON object
  14064. * @param serializationObject defines the JSON object
  14065. */
  14066. parse(serializationObject: any): void;
  14067. }
  14068. }
  14069. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14070. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14071. import { Effect } from "babylonjs/Materials/effect";
  14072. import { Particle } from "babylonjs/Particles/particle";
  14073. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14074. import { Nullable } from "babylonjs/types";
  14075. /**
  14076. * Particle emitter emitting particles from a custom list of positions.
  14077. */
  14078. export class CustomParticleEmitter implements IParticleEmitterType {
  14079. /**
  14080. * Gets or sets the position generator that will create the inital position of each particle.
  14081. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14082. */
  14083. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14084. /**
  14085. * Gets or sets the destination generator that will create the final destination of each particle.
  14086. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14087. */
  14088. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14089. /**
  14090. * Creates a new instance CustomParticleEmitter
  14091. */
  14092. constructor();
  14093. /**
  14094. * Called by the particle System when the direction is computed for the created particle.
  14095. * @param worldMatrix is the world matrix of the particle system
  14096. * @param directionToUpdate is the direction vector to update with the result
  14097. * @param particle is the particle we are computed the direction for
  14098. * @param isLocal defines if the direction should be set in local space
  14099. */
  14100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14101. /**
  14102. * Called by the particle System when the position is computed for the created particle.
  14103. * @param worldMatrix is the world matrix of the particle system
  14104. * @param positionToUpdate is the position vector to update with the result
  14105. * @param particle is the particle we are computed the position for
  14106. * @param isLocal defines if the position should be set in local space
  14107. */
  14108. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14109. /**
  14110. * Clones the current emitter and returns a copy of it
  14111. * @returns the new emitter
  14112. */
  14113. clone(): CustomParticleEmitter;
  14114. /**
  14115. * Called by the GPUParticleSystem to setup the update shader
  14116. * @param effect defines the update shader
  14117. */
  14118. applyToShader(effect: Effect): void;
  14119. /**
  14120. * Returns a string to use to update the GPU particles update shader
  14121. * @returns a string containng the defines string
  14122. */
  14123. getEffectDefines(): string;
  14124. /**
  14125. * Returns the string "PointParticleEmitter"
  14126. * @returns a string containing the class name
  14127. */
  14128. getClassName(): string;
  14129. /**
  14130. * Serializes the particle system to a JSON object.
  14131. * @returns the JSON object
  14132. */
  14133. serialize(): any;
  14134. /**
  14135. * Parse properties from a JSON object
  14136. * @param serializationObject defines the JSON object
  14137. */
  14138. parse(serializationObject: any): void;
  14139. }
  14140. }
  14141. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14142. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14143. import { Effect } from "babylonjs/Materials/effect";
  14144. import { Particle } from "babylonjs/Particles/particle";
  14145. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14146. import { Nullable } from "babylonjs/types";
  14147. import { Scene } from "babylonjs/scene";
  14148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14149. /**
  14150. * Particle emitter emitting particles from the inside of a box.
  14151. * It emits the particles randomly between 2 given directions.
  14152. */
  14153. export class MeshParticleEmitter implements IParticleEmitterType {
  14154. private _indices;
  14155. private _positions;
  14156. private _normals;
  14157. private _storedNormal;
  14158. private _mesh;
  14159. /**
  14160. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14161. */
  14162. direction1: Vector3;
  14163. /**
  14164. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14165. */
  14166. direction2: Vector3;
  14167. /**
  14168. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14169. */
  14170. useMeshNormalsForDirection: boolean;
  14171. /** Defines the mesh to use as source */
  14172. get mesh(): Nullable<AbstractMesh>;
  14173. set mesh(value: Nullable<AbstractMesh>);
  14174. /**
  14175. * Creates a new instance MeshParticleEmitter
  14176. * @param mesh defines the mesh to use as source
  14177. */
  14178. constructor(mesh?: Nullable<AbstractMesh>);
  14179. /**
  14180. * Called by the particle System when the direction is computed for the created particle.
  14181. * @param worldMatrix is the world matrix of the particle system
  14182. * @param directionToUpdate is the direction vector to update with the result
  14183. * @param particle is the particle we are computed the direction for
  14184. * @param isLocal defines if the direction should be set in local space
  14185. */
  14186. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14187. /**
  14188. * Called by the particle System when the position is computed for the created particle.
  14189. * @param worldMatrix is the world matrix of the particle system
  14190. * @param positionToUpdate is the position vector to update with the result
  14191. * @param particle is the particle we are computed the position for
  14192. * @param isLocal defines if the position should be set in local space
  14193. */
  14194. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14195. /**
  14196. * Clones the current emitter and returns a copy of it
  14197. * @returns the new emitter
  14198. */
  14199. clone(): MeshParticleEmitter;
  14200. /**
  14201. * Called by the GPUParticleSystem to setup the update shader
  14202. * @param effect defines the update shader
  14203. */
  14204. applyToShader(effect: Effect): void;
  14205. /**
  14206. * Returns a string to use to update the GPU particles update shader
  14207. * @returns a string containng the defines string
  14208. */
  14209. getEffectDefines(): string;
  14210. /**
  14211. * Returns the string "BoxParticleEmitter"
  14212. * @returns a string containing the class name
  14213. */
  14214. getClassName(): string;
  14215. /**
  14216. * Serializes the particle system to a JSON object.
  14217. * @returns the JSON object
  14218. */
  14219. serialize(): any;
  14220. /**
  14221. * Parse properties from a JSON object
  14222. * @param serializationObject defines the JSON object
  14223. * @param scene defines the hosting scene
  14224. */
  14225. parse(serializationObject: any, scene: Scene): void;
  14226. }
  14227. }
  14228. declare module "babylonjs/Particles/EmitterTypes/index" {
  14229. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14230. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14231. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14232. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14233. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14234. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14235. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14236. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14237. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14238. }
  14239. declare module "babylonjs/Particles/IParticleSystem" {
  14240. import { Nullable } from "babylonjs/types";
  14241. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14242. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14244. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14245. import { Texture } from "babylonjs/Materials/Textures/texture";
  14246. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14247. import { Scene } from "babylonjs/scene";
  14248. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14249. import { Effect } from "babylonjs/Materials/effect";
  14250. import { Observable } from "babylonjs/Misc/observable";
  14251. import { Animation } from "babylonjs/Animations/animation";
  14252. /**
  14253. * Interface representing a particle system in Babylon.js.
  14254. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14255. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14256. */
  14257. export interface IParticleSystem {
  14258. /**
  14259. * List of animations used by the particle system.
  14260. */
  14261. animations: Animation[];
  14262. /**
  14263. * The id of the Particle system.
  14264. */
  14265. id: string;
  14266. /**
  14267. * The name of the Particle system.
  14268. */
  14269. name: string;
  14270. /**
  14271. * The emitter represents the Mesh or position we are attaching the particle system to.
  14272. */
  14273. emitter: Nullable<AbstractMesh | Vector3>;
  14274. /**
  14275. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14276. */
  14277. isBillboardBased: boolean;
  14278. /**
  14279. * The rendering group used by the Particle system to chose when to render.
  14280. */
  14281. renderingGroupId: number;
  14282. /**
  14283. * The layer mask we are rendering the particles through.
  14284. */
  14285. layerMask: number;
  14286. /**
  14287. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14288. */
  14289. updateSpeed: number;
  14290. /**
  14291. * The amount of time the particle system is running (depends of the overall update speed).
  14292. */
  14293. targetStopDuration: number;
  14294. /**
  14295. * The texture used to render each particle. (this can be a spritesheet)
  14296. */
  14297. particleTexture: Nullable<Texture>;
  14298. /**
  14299. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14300. */
  14301. blendMode: number;
  14302. /**
  14303. * Minimum life time of emitting particles.
  14304. */
  14305. minLifeTime: number;
  14306. /**
  14307. * Maximum life time of emitting particles.
  14308. */
  14309. maxLifeTime: number;
  14310. /**
  14311. * Minimum Size of emitting particles.
  14312. */
  14313. minSize: number;
  14314. /**
  14315. * Maximum Size of emitting particles.
  14316. */
  14317. maxSize: number;
  14318. /**
  14319. * Minimum scale of emitting particles on X axis.
  14320. */
  14321. minScaleX: number;
  14322. /**
  14323. * Maximum scale of emitting particles on X axis.
  14324. */
  14325. maxScaleX: number;
  14326. /**
  14327. * Minimum scale of emitting particles on Y axis.
  14328. */
  14329. minScaleY: number;
  14330. /**
  14331. * Maximum scale of emitting particles on Y axis.
  14332. */
  14333. maxScaleY: number;
  14334. /**
  14335. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14336. */
  14337. color1: Color4;
  14338. /**
  14339. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14340. */
  14341. color2: Color4;
  14342. /**
  14343. * Color the particle will have at the end of its lifetime.
  14344. */
  14345. colorDead: Color4;
  14346. /**
  14347. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14348. */
  14349. emitRate: number;
  14350. /**
  14351. * You can use gravity if you want to give an orientation to your particles.
  14352. */
  14353. gravity: Vector3;
  14354. /**
  14355. * Minimum power of emitting particles.
  14356. */
  14357. minEmitPower: number;
  14358. /**
  14359. * Maximum power of emitting particles.
  14360. */
  14361. maxEmitPower: number;
  14362. /**
  14363. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14364. */
  14365. minAngularSpeed: number;
  14366. /**
  14367. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14368. */
  14369. maxAngularSpeed: number;
  14370. /**
  14371. * Gets or sets the minimal initial rotation in radians.
  14372. */
  14373. minInitialRotation: number;
  14374. /**
  14375. * Gets or sets the maximal initial rotation in radians.
  14376. */
  14377. maxInitialRotation: number;
  14378. /**
  14379. * The particle emitter type defines the emitter used by the particle system.
  14380. * It can be for example box, sphere, or cone...
  14381. */
  14382. particleEmitterType: Nullable<IParticleEmitterType>;
  14383. /**
  14384. * Defines the delay in milliseconds before starting the system (0 by default)
  14385. */
  14386. startDelay: number;
  14387. /**
  14388. * 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
  14389. */
  14390. preWarmCycles: number;
  14391. /**
  14392. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14393. */
  14394. preWarmStepOffset: number;
  14395. /**
  14396. * 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)
  14397. */
  14398. spriteCellChangeSpeed: number;
  14399. /**
  14400. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14401. */
  14402. startSpriteCellID: number;
  14403. /**
  14404. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14405. */
  14406. endSpriteCellID: number;
  14407. /**
  14408. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14409. */
  14410. spriteCellWidth: number;
  14411. /**
  14412. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14413. */
  14414. spriteCellHeight: number;
  14415. /**
  14416. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14417. */
  14418. spriteRandomStartCell: boolean;
  14419. /**
  14420. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14421. */
  14422. isAnimationSheetEnabled: boolean;
  14423. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14424. translationPivot: Vector2;
  14425. /**
  14426. * Gets or sets a texture used to add random noise to particle positions
  14427. */
  14428. noiseTexture: Nullable<BaseTexture>;
  14429. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14430. noiseStrength: Vector3;
  14431. /**
  14432. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14433. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14434. */
  14435. billboardMode: number;
  14436. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14437. limitVelocityDamping: number;
  14438. /**
  14439. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14440. */
  14441. beginAnimationOnStart: boolean;
  14442. /**
  14443. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14444. */
  14445. beginAnimationFrom: number;
  14446. /**
  14447. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14448. */
  14449. beginAnimationTo: number;
  14450. /**
  14451. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14452. */
  14453. beginAnimationLoop: boolean;
  14454. /**
  14455. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14456. */
  14457. disposeOnStop: boolean;
  14458. /**
  14459. * Specifies if the particles are updated in emitter local space or world space
  14460. */
  14461. isLocal: boolean;
  14462. /** Snippet ID if the particle system was created from the snippet server */
  14463. snippetId: string;
  14464. /**
  14465. * Gets the maximum number of particles active at the same time.
  14466. * @returns The max number of active particles.
  14467. */
  14468. getCapacity(): number;
  14469. /**
  14470. * Gets the number of particles active at the same time.
  14471. * @returns The number of active particles.
  14472. */
  14473. getActiveCount(): number;
  14474. /**
  14475. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14476. * @returns True if it has been started, otherwise false.
  14477. */
  14478. isStarted(): boolean;
  14479. /**
  14480. * Animates the particle system for this frame.
  14481. */
  14482. animate(): void;
  14483. /**
  14484. * Renders the particle system in its current state.
  14485. * @returns the current number of particles
  14486. */
  14487. render(): number;
  14488. /**
  14489. * Dispose the particle system and frees its associated resources.
  14490. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14491. */
  14492. dispose(disposeTexture?: boolean): void;
  14493. /**
  14494. * An event triggered when the system is disposed
  14495. */
  14496. onDisposeObservable: Observable<IParticleSystem>;
  14497. /**
  14498. * Clones the particle system.
  14499. * @param name The name of the cloned object
  14500. * @param newEmitter The new emitter to use
  14501. * @returns the cloned particle system
  14502. */
  14503. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14504. /**
  14505. * Serializes the particle system to a JSON object
  14506. * @param serializeTexture defines if the texture must be serialized as well
  14507. * @returns the JSON object
  14508. */
  14509. serialize(serializeTexture: boolean): any;
  14510. /**
  14511. * Rebuild the particle system
  14512. */
  14513. rebuild(): void;
  14514. /** Force the system to rebuild all gradients that need to be resync */
  14515. forceRefreshGradients(): void;
  14516. /**
  14517. * Starts the particle system and begins to emit
  14518. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14519. */
  14520. start(delay?: number): void;
  14521. /**
  14522. * Stops the particle system.
  14523. */
  14524. stop(): void;
  14525. /**
  14526. * Remove all active particles
  14527. */
  14528. reset(): void;
  14529. /**
  14530. * Gets a boolean indicating that the system is stopping
  14531. * @returns true if the system is currently stopping
  14532. */
  14533. isStopping(): boolean;
  14534. /**
  14535. * Is this system ready to be used/rendered
  14536. * @return true if the system is ready
  14537. */
  14538. isReady(): boolean;
  14539. /**
  14540. * Returns the string "ParticleSystem"
  14541. * @returns a string containing the class name
  14542. */
  14543. getClassName(): string;
  14544. /**
  14545. * Gets the custom effect used to render the particles
  14546. * @param blendMode Blend mode for which the effect should be retrieved
  14547. * @returns The effect
  14548. */
  14549. getCustomEffect(blendMode: number): Nullable<Effect>;
  14550. /**
  14551. * Sets the custom effect used to render the particles
  14552. * @param effect The effect to set
  14553. * @param blendMode Blend mode for which the effect should be set
  14554. */
  14555. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14556. /**
  14557. * Fill the defines array according to the current settings of the particle system
  14558. * @param defines Array to be updated
  14559. * @param blendMode blend mode to take into account when updating the array
  14560. */
  14561. fillDefines(defines: Array<string>, blendMode: number): void;
  14562. /**
  14563. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14564. * @param uniforms Uniforms array to fill
  14565. * @param attributes Attributes array to fill
  14566. * @param samplers Samplers array to fill
  14567. */
  14568. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14569. /**
  14570. * Observable that will be called just before the particles are drawn
  14571. */
  14572. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14573. /**
  14574. * Gets the name of the particle vertex shader
  14575. */
  14576. vertexShaderName: string;
  14577. /**
  14578. * Adds a new color gradient
  14579. * @param gradient defines the gradient to use (between 0 and 1)
  14580. * @param color1 defines the color to affect to the specified gradient
  14581. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14582. * @returns the current particle system
  14583. */
  14584. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14585. /**
  14586. * Remove a specific color gradient
  14587. * @param gradient defines the gradient to remove
  14588. * @returns the current particle system
  14589. */
  14590. removeColorGradient(gradient: number): IParticleSystem;
  14591. /**
  14592. * Adds a new size gradient
  14593. * @param gradient defines the gradient to use (between 0 and 1)
  14594. * @param factor defines the size factor to affect to the specified gradient
  14595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14596. * @returns the current particle system
  14597. */
  14598. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14599. /**
  14600. * Remove a specific size gradient
  14601. * @param gradient defines the gradient to remove
  14602. * @returns the current particle system
  14603. */
  14604. removeSizeGradient(gradient: number): IParticleSystem;
  14605. /**
  14606. * Gets the current list of color gradients.
  14607. * You must use addColorGradient and removeColorGradient to udpate this list
  14608. * @returns the list of color gradients
  14609. */
  14610. getColorGradients(): Nullable<Array<ColorGradient>>;
  14611. /**
  14612. * Gets the current list of size gradients.
  14613. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14614. * @returns the list of size gradients
  14615. */
  14616. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14617. /**
  14618. * Gets the current list of angular speed gradients.
  14619. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14620. * @returns the list of angular speed gradients
  14621. */
  14622. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14623. /**
  14624. * Adds a new angular speed gradient
  14625. * @param gradient defines the gradient to use (between 0 and 1)
  14626. * @param factor defines the angular speed to affect to the specified gradient
  14627. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14628. * @returns the current particle system
  14629. */
  14630. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14631. /**
  14632. * Remove a specific angular speed gradient
  14633. * @param gradient defines the gradient to remove
  14634. * @returns the current particle system
  14635. */
  14636. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14637. /**
  14638. * Gets the current list of velocity gradients.
  14639. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14640. * @returns the list of velocity gradients
  14641. */
  14642. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14643. /**
  14644. * Adds a new velocity gradient
  14645. * @param gradient defines the gradient to use (between 0 and 1)
  14646. * @param factor defines the velocity to affect to the specified gradient
  14647. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14648. * @returns the current particle system
  14649. */
  14650. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14651. /**
  14652. * Remove a specific velocity gradient
  14653. * @param gradient defines the gradient to remove
  14654. * @returns the current particle system
  14655. */
  14656. removeVelocityGradient(gradient: number): IParticleSystem;
  14657. /**
  14658. * Gets the current list of limit velocity gradients.
  14659. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14660. * @returns the list of limit velocity gradients
  14661. */
  14662. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14663. /**
  14664. * Adds a new limit velocity gradient
  14665. * @param gradient defines the gradient to use (between 0 and 1)
  14666. * @param factor defines the limit velocity to affect to the specified gradient
  14667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14668. * @returns the current particle system
  14669. */
  14670. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14671. /**
  14672. * Remove a specific limit velocity gradient
  14673. * @param gradient defines the gradient to remove
  14674. * @returns the current particle system
  14675. */
  14676. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14677. /**
  14678. * Adds a new drag gradient
  14679. * @param gradient defines the gradient to use (between 0 and 1)
  14680. * @param factor defines the drag to affect to the specified gradient
  14681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14682. * @returns the current particle system
  14683. */
  14684. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14685. /**
  14686. * Remove a specific drag gradient
  14687. * @param gradient defines the gradient to remove
  14688. * @returns the current particle system
  14689. */
  14690. removeDragGradient(gradient: number): IParticleSystem;
  14691. /**
  14692. * Gets the current list of drag gradients.
  14693. * You must use addDragGradient and removeDragGradient to udpate this list
  14694. * @returns the list of drag gradients
  14695. */
  14696. getDragGradients(): Nullable<Array<FactorGradient>>;
  14697. /**
  14698. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14699. * @param gradient defines the gradient to use (between 0 and 1)
  14700. * @param factor defines the emit rate to affect to the specified gradient
  14701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14702. * @returns the current particle system
  14703. */
  14704. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14705. /**
  14706. * Remove a specific emit rate gradient
  14707. * @param gradient defines the gradient to remove
  14708. * @returns the current particle system
  14709. */
  14710. removeEmitRateGradient(gradient: number): IParticleSystem;
  14711. /**
  14712. * Gets the current list of emit rate gradients.
  14713. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14714. * @returns the list of emit rate gradients
  14715. */
  14716. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14717. /**
  14718. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14719. * @param gradient defines the gradient to use (between 0 and 1)
  14720. * @param factor defines the start size to affect to the specified gradient
  14721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14722. * @returns the current particle system
  14723. */
  14724. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14725. /**
  14726. * Remove a specific start size gradient
  14727. * @param gradient defines the gradient to remove
  14728. * @returns the current particle system
  14729. */
  14730. removeStartSizeGradient(gradient: number): IParticleSystem;
  14731. /**
  14732. * Gets the current list of start size gradients.
  14733. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14734. * @returns the list of start size gradients
  14735. */
  14736. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14737. /**
  14738. * Adds a new life time gradient
  14739. * @param gradient defines the gradient to use (between 0 and 1)
  14740. * @param factor defines the life time factor to affect to the specified gradient
  14741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14742. * @returns the current particle system
  14743. */
  14744. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14745. /**
  14746. * Remove a specific life time gradient
  14747. * @param gradient defines the gradient to remove
  14748. * @returns the current particle system
  14749. */
  14750. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14751. /**
  14752. * Gets the current list of life time gradients.
  14753. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14754. * @returns the list of life time gradients
  14755. */
  14756. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14757. /**
  14758. * Gets the current list of color gradients.
  14759. * You must use addColorGradient and removeColorGradient to udpate this list
  14760. * @returns the list of color gradients
  14761. */
  14762. getColorGradients(): Nullable<Array<ColorGradient>>;
  14763. /**
  14764. * Adds a new ramp gradient used to remap particle colors
  14765. * @param gradient defines the gradient to use (between 0 and 1)
  14766. * @param color defines the color to affect to the specified gradient
  14767. * @returns the current particle system
  14768. */
  14769. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14770. /**
  14771. * Gets the current list of ramp gradients.
  14772. * You must use addRampGradient and removeRampGradient to udpate this list
  14773. * @returns the list of ramp gradients
  14774. */
  14775. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14776. /** Gets or sets a boolean indicating that ramp gradients must be used
  14777. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14778. */
  14779. useRampGradients: boolean;
  14780. /**
  14781. * Adds a new color remap gradient
  14782. * @param gradient defines the gradient to use (between 0 and 1)
  14783. * @param min defines the color remap minimal range
  14784. * @param max defines the color remap maximal range
  14785. * @returns the current particle system
  14786. */
  14787. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14788. /**
  14789. * Gets the current list of color remap gradients.
  14790. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14791. * @returns the list of color remap gradients
  14792. */
  14793. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14794. /**
  14795. * Adds a new alpha remap gradient
  14796. * @param gradient defines the gradient to use (between 0 and 1)
  14797. * @param min defines the alpha remap minimal range
  14798. * @param max defines the alpha remap maximal range
  14799. * @returns the current particle system
  14800. */
  14801. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14802. /**
  14803. * Gets the current list of alpha remap gradients.
  14804. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14805. * @returns the list of alpha remap gradients
  14806. */
  14807. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14808. /**
  14809. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14810. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14811. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14812. * @returns the emitter
  14813. */
  14814. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14815. /**
  14816. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14817. * @param radius The radius of the hemisphere to emit from
  14818. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14819. * @returns the emitter
  14820. */
  14821. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14822. /**
  14823. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14824. * @param radius The radius of the sphere to emit from
  14825. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14826. * @returns the emitter
  14827. */
  14828. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14829. /**
  14830. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14831. * @param radius The radius of the sphere to emit from
  14832. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14833. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14834. * @returns the emitter
  14835. */
  14836. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14837. /**
  14838. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14839. * @param radius The radius of the emission cylinder
  14840. * @param height The height of the emission cylinder
  14841. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14842. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14843. * @returns the emitter
  14844. */
  14845. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14846. /**
  14847. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14848. * @param radius The radius of the cylinder to emit from
  14849. * @param height The height of the emission cylinder
  14850. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14851. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14852. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14853. * @returns the emitter
  14854. */
  14855. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14856. /**
  14857. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14858. * @param radius The radius of the cone to emit from
  14859. * @param angle The base angle of the cone
  14860. * @returns the emitter
  14861. */
  14862. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14863. /**
  14864. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14865. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14866. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14867. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14868. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14869. * @returns the emitter
  14870. */
  14871. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14872. /**
  14873. * Get hosting scene
  14874. * @returns the scene
  14875. */
  14876. getScene(): Scene;
  14877. }
  14878. }
  14879. declare module "babylonjs/Meshes/transformNode" {
  14880. import { DeepImmutable } from "babylonjs/types";
  14881. import { Observable } from "babylonjs/Misc/observable";
  14882. import { Nullable } from "babylonjs/types";
  14883. import { Camera } from "babylonjs/Cameras/camera";
  14884. import { Scene } from "babylonjs/scene";
  14885. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14886. import { Node } from "babylonjs/node";
  14887. import { Bone } from "babylonjs/Bones/bone";
  14888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14889. import { Space } from "babylonjs/Maths/math.axis";
  14890. /**
  14891. * 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.
  14892. * @see https://doc.babylonjs.com/how_to/transformnode
  14893. */
  14894. export class TransformNode extends Node {
  14895. /**
  14896. * Object will not rotate to face the camera
  14897. */
  14898. static BILLBOARDMODE_NONE: number;
  14899. /**
  14900. * Object will rotate to face the camera but only on the x axis
  14901. */
  14902. static BILLBOARDMODE_X: number;
  14903. /**
  14904. * Object will rotate to face the camera but only on the y axis
  14905. */
  14906. static BILLBOARDMODE_Y: number;
  14907. /**
  14908. * Object will rotate to face the camera but only on the z axis
  14909. */
  14910. static BILLBOARDMODE_Z: number;
  14911. /**
  14912. * Object will rotate to face the camera
  14913. */
  14914. static BILLBOARDMODE_ALL: number;
  14915. /**
  14916. * Object will rotate to face the camera's position instead of orientation
  14917. */
  14918. static BILLBOARDMODE_USE_POSITION: number;
  14919. private static _TmpRotation;
  14920. private static _TmpScaling;
  14921. private static _TmpTranslation;
  14922. private _forward;
  14923. private _forwardInverted;
  14924. private _up;
  14925. private _right;
  14926. private _rightInverted;
  14927. private _position;
  14928. private _rotation;
  14929. private _rotationQuaternion;
  14930. protected _scaling: Vector3;
  14931. protected _isDirty: boolean;
  14932. private _transformToBoneReferal;
  14933. private _isAbsoluteSynced;
  14934. private _billboardMode;
  14935. /**
  14936. * Gets or sets the billboard mode. Default is 0.
  14937. *
  14938. * | Value | Type | Description |
  14939. * | --- | --- | --- |
  14940. * | 0 | BILLBOARDMODE_NONE | |
  14941. * | 1 | BILLBOARDMODE_X | |
  14942. * | 2 | BILLBOARDMODE_Y | |
  14943. * | 4 | BILLBOARDMODE_Z | |
  14944. * | 7 | BILLBOARDMODE_ALL | |
  14945. *
  14946. */
  14947. get billboardMode(): number;
  14948. set billboardMode(value: number);
  14949. private _preserveParentRotationForBillboard;
  14950. /**
  14951. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14952. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14953. */
  14954. get preserveParentRotationForBillboard(): boolean;
  14955. set preserveParentRotationForBillboard(value: boolean);
  14956. /**
  14957. * 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
  14958. */
  14959. scalingDeterminant: number;
  14960. private _infiniteDistance;
  14961. /**
  14962. * Gets or sets the distance of the object to max, often used by skybox
  14963. */
  14964. get infiniteDistance(): boolean;
  14965. set infiniteDistance(value: boolean);
  14966. /**
  14967. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14968. * By default the system will update normals to compensate
  14969. */
  14970. ignoreNonUniformScaling: boolean;
  14971. /**
  14972. * 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
  14973. */
  14974. reIntegrateRotationIntoRotationQuaternion: boolean;
  14975. /** @hidden */
  14976. _poseMatrix: Nullable<Matrix>;
  14977. /** @hidden */
  14978. _localMatrix: Matrix;
  14979. private _usePivotMatrix;
  14980. private _absolutePosition;
  14981. private _absoluteScaling;
  14982. private _absoluteRotationQuaternion;
  14983. private _pivotMatrix;
  14984. private _pivotMatrixInverse;
  14985. protected _postMultiplyPivotMatrix: boolean;
  14986. protected _isWorldMatrixFrozen: boolean;
  14987. /** @hidden */
  14988. _indexInSceneTransformNodesArray: number;
  14989. /**
  14990. * An event triggered after the world matrix is updated
  14991. */
  14992. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14993. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14994. /**
  14995. * Gets a string identifying the name of the class
  14996. * @returns "TransformNode" string
  14997. */
  14998. getClassName(): string;
  14999. /**
  15000. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15001. */
  15002. get position(): Vector3;
  15003. set position(newPosition: Vector3);
  15004. /**
  15005. * 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)).
  15006. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15007. */
  15008. get rotation(): Vector3;
  15009. set rotation(newRotation: Vector3);
  15010. /**
  15011. * 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)).
  15012. */
  15013. get scaling(): Vector3;
  15014. set scaling(newScaling: Vector3);
  15015. /**
  15016. * 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).
  15017. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15018. */
  15019. get rotationQuaternion(): Nullable<Quaternion>;
  15020. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15021. /**
  15022. * The forward direction of that transform in world space.
  15023. */
  15024. get forward(): Vector3;
  15025. /**
  15026. * The up direction of that transform in world space.
  15027. */
  15028. get up(): Vector3;
  15029. /**
  15030. * The right direction of that transform in world space.
  15031. */
  15032. get right(): Vector3;
  15033. /**
  15034. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15035. * @param matrix the matrix to copy the pose from
  15036. * @returns this TransformNode.
  15037. */
  15038. updatePoseMatrix(matrix: Matrix): TransformNode;
  15039. /**
  15040. * Returns the mesh Pose matrix.
  15041. * @returns the pose matrix
  15042. */
  15043. getPoseMatrix(): Matrix;
  15044. /** @hidden */
  15045. _isSynchronized(): boolean;
  15046. /** @hidden */
  15047. _initCache(): void;
  15048. /**
  15049. * Flag the transform node as dirty (Forcing it to update everything)
  15050. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15051. * @returns this transform node
  15052. */
  15053. markAsDirty(property: string): TransformNode;
  15054. /**
  15055. * Returns the current mesh absolute position.
  15056. * Returns a Vector3.
  15057. */
  15058. get absolutePosition(): Vector3;
  15059. /**
  15060. * Returns the current mesh absolute scaling.
  15061. * Returns a Vector3.
  15062. */
  15063. get absoluteScaling(): Vector3;
  15064. /**
  15065. * Returns the current mesh absolute rotation.
  15066. * Returns a Quaternion.
  15067. */
  15068. get absoluteRotationQuaternion(): Quaternion;
  15069. /**
  15070. * Sets a new matrix to apply before all other transformation
  15071. * @param matrix defines the transform matrix
  15072. * @returns the current TransformNode
  15073. */
  15074. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15075. /**
  15076. * Sets a new pivot matrix to the current node
  15077. * @param matrix defines the new pivot matrix to use
  15078. * @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
  15079. * @returns the current TransformNode
  15080. */
  15081. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15082. /**
  15083. * Returns the mesh pivot matrix.
  15084. * Default : Identity.
  15085. * @returns the matrix
  15086. */
  15087. getPivotMatrix(): Matrix;
  15088. /**
  15089. * Instantiate (when possible) or clone that node with its hierarchy
  15090. * @param newParent defines the new parent to use for the instance (or clone)
  15091. * @param options defines options to configure how copy is done
  15092. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15093. * @returns an instance (or a clone) of the current node with its hiearchy
  15094. */
  15095. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15096. doNotInstantiate: boolean;
  15097. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15098. /**
  15099. * Prevents the World matrix to be computed any longer
  15100. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15101. * @returns the TransformNode.
  15102. */
  15103. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15104. /**
  15105. * Allows back the World matrix computation.
  15106. * @returns the TransformNode.
  15107. */
  15108. unfreezeWorldMatrix(): this;
  15109. /**
  15110. * True if the World matrix has been frozen.
  15111. */
  15112. get isWorldMatrixFrozen(): boolean;
  15113. /**
  15114. * Retuns the mesh absolute position in the World.
  15115. * @returns a Vector3.
  15116. */
  15117. getAbsolutePosition(): Vector3;
  15118. /**
  15119. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15120. * @param absolutePosition the absolute position to set
  15121. * @returns the TransformNode.
  15122. */
  15123. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15124. /**
  15125. * Sets the mesh position in its local space.
  15126. * @param vector3 the position to set in localspace
  15127. * @returns the TransformNode.
  15128. */
  15129. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15130. /**
  15131. * Returns the mesh position in the local space from the current World matrix values.
  15132. * @returns a new Vector3.
  15133. */
  15134. getPositionExpressedInLocalSpace(): Vector3;
  15135. /**
  15136. * Translates the mesh along the passed Vector3 in its local space.
  15137. * @param vector3 the distance to translate in localspace
  15138. * @returns the TransformNode.
  15139. */
  15140. locallyTranslate(vector3: Vector3): TransformNode;
  15141. private static _lookAtVectorCache;
  15142. /**
  15143. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15144. * @param targetPoint the position (must be in same space as current mesh) to look at
  15145. * @param yawCor optional yaw (y-axis) correction in radians
  15146. * @param pitchCor optional pitch (x-axis) correction in radians
  15147. * @param rollCor optional roll (z-axis) correction in radians
  15148. * @param space the choosen space of the target
  15149. * @returns the TransformNode.
  15150. */
  15151. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15152. /**
  15153. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15154. * This Vector3 is expressed in the World space.
  15155. * @param localAxis axis to rotate
  15156. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15157. */
  15158. getDirection(localAxis: Vector3): Vector3;
  15159. /**
  15160. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15161. * localAxis is expressed in the mesh local space.
  15162. * result is computed in the Wordl space from the mesh World matrix.
  15163. * @param localAxis axis to rotate
  15164. * @param result the resulting transformnode
  15165. * @returns this TransformNode.
  15166. */
  15167. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15168. /**
  15169. * Sets this transform node rotation to the given local axis.
  15170. * @param localAxis the axis in local space
  15171. * @param yawCor optional yaw (y-axis) correction in radians
  15172. * @param pitchCor optional pitch (x-axis) correction in radians
  15173. * @param rollCor optional roll (z-axis) correction in radians
  15174. * @returns this TransformNode
  15175. */
  15176. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15177. /**
  15178. * Sets a new pivot point to the current node
  15179. * @param point defines the new pivot point to use
  15180. * @param space defines if the point is in world or local space (local by default)
  15181. * @returns the current TransformNode
  15182. */
  15183. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15184. /**
  15185. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15186. * @returns the pivot point
  15187. */
  15188. getPivotPoint(): Vector3;
  15189. /**
  15190. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15191. * @param result the vector3 to store the result
  15192. * @returns this TransformNode.
  15193. */
  15194. getPivotPointToRef(result: Vector3): TransformNode;
  15195. /**
  15196. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15197. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15198. */
  15199. getAbsolutePivotPoint(): Vector3;
  15200. /**
  15201. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15202. * @param result vector3 to store the result
  15203. * @returns this TransformNode.
  15204. */
  15205. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15206. /**
  15207. * Defines the passed node as the parent of the current node.
  15208. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15209. * @see https://doc.babylonjs.com/how_to/parenting
  15210. * @param node the node ot set as the parent
  15211. * @returns this TransformNode.
  15212. */
  15213. setParent(node: Nullable<Node>): TransformNode;
  15214. private _nonUniformScaling;
  15215. /**
  15216. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15217. */
  15218. get nonUniformScaling(): boolean;
  15219. /** @hidden */
  15220. _updateNonUniformScalingState(value: boolean): boolean;
  15221. /**
  15222. * Attach the current TransformNode to another TransformNode associated with a bone
  15223. * @param bone Bone affecting the TransformNode
  15224. * @param affectedTransformNode TransformNode associated with the bone
  15225. * @returns this object
  15226. */
  15227. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15228. /**
  15229. * Detach the transform node if its associated with a bone
  15230. * @returns this object
  15231. */
  15232. detachFromBone(): TransformNode;
  15233. private static _rotationAxisCache;
  15234. /**
  15235. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15236. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15237. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15238. * The passed axis is also normalized.
  15239. * @param axis the axis to rotate around
  15240. * @param amount the amount to rotate in radians
  15241. * @param space Space to rotate in (Default: local)
  15242. * @returns the TransformNode.
  15243. */
  15244. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15245. /**
  15246. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15247. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15248. * The passed axis is also normalized. .
  15249. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15250. * @param point the point to rotate around
  15251. * @param axis the axis to rotate around
  15252. * @param amount the amount to rotate in radians
  15253. * @returns the TransformNode
  15254. */
  15255. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15256. /**
  15257. * Translates the mesh along the axis vector for the passed distance in the given space.
  15258. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15259. * @param axis the axis to translate in
  15260. * @param distance the distance to translate
  15261. * @param space Space to rotate in (Default: local)
  15262. * @returns the TransformNode.
  15263. */
  15264. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15265. /**
  15266. * Adds a rotation step to the mesh current rotation.
  15267. * x, y, z are Euler angles expressed in radians.
  15268. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15269. * This means this rotation is made in the mesh local space only.
  15270. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15271. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15272. * ```javascript
  15273. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15274. * ```
  15275. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15276. * 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.
  15277. * @param x Rotation to add
  15278. * @param y Rotation to add
  15279. * @param z Rotation to add
  15280. * @returns the TransformNode.
  15281. */
  15282. addRotation(x: number, y: number, z: number): TransformNode;
  15283. /**
  15284. * @hidden
  15285. */
  15286. protected _getEffectiveParent(): Nullable<Node>;
  15287. /**
  15288. * Computes the world matrix of the node
  15289. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15290. * @returns the world matrix
  15291. */
  15292. computeWorldMatrix(force?: boolean): Matrix;
  15293. /**
  15294. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15295. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15296. */
  15297. resetLocalMatrix(independentOfChildren?: boolean): void;
  15298. protected _afterComputeWorldMatrix(): void;
  15299. /**
  15300. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15301. * @param func callback function to add
  15302. *
  15303. * @returns the TransformNode.
  15304. */
  15305. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15306. /**
  15307. * Removes a registered callback function.
  15308. * @param func callback function to remove
  15309. * @returns the TransformNode.
  15310. */
  15311. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15312. /**
  15313. * Gets the position of the current mesh in camera space
  15314. * @param camera defines the camera to use
  15315. * @returns a position
  15316. */
  15317. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15318. /**
  15319. * Returns the distance from the mesh to the active camera
  15320. * @param camera defines the camera to use
  15321. * @returns the distance
  15322. */
  15323. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15324. /**
  15325. * Clone the current transform node
  15326. * @param name Name of the new clone
  15327. * @param newParent New parent for the clone
  15328. * @param doNotCloneChildren Do not clone children hierarchy
  15329. * @returns the new transform node
  15330. */
  15331. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15332. /**
  15333. * Serializes the objects information.
  15334. * @param currentSerializationObject defines the object to serialize in
  15335. * @returns the serialized object
  15336. */
  15337. serialize(currentSerializationObject?: any): any;
  15338. /**
  15339. * Returns a new TransformNode object parsed from the source provided.
  15340. * @param parsedTransformNode is the source.
  15341. * @param scene the scne the object belongs to
  15342. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15343. * @returns a new TransformNode object parsed from the source provided.
  15344. */
  15345. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15346. /**
  15347. * Get all child-transformNodes of this node
  15348. * @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
  15349. * @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
  15350. * @returns an array of TransformNode
  15351. */
  15352. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15353. /**
  15354. * Releases resources associated with this transform node.
  15355. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15356. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15357. */
  15358. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15359. /**
  15360. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15361. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15362. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15363. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15364. * @returns the current mesh
  15365. */
  15366. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15367. private _syncAbsoluteScalingAndRotation;
  15368. }
  15369. }
  15370. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15371. /**
  15372. * Class used to override all child animations of a given target
  15373. */
  15374. export class AnimationPropertiesOverride {
  15375. /**
  15376. * Gets or sets a value indicating if animation blending must be used
  15377. */
  15378. enableBlending: boolean;
  15379. /**
  15380. * Gets or sets the blending speed to use when enableBlending is true
  15381. */
  15382. blendingSpeed: number;
  15383. /**
  15384. * Gets or sets the default loop mode to use
  15385. */
  15386. loopMode: number;
  15387. }
  15388. }
  15389. declare module "babylonjs/Bones/bone" {
  15390. import { Skeleton } from "babylonjs/Bones/skeleton";
  15391. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15392. import { Nullable } from "babylonjs/types";
  15393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15394. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15395. import { Node } from "babylonjs/node";
  15396. import { Space } from "babylonjs/Maths/math.axis";
  15397. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15398. /**
  15399. * Class used to store bone information
  15400. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15401. */
  15402. export class Bone extends Node {
  15403. /**
  15404. * defines the bone name
  15405. */
  15406. name: string;
  15407. private static _tmpVecs;
  15408. private static _tmpQuat;
  15409. private static _tmpMats;
  15410. /**
  15411. * Gets the list of child bones
  15412. */
  15413. children: Bone[];
  15414. /** Gets the animations associated with this bone */
  15415. animations: import("babylonjs/Animations/animation").Animation[];
  15416. /**
  15417. * Gets or sets bone length
  15418. */
  15419. length: number;
  15420. /**
  15421. * @hidden Internal only
  15422. * Set this value to map this bone to a different index in the transform matrices
  15423. * Set this value to -1 to exclude the bone from the transform matrices
  15424. */
  15425. _index: Nullable<number>;
  15426. private _skeleton;
  15427. private _localMatrix;
  15428. private _restPose;
  15429. private _baseMatrix;
  15430. private _absoluteTransform;
  15431. private _invertedAbsoluteTransform;
  15432. private _parent;
  15433. private _scalingDeterminant;
  15434. private _worldTransform;
  15435. private _localScaling;
  15436. private _localRotation;
  15437. private _localPosition;
  15438. private _needToDecompose;
  15439. private _needToCompose;
  15440. /** @hidden */
  15441. _linkedTransformNode: Nullable<TransformNode>;
  15442. /** @hidden */
  15443. _waitingTransformNodeId: Nullable<string>;
  15444. /** @hidden */
  15445. get _matrix(): Matrix;
  15446. /** @hidden */
  15447. set _matrix(value: Matrix);
  15448. /**
  15449. * Create a new bone
  15450. * @param name defines the bone name
  15451. * @param skeleton defines the parent skeleton
  15452. * @param parentBone defines the parent (can be null if the bone is the root)
  15453. * @param localMatrix defines the local matrix
  15454. * @param restPose defines the rest pose matrix
  15455. * @param baseMatrix defines the base matrix
  15456. * @param index defines index of the bone in the hiearchy
  15457. */
  15458. constructor(
  15459. /**
  15460. * defines the bone name
  15461. */
  15462. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15463. /**
  15464. * Gets the current object class name.
  15465. * @return the class name
  15466. */
  15467. getClassName(): string;
  15468. /**
  15469. * Gets the parent skeleton
  15470. * @returns a skeleton
  15471. */
  15472. getSkeleton(): Skeleton;
  15473. /**
  15474. * Gets parent bone
  15475. * @returns a bone or null if the bone is the root of the bone hierarchy
  15476. */
  15477. getParent(): Nullable<Bone>;
  15478. /**
  15479. * Returns an array containing the root bones
  15480. * @returns an array containing the root bones
  15481. */
  15482. getChildren(): Array<Bone>;
  15483. /**
  15484. * Gets the node index in matrix array generated for rendering
  15485. * @returns the node index
  15486. */
  15487. getIndex(): number;
  15488. /**
  15489. * Sets the parent bone
  15490. * @param parent defines the parent (can be null if the bone is the root)
  15491. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15492. */
  15493. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15494. /**
  15495. * Gets the local matrix
  15496. * @returns a matrix
  15497. */
  15498. getLocalMatrix(): Matrix;
  15499. /**
  15500. * Gets the base matrix (initial matrix which remains unchanged)
  15501. * @returns a matrix
  15502. */
  15503. getBaseMatrix(): Matrix;
  15504. /**
  15505. * Gets the rest pose matrix
  15506. * @returns a matrix
  15507. */
  15508. getRestPose(): Matrix;
  15509. /**
  15510. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15511. */
  15512. getWorldMatrix(): Matrix;
  15513. /**
  15514. * Sets the local matrix to rest pose matrix
  15515. */
  15516. returnToRest(): void;
  15517. /**
  15518. * Gets the inverse of the absolute transform matrix.
  15519. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15520. * @returns a matrix
  15521. */
  15522. getInvertedAbsoluteTransform(): Matrix;
  15523. /**
  15524. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15525. * @returns a matrix
  15526. */
  15527. getAbsoluteTransform(): Matrix;
  15528. /**
  15529. * Links with the given transform node.
  15530. * The local matrix of this bone is copied from the transform node every frame.
  15531. * @param transformNode defines the transform node to link to
  15532. */
  15533. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15534. /**
  15535. * Gets the node used to drive the bone's transformation
  15536. * @returns a transform node or null
  15537. */
  15538. getTransformNode(): Nullable<TransformNode>;
  15539. /** Gets or sets current position (in local space) */
  15540. get position(): Vector3;
  15541. set position(newPosition: Vector3);
  15542. /** Gets or sets current rotation (in local space) */
  15543. get rotation(): Vector3;
  15544. set rotation(newRotation: Vector3);
  15545. /** Gets or sets current rotation quaternion (in local space) */
  15546. get rotationQuaternion(): Quaternion;
  15547. set rotationQuaternion(newRotation: Quaternion);
  15548. /** Gets or sets current scaling (in local space) */
  15549. get scaling(): Vector3;
  15550. set scaling(newScaling: Vector3);
  15551. /**
  15552. * Gets the animation properties override
  15553. */
  15554. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15555. private _decompose;
  15556. private _compose;
  15557. /**
  15558. * Update the base and local matrices
  15559. * @param matrix defines the new base or local matrix
  15560. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15561. * @param updateLocalMatrix defines if the local matrix should be updated
  15562. */
  15563. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15564. /** @hidden */
  15565. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15566. /**
  15567. * Flag the bone as dirty (Forcing it to update everything)
  15568. */
  15569. markAsDirty(): void;
  15570. /** @hidden */
  15571. _markAsDirtyAndCompose(): void;
  15572. private _markAsDirtyAndDecompose;
  15573. /**
  15574. * Translate the bone in local or world space
  15575. * @param vec The amount to translate the bone
  15576. * @param space The space that the translation is in
  15577. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15578. */
  15579. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15580. /**
  15581. * Set the postion of the bone in local or world space
  15582. * @param position The position to set the bone
  15583. * @param space The space that the position is in
  15584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15585. */
  15586. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15587. /**
  15588. * Set the absolute position of the bone (world space)
  15589. * @param position The position to set the bone
  15590. * @param mesh The mesh that this bone is attached to
  15591. */
  15592. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15593. /**
  15594. * Scale the bone on the x, y and z axes (in local space)
  15595. * @param x The amount to scale the bone on the x axis
  15596. * @param y The amount to scale the bone on the y axis
  15597. * @param z The amount to scale the bone on the z axis
  15598. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15599. */
  15600. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15601. /**
  15602. * Set the bone scaling in local space
  15603. * @param scale defines the scaling vector
  15604. */
  15605. setScale(scale: Vector3): void;
  15606. /**
  15607. * Gets the current scaling in local space
  15608. * @returns the current scaling vector
  15609. */
  15610. getScale(): Vector3;
  15611. /**
  15612. * Gets the current scaling in local space and stores it in a target vector
  15613. * @param result defines the target vector
  15614. */
  15615. getScaleToRef(result: Vector3): void;
  15616. /**
  15617. * Set the yaw, pitch, and roll of the bone in local or world space
  15618. * @param yaw The rotation of the bone on the y axis
  15619. * @param pitch The rotation of the bone on the x axis
  15620. * @param roll The rotation of the bone on the z axis
  15621. * @param space The space that the axes of rotation are in
  15622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15623. */
  15624. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15625. /**
  15626. * Add a rotation to the bone on an axis in local or world space
  15627. * @param axis The axis to rotate the bone on
  15628. * @param amount The amount to rotate the bone
  15629. * @param space The space that the axis is in
  15630. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15631. */
  15632. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15633. /**
  15634. * Set the rotation of the bone to a particular axis angle in local or world space
  15635. * @param axis The axis to rotate the bone on
  15636. * @param angle The angle that the bone should be rotated to
  15637. * @param space The space that the axis is in
  15638. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15639. */
  15640. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15641. /**
  15642. * Set the euler rotation of the bone in local of world space
  15643. * @param rotation The euler rotation that the bone should be set to
  15644. * @param space The space that the rotation is in
  15645. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15646. */
  15647. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15648. /**
  15649. * Set the quaternion rotation of the bone in local of world space
  15650. * @param quat The quaternion rotation that the bone should be set to
  15651. * @param space The space that the rotation is in
  15652. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15653. */
  15654. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15655. /**
  15656. * Set the rotation matrix of the bone in local of world space
  15657. * @param rotMat The rotation matrix that the bone should be set to
  15658. * @param space The space that the rotation is in
  15659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15660. */
  15661. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15662. private _rotateWithMatrix;
  15663. private _getNegativeRotationToRef;
  15664. /**
  15665. * Get the position of the bone in local or world space
  15666. * @param space The space that the returned position is in
  15667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15668. * @returns The position of the bone
  15669. */
  15670. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15671. /**
  15672. * Copy the position of the bone to a vector3 in local or world space
  15673. * @param space The space that the returned position is in
  15674. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15675. * @param result The vector3 to copy the position to
  15676. */
  15677. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15678. /**
  15679. * Get the absolute position of the bone (world space)
  15680. * @param mesh The mesh that this bone is attached to
  15681. * @returns The absolute position of the bone
  15682. */
  15683. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15684. /**
  15685. * Copy the absolute position of the bone (world space) to the result param
  15686. * @param mesh The mesh that this bone is attached to
  15687. * @param result The vector3 to copy the absolute position to
  15688. */
  15689. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15690. /**
  15691. * Compute the absolute transforms of this bone and its children
  15692. */
  15693. computeAbsoluteTransforms(): void;
  15694. /**
  15695. * Get the world direction from an axis that is in the local space of the bone
  15696. * @param localAxis The local direction that is used to compute the world direction
  15697. * @param mesh The mesh that this bone is attached to
  15698. * @returns The world direction
  15699. */
  15700. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15701. /**
  15702. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15703. * @param localAxis The local direction that is used to compute the world direction
  15704. * @param mesh The mesh that this bone is attached to
  15705. * @param result The vector3 that the world direction will be copied to
  15706. */
  15707. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15708. /**
  15709. * Get the euler rotation of the bone in local or world space
  15710. * @param space The space that the rotation should be in
  15711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15712. * @returns The euler rotation
  15713. */
  15714. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15715. /**
  15716. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15717. * @param space The space that the rotation should be in
  15718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15719. * @param result The vector3 that the rotation should be copied to
  15720. */
  15721. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15722. /**
  15723. * Get the quaternion rotation of the bone in either local or world space
  15724. * @param space The space that the rotation should be in
  15725. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15726. * @returns The quaternion rotation
  15727. */
  15728. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15729. /**
  15730. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15731. * @param space The space that the rotation should be in
  15732. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15733. * @param result The quaternion that the rotation should be copied to
  15734. */
  15735. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15736. /**
  15737. * Get the rotation matrix of the bone in local or world space
  15738. * @param space The space that the rotation should be in
  15739. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15740. * @returns The rotation matrix
  15741. */
  15742. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15743. /**
  15744. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15745. * @param space The space that the rotation should be in
  15746. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15747. * @param result The quaternion that the rotation should be copied to
  15748. */
  15749. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15750. /**
  15751. * Get the world position of a point that is in the local space of the bone
  15752. * @param position The local position
  15753. * @param mesh The mesh that this bone is attached to
  15754. * @returns The world position
  15755. */
  15756. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15757. /**
  15758. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15759. * @param position The local position
  15760. * @param mesh The mesh that this bone is attached to
  15761. * @param result The vector3 that the world position should be copied to
  15762. */
  15763. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15764. /**
  15765. * Get the local position of a point that is in world space
  15766. * @param position The world position
  15767. * @param mesh The mesh that this bone is attached to
  15768. * @returns The local position
  15769. */
  15770. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15771. /**
  15772. * Get the local position of a point that is in world space and copy it to the result param
  15773. * @param position The world position
  15774. * @param mesh The mesh that this bone is attached to
  15775. * @param result The vector3 that the local position should be copied to
  15776. */
  15777. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15778. }
  15779. }
  15780. declare module "babylonjs/Animations/runtimeAnimation" {
  15781. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15782. import { Animatable } from "babylonjs/Animations/animatable";
  15783. import { Scene } from "babylonjs/scene";
  15784. /**
  15785. * Defines a runtime animation
  15786. */
  15787. export class RuntimeAnimation {
  15788. private _events;
  15789. /**
  15790. * The current frame of the runtime animation
  15791. */
  15792. private _currentFrame;
  15793. /**
  15794. * The animation used by the runtime animation
  15795. */
  15796. private _animation;
  15797. /**
  15798. * The target of the runtime animation
  15799. */
  15800. private _target;
  15801. /**
  15802. * The initiating animatable
  15803. */
  15804. private _host;
  15805. /**
  15806. * The original value of the runtime animation
  15807. */
  15808. private _originalValue;
  15809. /**
  15810. * The original blend value of the runtime animation
  15811. */
  15812. private _originalBlendValue;
  15813. /**
  15814. * The offsets cache of the runtime animation
  15815. */
  15816. private _offsetsCache;
  15817. /**
  15818. * The high limits cache of the runtime animation
  15819. */
  15820. private _highLimitsCache;
  15821. /**
  15822. * Specifies if the runtime animation has been stopped
  15823. */
  15824. private _stopped;
  15825. /**
  15826. * The blending factor of the runtime animation
  15827. */
  15828. private _blendingFactor;
  15829. /**
  15830. * The BabylonJS scene
  15831. */
  15832. private _scene;
  15833. /**
  15834. * The current value of the runtime animation
  15835. */
  15836. private _currentValue;
  15837. /** @hidden */
  15838. _animationState: _IAnimationState;
  15839. /**
  15840. * The active target of the runtime animation
  15841. */
  15842. private _activeTargets;
  15843. private _currentActiveTarget;
  15844. private _directTarget;
  15845. /**
  15846. * The target path of the runtime animation
  15847. */
  15848. private _targetPath;
  15849. /**
  15850. * The weight of the runtime animation
  15851. */
  15852. private _weight;
  15853. /**
  15854. * The ratio offset of the runtime animation
  15855. */
  15856. private _ratioOffset;
  15857. /**
  15858. * The previous delay of the runtime animation
  15859. */
  15860. private _previousDelay;
  15861. /**
  15862. * The previous ratio of the runtime animation
  15863. */
  15864. private _previousRatio;
  15865. private _enableBlending;
  15866. private _keys;
  15867. private _minFrame;
  15868. private _maxFrame;
  15869. private _minValue;
  15870. private _maxValue;
  15871. private _targetIsArray;
  15872. /**
  15873. * Gets the current frame of the runtime animation
  15874. */
  15875. get currentFrame(): number;
  15876. /**
  15877. * Gets the weight of the runtime animation
  15878. */
  15879. get weight(): number;
  15880. /**
  15881. * Gets the current value of the runtime animation
  15882. */
  15883. get currentValue(): any;
  15884. /**
  15885. * Gets the target path of the runtime animation
  15886. */
  15887. get targetPath(): string;
  15888. /**
  15889. * Gets the actual target of the runtime animation
  15890. */
  15891. get target(): any;
  15892. /**
  15893. * Gets the additive state of the runtime animation
  15894. */
  15895. get isAdditive(): boolean;
  15896. /** @hidden */
  15897. _onLoop: () => void;
  15898. /**
  15899. * Create a new RuntimeAnimation object
  15900. * @param target defines the target of the animation
  15901. * @param animation defines the source animation object
  15902. * @param scene defines the hosting scene
  15903. * @param host defines the initiating Animatable
  15904. */
  15905. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15906. private _preparePath;
  15907. /**
  15908. * Gets the animation from the runtime animation
  15909. */
  15910. get animation(): Animation;
  15911. /**
  15912. * Resets the runtime animation to the beginning
  15913. * @param restoreOriginal defines whether to restore the target property to the original value
  15914. */
  15915. reset(restoreOriginal?: boolean): void;
  15916. /**
  15917. * Specifies if the runtime animation is stopped
  15918. * @returns Boolean specifying if the runtime animation is stopped
  15919. */
  15920. isStopped(): boolean;
  15921. /**
  15922. * Disposes of the runtime animation
  15923. */
  15924. dispose(): void;
  15925. /**
  15926. * Apply the interpolated value to the target
  15927. * @param currentValue defines the value computed by the animation
  15928. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15929. */
  15930. setValue(currentValue: any, weight: number): void;
  15931. private _getOriginalValues;
  15932. private _setValue;
  15933. /**
  15934. * Gets the loop pmode of the runtime animation
  15935. * @returns Loop Mode
  15936. */
  15937. private _getCorrectLoopMode;
  15938. /**
  15939. * Move the current animation to a given frame
  15940. * @param frame defines the frame to move to
  15941. */
  15942. goToFrame(frame: number): void;
  15943. /**
  15944. * @hidden Internal use only
  15945. */
  15946. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15947. /**
  15948. * Execute the current animation
  15949. * @param delay defines the delay to add to the current frame
  15950. * @param from defines the lower bound of the animation range
  15951. * @param to defines the upper bound of the animation range
  15952. * @param loop defines if the current animation must loop
  15953. * @param speedRatio defines the current speed ratio
  15954. * @param weight defines the weight of the animation (default is -1 so no weight)
  15955. * @param onLoop optional callback called when animation loops
  15956. * @returns a boolean indicating if the animation is running
  15957. */
  15958. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15959. }
  15960. }
  15961. declare module "babylonjs/Animations/animatable" {
  15962. import { Animation } from "babylonjs/Animations/animation";
  15963. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15964. import { Nullable } from "babylonjs/types";
  15965. import { Observable } from "babylonjs/Misc/observable";
  15966. import { Scene } from "babylonjs/scene";
  15967. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15968. import { Node } from "babylonjs/node";
  15969. /**
  15970. * Class used to store an actual running animation
  15971. */
  15972. export class Animatable {
  15973. /** defines the target object */
  15974. target: any;
  15975. /** defines the starting frame number (default is 0) */
  15976. fromFrame: number;
  15977. /** defines the ending frame number (default is 100) */
  15978. toFrame: number;
  15979. /** defines if the animation must loop (default is false) */
  15980. loopAnimation: boolean;
  15981. /** defines a callback to call when animation ends if it is not looping */
  15982. onAnimationEnd?: (() => void) | null | undefined;
  15983. /** defines a callback to call when animation loops */
  15984. onAnimationLoop?: (() => void) | null | undefined;
  15985. /** defines whether the animation should be evaluated additively */
  15986. isAdditive: boolean;
  15987. private _localDelayOffset;
  15988. private _pausedDelay;
  15989. private _runtimeAnimations;
  15990. private _paused;
  15991. private _scene;
  15992. private _speedRatio;
  15993. private _weight;
  15994. private _syncRoot;
  15995. /**
  15996. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15997. * This will only apply for non looping animation (default is true)
  15998. */
  15999. disposeOnEnd: boolean;
  16000. /**
  16001. * Gets a boolean indicating if the animation has started
  16002. */
  16003. animationStarted: boolean;
  16004. /**
  16005. * Observer raised when the animation ends
  16006. */
  16007. onAnimationEndObservable: Observable<Animatable>;
  16008. /**
  16009. * Observer raised when the animation loops
  16010. */
  16011. onAnimationLoopObservable: Observable<Animatable>;
  16012. /**
  16013. * Gets the root Animatable used to synchronize and normalize animations
  16014. */
  16015. get syncRoot(): Nullable<Animatable>;
  16016. /**
  16017. * Gets the current frame of the first RuntimeAnimation
  16018. * Used to synchronize Animatables
  16019. */
  16020. get masterFrame(): number;
  16021. /**
  16022. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16023. */
  16024. get weight(): number;
  16025. set weight(value: number);
  16026. /**
  16027. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16028. */
  16029. get speedRatio(): number;
  16030. set speedRatio(value: number);
  16031. /**
  16032. * Creates a new Animatable
  16033. * @param scene defines the hosting scene
  16034. * @param target defines the target object
  16035. * @param fromFrame defines the starting frame number (default is 0)
  16036. * @param toFrame defines the ending frame number (default is 100)
  16037. * @param loopAnimation defines if the animation must loop (default is false)
  16038. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16039. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16040. * @param animations defines a group of animation to add to the new Animatable
  16041. * @param onAnimationLoop defines a callback to call when animation loops
  16042. * @param isAdditive defines whether the animation should be evaluated additively
  16043. */
  16044. constructor(scene: Scene,
  16045. /** defines the target object */
  16046. target: any,
  16047. /** defines the starting frame number (default is 0) */
  16048. fromFrame?: number,
  16049. /** defines the ending frame number (default is 100) */
  16050. toFrame?: number,
  16051. /** defines if the animation must loop (default is false) */
  16052. loopAnimation?: boolean, speedRatio?: number,
  16053. /** defines a callback to call when animation ends if it is not looping */
  16054. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16055. /** defines a callback to call when animation loops */
  16056. onAnimationLoop?: (() => void) | null | undefined,
  16057. /** defines whether the animation should be evaluated additively */
  16058. isAdditive?: boolean);
  16059. /**
  16060. * Synchronize and normalize current Animatable with a source Animatable
  16061. * This is useful when using animation weights and when animations are not of the same length
  16062. * @param root defines the root Animatable to synchronize with
  16063. * @returns the current Animatable
  16064. */
  16065. syncWith(root: Animatable): Animatable;
  16066. /**
  16067. * Gets the list of runtime animations
  16068. * @returns an array of RuntimeAnimation
  16069. */
  16070. getAnimations(): RuntimeAnimation[];
  16071. /**
  16072. * Adds more animations to the current animatable
  16073. * @param target defines the target of the animations
  16074. * @param animations defines the new animations to add
  16075. */
  16076. appendAnimations(target: any, animations: Animation[]): void;
  16077. /**
  16078. * Gets the source animation for a specific property
  16079. * @param property defines the propertyu to look for
  16080. * @returns null or the source animation for the given property
  16081. */
  16082. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16083. /**
  16084. * Gets the runtime animation for a specific property
  16085. * @param property defines the propertyu to look for
  16086. * @returns null or the runtime animation for the given property
  16087. */
  16088. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16089. /**
  16090. * Resets the animatable to its original state
  16091. */
  16092. reset(): void;
  16093. /**
  16094. * Allows the animatable to blend with current running animations
  16095. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16096. * @param blendingSpeed defines the blending speed to use
  16097. */
  16098. enableBlending(blendingSpeed: number): void;
  16099. /**
  16100. * Disable animation blending
  16101. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16102. */
  16103. disableBlending(): void;
  16104. /**
  16105. * Jump directly to a given frame
  16106. * @param frame defines the frame to jump to
  16107. */
  16108. goToFrame(frame: number): void;
  16109. /**
  16110. * Pause the animation
  16111. */
  16112. pause(): void;
  16113. /**
  16114. * Restart the animation
  16115. */
  16116. restart(): void;
  16117. private _raiseOnAnimationEnd;
  16118. /**
  16119. * Stop and delete the current animation
  16120. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16121. * @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)
  16122. */
  16123. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16124. /**
  16125. * Wait asynchronously for the animation to end
  16126. * @returns a promise which will be fullfilled when the animation ends
  16127. */
  16128. waitAsync(): Promise<Animatable>;
  16129. /** @hidden */
  16130. _animate(delay: number): boolean;
  16131. }
  16132. module "babylonjs/scene" {
  16133. interface Scene {
  16134. /** @hidden */
  16135. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16136. /** @hidden */
  16137. _processLateAnimationBindingsForMatrices(holder: {
  16138. totalWeight: number;
  16139. totalAdditiveWeight: number;
  16140. animations: RuntimeAnimation[];
  16141. additiveAnimations: RuntimeAnimation[];
  16142. originalValue: Matrix;
  16143. }): any;
  16144. /** @hidden */
  16145. _processLateAnimationBindingsForQuaternions(holder: {
  16146. totalWeight: number;
  16147. totalAdditiveWeight: number;
  16148. animations: RuntimeAnimation[];
  16149. additiveAnimations: RuntimeAnimation[];
  16150. originalValue: Quaternion;
  16151. }, refQuaternion: Quaternion): Quaternion;
  16152. /** @hidden */
  16153. _processLateAnimationBindings(): void;
  16154. /**
  16155. * Will start the animation sequence of a given target
  16156. * @param target defines the target
  16157. * @param from defines from which frame should animation start
  16158. * @param to defines until which frame should animation run.
  16159. * @param weight defines the weight to apply to the animation (1.0 by default)
  16160. * @param loop defines if the animation loops
  16161. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16162. * @param onAnimationEnd defines the function to be executed when the animation ends
  16163. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16164. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16165. * @param onAnimationLoop defines the callback to call when an animation loops
  16166. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16167. * @returns the animatable object created for this animation
  16168. */
  16169. 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;
  16170. /**
  16171. * Will start the animation sequence of a given target
  16172. * @param target defines the target
  16173. * @param from defines from which frame should animation start
  16174. * @param to defines until which frame should animation run.
  16175. * @param loop defines if the animation loops
  16176. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16177. * @param onAnimationEnd defines the function to be executed when the animation ends
  16178. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16179. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16180. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16181. * @param onAnimationLoop defines the callback to call when an animation loops
  16182. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16183. * @returns the animatable object created for this animation
  16184. */
  16185. 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;
  16186. /**
  16187. * Will start the animation sequence of a given target and its hierarchy
  16188. * @param target defines the target
  16189. * @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.
  16190. * @param from defines from which frame should animation start
  16191. * @param to defines until which frame should animation run.
  16192. * @param loop defines if the animation loops
  16193. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16194. * @param onAnimationEnd defines the function to be executed when the animation ends
  16195. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16196. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16197. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16198. * @param onAnimationLoop defines the callback to call when an animation loops
  16199. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16200. * @returns the list of created animatables
  16201. */
  16202. 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[];
  16203. /**
  16204. * Begin a new animation on a given node
  16205. * @param target defines the target where the animation will take place
  16206. * @param animations defines the list of animations to start
  16207. * @param from defines the initial value
  16208. * @param to defines the final value
  16209. * @param loop defines if you want animation to loop (off by default)
  16210. * @param speedRatio defines the speed ratio to apply to all animations
  16211. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16212. * @param onAnimationLoop defines the callback to call when an animation loops
  16213. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16214. * @returns the list of created animatables
  16215. */
  16216. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16217. /**
  16218. * Begin a new animation on a given node and its hierarchy
  16219. * @param target defines the root node where the animation will take place
  16220. * @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.
  16221. * @param animations defines the list of animations to start
  16222. * @param from defines the initial value
  16223. * @param to defines the final value
  16224. * @param loop defines if you want animation to loop (off by default)
  16225. * @param speedRatio defines the speed ratio to apply to all animations
  16226. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16227. * @param onAnimationLoop defines the callback to call when an animation loops
  16228. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16229. * @returns the list of animatables created for all nodes
  16230. */
  16231. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16232. /**
  16233. * Gets the animatable associated with a specific target
  16234. * @param target defines the target of the animatable
  16235. * @returns the required animatable if found
  16236. */
  16237. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16238. /**
  16239. * Gets all animatables associated with a given target
  16240. * @param target defines the target to look animatables for
  16241. * @returns an array of Animatables
  16242. */
  16243. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16244. /**
  16245. * Stops and removes all animations that have been applied to the scene
  16246. */
  16247. stopAllAnimations(): void;
  16248. /**
  16249. * Gets the current delta time used by animation engine
  16250. */
  16251. deltaTime: number;
  16252. }
  16253. }
  16254. module "babylonjs/Bones/bone" {
  16255. interface Bone {
  16256. /**
  16257. * Copy an animation range from another bone
  16258. * @param source defines the source bone
  16259. * @param rangeName defines the range name to copy
  16260. * @param frameOffset defines the frame offset
  16261. * @param rescaleAsRequired defines if rescaling must be applied if required
  16262. * @param skelDimensionsRatio defines the scaling ratio
  16263. * @returns true if operation was successful
  16264. */
  16265. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16266. }
  16267. }
  16268. }
  16269. declare module "babylonjs/Bones/skeleton" {
  16270. import { Bone } from "babylonjs/Bones/bone";
  16271. import { Observable } from "babylonjs/Misc/observable";
  16272. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16273. import { Scene } from "babylonjs/scene";
  16274. import { Nullable } from "babylonjs/types";
  16275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16276. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16277. import { Animatable } from "babylonjs/Animations/animatable";
  16278. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16279. import { Animation } from "babylonjs/Animations/animation";
  16280. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16281. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16282. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16283. /**
  16284. * Class used to handle skinning animations
  16285. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16286. */
  16287. export class Skeleton implements IAnimatable {
  16288. /** defines the skeleton name */
  16289. name: string;
  16290. /** defines the skeleton Id */
  16291. id: string;
  16292. /**
  16293. * Defines the list of child bones
  16294. */
  16295. bones: Bone[];
  16296. /**
  16297. * Defines an estimate of the dimension of the skeleton at rest
  16298. */
  16299. dimensionsAtRest: Vector3;
  16300. /**
  16301. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16302. */
  16303. needInitialSkinMatrix: boolean;
  16304. /**
  16305. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16306. */
  16307. overrideMesh: Nullable<AbstractMesh>;
  16308. /**
  16309. * Gets the list of animations attached to this skeleton
  16310. */
  16311. animations: Array<Animation>;
  16312. private _scene;
  16313. private _isDirty;
  16314. private _transformMatrices;
  16315. private _transformMatrixTexture;
  16316. private _meshesWithPoseMatrix;
  16317. private _animatables;
  16318. private _identity;
  16319. private _synchronizedWithMesh;
  16320. private _ranges;
  16321. private _lastAbsoluteTransformsUpdateId;
  16322. private _canUseTextureForBones;
  16323. private _uniqueId;
  16324. /** @hidden */
  16325. _numBonesWithLinkedTransformNode: number;
  16326. /** @hidden */
  16327. _hasWaitingData: Nullable<boolean>;
  16328. /**
  16329. * Specifies if the skeleton should be serialized
  16330. */
  16331. doNotSerialize: boolean;
  16332. private _useTextureToStoreBoneMatrices;
  16333. /**
  16334. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16335. * Please note that this option is not available if the hardware does not support it
  16336. */
  16337. get useTextureToStoreBoneMatrices(): boolean;
  16338. set useTextureToStoreBoneMatrices(value: boolean);
  16339. private _animationPropertiesOverride;
  16340. /**
  16341. * Gets or sets the animation properties override
  16342. */
  16343. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16344. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16345. /**
  16346. * List of inspectable custom properties (used by the Inspector)
  16347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16348. */
  16349. inspectableCustomProperties: IInspectable[];
  16350. /**
  16351. * An observable triggered before computing the skeleton's matrices
  16352. */
  16353. onBeforeComputeObservable: Observable<Skeleton>;
  16354. /**
  16355. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16356. */
  16357. get isUsingTextureForMatrices(): boolean;
  16358. /**
  16359. * Gets the unique ID of this skeleton
  16360. */
  16361. get uniqueId(): number;
  16362. /**
  16363. * Creates a new skeleton
  16364. * @param name defines the skeleton name
  16365. * @param id defines the skeleton Id
  16366. * @param scene defines the hosting scene
  16367. */
  16368. constructor(
  16369. /** defines the skeleton name */
  16370. name: string,
  16371. /** defines the skeleton Id */
  16372. id: string, scene: Scene);
  16373. /**
  16374. * Gets the current object class name.
  16375. * @return the class name
  16376. */
  16377. getClassName(): string;
  16378. /**
  16379. * Returns an array containing the root bones
  16380. * @returns an array containing the root bones
  16381. */
  16382. getChildren(): Array<Bone>;
  16383. /**
  16384. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16385. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16386. * @returns a Float32Array containing matrices data
  16387. */
  16388. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16389. /**
  16390. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16391. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16392. * @returns a raw texture containing the data
  16393. */
  16394. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16395. /**
  16396. * Gets the current hosting scene
  16397. * @returns a scene object
  16398. */
  16399. getScene(): Scene;
  16400. /**
  16401. * Gets a string representing the current skeleton data
  16402. * @param fullDetails defines a boolean indicating if we want a verbose version
  16403. * @returns a string representing the current skeleton data
  16404. */
  16405. toString(fullDetails?: boolean): string;
  16406. /**
  16407. * Get bone's index searching by name
  16408. * @param name defines bone's name to search for
  16409. * @return the indice of the bone. Returns -1 if not found
  16410. */
  16411. getBoneIndexByName(name: string): number;
  16412. /**
  16413. * Creater a new animation range
  16414. * @param name defines the name of the range
  16415. * @param from defines the start key
  16416. * @param to defines the end key
  16417. */
  16418. createAnimationRange(name: string, from: number, to: number): void;
  16419. /**
  16420. * Delete a specific animation range
  16421. * @param name defines the name of the range
  16422. * @param deleteFrames defines if frames must be removed as well
  16423. */
  16424. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16425. /**
  16426. * Gets a specific animation range
  16427. * @param name defines the name of the range to look for
  16428. * @returns the requested animation range or null if not found
  16429. */
  16430. getAnimationRange(name: string): Nullable<AnimationRange>;
  16431. /**
  16432. * Gets the list of all animation ranges defined on this skeleton
  16433. * @returns an array
  16434. */
  16435. getAnimationRanges(): Nullable<AnimationRange>[];
  16436. /**
  16437. * Copy animation range from a source skeleton.
  16438. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16439. * @param source defines the source skeleton
  16440. * @param name defines the name of the range to copy
  16441. * @param rescaleAsRequired defines if rescaling must be applied if required
  16442. * @returns true if operation was successful
  16443. */
  16444. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16445. /**
  16446. * Forces the skeleton to go to rest pose
  16447. */
  16448. returnToRest(): void;
  16449. private _getHighestAnimationFrame;
  16450. /**
  16451. * Begin a specific animation range
  16452. * @param name defines the name of the range to start
  16453. * @param loop defines if looping must be turned on (false by default)
  16454. * @param speedRatio defines the speed ratio to apply (1 by default)
  16455. * @param onAnimationEnd defines a callback which will be called when animation will end
  16456. * @returns a new animatable
  16457. */
  16458. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16459. /**
  16460. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16461. * @param skeleton defines the Skeleton containing the animation range to convert
  16462. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16463. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16464. * @returns the original skeleton
  16465. */
  16466. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16467. /** @hidden */
  16468. _markAsDirty(): void;
  16469. /** @hidden */
  16470. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16471. /** @hidden */
  16472. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16473. private _computeTransformMatrices;
  16474. /**
  16475. * Build all resources required to render a skeleton
  16476. */
  16477. prepare(): void;
  16478. /**
  16479. * Gets the list of animatables currently running for this skeleton
  16480. * @returns an array of animatables
  16481. */
  16482. getAnimatables(): IAnimatable[];
  16483. /**
  16484. * Clone the current skeleton
  16485. * @param name defines the name of the new skeleton
  16486. * @param id defines the id of the new skeleton
  16487. * @returns the new skeleton
  16488. */
  16489. clone(name: string, id?: string): Skeleton;
  16490. /**
  16491. * Enable animation blending for this skeleton
  16492. * @param blendingSpeed defines the blending speed to apply
  16493. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16494. */
  16495. enableBlending(blendingSpeed?: number): void;
  16496. /**
  16497. * Releases all resources associated with the current skeleton
  16498. */
  16499. dispose(): void;
  16500. /**
  16501. * Serialize the skeleton in a JSON object
  16502. * @returns a JSON object
  16503. */
  16504. serialize(): any;
  16505. /**
  16506. * Creates a new skeleton from serialized data
  16507. * @param parsedSkeleton defines the serialized data
  16508. * @param scene defines the hosting scene
  16509. * @returns a new skeleton
  16510. */
  16511. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16512. /**
  16513. * Compute all node absolute transforms
  16514. * @param forceUpdate defines if computation must be done even if cache is up to date
  16515. */
  16516. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16517. /**
  16518. * Gets the root pose matrix
  16519. * @returns a matrix
  16520. */
  16521. getPoseMatrix(): Nullable<Matrix>;
  16522. /**
  16523. * Sorts bones per internal index
  16524. */
  16525. sortBones(): void;
  16526. private _sortBones;
  16527. }
  16528. }
  16529. declare module "babylonjs/Meshes/instancedMesh" {
  16530. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16531. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16532. import { Camera } from "babylonjs/Cameras/camera";
  16533. import { Node } from "babylonjs/node";
  16534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16535. import { Mesh } from "babylonjs/Meshes/mesh";
  16536. import { Material } from "babylonjs/Materials/material";
  16537. import { Skeleton } from "babylonjs/Bones/skeleton";
  16538. import { Light } from "babylonjs/Lights/light";
  16539. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16540. /**
  16541. * Creates an instance based on a source mesh.
  16542. */
  16543. export class InstancedMesh extends AbstractMesh {
  16544. private _sourceMesh;
  16545. private _currentLOD;
  16546. /** @hidden */
  16547. _indexInSourceMeshInstanceArray: number;
  16548. constructor(name: string, source: Mesh);
  16549. /**
  16550. * Returns the string "InstancedMesh".
  16551. */
  16552. getClassName(): string;
  16553. /** Gets the list of lights affecting that mesh */
  16554. get lightSources(): Light[];
  16555. _resyncLightSources(): void;
  16556. _resyncLightSource(light: Light): void;
  16557. _removeLightSource(light: Light, dispose: boolean): void;
  16558. /**
  16559. * If the source mesh receives shadows
  16560. */
  16561. get receiveShadows(): boolean;
  16562. /**
  16563. * The material of the source mesh
  16564. */
  16565. get material(): Nullable<Material>;
  16566. /**
  16567. * Visibility of the source mesh
  16568. */
  16569. get visibility(): number;
  16570. /**
  16571. * Skeleton of the source mesh
  16572. */
  16573. get skeleton(): Nullable<Skeleton>;
  16574. /**
  16575. * Rendering ground id of the source mesh
  16576. */
  16577. get renderingGroupId(): number;
  16578. set renderingGroupId(value: number);
  16579. /**
  16580. * Returns the total number of vertices (integer).
  16581. */
  16582. getTotalVertices(): number;
  16583. /**
  16584. * Returns a positive integer : the total number of indices in this mesh geometry.
  16585. * @returns the numner of indices or zero if the mesh has no geometry.
  16586. */
  16587. getTotalIndices(): number;
  16588. /**
  16589. * The source mesh of the instance
  16590. */
  16591. get sourceMesh(): Mesh;
  16592. /**
  16593. * Creates a new InstancedMesh object from the mesh model.
  16594. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16595. * @param name defines the name of the new instance
  16596. * @returns a new InstancedMesh
  16597. */
  16598. createInstance(name: string): InstancedMesh;
  16599. /**
  16600. * Is this node ready to be used/rendered
  16601. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16602. * @return {boolean} is it ready
  16603. */
  16604. isReady(completeCheck?: boolean): boolean;
  16605. /**
  16606. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16607. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16608. * @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.
  16609. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16610. */
  16611. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16612. /**
  16613. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16614. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16615. * The `data` are either a numeric array either a Float32Array.
  16616. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16617. * 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).
  16618. * Note that a new underlying VertexBuffer object is created each call.
  16619. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16620. *
  16621. * Possible `kind` values :
  16622. * - VertexBuffer.PositionKind
  16623. * - VertexBuffer.UVKind
  16624. * - VertexBuffer.UV2Kind
  16625. * - VertexBuffer.UV3Kind
  16626. * - VertexBuffer.UV4Kind
  16627. * - VertexBuffer.UV5Kind
  16628. * - VertexBuffer.UV6Kind
  16629. * - VertexBuffer.ColorKind
  16630. * - VertexBuffer.MatricesIndicesKind
  16631. * - VertexBuffer.MatricesIndicesExtraKind
  16632. * - VertexBuffer.MatricesWeightsKind
  16633. * - VertexBuffer.MatricesWeightsExtraKind
  16634. *
  16635. * Returns the Mesh.
  16636. */
  16637. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16638. /**
  16639. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16640. * If the mesh has no geometry, it is simply returned as it is.
  16641. * The `data` are either a numeric array either a Float32Array.
  16642. * No new underlying VertexBuffer object is created.
  16643. * 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.
  16644. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16645. *
  16646. * Possible `kind` values :
  16647. * - VertexBuffer.PositionKind
  16648. * - VertexBuffer.UVKind
  16649. * - VertexBuffer.UV2Kind
  16650. * - VertexBuffer.UV3Kind
  16651. * - VertexBuffer.UV4Kind
  16652. * - VertexBuffer.UV5Kind
  16653. * - VertexBuffer.UV6Kind
  16654. * - VertexBuffer.ColorKind
  16655. * - VertexBuffer.MatricesIndicesKind
  16656. * - VertexBuffer.MatricesIndicesExtraKind
  16657. * - VertexBuffer.MatricesWeightsKind
  16658. * - VertexBuffer.MatricesWeightsExtraKind
  16659. *
  16660. * Returns the Mesh.
  16661. */
  16662. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16663. /**
  16664. * Sets the mesh indices.
  16665. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16666. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16667. * This method creates a new index buffer each call.
  16668. * Returns the Mesh.
  16669. */
  16670. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16671. /**
  16672. * Boolean : True if the mesh owns the requested kind of data.
  16673. */
  16674. isVerticesDataPresent(kind: string): boolean;
  16675. /**
  16676. * Returns an array of indices (IndicesArray).
  16677. */
  16678. getIndices(): Nullable<IndicesArray>;
  16679. get _positions(): Nullable<Vector3[]>;
  16680. /**
  16681. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16682. * This means the mesh underlying bounding box and sphere are recomputed.
  16683. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16684. * @returns the current mesh
  16685. */
  16686. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16687. /** @hidden */
  16688. _preActivate(): InstancedMesh;
  16689. /** @hidden */
  16690. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16691. /** @hidden */
  16692. _postActivate(): void;
  16693. getWorldMatrix(): Matrix;
  16694. get isAnInstance(): boolean;
  16695. /**
  16696. * Returns the current associated LOD AbstractMesh.
  16697. */
  16698. getLOD(camera: Camera): AbstractMesh;
  16699. /** @hidden */
  16700. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16701. /** @hidden */
  16702. _syncSubMeshes(): InstancedMesh;
  16703. /** @hidden */
  16704. _generatePointsArray(): boolean;
  16705. /**
  16706. * Creates a new InstancedMesh from the current mesh.
  16707. * - name (string) : the cloned mesh name
  16708. * - newParent (optional Node) : the optional Node to parent the clone to.
  16709. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16710. *
  16711. * Returns the clone.
  16712. */
  16713. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16714. /**
  16715. * Disposes the InstancedMesh.
  16716. * Returns nothing.
  16717. */
  16718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16719. }
  16720. module "babylonjs/Meshes/mesh" {
  16721. interface Mesh {
  16722. /**
  16723. * Register a custom buffer that will be instanced
  16724. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16725. * @param kind defines the buffer kind
  16726. * @param stride defines the stride in floats
  16727. */
  16728. registerInstancedBuffer(kind: string, stride: number): void;
  16729. /**
  16730. * true to use the edge renderer for all instances of this mesh
  16731. */
  16732. edgesShareWithInstances: boolean;
  16733. /** @hidden */
  16734. _userInstancedBuffersStorage: {
  16735. data: {
  16736. [key: string]: Float32Array;
  16737. };
  16738. sizes: {
  16739. [key: string]: number;
  16740. };
  16741. vertexBuffers: {
  16742. [key: string]: Nullable<VertexBuffer>;
  16743. };
  16744. strides: {
  16745. [key: string]: number;
  16746. };
  16747. };
  16748. }
  16749. }
  16750. module "babylonjs/Meshes/abstractMesh" {
  16751. interface AbstractMesh {
  16752. /**
  16753. * Object used to store instanced buffers defined by user
  16754. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16755. */
  16756. instancedBuffers: {
  16757. [key: string]: any;
  16758. };
  16759. }
  16760. }
  16761. }
  16762. declare module "babylonjs/Materials/shaderMaterial" {
  16763. import { Nullable } from "babylonjs/types";
  16764. import { Scene } from "babylonjs/scene";
  16765. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16767. import { Mesh } from "babylonjs/Meshes/mesh";
  16768. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16770. import { Effect } from "babylonjs/Materials/effect";
  16771. import { Material } from "babylonjs/Materials/material";
  16772. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16773. /**
  16774. * Defines the options associated with the creation of a shader material.
  16775. */
  16776. export interface IShaderMaterialOptions {
  16777. /**
  16778. * Does the material work in alpha blend mode
  16779. */
  16780. needAlphaBlending: boolean;
  16781. /**
  16782. * Does the material work in alpha test mode
  16783. */
  16784. needAlphaTesting: boolean;
  16785. /**
  16786. * The list of attribute names used in the shader
  16787. */
  16788. attributes: string[];
  16789. /**
  16790. * The list of unifrom names used in the shader
  16791. */
  16792. uniforms: string[];
  16793. /**
  16794. * The list of UBO names used in the shader
  16795. */
  16796. uniformBuffers: string[];
  16797. /**
  16798. * The list of sampler names used in the shader
  16799. */
  16800. samplers: string[];
  16801. /**
  16802. * The list of defines used in the shader
  16803. */
  16804. defines: string[];
  16805. }
  16806. /**
  16807. * 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.
  16808. *
  16809. * This returned material effects how the mesh will look based on the code in the shaders.
  16810. *
  16811. * @see http://doc.babylonjs.com/how_to/shader_material
  16812. */
  16813. export class ShaderMaterial extends Material {
  16814. private _shaderPath;
  16815. private _options;
  16816. private _textures;
  16817. private _textureArrays;
  16818. private _floats;
  16819. private _ints;
  16820. private _floatsArrays;
  16821. private _colors3;
  16822. private _colors3Arrays;
  16823. private _colors4;
  16824. private _colors4Arrays;
  16825. private _vectors2;
  16826. private _vectors3;
  16827. private _vectors4;
  16828. private _matrices;
  16829. private _matrixArrays;
  16830. private _matrices3x3;
  16831. private _matrices2x2;
  16832. private _vectors2Arrays;
  16833. private _vectors3Arrays;
  16834. private _vectors4Arrays;
  16835. private _cachedWorldViewMatrix;
  16836. private _cachedWorldViewProjectionMatrix;
  16837. private _renderId;
  16838. private _multiview;
  16839. private _cachedDefines;
  16840. /** Define the Url to load snippets */
  16841. static SnippetUrl: string;
  16842. /** Snippet ID if the material was created from the snippet server */
  16843. snippetId: string;
  16844. /**
  16845. * Instantiate a new shader material.
  16846. * 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.
  16847. * This returned material effects how the mesh will look based on the code in the shaders.
  16848. * @see http://doc.babylonjs.com/how_to/shader_material
  16849. * @param name Define the name of the material in the scene
  16850. * @param scene Define the scene the material belongs to
  16851. * @param shaderPath Defines the route to the shader code in one of three ways:
  16852. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16853. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16854. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16855. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16856. * @param options Define the options used to create the shader
  16857. */
  16858. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16859. /**
  16860. * Gets the shader path used to define the shader code
  16861. * It can be modified to trigger a new compilation
  16862. */
  16863. get shaderPath(): any;
  16864. /**
  16865. * Sets the shader path used to define the shader code
  16866. * It can be modified to trigger a new compilation
  16867. */
  16868. set shaderPath(shaderPath: any);
  16869. /**
  16870. * Gets the options used to compile the shader.
  16871. * They can be modified to trigger a new compilation
  16872. */
  16873. get options(): IShaderMaterialOptions;
  16874. /**
  16875. * Gets the current class name of the material e.g. "ShaderMaterial"
  16876. * Mainly use in serialization.
  16877. * @returns the class name
  16878. */
  16879. getClassName(): string;
  16880. /**
  16881. * Specifies if the material will require alpha blending
  16882. * @returns a boolean specifying if alpha blending is needed
  16883. */
  16884. needAlphaBlending(): boolean;
  16885. /**
  16886. * Specifies if this material should be rendered in alpha test mode
  16887. * @returns a boolean specifying if an alpha test is needed.
  16888. */
  16889. needAlphaTesting(): boolean;
  16890. private _checkUniform;
  16891. /**
  16892. * Set a texture in the shader.
  16893. * @param name Define the name of the uniform samplers as defined in the shader
  16894. * @param texture Define the texture to bind to this sampler
  16895. * @return the material itself allowing "fluent" like uniform updates
  16896. */
  16897. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16898. /**
  16899. * Set a texture array in the shader.
  16900. * @param name Define the name of the uniform sampler array as defined in the shader
  16901. * @param textures Define the list of textures to bind to this sampler
  16902. * @return the material itself allowing "fluent" like uniform updates
  16903. */
  16904. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16905. /**
  16906. * Set a float in the shader.
  16907. * @param name Define the name of the uniform as defined in the shader
  16908. * @param value Define the value to give to the uniform
  16909. * @return the material itself allowing "fluent" like uniform updates
  16910. */
  16911. setFloat(name: string, value: number): ShaderMaterial;
  16912. /**
  16913. * Set a int in the shader.
  16914. * @param name Define the name of the uniform as defined in the shader
  16915. * @param value Define the value to give to the uniform
  16916. * @return the material itself allowing "fluent" like uniform updates
  16917. */
  16918. setInt(name: string, value: number): ShaderMaterial;
  16919. /**
  16920. * Set an array of floats in the shader.
  16921. * @param name Define the name of the uniform as defined in the shader
  16922. * @param value Define the value to give to the uniform
  16923. * @return the material itself allowing "fluent" like uniform updates
  16924. */
  16925. setFloats(name: string, value: number[]): ShaderMaterial;
  16926. /**
  16927. * Set a vec3 in the shader from a Color3.
  16928. * @param name Define the name of the uniform as defined in the shader
  16929. * @param value Define the value to give to the uniform
  16930. * @return the material itself allowing "fluent" like uniform updates
  16931. */
  16932. setColor3(name: string, value: Color3): ShaderMaterial;
  16933. /**
  16934. * Set a vec3 array in the shader from a Color3 array.
  16935. * @param name Define the name of the uniform as defined in the shader
  16936. * @param value Define the value to give to the uniform
  16937. * @return the material itself allowing "fluent" like uniform updates
  16938. */
  16939. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16940. /**
  16941. * Set a vec4 in the shader from a Color4.
  16942. * @param name Define the name of the uniform as defined in the shader
  16943. * @param value Define the value to give to the uniform
  16944. * @return the material itself allowing "fluent" like uniform updates
  16945. */
  16946. setColor4(name: string, value: Color4): ShaderMaterial;
  16947. /**
  16948. * Set a vec4 array in the shader from a Color4 array.
  16949. * @param name Define the name of the uniform as defined in the shader
  16950. * @param value Define the value to give to the uniform
  16951. * @return the material itself allowing "fluent" like uniform updates
  16952. */
  16953. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16954. /**
  16955. * Set a vec2 in the shader from a Vector2.
  16956. * @param name Define the name of the uniform as defined in the shader
  16957. * @param value Define the value to give to the uniform
  16958. * @return the material itself allowing "fluent" like uniform updates
  16959. */
  16960. setVector2(name: string, value: Vector2): ShaderMaterial;
  16961. /**
  16962. * Set a vec3 in the shader from a Vector3.
  16963. * @param name Define the name of the uniform as defined in the shader
  16964. * @param value Define the value to give to the uniform
  16965. * @return the material itself allowing "fluent" like uniform updates
  16966. */
  16967. setVector3(name: string, value: Vector3): ShaderMaterial;
  16968. /**
  16969. * Set a vec4 in the shader from a Vector4.
  16970. * @param name Define the name of the uniform as defined in the shader
  16971. * @param value Define the value to give to the uniform
  16972. * @return the material itself allowing "fluent" like uniform updates
  16973. */
  16974. setVector4(name: string, value: Vector4): ShaderMaterial;
  16975. /**
  16976. * Set a mat4 in the shader from a Matrix.
  16977. * @param name Define the name of the uniform as defined in the shader
  16978. * @param value Define the value to give to the uniform
  16979. * @return the material itself allowing "fluent" like uniform updates
  16980. */
  16981. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16982. /**
  16983. * Set a float32Array in the shader from a matrix array.
  16984. * @param name Define the name of the uniform as defined in the shader
  16985. * @param value Define the value to give to the uniform
  16986. * @return the material itself allowing "fluent" like uniform updates
  16987. */
  16988. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16989. /**
  16990. * Set a mat3 in the shader from a Float32Array.
  16991. * @param name Define the name of the uniform as defined in the shader
  16992. * @param value Define the value to give to the uniform
  16993. * @return the material itself allowing "fluent" like uniform updates
  16994. */
  16995. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16996. /**
  16997. * Set a mat2 in the shader from a Float32Array.
  16998. * @param name Define the name of the uniform as defined in the shader
  16999. * @param value Define the value to give to the uniform
  17000. * @return the material itself allowing "fluent" like uniform updates
  17001. */
  17002. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17003. /**
  17004. * Set a vec2 array in the shader from a number array.
  17005. * @param name Define the name of the uniform as defined in the shader
  17006. * @param value Define the value to give to the uniform
  17007. * @return the material itself allowing "fluent" like uniform updates
  17008. */
  17009. setArray2(name: string, value: number[]): ShaderMaterial;
  17010. /**
  17011. * Set a vec3 array in the shader from a number array.
  17012. * @param name Define the name of the uniform as defined in the shader
  17013. * @param value Define the value to give to the uniform
  17014. * @return the material itself allowing "fluent" like uniform updates
  17015. */
  17016. setArray3(name: string, value: number[]): ShaderMaterial;
  17017. /**
  17018. * Set a vec4 array in the shader from a number array.
  17019. * @param name Define the name of the uniform as defined in the shader
  17020. * @param value Define the value to give to the uniform
  17021. * @return the material itself allowing "fluent" like uniform updates
  17022. */
  17023. setArray4(name: string, value: number[]): ShaderMaterial;
  17024. private _checkCache;
  17025. /**
  17026. * Specifies that the submesh is ready to be used
  17027. * @param mesh defines the mesh to check
  17028. * @param subMesh defines which submesh to check
  17029. * @param useInstances specifies that instances should be used
  17030. * @returns a boolean indicating that the submesh is ready or not
  17031. */
  17032. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17033. /**
  17034. * Checks if the material is ready to render the requested mesh
  17035. * @param mesh Define the mesh to render
  17036. * @param useInstances Define whether or not the material is used with instances
  17037. * @returns true if ready, otherwise false
  17038. */
  17039. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17040. /**
  17041. * Binds the world matrix to the material
  17042. * @param world defines the world transformation matrix
  17043. * @param effectOverride - If provided, use this effect instead of internal effect
  17044. */
  17045. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17046. /**
  17047. * Binds the submesh to this material by preparing the effect and shader to draw
  17048. * @param world defines the world transformation matrix
  17049. * @param mesh defines the mesh containing the submesh
  17050. * @param subMesh defines the submesh to bind the material to
  17051. */
  17052. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17053. /**
  17054. * Binds the material to the mesh
  17055. * @param world defines the world transformation matrix
  17056. * @param mesh defines the mesh to bind the material to
  17057. * @param effectOverride - If provided, use this effect instead of internal effect
  17058. */
  17059. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17060. protected _afterBind(mesh?: Mesh): void;
  17061. /**
  17062. * Gets the active textures from the material
  17063. * @returns an array of textures
  17064. */
  17065. getActiveTextures(): BaseTexture[];
  17066. /**
  17067. * Specifies if the material uses a texture
  17068. * @param texture defines the texture to check against the material
  17069. * @returns a boolean specifying if the material uses the texture
  17070. */
  17071. hasTexture(texture: BaseTexture): boolean;
  17072. /**
  17073. * Makes a duplicate of the material, and gives it a new name
  17074. * @param name defines the new name for the duplicated material
  17075. * @returns the cloned material
  17076. */
  17077. clone(name: string): ShaderMaterial;
  17078. /**
  17079. * Disposes the material
  17080. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17081. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17082. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17083. */
  17084. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17085. /**
  17086. * Serializes this material in a JSON representation
  17087. * @returns the serialized material object
  17088. */
  17089. serialize(): any;
  17090. /**
  17091. * Creates a shader material from parsed shader material data
  17092. * @param source defines the JSON represnetation of the material
  17093. * @param scene defines the hosting scene
  17094. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17095. * @returns a new material
  17096. */
  17097. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17098. /**
  17099. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17100. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17101. * @param url defines the url to load from
  17102. * @param scene defines the hosting scene
  17103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17104. * @returns a promise that will resolve to the new ShaderMaterial
  17105. */
  17106. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17107. /**
  17108. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17109. * @param snippetId defines the snippet to load
  17110. * @param scene defines the hosting scene
  17111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17112. * @returns a promise that will resolve to the new ShaderMaterial
  17113. */
  17114. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17115. }
  17116. }
  17117. declare module "babylonjs/Shaders/color.fragment" {
  17118. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17119. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17120. /** @hidden */
  17121. export var colorPixelShader: {
  17122. name: string;
  17123. shader: string;
  17124. };
  17125. }
  17126. declare module "babylonjs/Shaders/color.vertex" {
  17127. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17128. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17129. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17130. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17131. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17132. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17133. /** @hidden */
  17134. export var colorVertexShader: {
  17135. name: string;
  17136. shader: string;
  17137. };
  17138. }
  17139. declare module "babylonjs/Meshes/linesMesh" {
  17140. import { Nullable } from "babylonjs/types";
  17141. import { Scene } from "babylonjs/scene";
  17142. import { Color3 } from "babylonjs/Maths/math.color";
  17143. import { Node } from "babylonjs/node";
  17144. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17145. import { Mesh } from "babylonjs/Meshes/mesh";
  17146. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17147. import { Effect } from "babylonjs/Materials/effect";
  17148. import { Material } from "babylonjs/Materials/material";
  17149. import "babylonjs/Shaders/color.fragment";
  17150. import "babylonjs/Shaders/color.vertex";
  17151. /**
  17152. * Line mesh
  17153. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17154. */
  17155. export class LinesMesh extends Mesh {
  17156. /**
  17157. * If vertex color should be applied to the mesh
  17158. */
  17159. readonly useVertexColor?: boolean | undefined;
  17160. /**
  17161. * If vertex alpha should be applied to the mesh
  17162. */
  17163. readonly useVertexAlpha?: boolean | undefined;
  17164. /**
  17165. * Color of the line (Default: White)
  17166. */
  17167. color: Color3;
  17168. /**
  17169. * Alpha of the line (Default: 1)
  17170. */
  17171. alpha: number;
  17172. /**
  17173. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17174. * This margin is expressed in world space coordinates, so its value may vary.
  17175. * Default value is 0.1
  17176. */
  17177. intersectionThreshold: number;
  17178. private _colorShader;
  17179. private color4;
  17180. /**
  17181. * Creates a new LinesMesh
  17182. * @param name defines the name
  17183. * @param scene defines the hosting scene
  17184. * @param parent defines the parent mesh if any
  17185. * @param source defines the optional source LinesMesh used to clone data from
  17186. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17187. * When false, achieved by calling a clone(), also passing False.
  17188. * This will make creation of children, recursive.
  17189. * @param useVertexColor defines if this LinesMesh supports vertex color
  17190. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17191. */
  17192. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17193. /**
  17194. * If vertex color should be applied to the mesh
  17195. */
  17196. useVertexColor?: boolean | undefined,
  17197. /**
  17198. * If vertex alpha should be applied to the mesh
  17199. */
  17200. useVertexAlpha?: boolean | undefined);
  17201. private _addClipPlaneDefine;
  17202. private _removeClipPlaneDefine;
  17203. isReady(): boolean;
  17204. /**
  17205. * Returns the string "LineMesh"
  17206. */
  17207. getClassName(): string;
  17208. /**
  17209. * @hidden
  17210. */
  17211. get material(): Material;
  17212. /**
  17213. * @hidden
  17214. */
  17215. set material(value: Material);
  17216. /**
  17217. * @hidden
  17218. */
  17219. get checkCollisions(): boolean;
  17220. /** @hidden */
  17221. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17222. /** @hidden */
  17223. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17224. /**
  17225. * Disposes of the line mesh
  17226. * @param doNotRecurse If children should be disposed
  17227. */
  17228. dispose(doNotRecurse?: boolean): void;
  17229. /**
  17230. * Returns a new LineMesh object cloned from the current one.
  17231. */
  17232. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17233. /**
  17234. * Creates a new InstancedLinesMesh object from the mesh model.
  17235. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17236. * @param name defines the name of the new instance
  17237. * @returns a new InstancedLinesMesh
  17238. */
  17239. createInstance(name: string): InstancedLinesMesh;
  17240. }
  17241. /**
  17242. * Creates an instance based on a source LinesMesh
  17243. */
  17244. export class InstancedLinesMesh extends InstancedMesh {
  17245. /**
  17246. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17247. * This margin is expressed in world space coordinates, so its value may vary.
  17248. * Initilized with the intersectionThreshold value of the source LinesMesh
  17249. */
  17250. intersectionThreshold: number;
  17251. constructor(name: string, source: LinesMesh);
  17252. /**
  17253. * Returns the string "InstancedLinesMesh".
  17254. */
  17255. getClassName(): string;
  17256. }
  17257. }
  17258. declare module "babylonjs/Shaders/line.fragment" {
  17259. /** @hidden */
  17260. export var linePixelShader: {
  17261. name: string;
  17262. shader: string;
  17263. };
  17264. }
  17265. declare module "babylonjs/Shaders/line.vertex" {
  17266. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17267. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17268. /** @hidden */
  17269. export var lineVertexShader: {
  17270. name: string;
  17271. shader: string;
  17272. };
  17273. }
  17274. declare module "babylonjs/Rendering/edgesRenderer" {
  17275. import { Nullable } from "babylonjs/types";
  17276. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17278. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17279. import { IDisposable } from "babylonjs/scene";
  17280. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17281. import "babylonjs/Shaders/line.fragment";
  17282. import "babylonjs/Shaders/line.vertex";
  17283. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17284. import { SmartArray } from "babylonjs/Misc/smartArray";
  17285. module "babylonjs/scene" {
  17286. interface Scene {
  17287. /** @hidden */
  17288. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17289. }
  17290. }
  17291. module "babylonjs/Meshes/abstractMesh" {
  17292. interface AbstractMesh {
  17293. /**
  17294. * Gets the edgesRenderer associated with the mesh
  17295. */
  17296. edgesRenderer: Nullable<EdgesRenderer>;
  17297. }
  17298. }
  17299. module "babylonjs/Meshes/linesMesh" {
  17300. interface LinesMesh {
  17301. /**
  17302. * Enables the edge rendering mode on the mesh.
  17303. * This mode makes the mesh edges visible
  17304. * @param epsilon defines the maximal distance between two angles to detect a face
  17305. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17306. * @returns the currentAbstractMesh
  17307. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17308. */
  17309. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17310. }
  17311. }
  17312. module "babylonjs/Meshes/linesMesh" {
  17313. interface InstancedLinesMesh {
  17314. /**
  17315. * Enables the edge rendering mode on the mesh.
  17316. * This mode makes the mesh edges visible
  17317. * @param epsilon defines the maximal distance between two angles to detect a face
  17318. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17319. * @returns the current InstancedLinesMesh
  17320. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17321. */
  17322. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17323. }
  17324. }
  17325. /**
  17326. * Defines the minimum contract an Edges renderer should follow.
  17327. */
  17328. export interface IEdgesRenderer extends IDisposable {
  17329. /**
  17330. * Gets or sets a boolean indicating if the edgesRenderer is active
  17331. */
  17332. isEnabled: boolean;
  17333. /**
  17334. * Renders the edges of the attached mesh,
  17335. */
  17336. render(): void;
  17337. /**
  17338. * Checks wether or not the edges renderer is ready to render.
  17339. * @return true if ready, otherwise false.
  17340. */
  17341. isReady(): boolean;
  17342. /**
  17343. * List of instances to render in case the source mesh has instances
  17344. */
  17345. customInstances: SmartArray<Matrix>;
  17346. }
  17347. /**
  17348. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17349. */
  17350. export class EdgesRenderer implements IEdgesRenderer {
  17351. /**
  17352. * Define the size of the edges with an orthographic camera
  17353. */
  17354. edgesWidthScalerForOrthographic: number;
  17355. /**
  17356. * Define the size of the edges with a perspective camera
  17357. */
  17358. edgesWidthScalerForPerspective: number;
  17359. protected _source: AbstractMesh;
  17360. protected _linesPositions: number[];
  17361. protected _linesNormals: number[];
  17362. protected _linesIndices: number[];
  17363. protected _epsilon: number;
  17364. protected _indicesCount: number;
  17365. protected _lineShader: ShaderMaterial;
  17366. protected _ib: DataBuffer;
  17367. protected _buffers: {
  17368. [key: string]: Nullable<VertexBuffer>;
  17369. };
  17370. protected _buffersForInstances: {
  17371. [key: string]: Nullable<VertexBuffer>;
  17372. };
  17373. protected _checkVerticesInsteadOfIndices: boolean;
  17374. private _meshRebuildObserver;
  17375. private _meshDisposeObserver;
  17376. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17377. isEnabled: boolean;
  17378. /**
  17379. * List of instances to render in case the source mesh has instances
  17380. */
  17381. customInstances: SmartArray<Matrix>;
  17382. private static GetShader;
  17383. /**
  17384. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17385. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17386. * @param source Mesh used to create edges
  17387. * @param epsilon sum of angles in adjacency to check for edge
  17388. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17389. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17390. */
  17391. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17392. protected _prepareRessources(): void;
  17393. /** @hidden */
  17394. _rebuild(): void;
  17395. /**
  17396. * Releases the required resources for the edges renderer
  17397. */
  17398. dispose(): void;
  17399. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17400. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17401. /**
  17402. * Checks if the pair of p0 and p1 is en edge
  17403. * @param faceIndex
  17404. * @param edge
  17405. * @param faceNormals
  17406. * @param p0
  17407. * @param p1
  17408. * @private
  17409. */
  17410. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17411. /**
  17412. * push line into the position, normal and index buffer
  17413. * @protected
  17414. */
  17415. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17416. /**
  17417. * Generates lines edges from adjacencjes
  17418. * @private
  17419. */
  17420. _generateEdgesLines(): void;
  17421. /**
  17422. * Checks wether or not the edges renderer is ready to render.
  17423. * @return true if ready, otherwise false.
  17424. */
  17425. isReady(): boolean;
  17426. /**
  17427. * Renders the edges of the attached mesh,
  17428. */
  17429. render(): void;
  17430. }
  17431. /**
  17432. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17433. */
  17434. export class LineEdgesRenderer extends EdgesRenderer {
  17435. /**
  17436. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17437. * @param source LineMesh used to generate edges
  17438. * @param epsilon not important (specified angle for edge detection)
  17439. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17440. */
  17441. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17442. /**
  17443. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17444. */
  17445. _generateEdgesLines(): void;
  17446. }
  17447. }
  17448. declare module "babylonjs/Rendering/renderingGroup" {
  17449. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17450. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17452. import { Nullable } from "babylonjs/types";
  17453. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17454. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17455. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17456. import { Material } from "babylonjs/Materials/material";
  17457. import { Scene } from "babylonjs/scene";
  17458. /**
  17459. * This represents the object necessary to create a rendering group.
  17460. * This is exclusively used and created by the rendering manager.
  17461. * To modify the behavior, you use the available helpers in your scene or meshes.
  17462. * @hidden
  17463. */
  17464. export class RenderingGroup {
  17465. index: number;
  17466. private static _zeroVector;
  17467. private _scene;
  17468. private _opaqueSubMeshes;
  17469. private _transparentSubMeshes;
  17470. private _alphaTestSubMeshes;
  17471. private _depthOnlySubMeshes;
  17472. private _particleSystems;
  17473. private _spriteManagers;
  17474. private _opaqueSortCompareFn;
  17475. private _alphaTestSortCompareFn;
  17476. private _transparentSortCompareFn;
  17477. private _renderOpaque;
  17478. private _renderAlphaTest;
  17479. private _renderTransparent;
  17480. /** @hidden */
  17481. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17482. onBeforeTransparentRendering: () => void;
  17483. /**
  17484. * Set the opaque sort comparison function.
  17485. * If null the sub meshes will be render in the order they were created
  17486. */
  17487. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17488. /**
  17489. * Set the alpha test sort comparison function.
  17490. * If null the sub meshes will be render in the order they were created
  17491. */
  17492. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17493. /**
  17494. * Set the transparent sort comparison function.
  17495. * If null the sub meshes will be render in the order they were created
  17496. */
  17497. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17498. /**
  17499. * Creates a new rendering group.
  17500. * @param index The rendering group index
  17501. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17502. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17503. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17504. */
  17505. 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>);
  17506. /**
  17507. * Render all the sub meshes contained in the group.
  17508. * @param customRenderFunction Used to override the default render behaviour of the group.
  17509. * @returns true if rendered some submeshes.
  17510. */
  17511. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17512. /**
  17513. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17514. * @param subMeshes The submeshes to render
  17515. */
  17516. private renderOpaqueSorted;
  17517. /**
  17518. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17519. * @param subMeshes The submeshes to render
  17520. */
  17521. private renderAlphaTestSorted;
  17522. /**
  17523. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17524. * @param subMeshes The submeshes to render
  17525. */
  17526. private renderTransparentSorted;
  17527. /**
  17528. * Renders the submeshes in a specified order.
  17529. * @param subMeshes The submeshes to sort before render
  17530. * @param sortCompareFn The comparison function use to sort
  17531. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17532. * @param transparent Specifies to activate blending if true
  17533. */
  17534. private static renderSorted;
  17535. /**
  17536. * Renders the submeshes in the order they were dispatched (no sort applied).
  17537. * @param subMeshes The submeshes to render
  17538. */
  17539. private static renderUnsorted;
  17540. /**
  17541. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17542. * are rendered back to front if in the same alpha index.
  17543. *
  17544. * @param a The first submesh
  17545. * @param b The second submesh
  17546. * @returns The result of the comparison
  17547. */
  17548. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17549. /**
  17550. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17551. * are rendered back to front.
  17552. *
  17553. * @param a The first submesh
  17554. * @param b The second submesh
  17555. * @returns The result of the comparison
  17556. */
  17557. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17558. /**
  17559. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17560. * are rendered front to back (prevent overdraw).
  17561. *
  17562. * @param a The first submesh
  17563. * @param b The second submesh
  17564. * @returns The result of the comparison
  17565. */
  17566. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17567. /**
  17568. * Resets the different lists of submeshes to prepare a new frame.
  17569. */
  17570. prepare(): void;
  17571. dispose(): void;
  17572. /**
  17573. * Inserts the submesh in its correct queue depending on its material.
  17574. * @param subMesh The submesh to dispatch
  17575. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17576. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17577. */
  17578. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17579. dispatchSprites(spriteManager: ISpriteManager): void;
  17580. dispatchParticles(particleSystem: IParticleSystem): void;
  17581. private _renderParticles;
  17582. private _renderSprites;
  17583. }
  17584. }
  17585. declare module "babylonjs/Rendering/renderingManager" {
  17586. import { Nullable } from "babylonjs/types";
  17587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17588. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17589. import { SmartArray } from "babylonjs/Misc/smartArray";
  17590. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17591. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17592. import { Material } from "babylonjs/Materials/material";
  17593. import { Scene } from "babylonjs/scene";
  17594. import { Camera } from "babylonjs/Cameras/camera";
  17595. /**
  17596. * Interface describing the different options available in the rendering manager
  17597. * regarding Auto Clear between groups.
  17598. */
  17599. export interface IRenderingManagerAutoClearSetup {
  17600. /**
  17601. * Defines whether or not autoclear is enable.
  17602. */
  17603. autoClear: boolean;
  17604. /**
  17605. * Defines whether or not to autoclear the depth buffer.
  17606. */
  17607. depth: boolean;
  17608. /**
  17609. * Defines whether or not to autoclear the stencil buffer.
  17610. */
  17611. stencil: boolean;
  17612. }
  17613. /**
  17614. * This class is used by the onRenderingGroupObservable
  17615. */
  17616. export class RenderingGroupInfo {
  17617. /**
  17618. * The Scene that being rendered
  17619. */
  17620. scene: Scene;
  17621. /**
  17622. * The camera currently used for the rendering pass
  17623. */
  17624. camera: Nullable<Camera>;
  17625. /**
  17626. * The ID of the renderingGroup being processed
  17627. */
  17628. renderingGroupId: number;
  17629. }
  17630. /**
  17631. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17632. * It is enable to manage the different groups as well as the different necessary sort functions.
  17633. * This should not be used directly aside of the few static configurations
  17634. */
  17635. export class RenderingManager {
  17636. /**
  17637. * The max id used for rendering groups (not included)
  17638. */
  17639. static MAX_RENDERINGGROUPS: number;
  17640. /**
  17641. * The min id used for rendering groups (included)
  17642. */
  17643. static MIN_RENDERINGGROUPS: number;
  17644. /**
  17645. * Used to globally prevent autoclearing scenes.
  17646. */
  17647. static AUTOCLEAR: boolean;
  17648. /**
  17649. * @hidden
  17650. */
  17651. _useSceneAutoClearSetup: boolean;
  17652. private _scene;
  17653. private _renderingGroups;
  17654. private _depthStencilBufferAlreadyCleaned;
  17655. private _autoClearDepthStencil;
  17656. private _customOpaqueSortCompareFn;
  17657. private _customAlphaTestSortCompareFn;
  17658. private _customTransparentSortCompareFn;
  17659. private _renderingGroupInfo;
  17660. /**
  17661. * Instantiates a new rendering group for a particular scene
  17662. * @param scene Defines the scene the groups belongs to
  17663. */
  17664. constructor(scene: Scene);
  17665. private _clearDepthStencilBuffer;
  17666. /**
  17667. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17668. * @hidden
  17669. */
  17670. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17671. /**
  17672. * Resets the different information of the group to prepare a new frame
  17673. * @hidden
  17674. */
  17675. reset(): void;
  17676. /**
  17677. * Dispose and release the group and its associated resources.
  17678. * @hidden
  17679. */
  17680. dispose(): void;
  17681. /**
  17682. * Clear the info related to rendering groups preventing retention points during dispose.
  17683. */
  17684. freeRenderingGroups(): void;
  17685. private _prepareRenderingGroup;
  17686. /**
  17687. * Add a sprite manager to the rendering manager in order to render it this frame.
  17688. * @param spriteManager Define the sprite manager to render
  17689. */
  17690. dispatchSprites(spriteManager: ISpriteManager): void;
  17691. /**
  17692. * Add a particle system to the rendering manager in order to render it this frame.
  17693. * @param particleSystem Define the particle system to render
  17694. */
  17695. dispatchParticles(particleSystem: IParticleSystem): void;
  17696. /**
  17697. * Add a submesh to the manager in order to render it this frame
  17698. * @param subMesh The submesh to dispatch
  17699. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17700. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17701. */
  17702. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17703. /**
  17704. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17705. * This allowed control for front to back rendering or reversly depending of the special needs.
  17706. *
  17707. * @param renderingGroupId The rendering group id corresponding to its index
  17708. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17709. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17710. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17711. */
  17712. 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;
  17713. /**
  17714. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17715. *
  17716. * @param renderingGroupId The rendering group id corresponding to its index
  17717. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17718. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17719. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17720. */
  17721. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17722. /**
  17723. * Gets the current auto clear configuration for one rendering group of the rendering
  17724. * manager.
  17725. * @param index the rendering group index to get the information for
  17726. * @returns The auto clear setup for the requested rendering group
  17727. */
  17728. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17729. }
  17730. }
  17731. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17732. import { SmartArray } from "babylonjs/Misc/smartArray";
  17733. import { Nullable } from "babylonjs/types";
  17734. import { Scene } from "babylonjs/scene";
  17735. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17736. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17737. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17738. import { Mesh } from "babylonjs/Meshes/mesh";
  17739. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17740. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17741. import { Effect } from "babylonjs/Materials/effect";
  17742. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17743. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17744. import "babylonjs/Shaders/shadowMap.fragment";
  17745. import "babylonjs/Shaders/shadowMap.vertex";
  17746. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17747. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17748. import { Observable } from "babylonjs/Misc/observable";
  17749. /**
  17750. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17751. */
  17752. export interface ICustomShaderOptions {
  17753. /**
  17754. * Gets or sets the custom shader name to use
  17755. */
  17756. shaderName: string;
  17757. /**
  17758. * The list of attribute names used in the shader
  17759. */
  17760. attributes?: string[];
  17761. /**
  17762. * The list of unifrom names used in the shader
  17763. */
  17764. uniforms?: string[];
  17765. /**
  17766. * The list of sampler names used in the shader
  17767. */
  17768. samplers?: string[];
  17769. /**
  17770. * The list of defines used in the shader
  17771. */
  17772. defines?: string[];
  17773. }
  17774. /**
  17775. * Interface to implement to create a shadow generator compatible with BJS.
  17776. */
  17777. export interface IShadowGenerator {
  17778. /**
  17779. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17780. * @returns The render target texture if present otherwise, null
  17781. */
  17782. getShadowMap(): Nullable<RenderTargetTexture>;
  17783. /**
  17784. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17785. * @param subMesh The submesh we want to render in the shadow map
  17786. * @param useInstances Defines wether will draw in the map using instances
  17787. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17788. * @returns true if ready otherwise, false
  17789. */
  17790. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17791. /**
  17792. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17793. * @param defines Defines of the material we want to update
  17794. * @param lightIndex Index of the light in the enabled light list of the material
  17795. */
  17796. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17797. /**
  17798. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17799. * defined in the generator but impacting the effect).
  17800. * It implies the unifroms available on the materials are the standard BJS ones.
  17801. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17802. * @param effect The effect we are binfing the information for
  17803. */
  17804. bindShadowLight(lightIndex: string, effect: Effect): void;
  17805. /**
  17806. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17807. * (eq to shadow prjection matrix * light transform matrix)
  17808. * @returns The transform matrix used to create the shadow map
  17809. */
  17810. getTransformMatrix(): Matrix;
  17811. /**
  17812. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17813. * Cube and 2D textures for instance.
  17814. */
  17815. recreateShadowMap(): void;
  17816. /**
  17817. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17818. * @param onCompiled Callback triggered at the and of the effects compilation
  17819. * @param options Sets of optional options forcing the compilation with different modes
  17820. */
  17821. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17822. useInstances: boolean;
  17823. }>): void;
  17824. /**
  17825. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17826. * @param options Sets of optional options forcing the compilation with different modes
  17827. * @returns A promise that resolves when the compilation completes
  17828. */
  17829. forceCompilationAsync(options?: Partial<{
  17830. useInstances: boolean;
  17831. }>): Promise<void>;
  17832. /**
  17833. * Serializes the shadow generator setup to a json object.
  17834. * @returns The serialized JSON object
  17835. */
  17836. serialize(): any;
  17837. /**
  17838. * Disposes the Shadow map and related Textures and effects.
  17839. */
  17840. dispose(): void;
  17841. }
  17842. /**
  17843. * Default implementation IShadowGenerator.
  17844. * This is the main object responsible of generating shadows in the framework.
  17845. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17846. */
  17847. export class ShadowGenerator implements IShadowGenerator {
  17848. /**
  17849. * Name of the shadow generator class
  17850. */
  17851. static CLASSNAME: string;
  17852. /**
  17853. * Shadow generator mode None: no filtering applied.
  17854. */
  17855. static readonly FILTER_NONE: number;
  17856. /**
  17857. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17858. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17859. */
  17860. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17861. /**
  17862. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17863. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17864. */
  17865. static readonly FILTER_POISSONSAMPLING: number;
  17866. /**
  17867. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17868. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17869. */
  17870. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17871. /**
  17872. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17873. * edge artifacts on steep falloff.
  17874. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17875. */
  17876. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17877. /**
  17878. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17879. * edge artifacts on steep falloff.
  17880. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17881. */
  17882. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17883. /**
  17884. * Shadow generator mode PCF: Percentage Closer Filtering
  17885. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17886. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17887. */
  17888. static readonly FILTER_PCF: number;
  17889. /**
  17890. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17891. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17892. * Contact Hardening
  17893. */
  17894. static readonly FILTER_PCSS: number;
  17895. /**
  17896. * Reserved for PCF and PCSS
  17897. * Highest Quality.
  17898. *
  17899. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17900. *
  17901. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17902. */
  17903. static readonly QUALITY_HIGH: number;
  17904. /**
  17905. * Reserved for PCF and PCSS
  17906. * Good tradeoff for quality/perf cross devices
  17907. *
  17908. * Execute PCF on a 3*3 kernel.
  17909. *
  17910. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17911. */
  17912. static readonly QUALITY_MEDIUM: number;
  17913. /**
  17914. * Reserved for PCF and PCSS
  17915. * The lowest quality but the fastest.
  17916. *
  17917. * Execute PCF on a 1*1 kernel.
  17918. *
  17919. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17920. */
  17921. static readonly QUALITY_LOW: number;
  17922. /** Gets or sets the custom shader name to use */
  17923. customShaderOptions: ICustomShaderOptions;
  17924. /**
  17925. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17926. */
  17927. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17928. /**
  17929. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17930. */
  17931. onAfterShadowMapRenderObservable: Observable<Effect>;
  17932. /**
  17933. * Observable triggered before a mesh is rendered in the shadow map.
  17934. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17935. */
  17936. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17937. /**
  17938. * Observable triggered after a mesh is rendered in the shadow map.
  17939. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17940. */
  17941. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17942. protected _bias: number;
  17943. /**
  17944. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17945. */
  17946. get bias(): number;
  17947. /**
  17948. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17949. */
  17950. set bias(bias: number);
  17951. protected _normalBias: number;
  17952. /**
  17953. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17954. */
  17955. get normalBias(): number;
  17956. /**
  17957. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17958. */
  17959. set normalBias(normalBias: number);
  17960. protected _blurBoxOffset: number;
  17961. /**
  17962. * Gets the blur box offset: offset applied during the blur pass.
  17963. * Only useful if useKernelBlur = false
  17964. */
  17965. get blurBoxOffset(): number;
  17966. /**
  17967. * Sets the blur box offset: offset applied during the blur pass.
  17968. * Only useful if useKernelBlur = false
  17969. */
  17970. set blurBoxOffset(value: number);
  17971. protected _blurScale: number;
  17972. /**
  17973. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17974. * 2 means half of the size.
  17975. */
  17976. get blurScale(): number;
  17977. /**
  17978. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17979. * 2 means half of the size.
  17980. */
  17981. set blurScale(value: number);
  17982. protected _blurKernel: number;
  17983. /**
  17984. * Gets the blur kernel: kernel size of the blur pass.
  17985. * Only useful if useKernelBlur = true
  17986. */
  17987. get blurKernel(): number;
  17988. /**
  17989. * Sets the blur kernel: kernel size of the blur pass.
  17990. * Only useful if useKernelBlur = true
  17991. */
  17992. set blurKernel(value: number);
  17993. protected _useKernelBlur: boolean;
  17994. /**
  17995. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17996. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17997. */
  17998. get useKernelBlur(): boolean;
  17999. /**
  18000. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18001. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18002. */
  18003. set useKernelBlur(value: boolean);
  18004. protected _depthScale: number;
  18005. /**
  18006. * Gets the depth scale used in ESM mode.
  18007. */
  18008. get depthScale(): number;
  18009. /**
  18010. * Sets the depth scale used in ESM mode.
  18011. * This can override the scale stored on the light.
  18012. */
  18013. set depthScale(value: number);
  18014. protected _validateFilter(filter: number): number;
  18015. protected _filter: number;
  18016. /**
  18017. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18018. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18019. */
  18020. get filter(): number;
  18021. /**
  18022. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18023. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18024. */
  18025. set filter(value: number);
  18026. /**
  18027. * Gets if the current filter is set to Poisson Sampling.
  18028. */
  18029. get usePoissonSampling(): boolean;
  18030. /**
  18031. * Sets the current filter to Poisson Sampling.
  18032. */
  18033. set usePoissonSampling(value: boolean);
  18034. /**
  18035. * Gets if the current filter is set to ESM.
  18036. */
  18037. get useExponentialShadowMap(): boolean;
  18038. /**
  18039. * Sets the current filter is to ESM.
  18040. */
  18041. set useExponentialShadowMap(value: boolean);
  18042. /**
  18043. * Gets if the current filter is set to filtered ESM.
  18044. */
  18045. get useBlurExponentialShadowMap(): boolean;
  18046. /**
  18047. * Gets if the current filter is set to filtered ESM.
  18048. */
  18049. set useBlurExponentialShadowMap(value: boolean);
  18050. /**
  18051. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18052. * exponential to prevent steep falloff artifacts).
  18053. */
  18054. get useCloseExponentialShadowMap(): boolean;
  18055. /**
  18056. * Sets the current filter to "close ESM" (using the inverse of the
  18057. * exponential to prevent steep falloff artifacts).
  18058. */
  18059. set useCloseExponentialShadowMap(value: boolean);
  18060. /**
  18061. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18062. * exponential to prevent steep falloff artifacts).
  18063. */
  18064. get useBlurCloseExponentialShadowMap(): boolean;
  18065. /**
  18066. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18067. * exponential to prevent steep falloff artifacts).
  18068. */
  18069. set useBlurCloseExponentialShadowMap(value: boolean);
  18070. /**
  18071. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18072. */
  18073. get usePercentageCloserFiltering(): boolean;
  18074. /**
  18075. * Sets the current filter to "PCF" (percentage closer filtering).
  18076. */
  18077. set usePercentageCloserFiltering(value: boolean);
  18078. protected _filteringQuality: number;
  18079. /**
  18080. * Gets the PCF or PCSS Quality.
  18081. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18082. */
  18083. get filteringQuality(): number;
  18084. /**
  18085. * Sets the PCF or PCSS Quality.
  18086. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18087. */
  18088. set filteringQuality(filteringQuality: number);
  18089. /**
  18090. * Gets if the current filter is set to "PCSS" (contact hardening).
  18091. */
  18092. get useContactHardeningShadow(): boolean;
  18093. /**
  18094. * Sets the current filter to "PCSS" (contact hardening).
  18095. */
  18096. set useContactHardeningShadow(value: boolean);
  18097. protected _contactHardeningLightSizeUVRatio: number;
  18098. /**
  18099. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18100. * Using a ratio helps keeping shape stability independently of the map size.
  18101. *
  18102. * It does not account for the light projection as it was having too much
  18103. * instability during the light setup or during light position changes.
  18104. *
  18105. * Only valid if useContactHardeningShadow is true.
  18106. */
  18107. get contactHardeningLightSizeUVRatio(): number;
  18108. /**
  18109. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18110. * Using a ratio helps keeping shape stability independently of the map size.
  18111. *
  18112. * It does not account for the light projection as it was having too much
  18113. * instability during the light setup or during light position changes.
  18114. *
  18115. * Only valid if useContactHardeningShadow is true.
  18116. */
  18117. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18118. protected _darkness: number;
  18119. /** Gets or sets the actual darkness of a shadow */
  18120. get darkness(): number;
  18121. set darkness(value: number);
  18122. /**
  18123. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18124. * 0 means strongest and 1 would means no shadow.
  18125. * @returns the darkness.
  18126. */
  18127. getDarkness(): number;
  18128. /**
  18129. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18130. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18131. * @returns the shadow generator allowing fluent coding.
  18132. */
  18133. setDarkness(darkness: number): ShadowGenerator;
  18134. protected _transparencyShadow: boolean;
  18135. /** Gets or sets the ability to have transparent shadow */
  18136. get transparencyShadow(): boolean;
  18137. set transparencyShadow(value: boolean);
  18138. /**
  18139. * Sets the ability to have transparent shadow (boolean).
  18140. * @param transparent True if transparent else False
  18141. * @returns the shadow generator allowing fluent coding
  18142. */
  18143. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18144. /**
  18145. * Enables or disables shadows with varying strength based on the transparency
  18146. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18147. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18148. * mesh.visibility * alphaTexture.a
  18149. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18150. */
  18151. enableSoftTransparentShadow: boolean;
  18152. protected _shadowMap: Nullable<RenderTargetTexture>;
  18153. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18154. /**
  18155. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18156. * @returns The render target texture if present otherwise, null
  18157. */
  18158. getShadowMap(): Nullable<RenderTargetTexture>;
  18159. /**
  18160. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18161. * @returns The render target texture if the shadow map is present otherwise, null
  18162. */
  18163. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18164. /**
  18165. * Gets the class name of that object
  18166. * @returns "ShadowGenerator"
  18167. */
  18168. getClassName(): string;
  18169. /**
  18170. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18171. * @param mesh Mesh to add
  18172. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18173. * @returns the Shadow Generator itself
  18174. */
  18175. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18176. /**
  18177. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18178. * @param mesh Mesh to remove
  18179. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18180. * @returns the Shadow Generator itself
  18181. */
  18182. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18183. /**
  18184. * Controls the extent to which the shadows fade out at the edge of the frustum
  18185. */
  18186. frustumEdgeFalloff: number;
  18187. protected _light: IShadowLight;
  18188. /**
  18189. * Returns the associated light object.
  18190. * @returns the light generating the shadow
  18191. */
  18192. getLight(): IShadowLight;
  18193. /**
  18194. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18195. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18196. * It might on the other hand introduce peter panning.
  18197. */
  18198. forceBackFacesOnly: boolean;
  18199. protected _scene: Scene;
  18200. protected _lightDirection: Vector3;
  18201. protected _effect: Effect;
  18202. protected _viewMatrix: Matrix;
  18203. protected _projectionMatrix: Matrix;
  18204. protected _transformMatrix: Matrix;
  18205. protected _cachedPosition: Vector3;
  18206. protected _cachedDirection: Vector3;
  18207. protected _cachedDefines: string;
  18208. protected _currentRenderID: number;
  18209. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18210. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18211. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18212. protected _blurPostProcesses: PostProcess[];
  18213. protected _mapSize: number;
  18214. protected _currentFaceIndex: number;
  18215. protected _currentFaceIndexCache: number;
  18216. protected _textureType: number;
  18217. protected _defaultTextureMatrix: Matrix;
  18218. protected _storedUniqueId: Nullable<number>;
  18219. /** @hidden */
  18220. static _SceneComponentInitialization: (scene: Scene) => void;
  18221. /**
  18222. * Creates a ShadowGenerator object.
  18223. * A ShadowGenerator is the required tool to use the shadows.
  18224. * Each light casting shadows needs to use its own ShadowGenerator.
  18225. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18226. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18227. * @param light The light object generating the shadows.
  18228. * @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.
  18229. */
  18230. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18231. protected _initializeGenerator(): void;
  18232. protected _createTargetRenderTexture(): void;
  18233. protected _initializeShadowMap(): void;
  18234. protected _initializeBlurRTTAndPostProcesses(): void;
  18235. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18236. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18237. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18238. protected _applyFilterValues(): void;
  18239. /**
  18240. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18241. * @param onCompiled Callback triggered at the and of the effects compilation
  18242. * @param options Sets of optional options forcing the compilation with different modes
  18243. */
  18244. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18245. useInstances: boolean;
  18246. }>): void;
  18247. /**
  18248. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18249. * @param options Sets of optional options forcing the compilation with different modes
  18250. * @returns A promise that resolves when the compilation completes
  18251. */
  18252. forceCompilationAsync(options?: Partial<{
  18253. useInstances: boolean;
  18254. }>): Promise<void>;
  18255. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18256. private _prepareShadowDefines;
  18257. /**
  18258. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18259. * @param subMesh The submesh we want to render in the shadow map
  18260. * @param useInstances Defines wether will draw in the map using instances
  18261. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18262. * @returns true if ready otherwise, false
  18263. */
  18264. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18265. /**
  18266. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18267. * @param defines Defines of the material we want to update
  18268. * @param lightIndex Index of the light in the enabled light list of the material
  18269. */
  18270. prepareDefines(defines: any, lightIndex: number): void;
  18271. /**
  18272. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18273. * defined in the generator but impacting the effect).
  18274. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18275. * @param effect The effect we are binfing the information for
  18276. */
  18277. bindShadowLight(lightIndex: string, effect: Effect): void;
  18278. /**
  18279. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18280. * (eq to shadow prjection matrix * light transform matrix)
  18281. * @returns The transform matrix used to create the shadow map
  18282. */
  18283. getTransformMatrix(): Matrix;
  18284. /**
  18285. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18286. * Cube and 2D textures for instance.
  18287. */
  18288. recreateShadowMap(): void;
  18289. protected _disposeBlurPostProcesses(): void;
  18290. protected _disposeRTTandPostProcesses(): void;
  18291. /**
  18292. * Disposes the ShadowGenerator.
  18293. * Returns nothing.
  18294. */
  18295. dispose(): void;
  18296. /**
  18297. * Serializes the shadow generator setup to a json object.
  18298. * @returns The serialized JSON object
  18299. */
  18300. serialize(): any;
  18301. /**
  18302. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18303. * @param parsedShadowGenerator The JSON object to parse
  18304. * @param scene The scene to create the shadow map for
  18305. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18306. * @returns The parsed shadow generator
  18307. */
  18308. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18309. }
  18310. }
  18311. declare module "babylonjs/Lights/light" {
  18312. import { Nullable } from "babylonjs/types";
  18313. import { Scene } from "babylonjs/scene";
  18314. import { Vector3 } from "babylonjs/Maths/math.vector";
  18315. import { Color3 } from "babylonjs/Maths/math.color";
  18316. import { Node } from "babylonjs/node";
  18317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18318. import { Effect } from "babylonjs/Materials/effect";
  18319. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18320. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18321. /**
  18322. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18323. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18324. * 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.
  18325. */
  18326. export abstract class Light extends Node {
  18327. /**
  18328. * Falloff Default: light is falling off following the material specification:
  18329. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18330. */
  18331. static readonly FALLOFF_DEFAULT: number;
  18332. /**
  18333. * Falloff Physical: light is falling off following the inverse squared distance law.
  18334. */
  18335. static readonly FALLOFF_PHYSICAL: number;
  18336. /**
  18337. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18338. * to enhance interoperability with other engines.
  18339. */
  18340. static readonly FALLOFF_GLTF: number;
  18341. /**
  18342. * Falloff Standard: light is falling off like in the standard material
  18343. * to enhance interoperability with other materials.
  18344. */
  18345. static readonly FALLOFF_STANDARD: number;
  18346. /**
  18347. * If every light affecting the material is in this lightmapMode,
  18348. * material.lightmapTexture adds or multiplies
  18349. * (depends on material.useLightmapAsShadowmap)
  18350. * after every other light calculations.
  18351. */
  18352. static readonly LIGHTMAP_DEFAULT: number;
  18353. /**
  18354. * material.lightmapTexture as only diffuse lighting from this light
  18355. * adds only specular lighting from this light
  18356. * adds dynamic shadows
  18357. */
  18358. static readonly LIGHTMAP_SPECULAR: number;
  18359. /**
  18360. * material.lightmapTexture as only lighting
  18361. * no light calculation from this light
  18362. * only adds dynamic shadows from this light
  18363. */
  18364. static readonly LIGHTMAP_SHADOWSONLY: number;
  18365. /**
  18366. * Each light type uses the default quantity according to its type:
  18367. * point/spot lights use luminous intensity
  18368. * directional lights use illuminance
  18369. */
  18370. static readonly INTENSITYMODE_AUTOMATIC: number;
  18371. /**
  18372. * lumen (lm)
  18373. */
  18374. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18375. /**
  18376. * candela (lm/sr)
  18377. */
  18378. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18379. /**
  18380. * lux (lm/m^2)
  18381. */
  18382. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18383. /**
  18384. * nit (cd/m^2)
  18385. */
  18386. static readonly INTENSITYMODE_LUMINANCE: number;
  18387. /**
  18388. * Light type const id of the point light.
  18389. */
  18390. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18391. /**
  18392. * Light type const id of the directional light.
  18393. */
  18394. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18395. /**
  18396. * Light type const id of the spot light.
  18397. */
  18398. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18399. /**
  18400. * Light type const id of the hemispheric light.
  18401. */
  18402. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18403. /**
  18404. * Diffuse gives the basic color to an object.
  18405. */
  18406. diffuse: Color3;
  18407. /**
  18408. * Specular produces a highlight color on an object.
  18409. * Note: This is note affecting PBR materials.
  18410. */
  18411. specular: Color3;
  18412. /**
  18413. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18414. * falling off base on range or angle.
  18415. * This can be set to any values in Light.FALLOFF_x.
  18416. *
  18417. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18418. * other types of materials.
  18419. */
  18420. falloffType: number;
  18421. /**
  18422. * Strength of the light.
  18423. * Note: By default it is define in the framework own unit.
  18424. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18425. */
  18426. intensity: number;
  18427. private _range;
  18428. protected _inverseSquaredRange: number;
  18429. /**
  18430. * Defines how far from the source the light is impacting in scene units.
  18431. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18432. */
  18433. get range(): number;
  18434. /**
  18435. * Defines how far from the source the light is impacting in scene units.
  18436. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18437. */
  18438. set range(value: number);
  18439. /**
  18440. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18441. * of light.
  18442. */
  18443. private _photometricScale;
  18444. private _intensityMode;
  18445. /**
  18446. * Gets the photometric scale used to interpret the intensity.
  18447. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18448. */
  18449. get intensityMode(): number;
  18450. /**
  18451. * Sets the photometric scale used to interpret the intensity.
  18452. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18453. */
  18454. set intensityMode(value: number);
  18455. private _radius;
  18456. /**
  18457. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18458. */
  18459. get radius(): number;
  18460. /**
  18461. * sets the light radius used by PBR Materials to simulate soft area lights.
  18462. */
  18463. set radius(value: number);
  18464. private _renderPriority;
  18465. /**
  18466. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18467. * exceeding the number allowed of the materials.
  18468. */
  18469. renderPriority: number;
  18470. private _shadowEnabled;
  18471. /**
  18472. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18473. * the current shadow generator.
  18474. */
  18475. get shadowEnabled(): boolean;
  18476. /**
  18477. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18478. * the current shadow generator.
  18479. */
  18480. set shadowEnabled(value: boolean);
  18481. private _includedOnlyMeshes;
  18482. /**
  18483. * Gets the only meshes impacted by this light.
  18484. */
  18485. get includedOnlyMeshes(): AbstractMesh[];
  18486. /**
  18487. * Sets the only meshes impacted by this light.
  18488. */
  18489. set includedOnlyMeshes(value: AbstractMesh[]);
  18490. private _excludedMeshes;
  18491. /**
  18492. * Gets the meshes not impacted by this light.
  18493. */
  18494. get excludedMeshes(): AbstractMesh[];
  18495. /**
  18496. * Sets the meshes not impacted by this light.
  18497. */
  18498. set excludedMeshes(value: AbstractMesh[]);
  18499. private _excludeWithLayerMask;
  18500. /**
  18501. * Gets the layer id use to find what meshes are not impacted by the light.
  18502. * Inactive if 0
  18503. */
  18504. get excludeWithLayerMask(): number;
  18505. /**
  18506. * Sets the layer id use to find what meshes are not impacted by the light.
  18507. * Inactive if 0
  18508. */
  18509. set excludeWithLayerMask(value: number);
  18510. private _includeOnlyWithLayerMask;
  18511. /**
  18512. * Gets the layer id use to find what meshes are impacted by the light.
  18513. * Inactive if 0
  18514. */
  18515. get includeOnlyWithLayerMask(): number;
  18516. /**
  18517. * Sets the layer id use to find what meshes are impacted by the light.
  18518. * Inactive if 0
  18519. */
  18520. set includeOnlyWithLayerMask(value: number);
  18521. private _lightmapMode;
  18522. /**
  18523. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18524. */
  18525. get lightmapMode(): number;
  18526. /**
  18527. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18528. */
  18529. set lightmapMode(value: number);
  18530. /**
  18531. * Shadow generator associted to the light.
  18532. * @hidden Internal use only.
  18533. */
  18534. _shadowGenerator: Nullable<IShadowGenerator>;
  18535. /**
  18536. * @hidden Internal use only.
  18537. */
  18538. _excludedMeshesIds: string[];
  18539. /**
  18540. * @hidden Internal use only.
  18541. */
  18542. _includedOnlyMeshesIds: string[];
  18543. /**
  18544. * The current light unifom buffer.
  18545. * @hidden Internal use only.
  18546. */
  18547. _uniformBuffer: UniformBuffer;
  18548. /** @hidden */
  18549. _renderId: number;
  18550. /**
  18551. * Creates a Light object in the scene.
  18552. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18553. * @param name The firendly name of the light
  18554. * @param scene The scene the light belongs too
  18555. */
  18556. constructor(name: string, scene: Scene);
  18557. protected abstract _buildUniformLayout(): void;
  18558. /**
  18559. * Sets the passed Effect "effect" with the Light information.
  18560. * @param effect The effect to update
  18561. * @param lightIndex The index of the light in the effect to update
  18562. * @returns The light
  18563. */
  18564. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18565. /**
  18566. * Sets the passed Effect "effect" with the Light textures.
  18567. * @param effect The effect to update
  18568. * @param lightIndex The index of the light in the effect to update
  18569. * @returns The light
  18570. */
  18571. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18572. /**
  18573. * Binds the lights information from the scene to the effect for the given mesh.
  18574. * @param lightIndex Light index
  18575. * @param scene The scene where the light belongs to
  18576. * @param effect The effect we are binding the data to
  18577. * @param useSpecular Defines if specular is supported
  18578. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18579. */
  18580. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18581. /**
  18582. * Sets the passed Effect "effect" with the Light information.
  18583. * @param effect The effect to update
  18584. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18585. * @returns The light
  18586. */
  18587. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18588. /**
  18589. * Returns the string "Light".
  18590. * @returns the class name
  18591. */
  18592. getClassName(): string;
  18593. /** @hidden */
  18594. readonly _isLight: boolean;
  18595. /**
  18596. * Converts the light information to a readable string for debug purpose.
  18597. * @param fullDetails Supports for multiple levels of logging within scene loading
  18598. * @returns the human readable light info
  18599. */
  18600. toString(fullDetails?: boolean): string;
  18601. /** @hidden */
  18602. protected _syncParentEnabledState(): void;
  18603. /**
  18604. * Set the enabled state of this node.
  18605. * @param value - the new enabled state
  18606. */
  18607. setEnabled(value: boolean): void;
  18608. /**
  18609. * Returns the Light associated shadow generator if any.
  18610. * @return the associated shadow generator.
  18611. */
  18612. getShadowGenerator(): Nullable<IShadowGenerator>;
  18613. /**
  18614. * Returns a Vector3, the absolute light position in the World.
  18615. * @returns the world space position of the light
  18616. */
  18617. getAbsolutePosition(): Vector3;
  18618. /**
  18619. * Specifies if the light will affect the passed mesh.
  18620. * @param mesh The mesh to test against the light
  18621. * @return true the mesh is affected otherwise, false.
  18622. */
  18623. canAffectMesh(mesh: AbstractMesh): boolean;
  18624. /**
  18625. * Sort function to order lights for rendering.
  18626. * @param a First Light object to compare to second.
  18627. * @param b Second Light object to compare first.
  18628. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18629. */
  18630. static CompareLightsPriority(a: Light, b: Light): number;
  18631. /**
  18632. * Releases resources associated with this node.
  18633. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18634. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18635. */
  18636. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18637. /**
  18638. * Returns the light type ID (integer).
  18639. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18640. */
  18641. getTypeID(): number;
  18642. /**
  18643. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18644. * @returns the scaled intensity in intensity mode unit
  18645. */
  18646. getScaledIntensity(): number;
  18647. /**
  18648. * Returns a new Light object, named "name", from the current one.
  18649. * @param name The name of the cloned light
  18650. * @param newParent The parent of this light, if it has one
  18651. * @returns the new created light
  18652. */
  18653. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18654. /**
  18655. * Serializes the current light into a Serialization object.
  18656. * @returns the serialized object.
  18657. */
  18658. serialize(): any;
  18659. /**
  18660. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18661. * This new light is named "name" and added to the passed scene.
  18662. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18663. * @param name The friendly name of the light
  18664. * @param scene The scene the new light will belong to
  18665. * @returns the constructor function
  18666. */
  18667. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18668. /**
  18669. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18670. * @param parsedLight The JSON representation of the light
  18671. * @param scene The scene to create the parsed light in
  18672. * @returns the created light after parsing
  18673. */
  18674. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18675. private _hookArrayForExcluded;
  18676. private _hookArrayForIncludedOnly;
  18677. private _resyncMeshes;
  18678. /**
  18679. * Forces the meshes to update their light related information in their rendering used effects
  18680. * @hidden Internal Use Only
  18681. */
  18682. _markMeshesAsLightDirty(): void;
  18683. /**
  18684. * Recomputes the cached photometric scale if needed.
  18685. */
  18686. private _computePhotometricScale;
  18687. /**
  18688. * Returns the Photometric Scale according to the light type and intensity mode.
  18689. */
  18690. private _getPhotometricScale;
  18691. /**
  18692. * Reorder the light in the scene according to their defined priority.
  18693. * @hidden Internal Use Only
  18694. */
  18695. _reorderLightsInScene(): void;
  18696. /**
  18697. * Prepares the list of defines specific to the light type.
  18698. * @param defines the list of defines
  18699. * @param lightIndex defines the index of the light for the effect
  18700. */
  18701. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18702. }
  18703. }
  18704. declare module "babylonjs/Cameras/targetCamera" {
  18705. import { Nullable } from "babylonjs/types";
  18706. import { Camera } from "babylonjs/Cameras/camera";
  18707. import { Scene } from "babylonjs/scene";
  18708. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18709. /**
  18710. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18711. * This is the base of the follow, arc rotate cameras and Free camera
  18712. * @see http://doc.babylonjs.com/features/cameras
  18713. */
  18714. export class TargetCamera extends Camera {
  18715. private static _RigCamTransformMatrix;
  18716. private static _TargetTransformMatrix;
  18717. private static _TargetFocalPoint;
  18718. private _tmpUpVector;
  18719. private _tmpTargetVector;
  18720. /**
  18721. * Define the current direction the camera is moving to
  18722. */
  18723. cameraDirection: Vector3;
  18724. /**
  18725. * Define the current rotation the camera is rotating to
  18726. */
  18727. cameraRotation: Vector2;
  18728. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18729. ignoreParentScaling: boolean;
  18730. /**
  18731. * When set, the up vector of the camera will be updated by the rotation of the camera
  18732. */
  18733. updateUpVectorFromRotation: boolean;
  18734. private _tmpQuaternion;
  18735. /**
  18736. * Define the current rotation of the camera
  18737. */
  18738. rotation: Vector3;
  18739. /**
  18740. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18741. */
  18742. rotationQuaternion: Quaternion;
  18743. /**
  18744. * Define the current speed of the camera
  18745. */
  18746. speed: number;
  18747. /**
  18748. * Add constraint to the camera to prevent it to move freely in all directions and
  18749. * around all axis.
  18750. */
  18751. noRotationConstraint: boolean;
  18752. /**
  18753. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18754. * panning
  18755. */
  18756. invertRotation: boolean;
  18757. /**
  18758. * Speed multiplier for inverse camera panning
  18759. */
  18760. inverseRotationSpeed: number;
  18761. /**
  18762. * Define the current target of the camera as an object or a position.
  18763. */
  18764. lockedTarget: any;
  18765. /** @hidden */
  18766. _currentTarget: Vector3;
  18767. /** @hidden */
  18768. _initialFocalDistance: number;
  18769. /** @hidden */
  18770. _viewMatrix: Matrix;
  18771. /** @hidden */
  18772. _camMatrix: Matrix;
  18773. /** @hidden */
  18774. _cameraTransformMatrix: Matrix;
  18775. /** @hidden */
  18776. _cameraRotationMatrix: Matrix;
  18777. /** @hidden */
  18778. _referencePoint: Vector3;
  18779. /** @hidden */
  18780. _transformedReferencePoint: Vector3;
  18781. /** @hidden */
  18782. _reset: () => void;
  18783. private _defaultUp;
  18784. /**
  18785. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18786. * This is the base of the follow, arc rotate cameras and Free camera
  18787. * @see http://doc.babylonjs.com/features/cameras
  18788. * @param name Defines the name of the camera in the scene
  18789. * @param position Defines the start position of the camera in the scene
  18790. * @param scene Defines the scene the camera belongs to
  18791. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18792. */
  18793. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18794. /**
  18795. * Gets the position in front of the camera at a given distance.
  18796. * @param distance The distance from the camera we want the position to be
  18797. * @returns the position
  18798. */
  18799. getFrontPosition(distance: number): Vector3;
  18800. /** @hidden */
  18801. _getLockedTargetPosition(): Nullable<Vector3>;
  18802. private _storedPosition;
  18803. private _storedRotation;
  18804. private _storedRotationQuaternion;
  18805. /**
  18806. * Store current camera state of the camera (fov, position, rotation, etc..)
  18807. * @returns the camera
  18808. */
  18809. storeState(): Camera;
  18810. /**
  18811. * Restored camera state. You must call storeState() first
  18812. * @returns whether it was successful or not
  18813. * @hidden
  18814. */
  18815. _restoreStateValues(): boolean;
  18816. /** @hidden */
  18817. _initCache(): void;
  18818. /** @hidden */
  18819. _updateCache(ignoreParentClass?: boolean): void;
  18820. /** @hidden */
  18821. _isSynchronizedViewMatrix(): boolean;
  18822. /** @hidden */
  18823. _computeLocalCameraSpeed(): number;
  18824. /**
  18825. * Defines the target the camera should look at.
  18826. * @param target Defines the new target as a Vector or a mesh
  18827. */
  18828. setTarget(target: Vector3): void;
  18829. /**
  18830. * Return the current target position of the camera. This value is expressed in local space.
  18831. * @returns the target position
  18832. */
  18833. getTarget(): Vector3;
  18834. /** @hidden */
  18835. _decideIfNeedsToMove(): boolean;
  18836. /** @hidden */
  18837. _updatePosition(): void;
  18838. /** @hidden */
  18839. _checkInputs(): void;
  18840. protected _updateCameraRotationMatrix(): void;
  18841. /**
  18842. * 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)
  18843. * @returns the current camera
  18844. */
  18845. private _rotateUpVectorWithCameraRotationMatrix;
  18846. private _cachedRotationZ;
  18847. private _cachedQuaternionRotationZ;
  18848. /** @hidden */
  18849. _getViewMatrix(): Matrix;
  18850. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18851. /**
  18852. * @hidden
  18853. */
  18854. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18855. /**
  18856. * @hidden
  18857. */
  18858. _updateRigCameras(): void;
  18859. private _getRigCamPositionAndTarget;
  18860. /**
  18861. * Gets the current object class name.
  18862. * @return the class name
  18863. */
  18864. getClassName(): string;
  18865. }
  18866. }
  18867. declare module "babylonjs/Events/keyboardEvents" {
  18868. /**
  18869. * Gather the list of keyboard event types as constants.
  18870. */
  18871. export class KeyboardEventTypes {
  18872. /**
  18873. * The keydown event is fired when a key becomes active (pressed).
  18874. */
  18875. static readonly KEYDOWN: number;
  18876. /**
  18877. * The keyup event is fired when a key has been released.
  18878. */
  18879. static readonly KEYUP: number;
  18880. }
  18881. /**
  18882. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18883. */
  18884. export class KeyboardInfo {
  18885. /**
  18886. * Defines the type of event (KeyboardEventTypes)
  18887. */
  18888. type: number;
  18889. /**
  18890. * Defines the related dom event
  18891. */
  18892. event: KeyboardEvent;
  18893. /**
  18894. * Instantiates a new keyboard info.
  18895. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18896. * @param type Defines the type of event (KeyboardEventTypes)
  18897. * @param event Defines the related dom event
  18898. */
  18899. constructor(
  18900. /**
  18901. * Defines the type of event (KeyboardEventTypes)
  18902. */
  18903. type: number,
  18904. /**
  18905. * Defines the related dom event
  18906. */
  18907. event: KeyboardEvent);
  18908. }
  18909. /**
  18910. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18911. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18912. */
  18913. export class KeyboardInfoPre extends KeyboardInfo {
  18914. /**
  18915. * Defines the type of event (KeyboardEventTypes)
  18916. */
  18917. type: number;
  18918. /**
  18919. * Defines the related dom event
  18920. */
  18921. event: KeyboardEvent;
  18922. /**
  18923. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18924. */
  18925. skipOnPointerObservable: boolean;
  18926. /**
  18927. * Instantiates a new keyboard pre info.
  18928. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18929. * @param type Defines the type of event (KeyboardEventTypes)
  18930. * @param event Defines the related dom event
  18931. */
  18932. constructor(
  18933. /**
  18934. * Defines the type of event (KeyboardEventTypes)
  18935. */
  18936. type: number,
  18937. /**
  18938. * Defines the related dom event
  18939. */
  18940. event: KeyboardEvent);
  18941. }
  18942. }
  18943. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18944. import { Nullable } from "babylonjs/types";
  18945. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18946. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18947. /**
  18948. * Manage the keyboard inputs to control the movement of a free camera.
  18949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18950. */
  18951. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18952. /**
  18953. * Defines the camera the input is attached to.
  18954. */
  18955. camera: FreeCamera;
  18956. /**
  18957. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18958. */
  18959. keysUp: number[];
  18960. /**
  18961. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18962. */
  18963. keysUpward: number[];
  18964. /**
  18965. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18966. */
  18967. keysDown: number[];
  18968. /**
  18969. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18970. */
  18971. keysDownward: number[];
  18972. /**
  18973. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18974. */
  18975. keysLeft: number[];
  18976. /**
  18977. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18978. */
  18979. keysRight: number[];
  18980. private _keys;
  18981. private _onCanvasBlurObserver;
  18982. private _onKeyboardObserver;
  18983. private _engine;
  18984. private _scene;
  18985. /**
  18986. * Attach the input controls to a specific dom element to get the input from.
  18987. * @param element Defines the element the controls should be listened from
  18988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18989. */
  18990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18991. /**
  18992. * Detach the current controls from the specified dom element.
  18993. * @param element Defines the element to stop listening the inputs from
  18994. */
  18995. detachControl(element: Nullable<HTMLElement>): void;
  18996. /**
  18997. * Update the current camera state depending on the inputs that have been used this frame.
  18998. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18999. */
  19000. checkInputs(): void;
  19001. /**
  19002. * Gets the class name of the current intput.
  19003. * @returns the class name
  19004. */
  19005. getClassName(): string;
  19006. /** @hidden */
  19007. _onLostFocus(): void;
  19008. /**
  19009. * Get the friendly name associated with the input class.
  19010. * @returns the input friendly name
  19011. */
  19012. getSimpleName(): string;
  19013. }
  19014. }
  19015. declare module "babylonjs/Events/pointerEvents" {
  19016. import { Nullable } from "babylonjs/types";
  19017. import { Vector2 } from "babylonjs/Maths/math.vector";
  19018. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19019. import { Ray } from "babylonjs/Culling/ray";
  19020. /**
  19021. * Gather the list of pointer event types as constants.
  19022. */
  19023. export class PointerEventTypes {
  19024. /**
  19025. * 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.
  19026. */
  19027. static readonly POINTERDOWN: number;
  19028. /**
  19029. * The pointerup event is fired when a pointer is no longer active.
  19030. */
  19031. static readonly POINTERUP: number;
  19032. /**
  19033. * The pointermove event is fired when a pointer changes coordinates.
  19034. */
  19035. static readonly POINTERMOVE: number;
  19036. /**
  19037. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19038. */
  19039. static readonly POINTERWHEEL: number;
  19040. /**
  19041. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19042. */
  19043. static readonly POINTERPICK: number;
  19044. /**
  19045. * The pointertap event is fired when a the object has been touched and released without drag.
  19046. */
  19047. static readonly POINTERTAP: number;
  19048. /**
  19049. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19050. */
  19051. static readonly POINTERDOUBLETAP: number;
  19052. }
  19053. /**
  19054. * Base class of pointer info types.
  19055. */
  19056. export class PointerInfoBase {
  19057. /**
  19058. * Defines the type of event (PointerEventTypes)
  19059. */
  19060. type: number;
  19061. /**
  19062. * Defines the related dom event
  19063. */
  19064. event: PointerEvent | MouseWheelEvent;
  19065. /**
  19066. * Instantiates the base class of pointers info.
  19067. * @param type Defines the type of event (PointerEventTypes)
  19068. * @param event Defines the related dom event
  19069. */
  19070. constructor(
  19071. /**
  19072. * Defines the type of event (PointerEventTypes)
  19073. */
  19074. type: number,
  19075. /**
  19076. * Defines the related dom event
  19077. */
  19078. event: PointerEvent | MouseWheelEvent);
  19079. }
  19080. /**
  19081. * This class is used to store pointer related info for the onPrePointerObservable event.
  19082. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19083. */
  19084. export class PointerInfoPre extends PointerInfoBase {
  19085. /**
  19086. * Ray from a pointer if availible (eg. 6dof controller)
  19087. */
  19088. ray: Nullable<Ray>;
  19089. /**
  19090. * Defines the local position of the pointer on the canvas.
  19091. */
  19092. localPosition: Vector2;
  19093. /**
  19094. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19095. */
  19096. skipOnPointerObservable: boolean;
  19097. /**
  19098. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19099. * @param type Defines the type of event (PointerEventTypes)
  19100. * @param event Defines the related dom event
  19101. * @param localX Defines the local x coordinates of the pointer when the event occured
  19102. * @param localY Defines the local y coordinates of the pointer when the event occured
  19103. */
  19104. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19105. }
  19106. /**
  19107. * This type contains all the data related to a pointer event in Babylon.js.
  19108. * 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.
  19109. */
  19110. export class PointerInfo extends PointerInfoBase {
  19111. /**
  19112. * Defines the picking info associated to the info (if any)\
  19113. */
  19114. pickInfo: Nullable<PickingInfo>;
  19115. /**
  19116. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19117. * @param type Defines the type of event (PointerEventTypes)
  19118. * @param event Defines the related dom event
  19119. * @param pickInfo Defines the picking info associated to the info (if any)\
  19120. */
  19121. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19122. /**
  19123. * Defines the picking info associated to the info (if any)\
  19124. */
  19125. pickInfo: Nullable<PickingInfo>);
  19126. }
  19127. /**
  19128. * Data relating to a touch event on the screen.
  19129. */
  19130. export interface PointerTouch {
  19131. /**
  19132. * X coordinate of touch.
  19133. */
  19134. x: number;
  19135. /**
  19136. * Y coordinate of touch.
  19137. */
  19138. y: number;
  19139. /**
  19140. * Id of touch. Unique for each finger.
  19141. */
  19142. pointerId: number;
  19143. /**
  19144. * Event type passed from DOM.
  19145. */
  19146. type: any;
  19147. }
  19148. }
  19149. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19150. import { Observable } from "babylonjs/Misc/observable";
  19151. import { Nullable } from "babylonjs/types";
  19152. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19153. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19154. /**
  19155. * Manage the mouse inputs to control the movement of a free camera.
  19156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19157. */
  19158. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19159. /**
  19160. * Define if touch is enabled in the mouse input
  19161. */
  19162. touchEnabled: boolean;
  19163. /**
  19164. * Defines the camera the input is attached to.
  19165. */
  19166. camera: FreeCamera;
  19167. /**
  19168. * Defines the buttons associated with the input to handle camera move.
  19169. */
  19170. buttons: number[];
  19171. /**
  19172. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19173. */
  19174. angularSensibility: number;
  19175. private _pointerInput;
  19176. private _onMouseMove;
  19177. private _observer;
  19178. private previousPosition;
  19179. /**
  19180. * Observable for when a pointer move event occurs containing the move offset
  19181. */
  19182. onPointerMovedObservable: Observable<{
  19183. offsetX: number;
  19184. offsetY: number;
  19185. }>;
  19186. /**
  19187. * @hidden
  19188. * If the camera should be rotated automatically based on pointer movement
  19189. */
  19190. _allowCameraRotation: boolean;
  19191. /**
  19192. * Manage the mouse inputs to control the movement of a free camera.
  19193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19194. * @param touchEnabled Defines if touch is enabled or not
  19195. */
  19196. constructor(
  19197. /**
  19198. * Define if touch is enabled in the mouse input
  19199. */
  19200. touchEnabled?: boolean);
  19201. /**
  19202. * Attach the input controls to a specific dom element to get the input from.
  19203. * @param element Defines the element the controls should be listened from
  19204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19205. */
  19206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19207. /**
  19208. * Called on JS contextmenu event.
  19209. * Override this method to provide functionality.
  19210. */
  19211. protected onContextMenu(evt: PointerEvent): void;
  19212. /**
  19213. * Detach the current controls from the specified dom element.
  19214. * @param element Defines the element to stop listening the inputs from
  19215. */
  19216. detachControl(element: Nullable<HTMLElement>): void;
  19217. /**
  19218. * Gets the class name of the current intput.
  19219. * @returns the class name
  19220. */
  19221. getClassName(): string;
  19222. /**
  19223. * Get the friendly name associated with the input class.
  19224. * @returns the input friendly name
  19225. */
  19226. getSimpleName(): string;
  19227. }
  19228. }
  19229. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19230. import { Nullable } from "babylonjs/types";
  19231. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19232. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19233. /**
  19234. * Manage the touch inputs to control the movement of a free camera.
  19235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19236. */
  19237. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19238. /**
  19239. * Defines the camera the input is attached to.
  19240. */
  19241. camera: FreeCamera;
  19242. /**
  19243. * Defines the touch sensibility for rotation.
  19244. * The higher the faster.
  19245. */
  19246. touchAngularSensibility: number;
  19247. /**
  19248. * Defines the touch sensibility for move.
  19249. * The higher the faster.
  19250. */
  19251. touchMoveSensibility: number;
  19252. private _offsetX;
  19253. private _offsetY;
  19254. private _pointerPressed;
  19255. private _pointerInput;
  19256. private _observer;
  19257. private _onLostFocus;
  19258. /**
  19259. * Attach the input controls to a specific dom element to get the input from.
  19260. * @param element Defines the element the controls should be listened from
  19261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19262. */
  19263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19264. /**
  19265. * Detach the current controls from the specified dom element.
  19266. * @param element Defines the element to stop listening the inputs from
  19267. */
  19268. detachControl(element: Nullable<HTMLElement>): void;
  19269. /**
  19270. * Update the current camera state depending on the inputs that have been used this frame.
  19271. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19272. */
  19273. checkInputs(): void;
  19274. /**
  19275. * Gets the class name of the current intput.
  19276. * @returns the class name
  19277. */
  19278. getClassName(): string;
  19279. /**
  19280. * Get the friendly name associated with the input class.
  19281. * @returns the input friendly name
  19282. */
  19283. getSimpleName(): string;
  19284. }
  19285. }
  19286. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19287. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19288. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19289. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19290. import { Nullable } from "babylonjs/types";
  19291. /**
  19292. * Default Inputs manager for the FreeCamera.
  19293. * It groups all the default supported inputs for ease of use.
  19294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19295. */
  19296. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19297. /**
  19298. * @hidden
  19299. */
  19300. _mouseInput: Nullable<FreeCameraMouseInput>;
  19301. /**
  19302. * Instantiates a new FreeCameraInputsManager.
  19303. * @param camera Defines the camera the inputs belong to
  19304. */
  19305. constructor(camera: FreeCamera);
  19306. /**
  19307. * Add keyboard input support to the input manager.
  19308. * @returns the current input manager
  19309. */
  19310. addKeyboard(): FreeCameraInputsManager;
  19311. /**
  19312. * Add mouse input support to the input manager.
  19313. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19314. * @returns the current input manager
  19315. */
  19316. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19317. /**
  19318. * Removes the mouse input support from the manager
  19319. * @returns the current input manager
  19320. */
  19321. removeMouse(): FreeCameraInputsManager;
  19322. /**
  19323. * Add touch input support to the input manager.
  19324. * @returns the current input manager
  19325. */
  19326. addTouch(): FreeCameraInputsManager;
  19327. /**
  19328. * Remove all attached input methods from a camera
  19329. */
  19330. clear(): void;
  19331. }
  19332. }
  19333. declare module "babylonjs/Cameras/freeCamera" {
  19334. import { Vector3 } from "babylonjs/Maths/math.vector";
  19335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19336. import { Scene } from "babylonjs/scene";
  19337. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19338. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19339. /**
  19340. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19341. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19342. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19343. */
  19344. export class FreeCamera extends TargetCamera {
  19345. /**
  19346. * Define the collision ellipsoid of the camera.
  19347. * This is helpful to simulate a camera body like the player body around the camera
  19348. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19349. */
  19350. ellipsoid: Vector3;
  19351. /**
  19352. * Define an offset for the position of the ellipsoid around the camera.
  19353. * This can be helpful to determine the center of the body near the gravity center of the body
  19354. * instead of its head.
  19355. */
  19356. ellipsoidOffset: Vector3;
  19357. /**
  19358. * Enable or disable collisions of the camera with the rest of the scene objects.
  19359. */
  19360. checkCollisions: boolean;
  19361. /**
  19362. * Enable or disable gravity on the camera.
  19363. */
  19364. applyGravity: boolean;
  19365. /**
  19366. * Define the input manager associated to the camera.
  19367. */
  19368. inputs: FreeCameraInputsManager;
  19369. /**
  19370. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19371. * Higher values reduce sensitivity.
  19372. */
  19373. get angularSensibility(): number;
  19374. /**
  19375. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19376. * Higher values reduce sensitivity.
  19377. */
  19378. set angularSensibility(value: number);
  19379. /**
  19380. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19381. */
  19382. get keysUp(): number[];
  19383. set keysUp(value: number[]);
  19384. /**
  19385. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19386. */
  19387. get keysUpward(): number[];
  19388. set keysUpward(value: number[]);
  19389. /**
  19390. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19391. */
  19392. get keysDown(): number[];
  19393. set keysDown(value: number[]);
  19394. /**
  19395. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19396. */
  19397. get keysDownward(): number[];
  19398. set keysDownward(value: number[]);
  19399. /**
  19400. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19401. */
  19402. get keysLeft(): number[];
  19403. set keysLeft(value: number[]);
  19404. /**
  19405. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19406. */
  19407. get keysRight(): number[];
  19408. set keysRight(value: number[]);
  19409. /**
  19410. * Event raised when the camera collide with a mesh in the scene.
  19411. */
  19412. onCollide: (collidedMesh: AbstractMesh) => void;
  19413. private _collider;
  19414. private _needMoveForGravity;
  19415. private _oldPosition;
  19416. private _diffPosition;
  19417. private _newPosition;
  19418. /** @hidden */
  19419. _localDirection: Vector3;
  19420. /** @hidden */
  19421. _transformedDirection: Vector3;
  19422. /**
  19423. * Instantiates a Free Camera.
  19424. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19425. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19426. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19427. * @param name Define the name of the camera in the scene
  19428. * @param position Define the start position of the camera in the scene
  19429. * @param scene Define the scene the camera belongs to
  19430. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19431. */
  19432. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19433. /**
  19434. * Attached controls to the current camera.
  19435. * @param element Defines the element the controls should be listened from
  19436. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19437. */
  19438. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19439. /**
  19440. * Detach the current controls from the camera.
  19441. * The camera will stop reacting to inputs.
  19442. * @param element Defines the element to stop listening the inputs from
  19443. */
  19444. detachControl(element: HTMLElement): void;
  19445. private _collisionMask;
  19446. /**
  19447. * Define a collision mask to limit the list of object the camera can collide with
  19448. */
  19449. get collisionMask(): number;
  19450. set collisionMask(mask: number);
  19451. /** @hidden */
  19452. _collideWithWorld(displacement: Vector3): void;
  19453. private _onCollisionPositionChange;
  19454. /** @hidden */
  19455. _checkInputs(): void;
  19456. /** @hidden */
  19457. _decideIfNeedsToMove(): boolean;
  19458. /** @hidden */
  19459. _updatePosition(): void;
  19460. /**
  19461. * Destroy the camera and release the current resources hold by it.
  19462. */
  19463. dispose(): void;
  19464. /**
  19465. * Gets the current object class name.
  19466. * @return the class name
  19467. */
  19468. getClassName(): string;
  19469. }
  19470. }
  19471. declare module "babylonjs/Gamepads/gamepad" {
  19472. import { Observable } from "babylonjs/Misc/observable";
  19473. /**
  19474. * Represents a gamepad control stick position
  19475. */
  19476. export class StickValues {
  19477. /**
  19478. * The x component of the control stick
  19479. */
  19480. x: number;
  19481. /**
  19482. * The y component of the control stick
  19483. */
  19484. y: number;
  19485. /**
  19486. * Initializes the gamepad x and y control stick values
  19487. * @param x The x component of the gamepad control stick value
  19488. * @param y The y component of the gamepad control stick value
  19489. */
  19490. constructor(
  19491. /**
  19492. * The x component of the control stick
  19493. */
  19494. x: number,
  19495. /**
  19496. * The y component of the control stick
  19497. */
  19498. y: number);
  19499. }
  19500. /**
  19501. * An interface which manages callbacks for gamepad button changes
  19502. */
  19503. export interface GamepadButtonChanges {
  19504. /**
  19505. * Called when a gamepad has been changed
  19506. */
  19507. changed: boolean;
  19508. /**
  19509. * Called when a gamepad press event has been triggered
  19510. */
  19511. pressChanged: boolean;
  19512. /**
  19513. * Called when a touch event has been triggered
  19514. */
  19515. touchChanged: boolean;
  19516. /**
  19517. * Called when a value has changed
  19518. */
  19519. valueChanged: boolean;
  19520. }
  19521. /**
  19522. * Represents a gamepad
  19523. */
  19524. export class Gamepad {
  19525. /**
  19526. * The id of the gamepad
  19527. */
  19528. id: string;
  19529. /**
  19530. * The index of the gamepad
  19531. */
  19532. index: number;
  19533. /**
  19534. * The browser gamepad
  19535. */
  19536. browserGamepad: any;
  19537. /**
  19538. * Specifies what type of gamepad this represents
  19539. */
  19540. type: number;
  19541. private _leftStick;
  19542. private _rightStick;
  19543. /** @hidden */
  19544. _isConnected: boolean;
  19545. private _leftStickAxisX;
  19546. private _leftStickAxisY;
  19547. private _rightStickAxisX;
  19548. private _rightStickAxisY;
  19549. /**
  19550. * Triggered when the left control stick has been changed
  19551. */
  19552. private _onleftstickchanged;
  19553. /**
  19554. * Triggered when the right control stick has been changed
  19555. */
  19556. private _onrightstickchanged;
  19557. /**
  19558. * Represents a gamepad controller
  19559. */
  19560. static GAMEPAD: number;
  19561. /**
  19562. * Represents a generic controller
  19563. */
  19564. static GENERIC: number;
  19565. /**
  19566. * Represents an XBox controller
  19567. */
  19568. static XBOX: number;
  19569. /**
  19570. * Represents a pose-enabled controller
  19571. */
  19572. static POSE_ENABLED: number;
  19573. /**
  19574. * Represents an Dual Shock controller
  19575. */
  19576. static DUALSHOCK: number;
  19577. /**
  19578. * Specifies whether the left control stick should be Y-inverted
  19579. */
  19580. protected _invertLeftStickY: boolean;
  19581. /**
  19582. * Specifies if the gamepad has been connected
  19583. */
  19584. get isConnected(): boolean;
  19585. /**
  19586. * Initializes the gamepad
  19587. * @param id The id of the gamepad
  19588. * @param index The index of the gamepad
  19589. * @param browserGamepad The browser gamepad
  19590. * @param leftStickX The x component of the left joystick
  19591. * @param leftStickY The y component of the left joystick
  19592. * @param rightStickX The x component of the right joystick
  19593. * @param rightStickY The y component of the right joystick
  19594. */
  19595. constructor(
  19596. /**
  19597. * The id of the gamepad
  19598. */
  19599. id: string,
  19600. /**
  19601. * The index of the gamepad
  19602. */
  19603. index: number,
  19604. /**
  19605. * The browser gamepad
  19606. */
  19607. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19608. /**
  19609. * Callback triggered when the left joystick has changed
  19610. * @param callback
  19611. */
  19612. onleftstickchanged(callback: (values: StickValues) => void): void;
  19613. /**
  19614. * Callback triggered when the right joystick has changed
  19615. * @param callback
  19616. */
  19617. onrightstickchanged(callback: (values: StickValues) => void): void;
  19618. /**
  19619. * Gets the left joystick
  19620. */
  19621. get leftStick(): StickValues;
  19622. /**
  19623. * Sets the left joystick values
  19624. */
  19625. set leftStick(newValues: StickValues);
  19626. /**
  19627. * Gets the right joystick
  19628. */
  19629. get rightStick(): StickValues;
  19630. /**
  19631. * Sets the right joystick value
  19632. */
  19633. set rightStick(newValues: StickValues);
  19634. /**
  19635. * Updates the gamepad joystick positions
  19636. */
  19637. update(): void;
  19638. /**
  19639. * Disposes the gamepad
  19640. */
  19641. dispose(): void;
  19642. }
  19643. /**
  19644. * Represents a generic gamepad
  19645. */
  19646. export class GenericPad extends Gamepad {
  19647. private _buttons;
  19648. private _onbuttondown;
  19649. private _onbuttonup;
  19650. /**
  19651. * Observable triggered when a button has been pressed
  19652. */
  19653. onButtonDownObservable: Observable<number>;
  19654. /**
  19655. * Observable triggered when a button has been released
  19656. */
  19657. onButtonUpObservable: Observable<number>;
  19658. /**
  19659. * Callback triggered when a button has been pressed
  19660. * @param callback Called when a button has been pressed
  19661. */
  19662. onbuttondown(callback: (buttonPressed: number) => void): void;
  19663. /**
  19664. * Callback triggered when a button has been released
  19665. * @param callback Called when a button has been released
  19666. */
  19667. onbuttonup(callback: (buttonReleased: number) => void): void;
  19668. /**
  19669. * Initializes the generic gamepad
  19670. * @param id The id of the generic gamepad
  19671. * @param index The index of the generic gamepad
  19672. * @param browserGamepad The browser gamepad
  19673. */
  19674. constructor(id: string, index: number, browserGamepad: any);
  19675. private _setButtonValue;
  19676. /**
  19677. * Updates the generic gamepad
  19678. */
  19679. update(): void;
  19680. /**
  19681. * Disposes the generic gamepad
  19682. */
  19683. dispose(): void;
  19684. }
  19685. }
  19686. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19687. import { Observable } from "babylonjs/Misc/observable";
  19688. import { Nullable } from "babylonjs/types";
  19689. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19690. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19692. import { Ray } from "babylonjs/Culling/ray";
  19693. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19694. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19695. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19696. /**
  19697. * Defines the types of pose enabled controllers that are supported
  19698. */
  19699. export enum PoseEnabledControllerType {
  19700. /**
  19701. * HTC Vive
  19702. */
  19703. VIVE = 0,
  19704. /**
  19705. * Oculus Rift
  19706. */
  19707. OCULUS = 1,
  19708. /**
  19709. * Windows mixed reality
  19710. */
  19711. WINDOWS = 2,
  19712. /**
  19713. * Samsung gear VR
  19714. */
  19715. GEAR_VR = 3,
  19716. /**
  19717. * Google Daydream
  19718. */
  19719. DAYDREAM = 4,
  19720. /**
  19721. * Generic
  19722. */
  19723. GENERIC = 5
  19724. }
  19725. /**
  19726. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19727. */
  19728. export interface MutableGamepadButton {
  19729. /**
  19730. * Value of the button/trigger
  19731. */
  19732. value: number;
  19733. /**
  19734. * If the button/trigger is currently touched
  19735. */
  19736. touched: boolean;
  19737. /**
  19738. * If the button/trigger is currently pressed
  19739. */
  19740. pressed: boolean;
  19741. }
  19742. /**
  19743. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19744. * @hidden
  19745. */
  19746. export interface ExtendedGamepadButton extends GamepadButton {
  19747. /**
  19748. * If the button/trigger is currently pressed
  19749. */
  19750. readonly pressed: boolean;
  19751. /**
  19752. * If the button/trigger is currently touched
  19753. */
  19754. readonly touched: boolean;
  19755. /**
  19756. * Value of the button/trigger
  19757. */
  19758. readonly value: number;
  19759. }
  19760. /** @hidden */
  19761. export interface _GamePadFactory {
  19762. /**
  19763. * Returns whether or not the current gamepad can be created for this type of controller.
  19764. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19765. * @returns true if it can be created, otherwise false
  19766. */
  19767. canCreate(gamepadInfo: any): boolean;
  19768. /**
  19769. * Creates a new instance of the Gamepad.
  19770. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19771. * @returns the new gamepad instance
  19772. */
  19773. create(gamepadInfo: any): Gamepad;
  19774. }
  19775. /**
  19776. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19777. */
  19778. export class PoseEnabledControllerHelper {
  19779. /** @hidden */
  19780. static _ControllerFactories: _GamePadFactory[];
  19781. /** @hidden */
  19782. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19783. /**
  19784. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19785. * @param vrGamepad the gamepad to initialized
  19786. * @returns a vr controller of the type the gamepad identified as
  19787. */
  19788. static InitiateController(vrGamepad: any): Gamepad;
  19789. }
  19790. /**
  19791. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19792. */
  19793. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19794. /**
  19795. * If the controller is used in a webXR session
  19796. */
  19797. isXR: boolean;
  19798. private _deviceRoomPosition;
  19799. private _deviceRoomRotationQuaternion;
  19800. /**
  19801. * The device position in babylon space
  19802. */
  19803. devicePosition: Vector3;
  19804. /**
  19805. * The device rotation in babylon space
  19806. */
  19807. deviceRotationQuaternion: Quaternion;
  19808. /**
  19809. * The scale factor of the device in babylon space
  19810. */
  19811. deviceScaleFactor: number;
  19812. /**
  19813. * (Likely devicePosition should be used instead) The device position in its room space
  19814. */
  19815. position: Vector3;
  19816. /**
  19817. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19818. */
  19819. rotationQuaternion: Quaternion;
  19820. /**
  19821. * The type of controller (Eg. Windows mixed reality)
  19822. */
  19823. controllerType: PoseEnabledControllerType;
  19824. protected _calculatedPosition: Vector3;
  19825. private _calculatedRotation;
  19826. /**
  19827. * The raw pose from the device
  19828. */
  19829. rawPose: DevicePose;
  19830. private _trackPosition;
  19831. private _maxRotationDistFromHeadset;
  19832. private _draggedRoomRotation;
  19833. /**
  19834. * @hidden
  19835. */
  19836. _disableTrackPosition(fixedPosition: Vector3): void;
  19837. /**
  19838. * Internal, the mesh attached to the controller
  19839. * @hidden
  19840. */
  19841. _mesh: Nullable<AbstractMesh>;
  19842. private _poseControlledCamera;
  19843. private _leftHandSystemQuaternion;
  19844. /**
  19845. * Internal, matrix used to convert room space to babylon space
  19846. * @hidden
  19847. */
  19848. _deviceToWorld: Matrix;
  19849. /**
  19850. * Node to be used when casting a ray from the controller
  19851. * @hidden
  19852. */
  19853. _pointingPoseNode: Nullable<TransformNode>;
  19854. /**
  19855. * Name of the child mesh that can be used to cast a ray from the controller
  19856. */
  19857. static readonly POINTING_POSE: string;
  19858. /**
  19859. * Creates a new PoseEnabledController from a gamepad
  19860. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19861. */
  19862. constructor(browserGamepad: any);
  19863. private _workingMatrix;
  19864. /**
  19865. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19866. */
  19867. update(): void;
  19868. /**
  19869. * Updates only the pose device and mesh without doing any button event checking
  19870. */
  19871. protected _updatePoseAndMesh(): void;
  19872. /**
  19873. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19874. * @param poseData raw pose fromthe device
  19875. */
  19876. updateFromDevice(poseData: DevicePose): void;
  19877. /**
  19878. * @hidden
  19879. */
  19880. _meshAttachedObservable: Observable<AbstractMesh>;
  19881. /**
  19882. * Attaches a mesh to the controller
  19883. * @param mesh the mesh to be attached
  19884. */
  19885. attachToMesh(mesh: AbstractMesh): void;
  19886. /**
  19887. * Attaches the controllers mesh to a camera
  19888. * @param camera the camera the mesh should be attached to
  19889. */
  19890. attachToPoseControlledCamera(camera: TargetCamera): void;
  19891. /**
  19892. * Disposes of the controller
  19893. */
  19894. dispose(): void;
  19895. /**
  19896. * The mesh that is attached to the controller
  19897. */
  19898. get mesh(): Nullable<AbstractMesh>;
  19899. /**
  19900. * Gets the ray of the controller in the direction the controller is pointing
  19901. * @param length the length the resulting ray should be
  19902. * @returns a ray in the direction the controller is pointing
  19903. */
  19904. getForwardRay(length?: number): Ray;
  19905. }
  19906. }
  19907. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19908. import { Observable } from "babylonjs/Misc/observable";
  19909. import { Scene } from "babylonjs/scene";
  19910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19911. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19912. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19913. import { Nullable } from "babylonjs/types";
  19914. /**
  19915. * Defines the WebVRController object that represents controllers tracked in 3D space
  19916. */
  19917. export abstract class WebVRController extends PoseEnabledController {
  19918. /**
  19919. * Internal, the default controller model for the controller
  19920. */
  19921. protected _defaultModel: Nullable<AbstractMesh>;
  19922. /**
  19923. * Fired when the trigger state has changed
  19924. */
  19925. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19926. /**
  19927. * Fired when the main button state has changed
  19928. */
  19929. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19930. /**
  19931. * Fired when the secondary button state has changed
  19932. */
  19933. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19934. /**
  19935. * Fired when the pad state has changed
  19936. */
  19937. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19938. /**
  19939. * Fired when controllers stick values have changed
  19940. */
  19941. onPadValuesChangedObservable: Observable<StickValues>;
  19942. /**
  19943. * Array of button availible on the controller
  19944. */
  19945. protected _buttons: Array<MutableGamepadButton>;
  19946. private _onButtonStateChange;
  19947. /**
  19948. * Fired when a controller button's state has changed
  19949. * @param callback the callback containing the button that was modified
  19950. */
  19951. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19952. /**
  19953. * X and Y axis corresponding to the controllers joystick
  19954. */
  19955. pad: StickValues;
  19956. /**
  19957. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19958. */
  19959. hand: string;
  19960. /**
  19961. * The default controller model for the controller
  19962. */
  19963. get defaultModel(): Nullable<AbstractMesh>;
  19964. /**
  19965. * Creates a new WebVRController from a gamepad
  19966. * @param vrGamepad the gamepad that the WebVRController should be created from
  19967. */
  19968. constructor(vrGamepad: any);
  19969. /**
  19970. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19971. */
  19972. update(): void;
  19973. /**
  19974. * Function to be called when a button is modified
  19975. */
  19976. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19977. /**
  19978. * Loads a mesh and attaches it to the controller
  19979. * @param scene the scene the mesh should be added to
  19980. * @param meshLoaded callback for when the mesh has been loaded
  19981. */
  19982. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19983. private _setButtonValue;
  19984. private _changes;
  19985. private _checkChanges;
  19986. /**
  19987. * Disposes of th webVRCOntroller
  19988. */
  19989. dispose(): void;
  19990. }
  19991. }
  19992. declare module "babylonjs/Lights/hemisphericLight" {
  19993. import { Nullable } from "babylonjs/types";
  19994. import { Scene } from "babylonjs/scene";
  19995. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19996. import { Color3 } from "babylonjs/Maths/math.color";
  19997. import { Effect } from "babylonjs/Materials/effect";
  19998. import { Light } from "babylonjs/Lights/light";
  19999. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20000. /**
  20001. * The HemisphericLight simulates the ambient environment light,
  20002. * so the passed direction is the light reflection direction, not the incoming direction.
  20003. */
  20004. export class HemisphericLight extends Light {
  20005. /**
  20006. * The groundColor is the light in the opposite direction to the one specified during creation.
  20007. * 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.
  20008. */
  20009. groundColor: Color3;
  20010. /**
  20011. * The light reflection direction, not the incoming direction.
  20012. */
  20013. direction: Vector3;
  20014. /**
  20015. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20016. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20017. * The HemisphericLight can't cast shadows.
  20018. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20019. * @param name The friendly name of the light
  20020. * @param direction The direction of the light reflection
  20021. * @param scene The scene the light belongs to
  20022. */
  20023. constructor(name: string, direction: Vector3, scene: Scene);
  20024. protected _buildUniformLayout(): void;
  20025. /**
  20026. * Returns the string "HemisphericLight".
  20027. * @return The class name
  20028. */
  20029. getClassName(): string;
  20030. /**
  20031. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20032. * Returns the updated direction.
  20033. * @param target The target the direction should point to
  20034. * @return The computed direction
  20035. */
  20036. setDirectionToTarget(target: Vector3): Vector3;
  20037. /**
  20038. * Returns the shadow generator associated to the light.
  20039. * @returns Always null for hemispheric lights because it does not support shadows.
  20040. */
  20041. getShadowGenerator(): Nullable<IShadowGenerator>;
  20042. /**
  20043. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20044. * @param effect The effect to update
  20045. * @param lightIndex The index of the light in the effect to update
  20046. * @returns The hemispheric light
  20047. */
  20048. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20049. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20050. /**
  20051. * Computes the world matrix of the node
  20052. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20053. * @param useWasUpdatedFlag defines a reserved property
  20054. * @returns the world matrix
  20055. */
  20056. computeWorldMatrix(): Matrix;
  20057. /**
  20058. * Returns the integer 3.
  20059. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20060. */
  20061. getTypeID(): number;
  20062. /**
  20063. * Prepares the list of defines specific to the light type.
  20064. * @param defines the list of defines
  20065. * @param lightIndex defines the index of the light for the effect
  20066. */
  20067. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20068. }
  20069. }
  20070. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20071. /** @hidden */
  20072. export var vrMultiviewToSingleviewPixelShader: {
  20073. name: string;
  20074. shader: string;
  20075. };
  20076. }
  20077. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20078. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20079. import { Scene } from "babylonjs/scene";
  20080. /**
  20081. * Renders to multiple views with a single draw call
  20082. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20083. */
  20084. export class MultiviewRenderTarget extends RenderTargetTexture {
  20085. /**
  20086. * Creates a multiview render target
  20087. * @param scene scene used with the render target
  20088. * @param size the size of the render target (used for each view)
  20089. */
  20090. constructor(scene: Scene, size?: number | {
  20091. width: number;
  20092. height: number;
  20093. } | {
  20094. ratio: number;
  20095. });
  20096. /**
  20097. * @hidden
  20098. * @param faceIndex the face index, if its a cube texture
  20099. */
  20100. _bindFrameBuffer(faceIndex?: number): void;
  20101. /**
  20102. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20103. * @returns the view count
  20104. */
  20105. getViewCount(): number;
  20106. }
  20107. }
  20108. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20109. import { Camera } from "babylonjs/Cameras/camera";
  20110. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20111. import { Nullable } from "babylonjs/types";
  20112. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20113. import { Matrix } from "babylonjs/Maths/math.vector";
  20114. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20115. module "babylonjs/Engines/engine" {
  20116. interface Engine {
  20117. /**
  20118. * Creates a new multiview render target
  20119. * @param width defines the width of the texture
  20120. * @param height defines the height of the texture
  20121. * @returns the created multiview texture
  20122. */
  20123. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20124. /**
  20125. * Binds a multiview framebuffer to be drawn to
  20126. * @param multiviewTexture texture to bind
  20127. */
  20128. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20129. }
  20130. }
  20131. module "babylonjs/Cameras/camera" {
  20132. interface Camera {
  20133. /**
  20134. * @hidden
  20135. * 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)
  20136. */
  20137. _useMultiviewToSingleView: boolean;
  20138. /**
  20139. * @hidden
  20140. * 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)
  20141. */
  20142. _multiviewTexture: Nullable<RenderTargetTexture>;
  20143. /**
  20144. * @hidden
  20145. * ensures the multiview texture of the camera exists and has the specified width/height
  20146. * @param width height to set on the multiview texture
  20147. * @param height width to set on the multiview texture
  20148. */
  20149. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20150. }
  20151. }
  20152. module "babylonjs/scene" {
  20153. interface Scene {
  20154. /** @hidden */
  20155. _transformMatrixR: Matrix;
  20156. /** @hidden */
  20157. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20158. /** @hidden */
  20159. _createMultiviewUbo(): void;
  20160. /** @hidden */
  20161. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20162. /** @hidden */
  20163. _renderMultiviewToSingleView(camera: Camera): void;
  20164. }
  20165. }
  20166. }
  20167. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20168. import { Camera } from "babylonjs/Cameras/camera";
  20169. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20170. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20171. import "babylonjs/Engines/Extensions/engine.multiview";
  20172. /**
  20173. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20174. * This will not be used for webXR as it supports displaying texture arrays directly
  20175. */
  20176. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20177. /**
  20178. * Initializes a VRMultiviewToSingleview
  20179. * @param name name of the post process
  20180. * @param camera camera to be applied to
  20181. * @param scaleFactor scaling factor to the size of the output texture
  20182. */
  20183. constructor(name: string, camera: Camera, scaleFactor: number);
  20184. }
  20185. }
  20186. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20187. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20188. import { Nullable } from "babylonjs/types";
  20189. import { Size } from "babylonjs/Maths/math.size";
  20190. import { Observable } from "babylonjs/Misc/observable";
  20191. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20192. /**
  20193. * Interface used to define additional presentation attributes
  20194. */
  20195. export interface IVRPresentationAttributes {
  20196. /**
  20197. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20198. */
  20199. highRefreshRate: boolean;
  20200. /**
  20201. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20202. */
  20203. foveationLevel: number;
  20204. }
  20205. module "babylonjs/Engines/engine" {
  20206. interface Engine {
  20207. /** @hidden */
  20208. _vrDisplay: any;
  20209. /** @hidden */
  20210. _vrSupported: boolean;
  20211. /** @hidden */
  20212. _oldSize: Size;
  20213. /** @hidden */
  20214. _oldHardwareScaleFactor: number;
  20215. /** @hidden */
  20216. _vrExclusivePointerMode: boolean;
  20217. /** @hidden */
  20218. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20219. /** @hidden */
  20220. _onVRDisplayPointerRestricted: () => void;
  20221. /** @hidden */
  20222. _onVRDisplayPointerUnrestricted: () => void;
  20223. /** @hidden */
  20224. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20225. /** @hidden */
  20226. _onVrDisplayDisconnect: Nullable<() => void>;
  20227. /** @hidden */
  20228. _onVrDisplayPresentChange: Nullable<() => void>;
  20229. /**
  20230. * Observable signaled when VR display mode changes
  20231. */
  20232. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20233. /**
  20234. * Observable signaled when VR request present is complete
  20235. */
  20236. onVRRequestPresentComplete: Observable<boolean>;
  20237. /**
  20238. * Observable signaled when VR request present starts
  20239. */
  20240. onVRRequestPresentStart: Observable<Engine>;
  20241. /**
  20242. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20243. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20244. */
  20245. isInVRExclusivePointerMode: boolean;
  20246. /**
  20247. * Gets a boolean indicating if a webVR device was detected
  20248. * @returns true if a webVR device was detected
  20249. */
  20250. isVRDevicePresent(): boolean;
  20251. /**
  20252. * Gets the current webVR device
  20253. * @returns the current webVR device (or null)
  20254. */
  20255. getVRDevice(): any;
  20256. /**
  20257. * Initializes a webVR display and starts listening to display change events
  20258. * The onVRDisplayChangedObservable will be notified upon these changes
  20259. * @returns A promise containing a VRDisplay and if vr is supported
  20260. */
  20261. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20262. /** @hidden */
  20263. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20264. /**
  20265. * Gets or sets the presentation attributes used to configure VR rendering
  20266. */
  20267. vrPresentationAttributes?: IVRPresentationAttributes;
  20268. /**
  20269. * Call this function to switch to webVR mode
  20270. * Will do nothing if webVR is not supported or if there is no webVR device
  20271. * @param options the webvr options provided to the camera. mainly used for multiview
  20272. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20273. */
  20274. enableVR(options: WebVROptions): void;
  20275. /** @hidden */
  20276. _onVRFullScreenTriggered(): void;
  20277. }
  20278. }
  20279. }
  20280. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20281. import { Nullable } from "babylonjs/types";
  20282. import { Observable } from "babylonjs/Misc/observable";
  20283. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20284. import { Scene } from "babylonjs/scene";
  20285. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20286. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20287. import { Node } from "babylonjs/node";
  20288. import { Ray } from "babylonjs/Culling/ray";
  20289. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20290. import "babylonjs/Engines/Extensions/engine.webVR";
  20291. /**
  20292. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20293. * IMPORTANT!! The data is right-hand data.
  20294. * @export
  20295. * @interface DevicePose
  20296. */
  20297. export interface DevicePose {
  20298. /**
  20299. * The position of the device, values in array are [x,y,z].
  20300. */
  20301. readonly position: Nullable<Float32Array>;
  20302. /**
  20303. * The linearVelocity of the device, values in array are [x,y,z].
  20304. */
  20305. readonly linearVelocity: Nullable<Float32Array>;
  20306. /**
  20307. * The linearAcceleration of the device, values in array are [x,y,z].
  20308. */
  20309. readonly linearAcceleration: Nullable<Float32Array>;
  20310. /**
  20311. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20312. */
  20313. readonly orientation: Nullable<Float32Array>;
  20314. /**
  20315. * The angularVelocity of the device, values in array are [x,y,z].
  20316. */
  20317. readonly angularVelocity: Nullable<Float32Array>;
  20318. /**
  20319. * The angularAcceleration of the device, values in array are [x,y,z].
  20320. */
  20321. readonly angularAcceleration: Nullable<Float32Array>;
  20322. }
  20323. /**
  20324. * Interface representing a pose controlled object in Babylon.
  20325. * A pose controlled object has both regular pose values as well as pose values
  20326. * from an external device such as a VR head mounted display
  20327. */
  20328. export interface PoseControlled {
  20329. /**
  20330. * The position of the object in babylon space.
  20331. */
  20332. position: Vector3;
  20333. /**
  20334. * The rotation quaternion of the object in babylon space.
  20335. */
  20336. rotationQuaternion: Quaternion;
  20337. /**
  20338. * The position of the device in babylon space.
  20339. */
  20340. devicePosition?: Vector3;
  20341. /**
  20342. * The rotation quaternion of the device in babylon space.
  20343. */
  20344. deviceRotationQuaternion: Quaternion;
  20345. /**
  20346. * The raw pose coming from the device.
  20347. */
  20348. rawPose: Nullable<DevicePose>;
  20349. /**
  20350. * The scale of the device to be used when translating from device space to babylon space.
  20351. */
  20352. deviceScaleFactor: number;
  20353. /**
  20354. * Updates the poseControlled values based on the input device pose.
  20355. * @param poseData the pose data to update the object with
  20356. */
  20357. updateFromDevice(poseData: DevicePose): void;
  20358. }
  20359. /**
  20360. * Set of options to customize the webVRCamera
  20361. */
  20362. export interface WebVROptions {
  20363. /**
  20364. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20365. */
  20366. trackPosition?: boolean;
  20367. /**
  20368. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20369. */
  20370. positionScale?: number;
  20371. /**
  20372. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20373. */
  20374. displayName?: string;
  20375. /**
  20376. * Should the native controller meshes be initialized. (default: true)
  20377. */
  20378. controllerMeshes?: boolean;
  20379. /**
  20380. * Creating a default HemiLight only on controllers. (default: true)
  20381. */
  20382. defaultLightingOnControllers?: boolean;
  20383. /**
  20384. * If you don't want to use the default VR button of the helper. (default: false)
  20385. */
  20386. useCustomVRButton?: boolean;
  20387. /**
  20388. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20389. */
  20390. customVRButton?: HTMLButtonElement;
  20391. /**
  20392. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20393. */
  20394. rayLength?: number;
  20395. /**
  20396. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20397. */
  20398. defaultHeight?: number;
  20399. /**
  20400. * If multiview should be used if availible (default: false)
  20401. */
  20402. useMultiview?: boolean;
  20403. }
  20404. /**
  20405. * This represents a WebVR camera.
  20406. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20407. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20408. */
  20409. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20410. private webVROptions;
  20411. /**
  20412. * @hidden
  20413. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20414. */
  20415. _vrDevice: any;
  20416. /**
  20417. * The rawPose of the vrDevice.
  20418. */
  20419. rawPose: Nullable<DevicePose>;
  20420. private _onVREnabled;
  20421. private _specsVersion;
  20422. private _attached;
  20423. private _frameData;
  20424. protected _descendants: Array<Node>;
  20425. private _deviceRoomPosition;
  20426. /** @hidden */
  20427. _deviceRoomRotationQuaternion: Quaternion;
  20428. private _standingMatrix;
  20429. /**
  20430. * Represents device position in babylon space.
  20431. */
  20432. devicePosition: Vector3;
  20433. /**
  20434. * Represents device rotation in babylon space.
  20435. */
  20436. deviceRotationQuaternion: Quaternion;
  20437. /**
  20438. * The scale of the device to be used when translating from device space to babylon space.
  20439. */
  20440. deviceScaleFactor: number;
  20441. private _deviceToWorld;
  20442. private _worldToDevice;
  20443. /**
  20444. * References to the webVR controllers for the vrDevice.
  20445. */
  20446. controllers: Array<WebVRController>;
  20447. /**
  20448. * Emits an event when a controller is attached.
  20449. */
  20450. onControllersAttachedObservable: Observable<WebVRController[]>;
  20451. /**
  20452. * Emits an event when a controller's mesh has been loaded;
  20453. */
  20454. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20455. /**
  20456. * Emits an event when the HMD's pose has been updated.
  20457. */
  20458. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20459. private _poseSet;
  20460. /**
  20461. * If the rig cameras be used as parent instead of this camera.
  20462. */
  20463. rigParenting: boolean;
  20464. private _lightOnControllers;
  20465. private _defaultHeight?;
  20466. /**
  20467. * Instantiates a WebVRFreeCamera.
  20468. * @param name The name of the WebVRFreeCamera
  20469. * @param position The starting anchor position for the camera
  20470. * @param scene The scene the camera belongs to
  20471. * @param webVROptions a set of customizable options for the webVRCamera
  20472. */
  20473. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20474. /**
  20475. * Gets the device distance from the ground in meters.
  20476. * @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.
  20477. */
  20478. deviceDistanceToRoomGround(): number;
  20479. /**
  20480. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20481. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20482. */
  20483. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20484. /**
  20485. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20486. * @returns A promise with a boolean set to if the standing matrix is supported.
  20487. */
  20488. useStandingMatrixAsync(): Promise<boolean>;
  20489. /**
  20490. * Disposes the camera
  20491. */
  20492. dispose(): void;
  20493. /**
  20494. * Gets a vrController by name.
  20495. * @param name The name of the controller to retreive
  20496. * @returns the controller matching the name specified or null if not found
  20497. */
  20498. getControllerByName(name: string): Nullable<WebVRController>;
  20499. private _leftController;
  20500. /**
  20501. * The controller corresponding to the users left hand.
  20502. */
  20503. get leftController(): Nullable<WebVRController>;
  20504. private _rightController;
  20505. /**
  20506. * The controller corresponding to the users right hand.
  20507. */
  20508. get rightController(): Nullable<WebVRController>;
  20509. /**
  20510. * Casts a ray forward from the vrCamera's gaze.
  20511. * @param length Length of the ray (default: 100)
  20512. * @returns the ray corresponding to the gaze
  20513. */
  20514. getForwardRay(length?: number): Ray;
  20515. /**
  20516. * @hidden
  20517. * Updates the camera based on device's frame data
  20518. */
  20519. _checkInputs(): void;
  20520. /**
  20521. * Updates the poseControlled values based on the input device pose.
  20522. * @param poseData Pose coming from the device
  20523. */
  20524. updateFromDevice(poseData: DevicePose): void;
  20525. private _htmlElementAttached;
  20526. private _detachIfAttached;
  20527. /**
  20528. * WebVR's attach control will start broadcasting frames to the device.
  20529. * Note that in certain browsers (chrome for example) this function must be called
  20530. * within a user-interaction callback. Example:
  20531. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20532. *
  20533. * @param element html element to attach the vrDevice to
  20534. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20535. */
  20536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20537. /**
  20538. * Detaches the camera from the html element and disables VR
  20539. *
  20540. * @param element html element to detach from
  20541. */
  20542. detachControl(element: HTMLElement): void;
  20543. /**
  20544. * @returns the name of this class
  20545. */
  20546. getClassName(): string;
  20547. /**
  20548. * Calls resetPose on the vrDisplay
  20549. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20550. */
  20551. resetToCurrentRotation(): void;
  20552. /**
  20553. * @hidden
  20554. * Updates the rig cameras (left and right eye)
  20555. */
  20556. _updateRigCameras(): void;
  20557. private _workingVector;
  20558. private _oneVector;
  20559. private _workingMatrix;
  20560. private updateCacheCalled;
  20561. private _correctPositionIfNotTrackPosition;
  20562. /**
  20563. * @hidden
  20564. * Updates the cached values of the camera
  20565. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20566. */
  20567. _updateCache(ignoreParentClass?: boolean): void;
  20568. /**
  20569. * @hidden
  20570. * Get current device position in babylon world
  20571. */
  20572. _computeDevicePosition(): void;
  20573. /**
  20574. * Updates the current device position and rotation in the babylon world
  20575. */
  20576. update(): void;
  20577. /**
  20578. * @hidden
  20579. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20580. * @returns an identity matrix
  20581. */
  20582. _getViewMatrix(): Matrix;
  20583. private _tmpMatrix;
  20584. /**
  20585. * This function is called by the two RIG cameras.
  20586. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20587. * @hidden
  20588. */
  20589. _getWebVRViewMatrix(): Matrix;
  20590. /** @hidden */
  20591. _getWebVRProjectionMatrix(): Matrix;
  20592. private _onGamepadConnectedObserver;
  20593. private _onGamepadDisconnectedObserver;
  20594. private _updateCacheWhenTrackingDisabledObserver;
  20595. /**
  20596. * Initializes the controllers and their meshes
  20597. */
  20598. initControllers(): void;
  20599. }
  20600. }
  20601. declare module "babylonjs/Materials/materialHelper" {
  20602. import { Nullable } from "babylonjs/types";
  20603. import { Scene } from "babylonjs/scene";
  20604. import { Engine } from "babylonjs/Engines/engine";
  20605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20606. import { Light } from "babylonjs/Lights/light";
  20607. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20608. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20609. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20610. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20611. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20612. /**
  20613. * "Static Class" containing the most commonly used helper while dealing with material for
  20614. * rendering purpose.
  20615. *
  20616. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20617. *
  20618. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20619. */
  20620. export class MaterialHelper {
  20621. /**
  20622. * Bind the current view position to an effect.
  20623. * @param effect The effect to be bound
  20624. * @param scene The scene the eyes position is used from
  20625. * @param variableName name of the shader variable that will hold the eye position
  20626. */
  20627. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20628. /**
  20629. * Helps preparing the defines values about the UVs in used in the effect.
  20630. * UVs are shared as much as we can accross channels in the shaders.
  20631. * @param texture The texture we are preparing the UVs for
  20632. * @param defines The defines to update
  20633. * @param key The channel key "diffuse", "specular"... used in the shader
  20634. */
  20635. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20636. /**
  20637. * Binds a texture matrix value to its corrsponding uniform
  20638. * @param texture The texture to bind the matrix for
  20639. * @param uniformBuffer The uniform buffer receivin the data
  20640. * @param key The channel key "diffuse", "specular"... used in the shader
  20641. */
  20642. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20643. /**
  20644. * Gets the current status of the fog (should it be enabled?)
  20645. * @param mesh defines the mesh to evaluate for fog support
  20646. * @param scene defines the hosting scene
  20647. * @returns true if fog must be enabled
  20648. */
  20649. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20650. /**
  20651. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20652. * @param mesh defines the current mesh
  20653. * @param scene defines the current scene
  20654. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20655. * @param pointsCloud defines if point cloud rendering has to be turned on
  20656. * @param fogEnabled defines if fog has to be turned on
  20657. * @param alphaTest defines if alpha testing has to be turned on
  20658. * @param defines defines the current list of defines
  20659. */
  20660. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20661. /**
  20662. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20663. * @param scene defines the current scene
  20664. * @param engine defines the current engine
  20665. * @param defines specifies the list of active defines
  20666. * @param useInstances defines if instances have to be turned on
  20667. * @param useClipPlane defines if clip plane have to be turned on
  20668. * @param useInstances defines if instances have to be turned on
  20669. * @param useThinInstances defines if thin instances have to be turned on
  20670. */
  20671. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20672. /**
  20673. * Prepares the defines for bones
  20674. * @param mesh The mesh containing the geometry data we will draw
  20675. * @param defines The defines to update
  20676. */
  20677. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20678. /**
  20679. * Prepares the defines for morph targets
  20680. * @param mesh The mesh containing the geometry data we will draw
  20681. * @param defines The defines to update
  20682. */
  20683. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20684. /**
  20685. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20686. * @param mesh The mesh containing the geometry data we will draw
  20687. * @param defines The defines to update
  20688. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20689. * @param useBones Precise whether bones should be used or not (override mesh info)
  20690. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20691. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20692. * @returns false if defines are considered not dirty and have not been checked
  20693. */
  20694. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20695. /**
  20696. * Prepares the defines related to multiview
  20697. * @param scene The scene we are intending to draw
  20698. * @param defines The defines to update
  20699. */
  20700. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20701. /**
  20702. * Prepares the defines related to the light information passed in parameter
  20703. * @param scene The scene we are intending to draw
  20704. * @param mesh The mesh the effect is compiling for
  20705. * @param light The light the effect is compiling for
  20706. * @param lightIndex The index of the light
  20707. * @param defines The defines to update
  20708. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20709. * @param state Defines the current state regarding what is needed (normals, etc...)
  20710. */
  20711. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20712. needNormals: boolean;
  20713. needRebuild: boolean;
  20714. shadowEnabled: boolean;
  20715. specularEnabled: boolean;
  20716. lightmapMode: boolean;
  20717. }): void;
  20718. /**
  20719. * Prepares the defines related to the light information passed in parameter
  20720. * @param scene The scene we are intending to draw
  20721. * @param mesh The mesh the effect is compiling for
  20722. * @param defines The defines to update
  20723. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20724. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20725. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20726. * @returns true if normals will be required for the rest of the effect
  20727. */
  20728. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20729. /**
  20730. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20731. * @param lightIndex defines the light index
  20732. * @param uniformsList The uniform list
  20733. * @param samplersList The sampler list
  20734. * @param projectedLightTexture defines if projected texture must be used
  20735. * @param uniformBuffersList defines an optional list of uniform buffers
  20736. */
  20737. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20738. /**
  20739. * Prepares the uniforms and samplers list to be used in the effect
  20740. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20741. * @param samplersList The sampler list
  20742. * @param defines The defines helping in the list generation
  20743. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20744. */
  20745. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20746. /**
  20747. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20748. * @param defines The defines to update while falling back
  20749. * @param fallbacks The authorized effect fallbacks
  20750. * @param maxSimultaneousLights The maximum number of lights allowed
  20751. * @param rank the current rank of the Effect
  20752. * @returns The newly affected rank
  20753. */
  20754. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20755. private static _TmpMorphInfluencers;
  20756. /**
  20757. * Prepares the list of attributes required for morph targets according to the effect defines.
  20758. * @param attribs The current list of supported attribs
  20759. * @param mesh The mesh to prepare the morph targets attributes for
  20760. * @param influencers The number of influencers
  20761. */
  20762. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20763. /**
  20764. * Prepares the list of attributes required for morph targets according to the effect defines.
  20765. * @param attribs The current list of supported attribs
  20766. * @param mesh The mesh to prepare the morph targets attributes for
  20767. * @param defines The current Defines of the effect
  20768. */
  20769. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20770. /**
  20771. * Prepares the list of attributes required for bones according to the effect defines.
  20772. * @param attribs The current list of supported attribs
  20773. * @param mesh The mesh to prepare the bones attributes for
  20774. * @param defines The current Defines of the effect
  20775. * @param fallbacks The current efffect fallback strategy
  20776. */
  20777. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20778. /**
  20779. * Check and prepare the list of attributes required for instances according to the effect defines.
  20780. * @param attribs The current list of supported attribs
  20781. * @param defines The current MaterialDefines of the effect
  20782. */
  20783. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20784. /**
  20785. * Add the list of attributes required for instances to the attribs array.
  20786. * @param attribs The current list of supported attribs
  20787. */
  20788. static PushAttributesForInstances(attribs: string[]): void;
  20789. /**
  20790. * Binds the light information to the effect.
  20791. * @param light The light containing the generator
  20792. * @param effect The effect we are binding the data to
  20793. * @param lightIndex The light index in the effect used to render
  20794. */
  20795. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20796. /**
  20797. * Binds the lights information from the scene to the effect for the given mesh.
  20798. * @param light Light to bind
  20799. * @param lightIndex Light index
  20800. * @param scene The scene where the light belongs to
  20801. * @param effect The effect we are binding the data to
  20802. * @param useSpecular Defines if specular is supported
  20803. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20804. */
  20805. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20806. /**
  20807. * Binds the lights information from the scene to the effect for the given mesh.
  20808. * @param scene The scene the lights belongs to
  20809. * @param mesh The mesh we are binding the information to render
  20810. * @param effect The effect we are binding the data to
  20811. * @param defines The generated defines for the effect
  20812. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20813. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20814. */
  20815. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20816. private static _tempFogColor;
  20817. /**
  20818. * Binds the fog information from the scene to the effect for the given mesh.
  20819. * @param scene The scene the lights belongs to
  20820. * @param mesh The mesh we are binding the information to render
  20821. * @param effect The effect we are binding the data to
  20822. * @param linearSpace Defines if the fog effect is applied in linear space
  20823. */
  20824. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20825. /**
  20826. * Binds the bones information from the mesh to the effect.
  20827. * @param mesh The mesh we are binding the information to render
  20828. * @param effect The effect we are binding the data to
  20829. */
  20830. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20831. /**
  20832. * Binds the morph targets information from the mesh to the effect.
  20833. * @param abstractMesh The mesh we are binding the information to render
  20834. * @param effect The effect we are binding the data to
  20835. */
  20836. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20837. /**
  20838. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20839. * @param defines The generated defines used in the effect
  20840. * @param effect The effect we are binding the data to
  20841. * @param scene The scene we are willing to render with logarithmic scale for
  20842. */
  20843. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20844. /**
  20845. * Binds the clip plane information from the scene to the effect.
  20846. * @param scene The scene the clip plane information are extracted from
  20847. * @param effect The effect we are binding the data to
  20848. */
  20849. static BindClipPlane(effect: Effect, scene: Scene): void;
  20850. }
  20851. }
  20852. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20853. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20854. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20855. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20856. import { Nullable } from "babylonjs/types";
  20857. import { Effect } from "babylonjs/Materials/effect";
  20858. import { Matrix } from "babylonjs/Maths/math.vector";
  20859. import { Scene } from "babylonjs/scene";
  20860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20862. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20863. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20864. import { Observable } from "babylonjs/Misc/observable";
  20865. /**
  20866. * Block used to expose an input value
  20867. */
  20868. export class InputBlock extends NodeMaterialBlock {
  20869. private _mode;
  20870. private _associatedVariableName;
  20871. private _storedValue;
  20872. private _valueCallback;
  20873. private _type;
  20874. private _animationType;
  20875. /** Gets or set a value used to limit the range of float values */
  20876. min: number;
  20877. /** Gets or set a value used to limit the range of float values */
  20878. max: number;
  20879. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20880. isBoolean: boolean;
  20881. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20882. matrixMode: number;
  20883. /** @hidden */
  20884. _systemValue: Nullable<NodeMaterialSystemValues>;
  20885. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20886. visibleInInspector: boolean;
  20887. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20888. isConstant: boolean;
  20889. /** Gets or sets the group to use to display this block in the Inspector */
  20890. groupInInspector: string;
  20891. /** Gets an observable raised when the value is changed */
  20892. onValueChangedObservable: Observable<InputBlock>;
  20893. /**
  20894. * Gets or sets the connection point type (default is float)
  20895. */
  20896. get type(): NodeMaterialBlockConnectionPointTypes;
  20897. /**
  20898. * Creates a new InputBlock
  20899. * @param name defines the block name
  20900. * @param target defines the target of that block (Vertex by default)
  20901. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20902. */
  20903. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20904. /**
  20905. * Gets the output component
  20906. */
  20907. get output(): NodeMaterialConnectionPoint;
  20908. /**
  20909. * Set the source of this connection point to a vertex attribute
  20910. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20911. * @returns the current connection point
  20912. */
  20913. setAsAttribute(attributeName?: string): InputBlock;
  20914. /**
  20915. * Set the source of this connection point to a system value
  20916. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20917. * @returns the current connection point
  20918. */
  20919. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20920. /**
  20921. * Gets or sets the value of that point.
  20922. * Please note that this value will be ignored if valueCallback is defined
  20923. */
  20924. get value(): any;
  20925. set value(value: any);
  20926. /**
  20927. * Gets or sets a callback used to get the value of that point.
  20928. * Please note that setting this value will force the connection point to ignore the value property
  20929. */
  20930. get valueCallback(): () => any;
  20931. set valueCallback(value: () => any);
  20932. /**
  20933. * Gets or sets the associated variable name in the shader
  20934. */
  20935. get associatedVariableName(): string;
  20936. set associatedVariableName(value: string);
  20937. /** Gets or sets the type of animation applied to the input */
  20938. get animationType(): AnimatedInputBlockTypes;
  20939. set animationType(value: AnimatedInputBlockTypes);
  20940. /**
  20941. * Gets a boolean indicating that this connection point not defined yet
  20942. */
  20943. get isUndefined(): boolean;
  20944. /**
  20945. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20946. * In this case the connection point name must be the name of the uniform to use.
  20947. * Can only be set on inputs
  20948. */
  20949. get isUniform(): boolean;
  20950. set isUniform(value: boolean);
  20951. /**
  20952. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20953. * In this case the connection point name must be the name of the attribute to use
  20954. * Can only be set on inputs
  20955. */
  20956. get isAttribute(): boolean;
  20957. set isAttribute(value: boolean);
  20958. /**
  20959. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20960. * Can only be set on exit points
  20961. */
  20962. get isVarying(): boolean;
  20963. set isVarying(value: boolean);
  20964. /**
  20965. * Gets a boolean indicating that the current connection point is a system value
  20966. */
  20967. get isSystemValue(): boolean;
  20968. /**
  20969. * Gets or sets the current well known value or null if not defined as a system value
  20970. */
  20971. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20972. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20973. /**
  20974. * Gets the current class name
  20975. * @returns the class name
  20976. */
  20977. getClassName(): string;
  20978. /**
  20979. * Animate the input if animationType !== None
  20980. * @param scene defines the rendering scene
  20981. */
  20982. animate(scene: Scene): void;
  20983. private _emitDefine;
  20984. initialize(state: NodeMaterialBuildState): void;
  20985. /**
  20986. * Set the input block to its default value (based on its type)
  20987. */
  20988. setDefaultValue(): void;
  20989. private _emitConstant;
  20990. /** @hidden */
  20991. get _noContextSwitch(): boolean;
  20992. private _emit;
  20993. /** @hidden */
  20994. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20995. /** @hidden */
  20996. _transmit(effect: Effect, scene: Scene): void;
  20997. protected _buildBlock(state: NodeMaterialBuildState): void;
  20998. protected _dumpPropertiesCode(): string;
  20999. dispose(): void;
  21000. serialize(): any;
  21001. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21002. }
  21003. }
  21004. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21005. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21006. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21007. import { Nullable } from "babylonjs/types";
  21008. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21009. import { Observable } from "babylonjs/Misc/observable";
  21010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21011. /**
  21012. * Enum used to define the compatibility state between two connection points
  21013. */
  21014. export enum NodeMaterialConnectionPointCompatibilityStates {
  21015. /** Points are compatibles */
  21016. Compatible = 0,
  21017. /** Points are incompatible because of their types */
  21018. TypeIncompatible = 1,
  21019. /** Points are incompatible because of their targets (vertex vs fragment) */
  21020. TargetIncompatible = 2
  21021. }
  21022. /**
  21023. * Defines the direction of a connection point
  21024. */
  21025. export enum NodeMaterialConnectionPointDirection {
  21026. /** Input */
  21027. Input = 0,
  21028. /** Output */
  21029. Output = 1
  21030. }
  21031. /**
  21032. * Defines a connection point for a block
  21033. */
  21034. export class NodeMaterialConnectionPoint {
  21035. /** @hidden */
  21036. _ownerBlock: NodeMaterialBlock;
  21037. /** @hidden */
  21038. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21039. private _endpoints;
  21040. private _associatedVariableName;
  21041. private _direction;
  21042. /** @hidden */
  21043. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21044. /** @hidden */
  21045. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21046. private _type;
  21047. /** @hidden */
  21048. _enforceAssociatedVariableName: boolean;
  21049. /** Gets the direction of the point */
  21050. get direction(): NodeMaterialConnectionPointDirection;
  21051. /** Indicates that this connection point needs dual validation before being connected to another point */
  21052. needDualDirectionValidation: boolean;
  21053. /**
  21054. * Gets or sets the additional types supported by this connection point
  21055. */
  21056. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21057. /**
  21058. * Gets or sets the additional types excluded by this connection point
  21059. */
  21060. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21061. /**
  21062. * Observable triggered when this point is connected
  21063. */
  21064. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21065. /**
  21066. * Gets or sets the associated variable name in the shader
  21067. */
  21068. get associatedVariableName(): string;
  21069. set associatedVariableName(value: string);
  21070. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21071. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21072. /**
  21073. * Gets or sets the connection point type (default is float)
  21074. */
  21075. get type(): NodeMaterialBlockConnectionPointTypes;
  21076. set type(value: NodeMaterialBlockConnectionPointTypes);
  21077. /**
  21078. * Gets or sets the connection point name
  21079. */
  21080. name: string;
  21081. /**
  21082. * Gets or sets the connection point name
  21083. */
  21084. displayName: string;
  21085. /**
  21086. * Gets or sets a boolean indicating that this connection point can be omitted
  21087. */
  21088. isOptional: boolean;
  21089. /**
  21090. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21091. */
  21092. isExposedOnFrame: boolean;
  21093. /**
  21094. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21095. */
  21096. define: string;
  21097. /** @hidden */
  21098. _prioritizeVertex: boolean;
  21099. private _target;
  21100. /** Gets or sets the target of that connection point */
  21101. get target(): NodeMaterialBlockTargets;
  21102. set target(value: NodeMaterialBlockTargets);
  21103. /**
  21104. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21105. */
  21106. get isConnected(): boolean;
  21107. /**
  21108. * Gets a boolean indicating that the current point is connected to an input block
  21109. */
  21110. get isConnectedToInputBlock(): boolean;
  21111. /**
  21112. * Gets a the connected input block (if any)
  21113. */
  21114. get connectInputBlock(): Nullable<InputBlock>;
  21115. /** Get the other side of the connection (if any) */
  21116. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21117. /** Get the block that owns this connection point */
  21118. get ownerBlock(): NodeMaterialBlock;
  21119. /** Get the block connected on the other side of this connection (if any) */
  21120. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21121. /** Get the block connected on the endpoints of this connection (if any) */
  21122. get connectedBlocks(): Array<NodeMaterialBlock>;
  21123. /** Gets the list of connected endpoints */
  21124. get endpoints(): NodeMaterialConnectionPoint[];
  21125. /** Gets a boolean indicating if that output point is connected to at least one input */
  21126. get hasEndpoints(): boolean;
  21127. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21128. get isConnectedInVertexShader(): boolean;
  21129. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21130. get isConnectedInFragmentShader(): boolean;
  21131. /**
  21132. * Creates a block suitable to be used as an input for this input point.
  21133. * If null is returned, a block based on the point type will be created.
  21134. * @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
  21135. */
  21136. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21137. /**
  21138. * Creates a new connection point
  21139. * @param name defines the connection point name
  21140. * @param ownerBlock defines the block hosting this connection point
  21141. * @param direction defines the direction of the connection point
  21142. */
  21143. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21144. /**
  21145. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21146. * @returns the class name
  21147. */
  21148. getClassName(): string;
  21149. /**
  21150. * Gets a boolean indicating if the current point can be connected to another point
  21151. * @param connectionPoint defines the other connection point
  21152. * @returns a boolean
  21153. */
  21154. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21155. /**
  21156. * Gets a number indicating if the current point can be connected to another point
  21157. * @param connectionPoint defines the other connection point
  21158. * @returns a number defining the compatibility state
  21159. */
  21160. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21161. /**
  21162. * Connect this point to another connection point
  21163. * @param connectionPoint defines the other connection point
  21164. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21165. * @returns the current connection point
  21166. */
  21167. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21168. /**
  21169. * Disconnect this point from one of his endpoint
  21170. * @param endpoint defines the other connection point
  21171. * @returns the current connection point
  21172. */
  21173. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21174. /**
  21175. * Serializes this point in a JSON representation
  21176. * @param isInput defines if the connection point is an input (default is true)
  21177. * @returns the serialized point object
  21178. */
  21179. serialize(isInput?: boolean): any;
  21180. /**
  21181. * Release resources
  21182. */
  21183. dispose(): void;
  21184. }
  21185. }
  21186. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21187. /**
  21188. * Enum used to define the material modes
  21189. */
  21190. export enum NodeMaterialModes {
  21191. /** Regular material */
  21192. Material = 0,
  21193. /** For post process */
  21194. PostProcess = 1,
  21195. /** For particle system */
  21196. Particle = 2
  21197. }
  21198. }
  21199. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21202. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21203. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21205. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21206. import { Effect } from "babylonjs/Materials/effect";
  21207. import { Mesh } from "babylonjs/Meshes/mesh";
  21208. import { Nullable } from "babylonjs/types";
  21209. import { Texture } from "babylonjs/Materials/Textures/texture";
  21210. import { Scene } from "babylonjs/scene";
  21211. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21212. /**
  21213. * Block used to read a texture from a sampler
  21214. */
  21215. export class TextureBlock extends NodeMaterialBlock {
  21216. private _defineName;
  21217. private _linearDefineName;
  21218. private _gammaDefineName;
  21219. private _tempTextureRead;
  21220. private _samplerName;
  21221. private _transformedUVName;
  21222. private _textureTransformName;
  21223. private _textureInfoName;
  21224. private _mainUVName;
  21225. private _mainUVDefineName;
  21226. private _fragmentOnly;
  21227. /**
  21228. * Gets or sets the texture associated with the node
  21229. */
  21230. texture: Nullable<Texture>;
  21231. /**
  21232. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21233. */
  21234. convertToGammaSpace: boolean;
  21235. /**
  21236. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21237. */
  21238. convertToLinearSpace: boolean;
  21239. /**
  21240. * Create a new TextureBlock
  21241. * @param name defines the block name
  21242. */
  21243. constructor(name: string, fragmentOnly?: boolean);
  21244. /**
  21245. * Gets the current class name
  21246. * @returns the class name
  21247. */
  21248. getClassName(): string;
  21249. /**
  21250. * Gets the uv input component
  21251. */
  21252. get uv(): NodeMaterialConnectionPoint;
  21253. /**
  21254. * Gets the rgba output component
  21255. */
  21256. get rgba(): NodeMaterialConnectionPoint;
  21257. /**
  21258. * Gets the rgb output component
  21259. */
  21260. get rgb(): NodeMaterialConnectionPoint;
  21261. /**
  21262. * Gets the r output component
  21263. */
  21264. get r(): NodeMaterialConnectionPoint;
  21265. /**
  21266. * Gets the g output component
  21267. */
  21268. get g(): NodeMaterialConnectionPoint;
  21269. /**
  21270. * Gets the b output component
  21271. */
  21272. get b(): NodeMaterialConnectionPoint;
  21273. /**
  21274. * Gets the a output component
  21275. */
  21276. get a(): NodeMaterialConnectionPoint;
  21277. get target(): NodeMaterialBlockTargets;
  21278. autoConfigure(material: NodeMaterial): void;
  21279. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21280. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21281. isReady(): boolean;
  21282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21283. private get _isMixed();
  21284. private _injectVertexCode;
  21285. private _writeTextureRead;
  21286. private _writeOutput;
  21287. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21288. protected _dumpPropertiesCode(): string;
  21289. serialize(): any;
  21290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21291. }
  21292. }
  21293. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21294. /** @hidden */
  21295. export var reflectionFunction: {
  21296. name: string;
  21297. shader: string;
  21298. };
  21299. }
  21300. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21306. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21307. import { Effect } from "babylonjs/Materials/effect";
  21308. import { Mesh } from "babylonjs/Meshes/mesh";
  21309. import { Nullable } from "babylonjs/types";
  21310. import { Scene } from "babylonjs/scene";
  21311. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21312. /**
  21313. * Base block used to read a reflection texture from a sampler
  21314. */
  21315. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21316. /** @hidden */
  21317. _define3DName: string;
  21318. /** @hidden */
  21319. _defineCubicName: string;
  21320. /** @hidden */
  21321. _defineExplicitName: string;
  21322. /** @hidden */
  21323. _defineProjectionName: string;
  21324. /** @hidden */
  21325. _defineLocalCubicName: string;
  21326. /** @hidden */
  21327. _defineSphericalName: string;
  21328. /** @hidden */
  21329. _definePlanarName: string;
  21330. /** @hidden */
  21331. _defineEquirectangularName: string;
  21332. /** @hidden */
  21333. _defineMirroredEquirectangularFixedName: string;
  21334. /** @hidden */
  21335. _defineEquirectangularFixedName: string;
  21336. /** @hidden */
  21337. _defineSkyboxName: string;
  21338. /** @hidden */
  21339. _defineOppositeZ: string;
  21340. /** @hidden */
  21341. _cubeSamplerName: string;
  21342. /** @hidden */
  21343. _2DSamplerName: string;
  21344. protected _positionUVWName: string;
  21345. protected _directionWName: string;
  21346. protected _reflectionVectorName: string;
  21347. /** @hidden */
  21348. _reflectionCoordsName: string;
  21349. /** @hidden */
  21350. _reflectionMatrixName: string;
  21351. protected _reflectionColorName: string;
  21352. /**
  21353. * Gets or sets the texture associated with the node
  21354. */
  21355. texture: Nullable<BaseTexture>;
  21356. /**
  21357. * Create a new ReflectionTextureBaseBlock
  21358. * @param name defines the block name
  21359. */
  21360. constructor(name: string);
  21361. /**
  21362. * Gets the current class name
  21363. * @returns the class name
  21364. */
  21365. getClassName(): string;
  21366. /**
  21367. * Gets the world position input component
  21368. */
  21369. abstract get position(): NodeMaterialConnectionPoint;
  21370. /**
  21371. * Gets the world position input component
  21372. */
  21373. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21374. /**
  21375. * Gets the world normal input component
  21376. */
  21377. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21378. /**
  21379. * Gets the world input component
  21380. */
  21381. abstract get world(): NodeMaterialConnectionPoint;
  21382. /**
  21383. * Gets the camera (or eye) position component
  21384. */
  21385. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21386. /**
  21387. * Gets the view input component
  21388. */
  21389. abstract get view(): NodeMaterialConnectionPoint;
  21390. protected _getTexture(): Nullable<BaseTexture>;
  21391. autoConfigure(material: NodeMaterial): void;
  21392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21393. isReady(): boolean;
  21394. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21395. /**
  21396. * Gets the code to inject in the vertex shader
  21397. * @param state current state of the node material building
  21398. * @returns the shader code
  21399. */
  21400. handleVertexSide(state: NodeMaterialBuildState): string;
  21401. /**
  21402. * Handles the inits for the fragment code path
  21403. * @param state node material build state
  21404. */
  21405. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21406. /**
  21407. * Generates the reflection coords code for the fragment code path
  21408. * @param worldNormalVarName name of the world normal variable
  21409. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21410. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21411. * @returns the shader code
  21412. */
  21413. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21414. /**
  21415. * Generates the reflection color code for the fragment code path
  21416. * @param lodVarName name of the lod variable
  21417. * @param swizzleLookupTexture swizzle to use for the final color variable
  21418. * @returns the shader code
  21419. */
  21420. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21421. /**
  21422. * Generates the code corresponding to the connected output points
  21423. * @param state node material build state
  21424. * @param varName name of the variable to output
  21425. * @returns the shader code
  21426. */
  21427. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21428. protected _buildBlock(state: NodeMaterialBuildState): this;
  21429. protected _dumpPropertiesCode(): string;
  21430. serialize(): any;
  21431. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21432. }
  21433. }
  21434. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21436. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21437. import { Nullable } from "babylonjs/types";
  21438. /**
  21439. * Defines a connection point to be used for points with a custom object type
  21440. */
  21441. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21442. private _blockType;
  21443. private _blockName;
  21444. private _nameForCheking?;
  21445. /**
  21446. * Creates a new connection point
  21447. * @param name defines the connection point name
  21448. * @param ownerBlock defines the block hosting this connection point
  21449. * @param direction defines the direction of the connection point
  21450. */
  21451. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21452. /**
  21453. * Gets a number indicating if the current point can be connected to another point
  21454. * @param connectionPoint defines the other connection point
  21455. * @returns a number defining the compatibility state
  21456. */
  21457. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21458. /**
  21459. * Creates a block suitable to be used as an input for this input point.
  21460. * If null is returned, a block based on the point type will be created.
  21461. * @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
  21462. */
  21463. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21464. }
  21465. }
  21466. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21467. /**
  21468. * Enum defining the type of properties that can be edited in the property pages in the NME
  21469. */
  21470. export enum PropertyTypeForEdition {
  21471. /** property is a boolean */
  21472. Boolean = 0,
  21473. /** property is a float */
  21474. Float = 1,
  21475. /** property is a Vector2 */
  21476. Vector2 = 2,
  21477. /** property is a list of values */
  21478. List = 3
  21479. }
  21480. /**
  21481. * Interface that defines an option in a variable of type list
  21482. */
  21483. export interface IEditablePropertyListOption {
  21484. /** label of the option */
  21485. "label": string;
  21486. /** value of the option */
  21487. "value": number;
  21488. }
  21489. /**
  21490. * Interface that defines the options available for an editable property
  21491. */
  21492. export interface IEditablePropertyOption {
  21493. /** min value */
  21494. "min"?: number;
  21495. /** max value */
  21496. "max"?: number;
  21497. /** notifiers: indicates which actions to take when the property is changed */
  21498. "notifiers"?: {
  21499. /** the material should be rebuilt */
  21500. "rebuild"?: boolean;
  21501. /** the preview should be updated */
  21502. "update"?: boolean;
  21503. };
  21504. /** list of the options for a variable of type list */
  21505. "options"?: IEditablePropertyListOption[];
  21506. }
  21507. /**
  21508. * Interface that describes an editable property
  21509. */
  21510. export interface IPropertyDescriptionForEdition {
  21511. /** name of the property */
  21512. "propertyName": string;
  21513. /** display name of the property */
  21514. "displayName": string;
  21515. /** type of the property */
  21516. "type": PropertyTypeForEdition;
  21517. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21518. "groupName": string;
  21519. /** options for the property */
  21520. "options": IEditablePropertyOption;
  21521. }
  21522. /**
  21523. * Decorator that flags a property in a node material block as being editable
  21524. */
  21525. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21526. }
  21527. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21528. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21529. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21530. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21532. import { Nullable } from "babylonjs/types";
  21533. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21534. import { Mesh } from "babylonjs/Meshes/mesh";
  21535. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21536. import { Effect } from "babylonjs/Materials/effect";
  21537. import { Scene } from "babylonjs/scene";
  21538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21539. /**
  21540. * Block used to implement the refraction part of the sub surface module of the PBR material
  21541. */
  21542. export class RefractionBlock extends NodeMaterialBlock {
  21543. /** @hidden */
  21544. _define3DName: string;
  21545. /** @hidden */
  21546. _refractionMatrixName: string;
  21547. /** @hidden */
  21548. _defineLODRefractionAlpha: string;
  21549. /** @hidden */
  21550. _defineLinearSpecularRefraction: string;
  21551. /** @hidden */
  21552. _defineOppositeZ: string;
  21553. /** @hidden */
  21554. _cubeSamplerName: string;
  21555. /** @hidden */
  21556. _2DSamplerName: string;
  21557. /** @hidden */
  21558. _vRefractionMicrosurfaceInfosName: string;
  21559. /** @hidden */
  21560. _vRefractionInfosName: string;
  21561. private _scene;
  21562. /**
  21563. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21564. * Materials half opaque for instance using refraction could benefit from this control.
  21565. */
  21566. linkRefractionWithTransparency: boolean;
  21567. /**
  21568. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21569. */
  21570. invertRefractionY: boolean;
  21571. /**
  21572. * Gets or sets the texture associated with the node
  21573. */
  21574. texture: Nullable<BaseTexture>;
  21575. /**
  21576. * Create a new RefractionBlock
  21577. * @param name defines the block name
  21578. */
  21579. constructor(name: string);
  21580. /**
  21581. * Gets the current class name
  21582. * @returns the class name
  21583. */
  21584. getClassName(): string;
  21585. /**
  21586. * Gets the intensity input component
  21587. */
  21588. get intensity(): NodeMaterialConnectionPoint;
  21589. /**
  21590. * Gets the index of refraction input component
  21591. */
  21592. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21593. /**
  21594. * Gets the tint at distance input component
  21595. */
  21596. get tintAtDistance(): NodeMaterialConnectionPoint;
  21597. /**
  21598. * Gets the view input component
  21599. */
  21600. get view(): NodeMaterialConnectionPoint;
  21601. /**
  21602. * Gets the refraction object output component
  21603. */
  21604. get refraction(): NodeMaterialConnectionPoint;
  21605. /**
  21606. * Returns true if the block has a texture
  21607. */
  21608. get hasTexture(): boolean;
  21609. protected _getTexture(): Nullable<BaseTexture>;
  21610. autoConfigure(material: NodeMaterial): void;
  21611. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21612. isReady(): boolean;
  21613. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21614. /**
  21615. * Gets the main code of the block (fragment side)
  21616. * @param state current state of the node material building
  21617. * @returns the shader code
  21618. */
  21619. getCode(state: NodeMaterialBuildState): string;
  21620. protected _buildBlock(state: NodeMaterialBuildState): this;
  21621. protected _dumpPropertiesCode(): string;
  21622. serialize(): any;
  21623. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21624. }
  21625. }
  21626. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21627. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21628. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21629. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21632. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21634. import { Nullable } from "babylonjs/types";
  21635. import { Scene } from "babylonjs/scene";
  21636. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21637. /**
  21638. * Base block used as input for post process
  21639. */
  21640. export class CurrentScreenBlock extends NodeMaterialBlock {
  21641. private _samplerName;
  21642. private _linearDefineName;
  21643. private _gammaDefineName;
  21644. private _mainUVName;
  21645. private _tempTextureRead;
  21646. /**
  21647. * Gets or sets the texture associated with the node
  21648. */
  21649. texture: Nullable<BaseTexture>;
  21650. /**
  21651. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21652. */
  21653. convertToGammaSpace: boolean;
  21654. /**
  21655. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21656. */
  21657. convertToLinearSpace: boolean;
  21658. /**
  21659. * Create a new CurrentScreenBlock
  21660. * @param name defines the block name
  21661. */
  21662. constructor(name: string);
  21663. /**
  21664. * Gets the current class name
  21665. * @returns the class name
  21666. */
  21667. getClassName(): string;
  21668. /**
  21669. * Gets the uv input component
  21670. */
  21671. get uv(): NodeMaterialConnectionPoint;
  21672. /**
  21673. * Gets the rgba output component
  21674. */
  21675. get rgba(): NodeMaterialConnectionPoint;
  21676. /**
  21677. * Gets the rgb output component
  21678. */
  21679. get rgb(): NodeMaterialConnectionPoint;
  21680. /**
  21681. * Gets the r output component
  21682. */
  21683. get r(): NodeMaterialConnectionPoint;
  21684. /**
  21685. * Gets the g output component
  21686. */
  21687. get g(): NodeMaterialConnectionPoint;
  21688. /**
  21689. * Gets the b output component
  21690. */
  21691. get b(): NodeMaterialConnectionPoint;
  21692. /**
  21693. * Gets the a output component
  21694. */
  21695. get a(): NodeMaterialConnectionPoint;
  21696. /**
  21697. * Initialize the block and prepare the context for build
  21698. * @param state defines the state that will be used for the build
  21699. */
  21700. initialize(state: NodeMaterialBuildState): void;
  21701. get target(): NodeMaterialBlockTargets;
  21702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21703. isReady(): boolean;
  21704. private _injectVertexCode;
  21705. private _writeTextureRead;
  21706. private _writeOutput;
  21707. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21708. serialize(): any;
  21709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21710. }
  21711. }
  21712. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21713. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21714. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21715. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21717. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21718. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21719. import { Nullable } from "babylonjs/types";
  21720. import { Scene } from "babylonjs/scene";
  21721. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21722. /**
  21723. * Base block used for the particle texture
  21724. */
  21725. export class ParticleTextureBlock extends NodeMaterialBlock {
  21726. private _samplerName;
  21727. private _linearDefineName;
  21728. private _gammaDefineName;
  21729. private _tempTextureRead;
  21730. /**
  21731. * Gets or sets the texture associated with the node
  21732. */
  21733. texture: Nullable<BaseTexture>;
  21734. /**
  21735. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21736. */
  21737. convertToGammaSpace: boolean;
  21738. /**
  21739. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21740. */
  21741. convertToLinearSpace: boolean;
  21742. /**
  21743. * Create a new ParticleTextureBlock
  21744. * @param name defines the block name
  21745. */
  21746. constructor(name: string);
  21747. /**
  21748. * Gets the current class name
  21749. * @returns the class name
  21750. */
  21751. getClassName(): string;
  21752. /**
  21753. * Gets the uv input component
  21754. */
  21755. get uv(): NodeMaterialConnectionPoint;
  21756. /**
  21757. * Gets the rgba output component
  21758. */
  21759. get rgba(): NodeMaterialConnectionPoint;
  21760. /**
  21761. * Gets the rgb output component
  21762. */
  21763. get rgb(): NodeMaterialConnectionPoint;
  21764. /**
  21765. * Gets the r output component
  21766. */
  21767. get r(): NodeMaterialConnectionPoint;
  21768. /**
  21769. * Gets the g output component
  21770. */
  21771. get g(): NodeMaterialConnectionPoint;
  21772. /**
  21773. * Gets the b output component
  21774. */
  21775. get b(): NodeMaterialConnectionPoint;
  21776. /**
  21777. * Gets the a output component
  21778. */
  21779. get a(): NodeMaterialConnectionPoint;
  21780. /**
  21781. * Initialize the block and prepare the context for build
  21782. * @param state defines the state that will be used for the build
  21783. */
  21784. initialize(state: NodeMaterialBuildState): void;
  21785. autoConfigure(material: NodeMaterial): void;
  21786. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21787. isReady(): boolean;
  21788. private _writeOutput;
  21789. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21790. serialize(): any;
  21791. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21792. }
  21793. }
  21794. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21796. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21797. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21798. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21799. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21800. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21801. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21802. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21803. import { Scene } from "babylonjs/scene";
  21804. /**
  21805. * Class used to store shared data between 2 NodeMaterialBuildState
  21806. */
  21807. export class NodeMaterialBuildStateSharedData {
  21808. /**
  21809. * Gets the list of emitted varyings
  21810. */
  21811. temps: string[];
  21812. /**
  21813. * Gets the list of emitted varyings
  21814. */
  21815. varyings: string[];
  21816. /**
  21817. * Gets the varying declaration string
  21818. */
  21819. varyingDeclaration: string;
  21820. /**
  21821. * Input blocks
  21822. */
  21823. inputBlocks: InputBlock[];
  21824. /**
  21825. * Input blocks
  21826. */
  21827. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21828. /**
  21829. * Bindable blocks (Blocks that need to set data to the effect)
  21830. */
  21831. bindableBlocks: NodeMaterialBlock[];
  21832. /**
  21833. * List of blocks that can provide a compilation fallback
  21834. */
  21835. blocksWithFallbacks: NodeMaterialBlock[];
  21836. /**
  21837. * List of blocks that can provide a define update
  21838. */
  21839. blocksWithDefines: NodeMaterialBlock[];
  21840. /**
  21841. * List of blocks that can provide a repeatable content
  21842. */
  21843. repeatableContentBlocks: NodeMaterialBlock[];
  21844. /**
  21845. * List of blocks that can provide a dynamic list of uniforms
  21846. */
  21847. dynamicUniformBlocks: NodeMaterialBlock[];
  21848. /**
  21849. * List of blocks that can block the isReady function for the material
  21850. */
  21851. blockingBlocks: NodeMaterialBlock[];
  21852. /**
  21853. * Gets the list of animated inputs
  21854. */
  21855. animatedInputs: InputBlock[];
  21856. /**
  21857. * Build Id used to avoid multiple recompilations
  21858. */
  21859. buildId: number;
  21860. /** List of emitted variables */
  21861. variableNames: {
  21862. [key: string]: number;
  21863. };
  21864. /** List of emitted defines */
  21865. defineNames: {
  21866. [key: string]: number;
  21867. };
  21868. /** Should emit comments? */
  21869. emitComments: boolean;
  21870. /** Emit build activity */
  21871. verbose: boolean;
  21872. /** Gets or sets the hosting scene */
  21873. scene: Scene;
  21874. /**
  21875. * Gets the compilation hints emitted at compilation time
  21876. */
  21877. hints: {
  21878. needWorldViewMatrix: boolean;
  21879. needWorldViewProjectionMatrix: boolean;
  21880. needAlphaBlending: boolean;
  21881. needAlphaTesting: boolean;
  21882. };
  21883. /**
  21884. * List of compilation checks
  21885. */
  21886. checks: {
  21887. emitVertex: boolean;
  21888. emitFragment: boolean;
  21889. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21890. };
  21891. /**
  21892. * Is vertex program allowed to be empty?
  21893. */
  21894. allowEmptyVertexProgram: boolean;
  21895. /** Creates a new shared data */
  21896. constructor();
  21897. /**
  21898. * Emits console errors and exceptions if there is a failing check
  21899. */
  21900. emitErrors(): void;
  21901. }
  21902. }
  21903. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21904. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21905. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21906. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21907. /**
  21908. * Class used to store node based material build state
  21909. */
  21910. export class NodeMaterialBuildState {
  21911. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21912. supportUniformBuffers: boolean;
  21913. /**
  21914. * Gets the list of emitted attributes
  21915. */
  21916. attributes: string[];
  21917. /**
  21918. * Gets the list of emitted uniforms
  21919. */
  21920. uniforms: string[];
  21921. /**
  21922. * Gets the list of emitted constants
  21923. */
  21924. constants: string[];
  21925. /**
  21926. * Gets the list of emitted samplers
  21927. */
  21928. samplers: string[];
  21929. /**
  21930. * Gets the list of emitted functions
  21931. */
  21932. functions: {
  21933. [key: string]: string;
  21934. };
  21935. /**
  21936. * Gets the list of emitted extensions
  21937. */
  21938. extensions: {
  21939. [key: string]: string;
  21940. };
  21941. /**
  21942. * Gets the target of the compilation state
  21943. */
  21944. target: NodeMaterialBlockTargets;
  21945. /**
  21946. * Gets the list of emitted counters
  21947. */
  21948. counters: {
  21949. [key: string]: number;
  21950. };
  21951. /**
  21952. * Shared data between multiple NodeMaterialBuildState instances
  21953. */
  21954. sharedData: NodeMaterialBuildStateSharedData;
  21955. /** @hidden */
  21956. _vertexState: NodeMaterialBuildState;
  21957. /** @hidden */
  21958. _attributeDeclaration: string;
  21959. /** @hidden */
  21960. _uniformDeclaration: string;
  21961. /** @hidden */
  21962. _constantDeclaration: string;
  21963. /** @hidden */
  21964. _samplerDeclaration: string;
  21965. /** @hidden */
  21966. _varyingTransfer: string;
  21967. /** @hidden */
  21968. _injectAtEnd: string;
  21969. private _repeatableContentAnchorIndex;
  21970. /** @hidden */
  21971. _builtCompilationString: string;
  21972. /**
  21973. * Gets the emitted compilation strings
  21974. */
  21975. compilationString: string;
  21976. /**
  21977. * Finalize the compilation strings
  21978. * @param state defines the current compilation state
  21979. */
  21980. finalize(state: NodeMaterialBuildState): void;
  21981. /** @hidden */
  21982. get _repeatableContentAnchor(): string;
  21983. /** @hidden */
  21984. _getFreeVariableName(prefix: string): string;
  21985. /** @hidden */
  21986. _getFreeDefineName(prefix: string): string;
  21987. /** @hidden */
  21988. _excludeVariableName(name: string): void;
  21989. /** @hidden */
  21990. _emit2DSampler(name: string): void;
  21991. /** @hidden */
  21992. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21993. /** @hidden */
  21994. _emitExtension(name: string, extension: string, define?: string): void;
  21995. /** @hidden */
  21996. _emitFunction(name: string, code: string, comments: string): void;
  21997. /** @hidden */
  21998. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21999. replaceStrings?: {
  22000. search: RegExp;
  22001. replace: string;
  22002. }[];
  22003. repeatKey?: string;
  22004. }): string;
  22005. /** @hidden */
  22006. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22007. repeatKey?: string;
  22008. removeAttributes?: boolean;
  22009. removeUniforms?: boolean;
  22010. removeVaryings?: boolean;
  22011. removeIfDef?: boolean;
  22012. replaceStrings?: {
  22013. search: RegExp;
  22014. replace: string;
  22015. }[];
  22016. }, storeKey?: string): void;
  22017. /** @hidden */
  22018. _registerTempVariable(name: string): boolean;
  22019. /** @hidden */
  22020. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22021. /** @hidden */
  22022. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22023. /** @hidden */
  22024. _emitFloat(value: number): string;
  22025. }
  22026. }
  22027. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22028. /**
  22029. * Helper class used to generate session unique ID
  22030. */
  22031. export class UniqueIdGenerator {
  22032. private static _UniqueIdCounter;
  22033. /**
  22034. * Gets an unique (relatively to the current scene) Id
  22035. */
  22036. static get UniqueId(): number;
  22037. }
  22038. }
  22039. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22040. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22041. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22042. import { Nullable } from "babylonjs/types";
  22043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22044. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22045. import { Effect } from "babylonjs/Materials/effect";
  22046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22047. import { Mesh } from "babylonjs/Meshes/mesh";
  22048. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22049. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22050. import { Scene } from "babylonjs/scene";
  22051. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22052. /**
  22053. * Defines a block that can be used inside a node based material
  22054. */
  22055. export class NodeMaterialBlock {
  22056. private _buildId;
  22057. private _buildTarget;
  22058. private _target;
  22059. private _isFinalMerger;
  22060. private _isInput;
  22061. protected _isUnique: boolean;
  22062. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22063. inputsAreExclusive: boolean;
  22064. /** @hidden */
  22065. _codeVariableName: string;
  22066. /** @hidden */
  22067. _inputs: NodeMaterialConnectionPoint[];
  22068. /** @hidden */
  22069. _outputs: NodeMaterialConnectionPoint[];
  22070. /** @hidden */
  22071. _preparationId: number;
  22072. /**
  22073. * Gets or sets the name of the block
  22074. */
  22075. name: string;
  22076. /**
  22077. * Gets or sets the unique id of the node
  22078. */
  22079. uniqueId: number;
  22080. /**
  22081. * Gets or sets the comments associated with this block
  22082. */
  22083. comments: string;
  22084. /**
  22085. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22086. */
  22087. get isUnique(): boolean;
  22088. /**
  22089. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22090. */
  22091. get isFinalMerger(): boolean;
  22092. /**
  22093. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22094. */
  22095. get isInput(): boolean;
  22096. /**
  22097. * Gets or sets the build Id
  22098. */
  22099. get buildId(): number;
  22100. set buildId(value: number);
  22101. /**
  22102. * Gets or sets the target of the block
  22103. */
  22104. get target(): NodeMaterialBlockTargets;
  22105. set target(value: NodeMaterialBlockTargets);
  22106. /**
  22107. * Gets the list of input points
  22108. */
  22109. get inputs(): NodeMaterialConnectionPoint[];
  22110. /** Gets the list of output points */
  22111. get outputs(): NodeMaterialConnectionPoint[];
  22112. /**
  22113. * Find an input by its name
  22114. * @param name defines the name of the input to look for
  22115. * @returns the input or null if not found
  22116. */
  22117. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22118. /**
  22119. * Find an output by its name
  22120. * @param name defines the name of the outputto look for
  22121. * @returns the output or null if not found
  22122. */
  22123. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22124. /**
  22125. * Creates a new NodeMaterialBlock
  22126. * @param name defines the block name
  22127. * @param target defines the target of that block (Vertex by default)
  22128. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22129. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22130. */
  22131. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22132. /**
  22133. * Initialize the block and prepare the context for build
  22134. * @param state defines the state that will be used for the build
  22135. */
  22136. initialize(state: NodeMaterialBuildState): void;
  22137. /**
  22138. * Bind data to effect. Will only be called for blocks with isBindable === true
  22139. * @param effect defines the effect to bind data to
  22140. * @param nodeMaterial defines the hosting NodeMaterial
  22141. * @param mesh defines the mesh that will be rendered
  22142. * @param subMesh defines the submesh that will be rendered
  22143. */
  22144. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22145. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22146. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22147. protected _writeFloat(value: number): string;
  22148. /**
  22149. * Gets the current class name e.g. "NodeMaterialBlock"
  22150. * @returns the class name
  22151. */
  22152. getClassName(): string;
  22153. /**
  22154. * Register a new input. Must be called inside a block constructor
  22155. * @param name defines the connection point name
  22156. * @param type defines the connection point type
  22157. * @param isOptional defines a boolean indicating that this input can be omitted
  22158. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22159. * @param point an already created connection point. If not provided, create a new one
  22160. * @returns the current block
  22161. */
  22162. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22163. /**
  22164. * Register a new output. Must be called inside a block constructor
  22165. * @param name defines the connection point name
  22166. * @param type defines the connection point type
  22167. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22168. * @param point an already created connection point. If not provided, create a new one
  22169. * @returns the current block
  22170. */
  22171. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22172. /**
  22173. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22174. * @param forOutput defines an optional connection point to check compatibility with
  22175. * @returns the first available input or null
  22176. */
  22177. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22178. /**
  22179. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22180. * @param forBlock defines an optional block to check compatibility with
  22181. * @returns the first available input or null
  22182. */
  22183. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22184. /**
  22185. * Gets the sibling of the given output
  22186. * @param current defines the current output
  22187. * @returns the next output in the list or null
  22188. */
  22189. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22190. /**
  22191. * Connect current block with another block
  22192. * @param other defines the block to connect with
  22193. * @param options define the various options to help pick the right connections
  22194. * @returns the current block
  22195. */
  22196. connectTo(other: NodeMaterialBlock, options?: {
  22197. input?: string;
  22198. output?: string;
  22199. outputSwizzle?: string;
  22200. }): this | undefined;
  22201. protected _buildBlock(state: NodeMaterialBuildState): void;
  22202. /**
  22203. * Add uniforms, samplers and uniform buffers at compilation time
  22204. * @param state defines the state to update
  22205. * @param nodeMaterial defines the node material requesting the update
  22206. * @param defines defines the material defines to update
  22207. * @param uniformBuffers defines the list of uniform buffer names
  22208. */
  22209. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22210. /**
  22211. * Add potential fallbacks if shader compilation fails
  22212. * @param mesh defines the mesh to be rendered
  22213. * @param fallbacks defines the current prioritized list of fallbacks
  22214. */
  22215. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22216. /**
  22217. * Initialize defines for shader compilation
  22218. * @param mesh defines the mesh to be rendered
  22219. * @param nodeMaterial defines the node material requesting the update
  22220. * @param defines defines the material defines to update
  22221. * @param useInstances specifies that instances should be used
  22222. */
  22223. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22224. /**
  22225. * Update defines for shader compilation
  22226. * @param mesh defines the mesh to be rendered
  22227. * @param nodeMaterial defines the node material requesting the update
  22228. * @param defines defines the material defines to update
  22229. * @param useInstances specifies that instances should be used
  22230. * @param subMesh defines which submesh to render
  22231. */
  22232. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22233. /**
  22234. * Lets the block try to connect some inputs automatically
  22235. * @param material defines the hosting NodeMaterial
  22236. */
  22237. autoConfigure(material: NodeMaterial): void;
  22238. /**
  22239. * Function called when a block is declared as repeatable content generator
  22240. * @param vertexShaderState defines the current compilation state for the vertex shader
  22241. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22242. * @param mesh defines the mesh to be rendered
  22243. * @param defines defines the material defines to update
  22244. */
  22245. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22246. /**
  22247. * Checks if the block is ready
  22248. * @param mesh defines the mesh to be rendered
  22249. * @param nodeMaterial defines the node material requesting the update
  22250. * @param defines defines the material defines to update
  22251. * @param useInstances specifies that instances should be used
  22252. * @returns true if the block is ready
  22253. */
  22254. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22255. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22256. private _processBuild;
  22257. /**
  22258. * Compile the current node and generate the shader code
  22259. * @param state defines the current compilation state (uniforms, samplers, current string)
  22260. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22261. * @returns true if already built
  22262. */
  22263. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22264. protected _inputRename(name: string): string;
  22265. protected _outputRename(name: string): string;
  22266. protected _dumpPropertiesCode(): string;
  22267. /** @hidden */
  22268. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22269. /** @hidden */
  22270. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22271. /**
  22272. * Clone the current block to a new identical block
  22273. * @param scene defines the hosting scene
  22274. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22275. * @returns a copy of the current block
  22276. */
  22277. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22278. /**
  22279. * Serializes this block in a JSON representation
  22280. * @returns the serialized block object
  22281. */
  22282. serialize(): any;
  22283. /** @hidden */
  22284. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22285. private _deserializePortDisplayNamesAndExposedOnFrame;
  22286. /**
  22287. * Release resources
  22288. */
  22289. dispose(): void;
  22290. }
  22291. }
  22292. declare module "babylonjs/Materials/pushMaterial" {
  22293. import { Nullable } from "babylonjs/types";
  22294. import { Scene } from "babylonjs/scene";
  22295. import { Matrix } from "babylonjs/Maths/math.vector";
  22296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22297. import { Mesh } from "babylonjs/Meshes/mesh";
  22298. import { Material } from "babylonjs/Materials/material";
  22299. import { Effect } from "babylonjs/Materials/effect";
  22300. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22301. /**
  22302. * Base class of materials working in push mode in babylon JS
  22303. * @hidden
  22304. */
  22305. export class PushMaterial extends Material {
  22306. protected _activeEffect: Effect;
  22307. protected _normalMatrix: Matrix;
  22308. constructor(name: string, scene: Scene);
  22309. getEffect(): Effect;
  22310. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22311. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22312. /**
  22313. * Binds the given world matrix to the active effect
  22314. *
  22315. * @param world the matrix to bind
  22316. */
  22317. bindOnlyWorldMatrix(world: Matrix): void;
  22318. /**
  22319. * Binds the given normal matrix to the active effect
  22320. *
  22321. * @param normalMatrix the matrix to bind
  22322. */
  22323. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22324. bind(world: Matrix, mesh?: Mesh): void;
  22325. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22326. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22327. }
  22328. }
  22329. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22330. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22331. /**
  22332. * Root class for all node material optimizers
  22333. */
  22334. export class NodeMaterialOptimizer {
  22335. /**
  22336. * Function used to optimize a NodeMaterial graph
  22337. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22338. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22339. */
  22340. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22341. }
  22342. }
  22343. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22344. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22345. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22346. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22347. import { Scene } from "babylonjs/scene";
  22348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22349. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22350. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22351. /**
  22352. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22353. */
  22354. export class TransformBlock extends NodeMaterialBlock {
  22355. /**
  22356. * Defines the value to use to complement W value to transform it to a Vector4
  22357. */
  22358. complementW: number;
  22359. /**
  22360. * Defines the value to use to complement z value to transform it to a Vector4
  22361. */
  22362. complementZ: number;
  22363. /**
  22364. * Creates a new TransformBlock
  22365. * @param name defines the block name
  22366. */
  22367. constructor(name: string);
  22368. /**
  22369. * Gets the current class name
  22370. * @returns the class name
  22371. */
  22372. getClassName(): string;
  22373. /**
  22374. * Gets the vector input
  22375. */
  22376. get vector(): NodeMaterialConnectionPoint;
  22377. /**
  22378. * Gets the output component
  22379. */
  22380. get output(): NodeMaterialConnectionPoint;
  22381. /**
  22382. * Gets the xyz output component
  22383. */
  22384. get xyz(): NodeMaterialConnectionPoint;
  22385. /**
  22386. * Gets the matrix transform input
  22387. */
  22388. get transform(): NodeMaterialConnectionPoint;
  22389. protected _buildBlock(state: NodeMaterialBuildState): this;
  22390. /**
  22391. * Update defines for shader compilation
  22392. * @param mesh defines the mesh to be rendered
  22393. * @param nodeMaterial defines the node material requesting the update
  22394. * @param defines defines the material defines to update
  22395. * @param useInstances specifies that instances should be used
  22396. * @param subMesh defines which submesh to render
  22397. */
  22398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22399. serialize(): any;
  22400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22401. protected _dumpPropertiesCode(): string;
  22402. }
  22403. }
  22404. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22408. /**
  22409. * Block used to output the vertex position
  22410. */
  22411. export class VertexOutputBlock extends NodeMaterialBlock {
  22412. /**
  22413. * Creates a new VertexOutputBlock
  22414. * @param name defines the block name
  22415. */
  22416. constructor(name: string);
  22417. /**
  22418. * Gets the current class name
  22419. * @returns the class name
  22420. */
  22421. getClassName(): string;
  22422. /**
  22423. * Gets the vector input component
  22424. */
  22425. get vector(): NodeMaterialConnectionPoint;
  22426. protected _buildBlock(state: NodeMaterialBuildState): this;
  22427. }
  22428. }
  22429. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22430. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22431. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22432. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22433. /**
  22434. * Block used to output the final color
  22435. */
  22436. export class FragmentOutputBlock extends NodeMaterialBlock {
  22437. /**
  22438. * Create a new FragmentOutputBlock
  22439. * @param name defines the block name
  22440. */
  22441. constructor(name: string);
  22442. /**
  22443. * Gets the current class name
  22444. * @returns the class name
  22445. */
  22446. getClassName(): string;
  22447. /**
  22448. * Gets the rgba input component
  22449. */
  22450. get rgba(): NodeMaterialConnectionPoint;
  22451. /**
  22452. * Gets the rgb input component
  22453. */
  22454. get rgb(): NodeMaterialConnectionPoint;
  22455. /**
  22456. * Gets the a input component
  22457. */
  22458. get a(): NodeMaterialConnectionPoint;
  22459. protected _buildBlock(state: NodeMaterialBuildState): this;
  22460. }
  22461. }
  22462. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22464. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22466. /**
  22467. * Block used for the particle ramp gradient section
  22468. */
  22469. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22470. /**
  22471. * Create a new ParticleRampGradientBlock
  22472. * @param name defines the block name
  22473. */
  22474. constructor(name: string);
  22475. /**
  22476. * Gets the current class name
  22477. * @returns the class name
  22478. */
  22479. getClassName(): string;
  22480. /**
  22481. * Gets the color input component
  22482. */
  22483. get color(): NodeMaterialConnectionPoint;
  22484. /**
  22485. * Gets the rampColor output component
  22486. */
  22487. get rampColor(): NodeMaterialConnectionPoint;
  22488. /**
  22489. * Initialize the block and prepare the context for build
  22490. * @param state defines the state that will be used for the build
  22491. */
  22492. initialize(state: NodeMaterialBuildState): void;
  22493. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22494. }
  22495. }
  22496. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22497. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22498. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22499. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22500. /**
  22501. * Block used for the particle blend multiply section
  22502. */
  22503. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22504. /**
  22505. * Create a new ParticleBlendMultiplyBlock
  22506. * @param name defines the block name
  22507. */
  22508. constructor(name: string);
  22509. /**
  22510. * Gets the current class name
  22511. * @returns the class name
  22512. */
  22513. getClassName(): string;
  22514. /**
  22515. * Gets the color input component
  22516. */
  22517. get color(): NodeMaterialConnectionPoint;
  22518. /**
  22519. * Gets the alphaTexture input component
  22520. */
  22521. get alphaTexture(): NodeMaterialConnectionPoint;
  22522. /**
  22523. * Gets the alphaColor input component
  22524. */
  22525. get alphaColor(): NodeMaterialConnectionPoint;
  22526. /**
  22527. * Gets the blendColor output component
  22528. */
  22529. get blendColor(): NodeMaterialConnectionPoint;
  22530. /**
  22531. * Initialize the block and prepare the context for build
  22532. * @param state defines the state that will be used for the build
  22533. */
  22534. initialize(state: NodeMaterialBuildState): void;
  22535. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22536. }
  22537. }
  22538. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22541. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22542. /**
  22543. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22544. */
  22545. export class VectorMergerBlock extends NodeMaterialBlock {
  22546. /**
  22547. * Create a new VectorMergerBlock
  22548. * @param name defines the block name
  22549. */
  22550. constructor(name: string);
  22551. /**
  22552. * Gets the current class name
  22553. * @returns the class name
  22554. */
  22555. getClassName(): string;
  22556. /**
  22557. * Gets the xyz component (input)
  22558. */
  22559. get xyzIn(): NodeMaterialConnectionPoint;
  22560. /**
  22561. * Gets the xy component (input)
  22562. */
  22563. get xyIn(): NodeMaterialConnectionPoint;
  22564. /**
  22565. * Gets the x component (input)
  22566. */
  22567. get x(): NodeMaterialConnectionPoint;
  22568. /**
  22569. * Gets the y component (input)
  22570. */
  22571. get y(): NodeMaterialConnectionPoint;
  22572. /**
  22573. * Gets the z component (input)
  22574. */
  22575. get z(): NodeMaterialConnectionPoint;
  22576. /**
  22577. * Gets the w component (input)
  22578. */
  22579. get w(): NodeMaterialConnectionPoint;
  22580. /**
  22581. * Gets the xyzw component (output)
  22582. */
  22583. get xyzw(): NodeMaterialConnectionPoint;
  22584. /**
  22585. * Gets the xyz component (output)
  22586. */
  22587. get xyzOut(): NodeMaterialConnectionPoint;
  22588. /**
  22589. * Gets the xy component (output)
  22590. */
  22591. get xyOut(): NodeMaterialConnectionPoint;
  22592. /**
  22593. * Gets the xy component (output)
  22594. * @deprecated Please use xyOut instead.
  22595. */
  22596. get xy(): NodeMaterialConnectionPoint;
  22597. /**
  22598. * Gets the xyz component (output)
  22599. * @deprecated Please use xyzOut instead.
  22600. */
  22601. get xyz(): NodeMaterialConnectionPoint;
  22602. protected _buildBlock(state: NodeMaterialBuildState): this;
  22603. }
  22604. }
  22605. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22609. import { Vector2 } from "babylonjs/Maths/math.vector";
  22610. import { Scene } from "babylonjs/scene";
  22611. /**
  22612. * Block used to remap a float from a range to a new one
  22613. */
  22614. export class RemapBlock extends NodeMaterialBlock {
  22615. /**
  22616. * Gets or sets the source range
  22617. */
  22618. sourceRange: Vector2;
  22619. /**
  22620. * Gets or sets the target range
  22621. */
  22622. targetRange: Vector2;
  22623. /**
  22624. * Creates a new RemapBlock
  22625. * @param name defines the block name
  22626. */
  22627. constructor(name: string);
  22628. /**
  22629. * Gets the current class name
  22630. * @returns the class name
  22631. */
  22632. getClassName(): string;
  22633. /**
  22634. * Gets the input component
  22635. */
  22636. get input(): NodeMaterialConnectionPoint;
  22637. /**
  22638. * Gets the source min input component
  22639. */
  22640. get sourceMin(): NodeMaterialConnectionPoint;
  22641. /**
  22642. * Gets the source max input component
  22643. */
  22644. get sourceMax(): NodeMaterialConnectionPoint;
  22645. /**
  22646. * Gets the target min input component
  22647. */
  22648. get targetMin(): NodeMaterialConnectionPoint;
  22649. /**
  22650. * Gets the target max input component
  22651. */
  22652. get targetMax(): NodeMaterialConnectionPoint;
  22653. /**
  22654. * Gets the output component
  22655. */
  22656. get output(): NodeMaterialConnectionPoint;
  22657. protected _buildBlock(state: NodeMaterialBuildState): this;
  22658. protected _dumpPropertiesCode(): string;
  22659. serialize(): any;
  22660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22661. }
  22662. }
  22663. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22667. /**
  22668. * Block used to multiply 2 values
  22669. */
  22670. export class MultiplyBlock extends NodeMaterialBlock {
  22671. /**
  22672. * Creates a new MultiplyBlock
  22673. * @param name defines the block name
  22674. */
  22675. constructor(name: string);
  22676. /**
  22677. * Gets the current class name
  22678. * @returns the class name
  22679. */
  22680. getClassName(): string;
  22681. /**
  22682. * Gets the left operand input component
  22683. */
  22684. get left(): NodeMaterialConnectionPoint;
  22685. /**
  22686. * Gets the right operand input component
  22687. */
  22688. get right(): NodeMaterialConnectionPoint;
  22689. /**
  22690. * Gets the output component
  22691. */
  22692. get output(): NodeMaterialConnectionPoint;
  22693. protected _buildBlock(state: NodeMaterialBuildState): this;
  22694. }
  22695. }
  22696. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22700. /**
  22701. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22702. */
  22703. export class ColorSplitterBlock extends NodeMaterialBlock {
  22704. /**
  22705. * Create a new ColorSplitterBlock
  22706. * @param name defines the block name
  22707. */
  22708. constructor(name: string);
  22709. /**
  22710. * Gets the current class name
  22711. * @returns the class name
  22712. */
  22713. getClassName(): string;
  22714. /**
  22715. * Gets the rgba component (input)
  22716. */
  22717. get rgba(): NodeMaterialConnectionPoint;
  22718. /**
  22719. * Gets the rgb component (input)
  22720. */
  22721. get rgbIn(): NodeMaterialConnectionPoint;
  22722. /**
  22723. * Gets the rgb component (output)
  22724. */
  22725. get rgbOut(): NodeMaterialConnectionPoint;
  22726. /**
  22727. * Gets the r component (output)
  22728. */
  22729. get r(): NodeMaterialConnectionPoint;
  22730. /**
  22731. * Gets the g component (output)
  22732. */
  22733. get g(): NodeMaterialConnectionPoint;
  22734. /**
  22735. * Gets the b component (output)
  22736. */
  22737. get b(): NodeMaterialConnectionPoint;
  22738. /**
  22739. * Gets the a component (output)
  22740. */
  22741. get a(): NodeMaterialConnectionPoint;
  22742. protected _inputRename(name: string): string;
  22743. protected _outputRename(name: string): string;
  22744. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22745. }
  22746. }
  22747. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22749. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22750. import { Scene } from "babylonjs/scene";
  22751. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22752. import { Matrix } from "babylonjs/Maths/math.vector";
  22753. import { Mesh } from "babylonjs/Meshes/mesh";
  22754. import { Engine } from "babylonjs/Engines/engine";
  22755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22756. import { Observable } from "babylonjs/Misc/observable";
  22757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22758. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22759. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22760. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22761. import { Nullable } from "babylonjs/types";
  22762. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22763. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22764. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22765. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22766. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22767. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22768. import { Effect } from "babylonjs/Materials/effect";
  22769. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22770. import { Camera } from "babylonjs/Cameras/camera";
  22771. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22772. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22773. /**
  22774. * Interface used to configure the node material editor
  22775. */
  22776. export interface INodeMaterialEditorOptions {
  22777. /** Define the URl to load node editor script */
  22778. editorURL?: string;
  22779. }
  22780. /** @hidden */
  22781. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22782. NORMAL: boolean;
  22783. TANGENT: boolean;
  22784. UV1: boolean;
  22785. /** BONES */
  22786. NUM_BONE_INFLUENCERS: number;
  22787. BonesPerMesh: number;
  22788. BONETEXTURE: boolean;
  22789. /** MORPH TARGETS */
  22790. MORPHTARGETS: boolean;
  22791. MORPHTARGETS_NORMAL: boolean;
  22792. MORPHTARGETS_TANGENT: boolean;
  22793. MORPHTARGETS_UV: boolean;
  22794. NUM_MORPH_INFLUENCERS: number;
  22795. /** IMAGE PROCESSING */
  22796. IMAGEPROCESSING: boolean;
  22797. VIGNETTE: boolean;
  22798. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22799. VIGNETTEBLENDMODEOPAQUE: boolean;
  22800. TONEMAPPING: boolean;
  22801. TONEMAPPING_ACES: boolean;
  22802. CONTRAST: boolean;
  22803. EXPOSURE: boolean;
  22804. COLORCURVES: boolean;
  22805. COLORGRADING: boolean;
  22806. COLORGRADING3D: boolean;
  22807. SAMPLER3DGREENDEPTH: boolean;
  22808. SAMPLER3DBGRMAP: boolean;
  22809. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22810. /** MISC. */
  22811. BUMPDIRECTUV: number;
  22812. constructor();
  22813. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22814. }
  22815. /**
  22816. * Class used to configure NodeMaterial
  22817. */
  22818. export interface INodeMaterialOptions {
  22819. /**
  22820. * Defines if blocks should emit comments
  22821. */
  22822. emitComments: boolean;
  22823. }
  22824. /**
  22825. * Class used to create a node based material built by assembling shader blocks
  22826. */
  22827. export class NodeMaterial extends PushMaterial {
  22828. private static _BuildIdGenerator;
  22829. private _options;
  22830. private _vertexCompilationState;
  22831. private _fragmentCompilationState;
  22832. private _sharedData;
  22833. private _buildId;
  22834. private _buildWasSuccessful;
  22835. private _cachedWorldViewMatrix;
  22836. private _cachedWorldViewProjectionMatrix;
  22837. private _optimizers;
  22838. private _animationFrame;
  22839. /** Define the Url to load node editor script */
  22840. static EditorURL: string;
  22841. /** Define the Url to load snippets */
  22842. static SnippetUrl: string;
  22843. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22844. static IgnoreTexturesAtLoadTime: boolean;
  22845. private BJSNODEMATERIALEDITOR;
  22846. /** Get the inspector from bundle or global */
  22847. private _getGlobalNodeMaterialEditor;
  22848. /**
  22849. * Snippet ID if the material was created from the snippet server
  22850. */
  22851. snippetId: string;
  22852. /**
  22853. * Gets or sets data used by visual editor
  22854. * @see https://nme.babylonjs.com
  22855. */
  22856. editorData: any;
  22857. /**
  22858. * 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)
  22859. */
  22860. ignoreAlpha: boolean;
  22861. /**
  22862. * Defines the maximum number of lights that can be used in the material
  22863. */
  22864. maxSimultaneousLights: number;
  22865. /**
  22866. * Observable raised when the material is built
  22867. */
  22868. onBuildObservable: Observable<NodeMaterial>;
  22869. /**
  22870. * Gets or sets the root nodes of the material vertex shader
  22871. */
  22872. _vertexOutputNodes: NodeMaterialBlock[];
  22873. /**
  22874. * Gets or sets the root nodes of the material fragment (pixel) shader
  22875. */
  22876. _fragmentOutputNodes: NodeMaterialBlock[];
  22877. /** Gets or sets options to control the node material overall behavior */
  22878. get options(): INodeMaterialOptions;
  22879. set options(options: INodeMaterialOptions);
  22880. /**
  22881. * Default configuration related to image processing available in the standard Material.
  22882. */
  22883. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22884. /**
  22885. * Gets the image processing configuration used either in this material.
  22886. */
  22887. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22888. /**
  22889. * Sets the Default image processing configuration used either in the this material.
  22890. *
  22891. * If sets to null, the scene one is in use.
  22892. */
  22893. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22894. /**
  22895. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22896. */
  22897. attachedBlocks: NodeMaterialBlock[];
  22898. /**
  22899. * Specifies the mode of the node material
  22900. * @hidden
  22901. */
  22902. _mode: NodeMaterialModes;
  22903. /**
  22904. * Gets the mode property
  22905. */
  22906. get mode(): NodeMaterialModes;
  22907. /**
  22908. * Create a new node based material
  22909. * @param name defines the material name
  22910. * @param scene defines the hosting scene
  22911. * @param options defines creation option
  22912. */
  22913. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22914. /**
  22915. * Gets the current class name of the material e.g. "NodeMaterial"
  22916. * @returns the class name
  22917. */
  22918. getClassName(): string;
  22919. /**
  22920. * Keep track of the image processing observer to allow dispose and replace.
  22921. */
  22922. private _imageProcessingObserver;
  22923. /**
  22924. * Attaches a new image processing configuration to the Standard Material.
  22925. * @param configuration
  22926. */
  22927. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22928. /**
  22929. * Get a block by its name
  22930. * @param name defines the name of the block to retrieve
  22931. * @returns the required block or null if not found
  22932. */
  22933. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22934. /**
  22935. * Get a block by its name
  22936. * @param predicate defines the predicate used to find the good candidate
  22937. * @returns the required block or null if not found
  22938. */
  22939. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22940. /**
  22941. * Get an input block by its name
  22942. * @param predicate defines the predicate used to find the good candidate
  22943. * @returns the required input block or null if not found
  22944. */
  22945. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22946. /**
  22947. * Gets the list of input blocks attached to this material
  22948. * @returns an array of InputBlocks
  22949. */
  22950. getInputBlocks(): InputBlock[];
  22951. /**
  22952. * Adds a new optimizer to the list of optimizers
  22953. * @param optimizer defines the optimizers to add
  22954. * @returns the current material
  22955. */
  22956. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22957. /**
  22958. * Remove an optimizer from the list of optimizers
  22959. * @param optimizer defines the optimizers to remove
  22960. * @returns the current material
  22961. */
  22962. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22963. /**
  22964. * Add a new block to the list of output nodes
  22965. * @param node defines the node to add
  22966. * @returns the current material
  22967. */
  22968. addOutputNode(node: NodeMaterialBlock): this;
  22969. /**
  22970. * Remove a block from the list of root nodes
  22971. * @param node defines the node to remove
  22972. * @returns the current material
  22973. */
  22974. removeOutputNode(node: NodeMaterialBlock): this;
  22975. private _addVertexOutputNode;
  22976. private _removeVertexOutputNode;
  22977. private _addFragmentOutputNode;
  22978. private _removeFragmentOutputNode;
  22979. /**
  22980. * Specifies if the material will require alpha blending
  22981. * @returns a boolean specifying if alpha blending is needed
  22982. */
  22983. needAlphaBlending(): boolean;
  22984. /**
  22985. * Specifies if this material should be rendered in alpha test mode
  22986. * @returns a boolean specifying if an alpha test is needed.
  22987. */
  22988. needAlphaTesting(): boolean;
  22989. private _initializeBlock;
  22990. private _resetDualBlocks;
  22991. /**
  22992. * Remove a block from the current node material
  22993. * @param block defines the block to remove
  22994. */
  22995. removeBlock(block: NodeMaterialBlock): void;
  22996. /**
  22997. * Build the material and generates the inner effect
  22998. * @param verbose defines if the build should log activity
  22999. */
  23000. build(verbose?: boolean): void;
  23001. /**
  23002. * Runs an otpimization phase to try to improve the shader code
  23003. */
  23004. optimize(): void;
  23005. private _prepareDefinesForAttributes;
  23006. /**
  23007. * Create a post process from the material
  23008. * @param camera The camera to apply the render pass to.
  23009. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23011. * @param engine The engine which the post process will be applied. (default: current engine)
  23012. * @param reusable If the post process can be reused on the same frame. (default: false)
  23013. * @param textureType Type of textures used when performing the post process. (default: 0)
  23014. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23015. * @returns the post process created
  23016. */
  23017. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23018. /**
  23019. * Create the post process effect from the material
  23020. * @param postProcess The post process to create the effect for
  23021. */
  23022. createEffectForPostProcess(postProcess: PostProcess): void;
  23023. private _createEffectOrPostProcess;
  23024. private _createEffectForParticles;
  23025. /**
  23026. * Create the effect to be used as the custom effect for a particle system
  23027. * @param particleSystem Particle system to create the effect for
  23028. * @param onCompiled defines a function to call when the effect creation is successful
  23029. * @param onError defines a function to call when the effect creation has failed
  23030. */
  23031. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23032. private _processDefines;
  23033. /**
  23034. * Get if the submesh is ready to be used and all its information available.
  23035. * Child classes can use it to update shaders
  23036. * @param mesh defines the mesh to check
  23037. * @param subMesh defines which submesh to check
  23038. * @param useInstances specifies that instances should be used
  23039. * @returns a boolean indicating that the submesh is ready or not
  23040. */
  23041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23042. /**
  23043. * Get a string representing the shaders built by the current node graph
  23044. */
  23045. get compiledShaders(): string;
  23046. /**
  23047. * Binds the world matrix to the material
  23048. * @param world defines the world transformation matrix
  23049. */
  23050. bindOnlyWorldMatrix(world: Matrix): void;
  23051. /**
  23052. * Binds the submesh to this material by preparing the effect and shader to draw
  23053. * @param world defines the world transformation matrix
  23054. * @param mesh defines the mesh containing the submesh
  23055. * @param subMesh defines the submesh to bind the material to
  23056. */
  23057. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23058. /**
  23059. * Gets the active textures from the material
  23060. * @returns an array of textures
  23061. */
  23062. getActiveTextures(): BaseTexture[];
  23063. /**
  23064. * Gets the list of texture blocks
  23065. * @returns an array of texture blocks
  23066. */
  23067. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23068. /**
  23069. * Specifies if the material uses a texture
  23070. * @param texture defines the texture to check against the material
  23071. * @returns a boolean specifying if the material uses the texture
  23072. */
  23073. hasTexture(texture: BaseTexture): boolean;
  23074. /**
  23075. * Disposes the material
  23076. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23077. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23078. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23079. */
  23080. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23081. /** Creates the node editor window. */
  23082. private _createNodeEditor;
  23083. /**
  23084. * Launch the node material editor
  23085. * @param config Define the configuration of the editor
  23086. * @return a promise fulfilled when the node editor is visible
  23087. */
  23088. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23089. /**
  23090. * Clear the current material
  23091. */
  23092. clear(): void;
  23093. /**
  23094. * Clear the current material and set it to a default state
  23095. */
  23096. setToDefault(): void;
  23097. /**
  23098. * Clear the current material and set it to a default state for post process
  23099. */
  23100. setToDefaultPostProcess(): void;
  23101. /**
  23102. * Clear the current material and set it to a default state for particle
  23103. */
  23104. setToDefaultParticle(): void;
  23105. /**
  23106. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23107. * @param url defines the url to load from
  23108. * @returns a promise that will fullfil when the material is fully loaded
  23109. */
  23110. loadAsync(url: string): Promise<void>;
  23111. private _gatherBlocks;
  23112. /**
  23113. * Generate a string containing the code declaration required to create an equivalent of this material
  23114. * @returns a string
  23115. */
  23116. generateCode(): string;
  23117. /**
  23118. * Serializes this material in a JSON representation
  23119. * @returns the serialized material object
  23120. */
  23121. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23122. private _restoreConnections;
  23123. /**
  23124. * Clear the current graph and load a new one from a serialization object
  23125. * @param source defines the JSON representation of the material
  23126. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23127. * @param merge defines whether or not the source must be merged or replace the current content
  23128. */
  23129. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23130. /**
  23131. * Makes a duplicate of the current material.
  23132. * @param name - name to use for the new material.
  23133. */
  23134. clone(name: string): NodeMaterial;
  23135. /**
  23136. * Creates a node material from parsed material data
  23137. * @param source defines the JSON representation of the material
  23138. * @param scene defines the hosting scene
  23139. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23140. * @returns a new node material
  23141. */
  23142. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23143. /**
  23144. * Creates a node material from a snippet saved in a remote file
  23145. * @param name defines the name of the material to create
  23146. * @param url defines the url to load from
  23147. * @param scene defines the hosting scene
  23148. * @returns a promise that will resolve to the new node material
  23149. */
  23150. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23151. /**
  23152. * Creates a node material from a snippet saved by the node material editor
  23153. * @param snippetId defines the snippet to load
  23154. * @param scene defines the hosting scene
  23155. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23156. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23157. * @returns a promise that will resolve to the new node material
  23158. */
  23159. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23160. /**
  23161. * Creates a new node material set to default basic configuration
  23162. * @param name defines the name of the material
  23163. * @param scene defines the hosting scene
  23164. * @returns a new NodeMaterial
  23165. */
  23166. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23167. }
  23168. }
  23169. declare module "babylonjs/PostProcesses/postProcess" {
  23170. import { Nullable } from "babylonjs/types";
  23171. import { SmartArray } from "babylonjs/Misc/smartArray";
  23172. import { Observable } from "babylonjs/Misc/observable";
  23173. import { Vector2 } from "babylonjs/Maths/math.vector";
  23174. import { Camera } from "babylonjs/Cameras/camera";
  23175. import { Effect } from "babylonjs/Materials/effect";
  23176. import "babylonjs/Shaders/postprocess.vertex";
  23177. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23178. import { Engine } from "babylonjs/Engines/engine";
  23179. import { Color4 } from "babylonjs/Maths/math.color";
  23180. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23181. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23182. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23183. /**
  23184. * Size options for a post process
  23185. */
  23186. export type PostProcessOptions = {
  23187. width: number;
  23188. height: number;
  23189. };
  23190. /**
  23191. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23192. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23193. */
  23194. export class PostProcess {
  23195. /** Name of the PostProcess. */
  23196. name: string;
  23197. /**
  23198. * Gets or sets the unique id of the post process
  23199. */
  23200. uniqueId: number;
  23201. /**
  23202. * Width of the texture to apply the post process on
  23203. */
  23204. width: number;
  23205. /**
  23206. * Height of the texture to apply the post process on
  23207. */
  23208. height: number;
  23209. /**
  23210. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23211. */
  23212. nodeMaterialSource: Nullable<NodeMaterial>;
  23213. /**
  23214. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23215. * @hidden
  23216. */
  23217. _outputTexture: Nullable<InternalTexture>;
  23218. /**
  23219. * Sampling mode used by the shader
  23220. * See https://doc.babylonjs.com/classes/3.1/texture
  23221. */
  23222. renderTargetSamplingMode: number;
  23223. /**
  23224. * Clear color to use when screen clearing
  23225. */
  23226. clearColor: Color4;
  23227. /**
  23228. * If the buffer needs to be cleared before applying the post process. (default: true)
  23229. * Should be set to false if shader will overwrite all previous pixels.
  23230. */
  23231. autoClear: boolean;
  23232. /**
  23233. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23234. */
  23235. alphaMode: number;
  23236. /**
  23237. * Sets the setAlphaBlendConstants of the babylon engine
  23238. */
  23239. alphaConstants: Color4;
  23240. /**
  23241. * Animations to be used for the post processing
  23242. */
  23243. animations: import("babylonjs/Animations/animation").Animation[];
  23244. /**
  23245. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23246. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23247. */
  23248. enablePixelPerfectMode: boolean;
  23249. /**
  23250. * Force the postprocess to be applied without taking in account viewport
  23251. */
  23252. forceFullscreenViewport: boolean;
  23253. /**
  23254. * List of inspectable custom properties (used by the Inspector)
  23255. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23256. */
  23257. inspectableCustomProperties: IInspectable[];
  23258. /**
  23259. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23260. *
  23261. * | Value | Type | Description |
  23262. * | ----- | ----------------------------------- | ----------- |
  23263. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23264. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23265. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23266. *
  23267. */
  23268. scaleMode: number;
  23269. /**
  23270. * Force textures to be a power of two (default: false)
  23271. */
  23272. alwaysForcePOT: boolean;
  23273. private _samples;
  23274. /**
  23275. * Number of sample textures (default: 1)
  23276. */
  23277. get samples(): number;
  23278. set samples(n: number);
  23279. /**
  23280. * Modify the scale of the post process to be the same as the viewport (default: false)
  23281. */
  23282. adaptScaleToCurrentViewport: boolean;
  23283. private _camera;
  23284. private _scene;
  23285. private _engine;
  23286. private _options;
  23287. private _reusable;
  23288. private _textureType;
  23289. private _textureFormat;
  23290. /**
  23291. * Smart array of input and output textures for the post process.
  23292. * @hidden
  23293. */
  23294. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23295. /**
  23296. * The index in _textures that corresponds to the output texture.
  23297. * @hidden
  23298. */
  23299. _currentRenderTextureInd: number;
  23300. private _effect;
  23301. private _samplers;
  23302. private _fragmentUrl;
  23303. private _vertexUrl;
  23304. private _parameters;
  23305. private _scaleRatio;
  23306. protected _indexParameters: any;
  23307. private _shareOutputWithPostProcess;
  23308. private _texelSize;
  23309. private _forcedOutputTexture;
  23310. /**
  23311. * Returns the fragment url or shader name used in the post process.
  23312. * @returns the fragment url or name in the shader store.
  23313. */
  23314. getEffectName(): string;
  23315. /**
  23316. * An event triggered when the postprocess is activated.
  23317. */
  23318. onActivateObservable: Observable<Camera>;
  23319. private _onActivateObserver;
  23320. /**
  23321. * A function that is added to the onActivateObservable
  23322. */
  23323. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23324. /**
  23325. * An event triggered when the postprocess changes its size.
  23326. */
  23327. onSizeChangedObservable: Observable<PostProcess>;
  23328. private _onSizeChangedObserver;
  23329. /**
  23330. * A function that is added to the onSizeChangedObservable
  23331. */
  23332. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23333. /**
  23334. * An event triggered when the postprocess applies its effect.
  23335. */
  23336. onApplyObservable: Observable<Effect>;
  23337. private _onApplyObserver;
  23338. /**
  23339. * A function that is added to the onApplyObservable
  23340. */
  23341. set onApply(callback: (effect: Effect) => void);
  23342. /**
  23343. * An event triggered before rendering the postprocess
  23344. */
  23345. onBeforeRenderObservable: Observable<Effect>;
  23346. private _onBeforeRenderObserver;
  23347. /**
  23348. * A function that is added to the onBeforeRenderObservable
  23349. */
  23350. set onBeforeRender(callback: (effect: Effect) => void);
  23351. /**
  23352. * An event triggered after rendering the postprocess
  23353. */
  23354. onAfterRenderObservable: Observable<Effect>;
  23355. private _onAfterRenderObserver;
  23356. /**
  23357. * A function that is added to the onAfterRenderObservable
  23358. */
  23359. set onAfterRender(callback: (efect: Effect) => void);
  23360. /**
  23361. * 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
  23362. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23363. */
  23364. get inputTexture(): InternalTexture;
  23365. set inputTexture(value: InternalTexture);
  23366. /**
  23367. * Gets the camera which post process is applied to.
  23368. * @returns The camera the post process is applied to.
  23369. */
  23370. getCamera(): Camera;
  23371. /**
  23372. * Gets the texel size of the postprocess.
  23373. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23374. */
  23375. get texelSize(): Vector2;
  23376. /**
  23377. * Creates a new instance PostProcess
  23378. * @param name The name of the PostProcess.
  23379. * @param fragmentUrl The url of the fragment shader to be used.
  23380. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23381. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23382. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23383. * @param camera The camera to apply the render pass to.
  23384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23385. * @param engine The engine which the post process will be applied. (default: current engine)
  23386. * @param reusable If the post process can be reused on the same frame. (default: false)
  23387. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23388. * @param textureType Type of textures used when performing the post process. (default: 0)
  23389. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23390. * @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
  23391. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23392. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23393. */
  23394. constructor(
  23395. /** Name of the PostProcess. */
  23396. 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);
  23397. /**
  23398. * Gets a string idenfifying the name of the class
  23399. * @returns "PostProcess" string
  23400. */
  23401. getClassName(): string;
  23402. /**
  23403. * Gets the engine which this post process belongs to.
  23404. * @returns The engine the post process was enabled with.
  23405. */
  23406. getEngine(): Engine;
  23407. /**
  23408. * The effect that is created when initializing the post process.
  23409. * @returns The created effect corresponding the the postprocess.
  23410. */
  23411. getEffect(): Effect;
  23412. /**
  23413. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23414. * @param postProcess The post process to share the output with.
  23415. * @returns This post process.
  23416. */
  23417. shareOutputWith(postProcess: PostProcess): PostProcess;
  23418. /**
  23419. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23420. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23421. */
  23422. useOwnOutput(): void;
  23423. /**
  23424. * Updates the effect with the current post process compile time values and recompiles the shader.
  23425. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23426. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23427. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23428. * @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
  23429. * @param onCompiled Called when the shader has been compiled.
  23430. * @param onError Called if there is an error when compiling a shader.
  23431. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23432. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23433. */
  23434. 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;
  23435. /**
  23436. * The post process is reusable if it can be used multiple times within one frame.
  23437. * @returns If the post process is reusable
  23438. */
  23439. isReusable(): boolean;
  23440. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23441. markTextureDirty(): void;
  23442. /**
  23443. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23444. * 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.
  23445. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23446. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23447. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23448. * @returns The target texture that was bound to be written to.
  23449. */
  23450. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23451. /**
  23452. * If the post process is supported.
  23453. */
  23454. get isSupported(): boolean;
  23455. /**
  23456. * The aspect ratio of the output texture.
  23457. */
  23458. get aspectRatio(): number;
  23459. /**
  23460. * Get a value indicating if the post-process is ready to be used
  23461. * @returns true if the post-process is ready (shader is compiled)
  23462. */
  23463. isReady(): boolean;
  23464. /**
  23465. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23466. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23467. */
  23468. apply(): Nullable<Effect>;
  23469. private _disposeTextures;
  23470. /**
  23471. * Disposes the post process.
  23472. * @param camera The camera to dispose the post process on.
  23473. */
  23474. dispose(camera?: Camera): void;
  23475. }
  23476. }
  23477. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23478. /** @hidden */
  23479. export var kernelBlurVaryingDeclaration: {
  23480. name: string;
  23481. shader: string;
  23482. };
  23483. }
  23484. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23485. /** @hidden */
  23486. export var kernelBlurFragment: {
  23487. name: string;
  23488. shader: string;
  23489. };
  23490. }
  23491. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23492. /** @hidden */
  23493. export var kernelBlurFragment2: {
  23494. name: string;
  23495. shader: string;
  23496. };
  23497. }
  23498. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23499. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23500. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23501. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23502. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23503. /** @hidden */
  23504. export var kernelBlurPixelShader: {
  23505. name: string;
  23506. shader: string;
  23507. };
  23508. }
  23509. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23510. /** @hidden */
  23511. export var kernelBlurVertex: {
  23512. name: string;
  23513. shader: string;
  23514. };
  23515. }
  23516. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23517. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23518. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23519. /** @hidden */
  23520. export var kernelBlurVertexShader: {
  23521. name: string;
  23522. shader: string;
  23523. };
  23524. }
  23525. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23526. import { Vector2 } from "babylonjs/Maths/math.vector";
  23527. import { Nullable } from "babylonjs/types";
  23528. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23529. import { Camera } from "babylonjs/Cameras/camera";
  23530. import { Effect } from "babylonjs/Materials/effect";
  23531. import { Engine } from "babylonjs/Engines/engine";
  23532. import "babylonjs/Shaders/kernelBlur.fragment";
  23533. import "babylonjs/Shaders/kernelBlur.vertex";
  23534. /**
  23535. * The Blur Post Process which blurs an image based on a kernel and direction.
  23536. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23537. */
  23538. export class BlurPostProcess extends PostProcess {
  23539. /** The direction in which to blur the image. */
  23540. direction: Vector2;
  23541. private blockCompilation;
  23542. protected _kernel: number;
  23543. protected _idealKernel: number;
  23544. protected _packedFloat: boolean;
  23545. private _staticDefines;
  23546. /**
  23547. * Sets the length in pixels of the blur sample region
  23548. */
  23549. set kernel(v: number);
  23550. /**
  23551. * Gets the length in pixels of the blur sample region
  23552. */
  23553. get kernel(): number;
  23554. /**
  23555. * Sets wether or not the blur needs to unpack/repack floats
  23556. */
  23557. set packedFloat(v: boolean);
  23558. /**
  23559. * Gets wether or not the blur is unpacking/repacking floats
  23560. */
  23561. get packedFloat(): boolean;
  23562. /**
  23563. * Creates a new instance BlurPostProcess
  23564. * @param name The name of the effect.
  23565. * @param direction The direction in which to blur the image.
  23566. * @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.
  23567. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23568. * @param camera The camera to apply the render pass to.
  23569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23570. * @param engine The engine which the post process will be applied. (default: current engine)
  23571. * @param reusable If the post process can be reused on the same frame. (default: false)
  23572. * @param textureType Type of textures used when performing the post process. (default: 0)
  23573. * @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)
  23574. */
  23575. constructor(name: string,
  23576. /** The direction in which to blur the image. */
  23577. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23578. /**
  23579. * Updates the effect with the current post process compile time values and recompiles the shader.
  23580. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23581. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23582. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23583. * @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
  23584. * @param onCompiled Called when the shader has been compiled.
  23585. * @param onError Called if there is an error when compiling a shader.
  23586. */
  23587. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23588. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23589. /**
  23590. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23591. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23592. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23593. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23594. * The gaps between physical kernels are compensated for in the weighting of the samples
  23595. * @param idealKernel Ideal blur kernel.
  23596. * @return Nearest best kernel.
  23597. */
  23598. protected _nearestBestKernel(idealKernel: number): number;
  23599. /**
  23600. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23601. * @param x The point on the Gaussian distribution to sample.
  23602. * @return the value of the Gaussian function at x.
  23603. */
  23604. protected _gaussianWeight(x: number): number;
  23605. /**
  23606. * Generates a string that can be used as a floating point number in GLSL.
  23607. * @param x Value to print.
  23608. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23609. * @return GLSL float string.
  23610. */
  23611. protected _glslFloat(x: number, decimalFigures?: number): string;
  23612. }
  23613. }
  23614. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23615. import { Scene } from "babylonjs/scene";
  23616. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23617. import { Plane } from "babylonjs/Maths/math.plane";
  23618. /**
  23619. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23620. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23621. * You can then easily use it as a reflectionTexture on a flat surface.
  23622. * In case the surface is not a plane, please consider relying on reflection probes.
  23623. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23624. */
  23625. export class MirrorTexture extends RenderTargetTexture {
  23626. private scene;
  23627. /**
  23628. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23629. * 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.
  23630. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23631. */
  23632. mirrorPlane: Plane;
  23633. /**
  23634. * Define the blur ratio used to blur the reflection if needed.
  23635. */
  23636. set blurRatio(value: number);
  23637. get blurRatio(): number;
  23638. /**
  23639. * Define the adaptive blur kernel used to blur the reflection if needed.
  23640. * This will autocompute the closest best match for the `blurKernel`
  23641. */
  23642. set adaptiveBlurKernel(value: number);
  23643. /**
  23644. * Define the blur kernel used to blur the reflection if needed.
  23645. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23646. */
  23647. set blurKernel(value: number);
  23648. /**
  23649. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23650. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23651. */
  23652. set blurKernelX(value: number);
  23653. get blurKernelX(): number;
  23654. /**
  23655. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23656. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23657. */
  23658. set blurKernelY(value: number);
  23659. get blurKernelY(): number;
  23660. private _autoComputeBlurKernel;
  23661. protected _onRatioRescale(): void;
  23662. private _updateGammaSpace;
  23663. private _imageProcessingConfigChangeObserver;
  23664. private _transformMatrix;
  23665. private _mirrorMatrix;
  23666. private _savedViewMatrix;
  23667. private _blurX;
  23668. private _blurY;
  23669. private _adaptiveBlurKernel;
  23670. private _blurKernelX;
  23671. private _blurKernelY;
  23672. private _blurRatio;
  23673. /**
  23674. * Instantiates a Mirror Texture.
  23675. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23676. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23677. * You can then easily use it as a reflectionTexture on a flat surface.
  23678. * In case the surface is not a plane, please consider relying on reflection probes.
  23679. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23680. * @param name
  23681. * @param size
  23682. * @param scene
  23683. * @param generateMipMaps
  23684. * @param type
  23685. * @param samplingMode
  23686. * @param generateDepthBuffer
  23687. */
  23688. constructor(name: string, size: number | {
  23689. width: number;
  23690. height: number;
  23691. } | {
  23692. ratio: number;
  23693. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23694. private _preparePostProcesses;
  23695. /**
  23696. * Clone the mirror texture.
  23697. * @returns the cloned texture
  23698. */
  23699. clone(): MirrorTexture;
  23700. /**
  23701. * Serialize the texture to a JSON representation you could use in Parse later on
  23702. * @returns the serialized JSON representation
  23703. */
  23704. serialize(): any;
  23705. /**
  23706. * Dispose the texture and release its associated resources.
  23707. */
  23708. dispose(): void;
  23709. }
  23710. }
  23711. declare module "babylonjs/Materials/Textures/texture" {
  23712. import { Observable } from "babylonjs/Misc/observable";
  23713. import { Nullable } from "babylonjs/types";
  23714. import { Matrix } from "babylonjs/Maths/math.vector";
  23715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23716. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23717. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23718. import { Scene } from "babylonjs/scene";
  23719. /**
  23720. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23721. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23722. */
  23723. export class Texture extends BaseTexture {
  23724. /**
  23725. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23726. */
  23727. static SerializeBuffers: boolean;
  23728. /** @hidden */
  23729. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23730. /** @hidden */
  23731. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23732. /** @hidden */
  23733. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23734. /** nearest is mag = nearest and min = nearest and mip = linear */
  23735. static readonly NEAREST_SAMPLINGMODE: number;
  23736. /** nearest is mag = nearest and min = nearest and mip = linear */
  23737. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23738. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23739. static readonly BILINEAR_SAMPLINGMODE: number;
  23740. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23741. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23742. /** Trilinear is mag = linear and min = linear and mip = linear */
  23743. static readonly TRILINEAR_SAMPLINGMODE: number;
  23744. /** Trilinear is mag = linear and min = linear and mip = linear */
  23745. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23746. /** mag = nearest and min = nearest and mip = nearest */
  23747. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23748. /** mag = nearest and min = linear and mip = nearest */
  23749. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23750. /** mag = nearest and min = linear and mip = linear */
  23751. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23752. /** mag = nearest and min = linear and mip = none */
  23753. static readonly NEAREST_LINEAR: number;
  23754. /** mag = nearest and min = nearest and mip = none */
  23755. static readonly NEAREST_NEAREST: number;
  23756. /** mag = linear and min = nearest and mip = nearest */
  23757. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23758. /** mag = linear and min = nearest and mip = linear */
  23759. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23760. /** mag = linear and min = linear and mip = none */
  23761. static readonly LINEAR_LINEAR: number;
  23762. /** mag = linear and min = nearest and mip = none */
  23763. static readonly LINEAR_NEAREST: number;
  23764. /** Explicit coordinates mode */
  23765. static readonly EXPLICIT_MODE: number;
  23766. /** Spherical coordinates mode */
  23767. static readonly SPHERICAL_MODE: number;
  23768. /** Planar coordinates mode */
  23769. static readonly PLANAR_MODE: number;
  23770. /** Cubic coordinates mode */
  23771. static readonly CUBIC_MODE: number;
  23772. /** Projection coordinates mode */
  23773. static readonly PROJECTION_MODE: number;
  23774. /** Inverse Cubic coordinates mode */
  23775. static readonly SKYBOX_MODE: number;
  23776. /** Inverse Cubic coordinates mode */
  23777. static readonly INVCUBIC_MODE: number;
  23778. /** Equirectangular coordinates mode */
  23779. static readonly EQUIRECTANGULAR_MODE: number;
  23780. /** Equirectangular Fixed coordinates mode */
  23781. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23782. /** Equirectangular Fixed Mirrored coordinates mode */
  23783. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23784. /** Texture is not repeating outside of 0..1 UVs */
  23785. static readonly CLAMP_ADDRESSMODE: number;
  23786. /** Texture is repeating outside of 0..1 UVs */
  23787. static readonly WRAP_ADDRESSMODE: number;
  23788. /** Texture is repeating and mirrored */
  23789. static readonly MIRROR_ADDRESSMODE: number;
  23790. /**
  23791. * 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
  23792. */
  23793. static UseSerializedUrlIfAny: boolean;
  23794. /**
  23795. * Define the url of the texture.
  23796. */
  23797. url: Nullable<string>;
  23798. /**
  23799. * Define an offset on the texture to offset the u coordinates of the UVs
  23800. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23801. */
  23802. uOffset: number;
  23803. /**
  23804. * Define an offset on the texture to offset the v coordinates of the UVs
  23805. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23806. */
  23807. vOffset: number;
  23808. /**
  23809. * Define an offset on the texture to scale the u coordinates of the UVs
  23810. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23811. */
  23812. uScale: number;
  23813. /**
  23814. * Define an offset on the texture to scale the v coordinates of the UVs
  23815. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23816. */
  23817. vScale: number;
  23818. /**
  23819. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23820. * @see http://doc.babylonjs.com/how_to/more_materials
  23821. */
  23822. uAng: number;
  23823. /**
  23824. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23825. * @see http://doc.babylonjs.com/how_to/more_materials
  23826. */
  23827. vAng: number;
  23828. /**
  23829. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23830. * @see http://doc.babylonjs.com/how_to/more_materials
  23831. */
  23832. wAng: number;
  23833. /**
  23834. * Defines the center of rotation (U)
  23835. */
  23836. uRotationCenter: number;
  23837. /**
  23838. * Defines the center of rotation (V)
  23839. */
  23840. vRotationCenter: number;
  23841. /**
  23842. * Defines the center of rotation (W)
  23843. */
  23844. wRotationCenter: number;
  23845. /**
  23846. * Are mip maps generated for this texture or not.
  23847. */
  23848. get noMipmap(): boolean;
  23849. /**
  23850. * List of inspectable custom properties (used by the Inspector)
  23851. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23852. */
  23853. inspectableCustomProperties: Nullable<IInspectable[]>;
  23854. private _noMipmap;
  23855. /** @hidden */
  23856. _invertY: boolean;
  23857. private _rowGenerationMatrix;
  23858. private _cachedTextureMatrix;
  23859. private _projectionModeMatrix;
  23860. private _t0;
  23861. private _t1;
  23862. private _t2;
  23863. private _cachedUOffset;
  23864. private _cachedVOffset;
  23865. private _cachedUScale;
  23866. private _cachedVScale;
  23867. private _cachedUAng;
  23868. private _cachedVAng;
  23869. private _cachedWAng;
  23870. private _cachedProjectionMatrixId;
  23871. private _cachedCoordinatesMode;
  23872. /** @hidden */
  23873. protected _initialSamplingMode: number;
  23874. /** @hidden */
  23875. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23876. private _deleteBuffer;
  23877. protected _format: Nullable<number>;
  23878. private _delayedOnLoad;
  23879. private _delayedOnError;
  23880. private _mimeType?;
  23881. /**
  23882. * Observable triggered once the texture has been loaded.
  23883. */
  23884. onLoadObservable: Observable<Texture>;
  23885. protected _isBlocking: boolean;
  23886. /**
  23887. * Is the texture preventing material to render while loading.
  23888. * If false, a default texture will be used instead of the loading one during the preparation step.
  23889. */
  23890. set isBlocking(value: boolean);
  23891. get isBlocking(): boolean;
  23892. /**
  23893. * Get the current sampling mode associated with the texture.
  23894. */
  23895. get samplingMode(): number;
  23896. /**
  23897. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23898. */
  23899. get invertY(): boolean;
  23900. /**
  23901. * Instantiates a new texture.
  23902. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23903. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23904. * @param url defines the url of the picture to load as a texture
  23905. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23906. * @param noMipmap defines if the texture will require mip maps or not
  23907. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23908. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23909. * @param onLoad defines a callback triggered when the texture has been loaded
  23910. * @param onError defines a callback triggered when an error occurred during the loading session
  23911. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23912. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23913. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23914. * @param mimeType defines an optional mime type information
  23915. */
  23916. 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);
  23917. /**
  23918. * Update the url (and optional buffer) of this texture if url was null during construction.
  23919. * @param url the url of the texture
  23920. * @param buffer the buffer of the texture (defaults to null)
  23921. * @param onLoad callback called when the texture is loaded (defaults to null)
  23922. */
  23923. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23924. /**
  23925. * Finish the loading sequence of a texture flagged as delayed load.
  23926. * @hidden
  23927. */
  23928. delayLoad(): void;
  23929. private _prepareRowForTextureGeneration;
  23930. /**
  23931. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23932. * @returns the transform matrix of the texture.
  23933. */
  23934. getTextureMatrix(uBase?: number): Matrix;
  23935. /**
  23936. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23937. * @returns The reflection texture transform
  23938. */
  23939. getReflectionTextureMatrix(): Matrix;
  23940. /**
  23941. * Clones the texture.
  23942. * @returns the cloned texture
  23943. */
  23944. clone(): Texture;
  23945. /**
  23946. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23947. * @returns The JSON representation of the texture
  23948. */
  23949. serialize(): any;
  23950. /**
  23951. * Get the current class name of the texture useful for serialization or dynamic coding.
  23952. * @returns "Texture"
  23953. */
  23954. getClassName(): string;
  23955. /**
  23956. * Dispose the texture and release its associated resources.
  23957. */
  23958. dispose(): void;
  23959. /**
  23960. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23961. * @param parsedTexture Define the JSON representation of the texture
  23962. * @param scene Define the scene the parsed texture should be instantiated in
  23963. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23964. * @returns The parsed texture if successful
  23965. */
  23966. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23967. /**
  23968. * Creates a texture from its base 64 representation.
  23969. * @param data Define the base64 payload without the data: prefix
  23970. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23971. * @param scene Define the scene the texture should belong to
  23972. * @param noMipmap Forces the texture to not create mip map information if true
  23973. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23974. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23975. * @param onLoad define a callback triggered when the texture has been loaded
  23976. * @param onError define a callback triggered when an error occurred during the loading session
  23977. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23978. * @returns the created texture
  23979. */
  23980. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23981. /**
  23982. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23983. * @param data Define the base64 payload without the data: prefix
  23984. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23985. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23986. * @param scene Define the scene the texture should belong to
  23987. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23988. * @param noMipmap Forces the texture to not create mip map information if true
  23989. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23990. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23991. * @param onLoad define a callback triggered when the texture has been loaded
  23992. * @param onError define a callback triggered when an error occurred during the loading session
  23993. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23994. * @returns the created texture
  23995. */
  23996. 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;
  23997. }
  23998. }
  23999. declare module "babylonjs/PostProcesses/postProcessManager" {
  24000. import { Nullable } from "babylonjs/types";
  24001. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24002. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24003. import { Scene } from "babylonjs/scene";
  24004. /**
  24005. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24006. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24007. */
  24008. export class PostProcessManager {
  24009. private _scene;
  24010. private _indexBuffer;
  24011. private _vertexBuffers;
  24012. /**
  24013. * Creates a new instance PostProcess
  24014. * @param scene The scene that the post process is associated with.
  24015. */
  24016. constructor(scene: Scene);
  24017. private _prepareBuffers;
  24018. private _buildIndexBuffer;
  24019. /**
  24020. * Rebuilds the vertex buffers of the manager.
  24021. * @hidden
  24022. */
  24023. _rebuild(): void;
  24024. /**
  24025. * Prepares a frame to be run through a post process.
  24026. * @param sourceTexture The input texture to the post procesess. (default: null)
  24027. * @param postProcesses An array of post processes to be run. (default: null)
  24028. * @returns True if the post processes were able to be run.
  24029. * @hidden
  24030. */
  24031. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24032. /**
  24033. * Manually render a set of post processes to a texture.
  24034. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24035. * @param postProcesses An array of post processes to be run.
  24036. * @param targetTexture The target texture to render to.
  24037. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24038. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24039. * @param lodLevel defines which lod of the texture to render to
  24040. */
  24041. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  24042. /**
  24043. * Finalize the result of the output of the postprocesses.
  24044. * @param doNotPresent If true the result will not be displayed to the screen.
  24045. * @param targetTexture The target texture to render to.
  24046. * @param faceIndex The index of the face to bind the target texture to.
  24047. * @param postProcesses The array of post processes to render.
  24048. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24049. * @hidden
  24050. */
  24051. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24052. /**
  24053. * Disposes of the post process manager.
  24054. */
  24055. dispose(): void;
  24056. }
  24057. }
  24058. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24059. import { Observable } from "babylonjs/Misc/observable";
  24060. import { SmartArray } from "babylonjs/Misc/smartArray";
  24061. import { Nullable, Immutable } from "babylonjs/types";
  24062. import { Camera } from "babylonjs/Cameras/camera";
  24063. import { Scene } from "babylonjs/scene";
  24064. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24065. import { Color4 } from "babylonjs/Maths/math.color";
  24066. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24068. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24069. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24070. import { Texture } from "babylonjs/Materials/Textures/texture";
  24071. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24072. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24073. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24074. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24075. import { Engine } from "babylonjs/Engines/engine";
  24076. /**
  24077. * This Helps creating a texture that will be created from a camera in your scene.
  24078. * It is basically a dynamic texture that could be used to create special effects for instance.
  24079. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24080. */
  24081. export class RenderTargetTexture extends Texture {
  24082. isCube: boolean;
  24083. /**
  24084. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24085. */
  24086. static readonly REFRESHRATE_RENDER_ONCE: number;
  24087. /**
  24088. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24089. */
  24090. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24091. /**
  24092. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24093. * the central point of your effect and can save a lot of performances.
  24094. */
  24095. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24096. /**
  24097. * Use this predicate to dynamically define the list of mesh you want to render.
  24098. * If set, the renderList property will be overwritten.
  24099. */
  24100. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24101. private _renderList;
  24102. /**
  24103. * Use this list to define the list of mesh you want to render.
  24104. */
  24105. get renderList(): Nullable<Array<AbstractMesh>>;
  24106. set renderList(value: Nullable<Array<AbstractMesh>>);
  24107. /**
  24108. * Use this function to overload the renderList array at rendering time.
  24109. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24110. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24111. * the cube (if the RTT is a cube, else layerOrFace=0).
  24112. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24113. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24114. * hold dummy elements!
  24115. */
  24116. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24117. private _hookArray;
  24118. /**
  24119. * Define if particles should be rendered in your texture.
  24120. */
  24121. renderParticles: boolean;
  24122. /**
  24123. * Define if sprites should be rendered in your texture.
  24124. */
  24125. renderSprites: boolean;
  24126. /**
  24127. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24128. */
  24129. coordinatesMode: number;
  24130. /**
  24131. * Define the camera used to render the texture.
  24132. */
  24133. activeCamera: Nullable<Camera>;
  24134. /**
  24135. * Override the mesh isReady function with your own one.
  24136. */
  24137. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24138. /**
  24139. * Override the render function of the texture with your own one.
  24140. */
  24141. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24142. /**
  24143. * Define if camera post processes should be use while rendering the texture.
  24144. */
  24145. useCameraPostProcesses: boolean;
  24146. /**
  24147. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24148. */
  24149. ignoreCameraViewport: boolean;
  24150. private _postProcessManager;
  24151. private _postProcesses;
  24152. private _resizeObserver;
  24153. /**
  24154. * An event triggered when the texture is unbind.
  24155. */
  24156. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24157. /**
  24158. * An event triggered when the texture is unbind.
  24159. */
  24160. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24161. private _onAfterUnbindObserver;
  24162. /**
  24163. * Set a after unbind callback in the texture.
  24164. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24165. */
  24166. set onAfterUnbind(callback: () => void);
  24167. /**
  24168. * An event triggered before rendering the texture
  24169. */
  24170. onBeforeRenderObservable: Observable<number>;
  24171. private _onBeforeRenderObserver;
  24172. /**
  24173. * Set a before render callback in the texture.
  24174. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24175. */
  24176. set onBeforeRender(callback: (faceIndex: number) => void);
  24177. /**
  24178. * An event triggered after rendering the texture
  24179. */
  24180. onAfterRenderObservable: Observable<number>;
  24181. private _onAfterRenderObserver;
  24182. /**
  24183. * Set a after render callback in the texture.
  24184. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24185. */
  24186. set onAfterRender(callback: (faceIndex: number) => void);
  24187. /**
  24188. * An event triggered after the texture clear
  24189. */
  24190. onClearObservable: Observable<Engine>;
  24191. private _onClearObserver;
  24192. /**
  24193. * Set a clear callback in the texture.
  24194. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24195. */
  24196. set onClear(callback: (Engine: Engine) => void);
  24197. /**
  24198. * An event triggered when the texture is resized.
  24199. */
  24200. onResizeObservable: Observable<RenderTargetTexture>;
  24201. /**
  24202. * Define the clear color of the Render Target if it should be different from the scene.
  24203. */
  24204. clearColor: Color4;
  24205. protected _size: number | {
  24206. width: number;
  24207. height: number;
  24208. layers?: number;
  24209. };
  24210. protected _initialSizeParameter: number | {
  24211. width: number;
  24212. height: number;
  24213. } | {
  24214. ratio: number;
  24215. };
  24216. protected _sizeRatio: Nullable<number>;
  24217. /** @hidden */
  24218. _generateMipMaps: boolean;
  24219. protected _renderingManager: RenderingManager;
  24220. /** @hidden */
  24221. _waitingRenderList: string[];
  24222. protected _doNotChangeAspectRatio: boolean;
  24223. protected _currentRefreshId: number;
  24224. protected _refreshRate: number;
  24225. protected _textureMatrix: Matrix;
  24226. protected _samples: number;
  24227. protected _renderTargetOptions: RenderTargetCreationOptions;
  24228. /**
  24229. * Gets render target creation options that were used.
  24230. */
  24231. get renderTargetOptions(): RenderTargetCreationOptions;
  24232. protected _onRatioRescale(): void;
  24233. /**
  24234. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24235. * It must define where the camera used to render the texture is set
  24236. */
  24237. boundingBoxPosition: Vector3;
  24238. private _boundingBoxSize;
  24239. /**
  24240. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24241. * When defined, the cubemap will switch to local mode
  24242. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24243. * @example https://www.babylonjs-playground.com/#RNASML
  24244. */
  24245. set boundingBoxSize(value: Vector3);
  24246. get boundingBoxSize(): Vector3;
  24247. /**
  24248. * In case the RTT has been created with a depth texture, get the associated
  24249. * depth texture.
  24250. * Otherwise, return null.
  24251. */
  24252. get depthStencilTexture(): Nullable<InternalTexture>;
  24253. /**
  24254. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24255. * or used a shadow, depth texture...
  24256. * @param name The friendly name of the texture
  24257. * @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)
  24258. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24259. * @param generateMipMaps True if mip maps need to be generated after render.
  24260. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24261. * @param type The type of the buffer in the RTT (int, half float, float...)
  24262. * @param isCube True if a cube texture needs to be created
  24263. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24264. * @param generateDepthBuffer True to generate a depth buffer
  24265. * @param generateStencilBuffer True to generate a stencil buffer
  24266. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24267. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24268. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24269. */
  24270. constructor(name: string, size: number | {
  24271. width: number;
  24272. height: number;
  24273. layers?: number;
  24274. } | {
  24275. ratio: number;
  24276. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24277. /**
  24278. * Creates a depth stencil texture.
  24279. * This is only available in WebGL 2 or with the depth texture extension available.
  24280. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24281. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24282. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24283. */
  24284. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24285. private _processSizeParameter;
  24286. /**
  24287. * Define the number of samples to use in case of MSAA.
  24288. * It defaults to one meaning no MSAA has been enabled.
  24289. */
  24290. get samples(): number;
  24291. set samples(value: number);
  24292. /**
  24293. * Resets the refresh counter of the texture and start bak from scratch.
  24294. * Could be useful to regenerate the texture if it is setup to render only once.
  24295. */
  24296. resetRefreshCounter(): void;
  24297. /**
  24298. * Define the refresh rate of the texture or the rendering frequency.
  24299. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24300. */
  24301. get refreshRate(): number;
  24302. set refreshRate(value: number);
  24303. /**
  24304. * Adds a post process to the render target rendering passes.
  24305. * @param postProcess define the post process to add
  24306. */
  24307. addPostProcess(postProcess: PostProcess): void;
  24308. /**
  24309. * Clear all the post processes attached to the render target
  24310. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24311. */
  24312. clearPostProcesses(dispose?: boolean): void;
  24313. /**
  24314. * Remove one of the post process from the list of attached post processes to the texture
  24315. * @param postProcess define the post process to remove from the list
  24316. */
  24317. removePostProcess(postProcess: PostProcess): void;
  24318. /** @hidden */
  24319. _shouldRender(): boolean;
  24320. /**
  24321. * Gets the actual render size of the texture.
  24322. * @returns the width of the render size
  24323. */
  24324. getRenderSize(): number;
  24325. /**
  24326. * Gets the actual render width of the texture.
  24327. * @returns the width of the render size
  24328. */
  24329. getRenderWidth(): number;
  24330. /**
  24331. * Gets the actual render height of the texture.
  24332. * @returns the height of the render size
  24333. */
  24334. getRenderHeight(): number;
  24335. /**
  24336. * Gets the actual number of layers of the texture.
  24337. * @returns the number of layers
  24338. */
  24339. getRenderLayers(): number;
  24340. /**
  24341. * Get if the texture can be rescaled or not.
  24342. */
  24343. get canRescale(): boolean;
  24344. /**
  24345. * Resize the texture using a ratio.
  24346. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24347. */
  24348. scale(ratio: number): void;
  24349. /**
  24350. * Get the texture reflection matrix used to rotate/transform the reflection.
  24351. * @returns the reflection matrix
  24352. */
  24353. getReflectionTextureMatrix(): Matrix;
  24354. /**
  24355. * Resize the texture to a new desired size.
  24356. * Be carrefull as it will recreate all the data in the new texture.
  24357. * @param size Define the new size. It can be:
  24358. * - a number for squared texture,
  24359. * - an object containing { width: number, height: number }
  24360. * - or an object containing a ratio { ratio: number }
  24361. */
  24362. resize(size: number | {
  24363. width: number;
  24364. height: number;
  24365. } | {
  24366. ratio: number;
  24367. }): void;
  24368. private _defaultRenderListPrepared;
  24369. /**
  24370. * Renders all the objects from the render list into the texture.
  24371. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24372. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24373. */
  24374. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24375. private _bestReflectionRenderTargetDimension;
  24376. private _prepareRenderingManager;
  24377. /**
  24378. * @hidden
  24379. * @param faceIndex face index to bind to if this is a cubetexture
  24380. * @param layer defines the index of the texture to bind in the array
  24381. */
  24382. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24383. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24384. private renderToTarget;
  24385. /**
  24386. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24387. * This allowed control for front to back rendering or reversly depending of the special needs.
  24388. *
  24389. * @param renderingGroupId The rendering group id corresponding to its index
  24390. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24391. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24392. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24393. */
  24394. 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;
  24395. /**
  24396. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24397. *
  24398. * @param renderingGroupId The rendering group id corresponding to its index
  24399. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24400. */
  24401. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24402. /**
  24403. * Clones the texture.
  24404. * @returns the cloned texture
  24405. */
  24406. clone(): RenderTargetTexture;
  24407. /**
  24408. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24409. * @returns The JSON representation of the texture
  24410. */
  24411. serialize(): any;
  24412. /**
  24413. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24414. */
  24415. disposeFramebufferObjects(): void;
  24416. /**
  24417. * Dispose the texture and release its associated resources.
  24418. */
  24419. dispose(): void;
  24420. /** @hidden */
  24421. _rebuild(): void;
  24422. /**
  24423. * Clear the info related to rendering groups preventing retention point in material dispose.
  24424. */
  24425. freeRenderingGroups(): void;
  24426. /**
  24427. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24428. * @returns the view count
  24429. */
  24430. getViewCount(): number;
  24431. }
  24432. }
  24433. declare module "babylonjs/Misc/guid" {
  24434. /**
  24435. * Class used to manipulate GUIDs
  24436. */
  24437. export class GUID {
  24438. /**
  24439. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24440. * Be aware Math.random() could cause collisions, but:
  24441. * "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"
  24442. * @returns a pseudo random id
  24443. */
  24444. static RandomId(): string;
  24445. }
  24446. }
  24447. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24448. import { Nullable } from "babylonjs/types";
  24449. import { Scene } from "babylonjs/scene";
  24450. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24451. import { Material } from "babylonjs/Materials/material";
  24452. import { Effect } from "babylonjs/Materials/effect";
  24453. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24454. /**
  24455. * Options to be used when creating a shadow depth material
  24456. */
  24457. export interface IIOptionShadowDepthMaterial {
  24458. /** Variables in the vertex shader code that need to have their names remapped.
  24459. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24460. * "var_name" should be either: worldPos or vNormalW
  24461. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24462. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24463. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24464. */
  24465. remappedVariables?: string[];
  24466. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24467. standalone?: boolean;
  24468. }
  24469. /**
  24470. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24471. */
  24472. export class ShadowDepthWrapper {
  24473. private _scene;
  24474. private _options?;
  24475. private _baseMaterial;
  24476. private _onEffectCreatedObserver;
  24477. private _subMeshToEffect;
  24478. private _subMeshToDepthEffect;
  24479. private _meshes;
  24480. /** @hidden */
  24481. _matriceNames: any;
  24482. /** Gets the standalone status of the wrapper */
  24483. get standalone(): boolean;
  24484. /** Gets the base material the wrapper is built upon */
  24485. get baseMaterial(): Material;
  24486. /**
  24487. * Instantiate a new shadow depth wrapper.
  24488. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24489. * generate the shadow depth map. For more information, please refer to the documentation:
  24490. * https://doc.babylonjs.com/babylon101/shadows
  24491. * @param baseMaterial Material to wrap
  24492. * @param scene Define the scene the material belongs to
  24493. * @param options Options used to create the wrapper
  24494. */
  24495. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24496. /**
  24497. * Gets the effect to use to generate the depth map
  24498. * @param subMesh subMesh to get the effect for
  24499. * @param shadowGenerator shadow generator to get the effect for
  24500. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24501. */
  24502. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24503. /**
  24504. * Specifies that the submesh is ready to be used for depth rendering
  24505. * @param subMesh submesh to check
  24506. * @param defines the list of defines to take into account when checking the effect
  24507. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24508. * @param useInstances specifies that instances should be used
  24509. * @returns a boolean indicating that the submesh is ready or not
  24510. */
  24511. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24512. /**
  24513. * Disposes the resources
  24514. */
  24515. dispose(): void;
  24516. private _makeEffect;
  24517. }
  24518. }
  24519. declare module "babylonjs/Materials/material" {
  24520. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24521. import { SmartArray } from "babylonjs/Misc/smartArray";
  24522. import { Observable } from "babylonjs/Misc/observable";
  24523. import { Nullable } from "babylonjs/types";
  24524. import { Scene } from "babylonjs/scene";
  24525. import { Matrix } from "babylonjs/Maths/math.vector";
  24526. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24528. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24529. import { Effect } from "babylonjs/Materials/effect";
  24530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24531. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24532. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24533. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24534. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24535. import { Mesh } from "babylonjs/Meshes/mesh";
  24536. import { Animation } from "babylonjs/Animations/animation";
  24537. /**
  24538. * Options for compiling materials.
  24539. */
  24540. export interface IMaterialCompilationOptions {
  24541. /**
  24542. * Defines whether clip planes are enabled.
  24543. */
  24544. clipPlane: boolean;
  24545. /**
  24546. * Defines whether instances are enabled.
  24547. */
  24548. useInstances: boolean;
  24549. }
  24550. /**
  24551. * Options passed when calling customShaderNameResolve
  24552. */
  24553. export interface ICustomShaderNameResolveOptions {
  24554. /**
  24555. * 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
  24556. */
  24557. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24558. }
  24559. /**
  24560. * Base class for the main features of a material in Babylon.js
  24561. */
  24562. export class Material implements IAnimatable {
  24563. /**
  24564. * Returns the triangle fill mode
  24565. */
  24566. static readonly TriangleFillMode: number;
  24567. /**
  24568. * Returns the wireframe mode
  24569. */
  24570. static readonly WireFrameFillMode: number;
  24571. /**
  24572. * Returns the point fill mode
  24573. */
  24574. static readonly PointFillMode: number;
  24575. /**
  24576. * Returns the point list draw mode
  24577. */
  24578. static readonly PointListDrawMode: number;
  24579. /**
  24580. * Returns the line list draw mode
  24581. */
  24582. static readonly LineListDrawMode: number;
  24583. /**
  24584. * Returns the line loop draw mode
  24585. */
  24586. static readonly LineLoopDrawMode: number;
  24587. /**
  24588. * Returns the line strip draw mode
  24589. */
  24590. static readonly LineStripDrawMode: number;
  24591. /**
  24592. * Returns the triangle strip draw mode
  24593. */
  24594. static readonly TriangleStripDrawMode: number;
  24595. /**
  24596. * Returns the triangle fan draw mode
  24597. */
  24598. static readonly TriangleFanDrawMode: number;
  24599. /**
  24600. * Stores the clock-wise side orientation
  24601. */
  24602. static readonly ClockWiseSideOrientation: number;
  24603. /**
  24604. * Stores the counter clock-wise side orientation
  24605. */
  24606. static readonly CounterClockWiseSideOrientation: number;
  24607. /**
  24608. * The dirty texture flag value
  24609. */
  24610. static readonly TextureDirtyFlag: number;
  24611. /**
  24612. * The dirty light flag value
  24613. */
  24614. static readonly LightDirtyFlag: number;
  24615. /**
  24616. * The dirty fresnel flag value
  24617. */
  24618. static readonly FresnelDirtyFlag: number;
  24619. /**
  24620. * The dirty attribute flag value
  24621. */
  24622. static readonly AttributesDirtyFlag: number;
  24623. /**
  24624. * The dirty misc flag value
  24625. */
  24626. static readonly MiscDirtyFlag: number;
  24627. /**
  24628. * The all dirty flag value
  24629. */
  24630. static readonly AllDirtyFlag: number;
  24631. /**
  24632. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24633. */
  24634. static readonly MATERIAL_OPAQUE: number;
  24635. /**
  24636. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24637. */
  24638. static readonly MATERIAL_ALPHATEST: number;
  24639. /**
  24640. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24641. */
  24642. static readonly MATERIAL_ALPHABLEND: number;
  24643. /**
  24644. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24645. * They are also discarded below the alpha cutoff threshold to improve performances.
  24646. */
  24647. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24648. /**
  24649. * The Whiteout method is used to blend normals.
  24650. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24651. */
  24652. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24653. /**
  24654. * The Reoriented Normal Mapping method is used to blend normals.
  24655. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24656. */
  24657. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24658. /**
  24659. * Custom callback helping to override the default shader used in the material.
  24660. */
  24661. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24662. /**
  24663. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24664. */
  24665. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24666. /**
  24667. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24668. * This means that the material can keep using a previous shader while a new one is being compiled.
  24669. * This is mostly used when shader parallel compilation is supported (true by default)
  24670. */
  24671. allowShaderHotSwapping: boolean;
  24672. /**
  24673. * The ID of the material
  24674. */
  24675. id: string;
  24676. /**
  24677. * Gets or sets the unique id of the material
  24678. */
  24679. uniqueId: number;
  24680. /**
  24681. * The name of the material
  24682. */
  24683. name: string;
  24684. /**
  24685. * Gets or sets user defined metadata
  24686. */
  24687. metadata: any;
  24688. /**
  24689. * For internal use only. Please do not use.
  24690. */
  24691. reservedDataStore: any;
  24692. /**
  24693. * Specifies if the ready state should be checked on each call
  24694. */
  24695. checkReadyOnEveryCall: boolean;
  24696. /**
  24697. * Specifies if the ready state should be checked once
  24698. */
  24699. checkReadyOnlyOnce: boolean;
  24700. /**
  24701. * The state of the material
  24702. */
  24703. state: string;
  24704. /**
  24705. * The alpha value of the material
  24706. */
  24707. protected _alpha: number;
  24708. /**
  24709. * List of inspectable custom properties (used by the Inspector)
  24710. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24711. */
  24712. inspectableCustomProperties: IInspectable[];
  24713. /**
  24714. * Sets the alpha value of the material
  24715. */
  24716. set alpha(value: number);
  24717. /**
  24718. * Gets the alpha value of the material
  24719. */
  24720. get alpha(): number;
  24721. /**
  24722. * Specifies if back face culling is enabled
  24723. */
  24724. protected _backFaceCulling: boolean;
  24725. /**
  24726. * Sets the back-face culling state
  24727. */
  24728. set backFaceCulling(value: boolean);
  24729. /**
  24730. * Gets the back-face culling state
  24731. */
  24732. get backFaceCulling(): boolean;
  24733. /**
  24734. * Stores the value for side orientation
  24735. */
  24736. sideOrientation: number;
  24737. /**
  24738. * Callback triggered when the material is compiled
  24739. */
  24740. onCompiled: Nullable<(effect: Effect) => void>;
  24741. /**
  24742. * Callback triggered when an error occurs
  24743. */
  24744. onError: Nullable<(effect: Effect, errors: string) => void>;
  24745. /**
  24746. * Callback triggered to get the render target textures
  24747. */
  24748. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24749. /**
  24750. * Gets a boolean indicating that current material needs to register RTT
  24751. */
  24752. get hasRenderTargetTextures(): boolean;
  24753. /**
  24754. * Specifies if the material should be serialized
  24755. */
  24756. doNotSerialize: boolean;
  24757. /**
  24758. * @hidden
  24759. */
  24760. _storeEffectOnSubMeshes: boolean;
  24761. /**
  24762. * Stores the animations for the material
  24763. */
  24764. animations: Nullable<Array<Animation>>;
  24765. /**
  24766. * An event triggered when the material is disposed
  24767. */
  24768. onDisposeObservable: Observable<Material>;
  24769. /**
  24770. * An observer which watches for dispose events
  24771. */
  24772. private _onDisposeObserver;
  24773. private _onUnBindObservable;
  24774. /**
  24775. * Called during a dispose event
  24776. */
  24777. set onDispose(callback: () => void);
  24778. private _onBindObservable;
  24779. /**
  24780. * An event triggered when the material is bound
  24781. */
  24782. get onBindObservable(): Observable<AbstractMesh>;
  24783. /**
  24784. * An observer which watches for bind events
  24785. */
  24786. private _onBindObserver;
  24787. /**
  24788. * Called during a bind event
  24789. */
  24790. set onBind(callback: (Mesh: AbstractMesh) => void);
  24791. /**
  24792. * An event triggered when the material is unbound
  24793. */
  24794. get onUnBindObservable(): Observable<Material>;
  24795. protected _onEffectCreatedObservable: Nullable<Observable<{
  24796. effect: Effect;
  24797. subMesh: Nullable<SubMesh>;
  24798. }>>;
  24799. /**
  24800. * An event triggered when the effect is (re)created
  24801. */
  24802. get onEffectCreatedObservable(): Observable<{
  24803. effect: Effect;
  24804. subMesh: Nullable<SubMesh>;
  24805. }>;
  24806. /**
  24807. * Stores the value of the alpha mode
  24808. */
  24809. private _alphaMode;
  24810. /**
  24811. * Sets the value of the alpha mode.
  24812. *
  24813. * | Value | Type | Description |
  24814. * | --- | --- | --- |
  24815. * | 0 | ALPHA_DISABLE | |
  24816. * | 1 | ALPHA_ADD | |
  24817. * | 2 | ALPHA_COMBINE | |
  24818. * | 3 | ALPHA_SUBTRACT | |
  24819. * | 4 | ALPHA_MULTIPLY | |
  24820. * | 5 | ALPHA_MAXIMIZED | |
  24821. * | 6 | ALPHA_ONEONE | |
  24822. * | 7 | ALPHA_PREMULTIPLIED | |
  24823. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24824. * | 9 | ALPHA_INTERPOLATE | |
  24825. * | 10 | ALPHA_SCREENMODE | |
  24826. *
  24827. */
  24828. set alphaMode(value: number);
  24829. /**
  24830. * Gets the value of the alpha mode
  24831. */
  24832. get alphaMode(): number;
  24833. /**
  24834. * Stores the state of the need depth pre-pass value
  24835. */
  24836. private _needDepthPrePass;
  24837. /**
  24838. * Sets the need depth pre-pass value
  24839. */
  24840. set needDepthPrePass(value: boolean);
  24841. /**
  24842. * Gets the depth pre-pass value
  24843. */
  24844. get needDepthPrePass(): boolean;
  24845. /**
  24846. * Specifies if depth writing should be disabled
  24847. */
  24848. disableDepthWrite: boolean;
  24849. /**
  24850. * Specifies if color writing should be disabled
  24851. */
  24852. disableColorWrite: boolean;
  24853. /**
  24854. * Specifies if depth writing should be forced
  24855. */
  24856. forceDepthWrite: boolean;
  24857. /**
  24858. * Specifies the depth function that should be used. 0 means the default engine function
  24859. */
  24860. depthFunction: number;
  24861. /**
  24862. * Specifies if there should be a separate pass for culling
  24863. */
  24864. separateCullingPass: boolean;
  24865. /**
  24866. * Stores the state specifing if fog should be enabled
  24867. */
  24868. private _fogEnabled;
  24869. /**
  24870. * Sets the state for enabling fog
  24871. */
  24872. set fogEnabled(value: boolean);
  24873. /**
  24874. * Gets the value of the fog enabled state
  24875. */
  24876. get fogEnabled(): boolean;
  24877. /**
  24878. * Stores the size of points
  24879. */
  24880. pointSize: number;
  24881. /**
  24882. * Stores the z offset value
  24883. */
  24884. zOffset: number;
  24885. get wireframe(): boolean;
  24886. /**
  24887. * Sets the state of wireframe mode
  24888. */
  24889. set wireframe(value: boolean);
  24890. /**
  24891. * Gets the value specifying if point clouds are enabled
  24892. */
  24893. get pointsCloud(): boolean;
  24894. /**
  24895. * Sets the state of point cloud mode
  24896. */
  24897. set pointsCloud(value: boolean);
  24898. /**
  24899. * Gets the material fill mode
  24900. */
  24901. get fillMode(): number;
  24902. /**
  24903. * Sets the material fill mode
  24904. */
  24905. set fillMode(value: number);
  24906. /**
  24907. * @hidden
  24908. * Stores the effects for the material
  24909. */
  24910. _effect: Nullable<Effect>;
  24911. /**
  24912. * Specifies if uniform buffers should be used
  24913. */
  24914. private _useUBO;
  24915. /**
  24916. * Stores a reference to the scene
  24917. */
  24918. private _scene;
  24919. /**
  24920. * Stores the fill mode state
  24921. */
  24922. private _fillMode;
  24923. /**
  24924. * Specifies if the depth write state should be cached
  24925. */
  24926. private _cachedDepthWriteState;
  24927. /**
  24928. * Specifies if the color write state should be cached
  24929. */
  24930. private _cachedColorWriteState;
  24931. /**
  24932. * Specifies if the depth function state should be cached
  24933. */
  24934. private _cachedDepthFunctionState;
  24935. /**
  24936. * Stores the uniform buffer
  24937. */
  24938. protected _uniformBuffer: UniformBuffer;
  24939. /** @hidden */
  24940. _indexInSceneMaterialArray: number;
  24941. /** @hidden */
  24942. meshMap: Nullable<{
  24943. [id: string]: AbstractMesh | undefined;
  24944. }>;
  24945. /**
  24946. * Creates a material instance
  24947. * @param name defines the name of the material
  24948. * @param scene defines the scene to reference
  24949. * @param doNotAdd specifies if the material should be added to the scene
  24950. */
  24951. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24952. /**
  24953. * Returns a string representation of the current material
  24954. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24955. * @returns a string with material information
  24956. */
  24957. toString(fullDetails?: boolean): string;
  24958. /**
  24959. * Gets the class name of the material
  24960. * @returns a string with the class name of the material
  24961. */
  24962. getClassName(): string;
  24963. /**
  24964. * Specifies if updates for the material been locked
  24965. */
  24966. get isFrozen(): boolean;
  24967. /**
  24968. * Locks updates for the material
  24969. */
  24970. freeze(): void;
  24971. /**
  24972. * Unlocks updates for the material
  24973. */
  24974. unfreeze(): void;
  24975. /**
  24976. * Specifies if the material is ready to be used
  24977. * @param mesh defines the mesh to check
  24978. * @param useInstances specifies if instances should be used
  24979. * @returns a boolean indicating if the material is ready to be used
  24980. */
  24981. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24982. /**
  24983. * Specifies that the submesh is ready to be used
  24984. * @param mesh defines the mesh to check
  24985. * @param subMesh defines which submesh to check
  24986. * @param useInstances specifies that instances should be used
  24987. * @returns a boolean indicating that the submesh is ready or not
  24988. */
  24989. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24990. /**
  24991. * Returns the material effect
  24992. * @returns the effect associated with the material
  24993. */
  24994. getEffect(): Nullable<Effect>;
  24995. /**
  24996. * Returns the current scene
  24997. * @returns a Scene
  24998. */
  24999. getScene(): Scene;
  25000. /**
  25001. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25002. */
  25003. protected _forceAlphaTest: boolean;
  25004. /**
  25005. * The transparency mode of the material.
  25006. */
  25007. protected _transparencyMode: Nullable<number>;
  25008. /**
  25009. * Gets the current transparency mode.
  25010. */
  25011. get transparencyMode(): Nullable<number>;
  25012. /**
  25013. * Sets the transparency mode of the material.
  25014. *
  25015. * | Value | Type | Description |
  25016. * | ----- | ----------------------------------- | ----------- |
  25017. * | 0 | OPAQUE | |
  25018. * | 1 | ALPHATEST | |
  25019. * | 2 | ALPHABLEND | |
  25020. * | 3 | ALPHATESTANDBLEND | |
  25021. *
  25022. */
  25023. set transparencyMode(value: Nullable<number>);
  25024. /**
  25025. * Returns true if alpha blending should be disabled.
  25026. */
  25027. protected get _disableAlphaBlending(): boolean;
  25028. /**
  25029. * Specifies whether or not this material should be rendered in alpha blend mode.
  25030. * @returns a boolean specifying if alpha blending is needed
  25031. */
  25032. needAlphaBlending(): boolean;
  25033. /**
  25034. * Specifies if the mesh will require alpha blending
  25035. * @param mesh defines the mesh to check
  25036. * @returns a boolean specifying if alpha blending is needed for the mesh
  25037. */
  25038. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25039. /**
  25040. * Specifies whether or not this material should be rendered in alpha test mode.
  25041. * @returns a boolean specifying if an alpha test is needed.
  25042. */
  25043. needAlphaTesting(): boolean;
  25044. /**
  25045. * Specifies if material alpha testing should be turned on for the mesh
  25046. * @param mesh defines the mesh to check
  25047. */
  25048. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25049. /**
  25050. * Gets the texture used for the alpha test
  25051. * @returns the texture to use for alpha testing
  25052. */
  25053. getAlphaTestTexture(): Nullable<BaseTexture>;
  25054. /**
  25055. * Marks the material to indicate that it needs to be re-calculated
  25056. */
  25057. markDirty(): void;
  25058. /** @hidden */
  25059. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25060. /**
  25061. * Binds the material to the mesh
  25062. * @param world defines the world transformation matrix
  25063. * @param mesh defines the mesh to bind the material to
  25064. */
  25065. bind(world: Matrix, mesh?: Mesh): void;
  25066. /**
  25067. * Binds the submesh to the material
  25068. * @param world defines the world transformation matrix
  25069. * @param mesh defines the mesh containing the submesh
  25070. * @param subMesh defines the submesh to bind the material to
  25071. */
  25072. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25073. /**
  25074. * Binds the world matrix to the material
  25075. * @param world defines the world transformation matrix
  25076. */
  25077. bindOnlyWorldMatrix(world: Matrix): void;
  25078. /**
  25079. * Binds the scene's uniform buffer to the effect.
  25080. * @param effect defines the effect to bind to the scene uniform buffer
  25081. * @param sceneUbo defines the uniform buffer storing scene data
  25082. */
  25083. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25084. /**
  25085. * Binds the view matrix to the effect
  25086. * @param effect defines the effect to bind the view matrix to
  25087. */
  25088. bindView(effect: Effect): void;
  25089. /**
  25090. * Binds the view projection matrix to the effect
  25091. * @param effect defines the effect to bind the view projection matrix to
  25092. */
  25093. bindViewProjection(effect: Effect): void;
  25094. /**
  25095. * Processes to execute after binding the material to a mesh
  25096. * @param mesh defines the rendered mesh
  25097. */
  25098. protected _afterBind(mesh?: Mesh): void;
  25099. /**
  25100. * Unbinds the material from the mesh
  25101. */
  25102. unbind(): void;
  25103. /**
  25104. * Gets the active textures from the material
  25105. * @returns an array of textures
  25106. */
  25107. getActiveTextures(): BaseTexture[];
  25108. /**
  25109. * Specifies if the material uses a texture
  25110. * @param texture defines the texture to check against the material
  25111. * @returns a boolean specifying if the material uses the texture
  25112. */
  25113. hasTexture(texture: BaseTexture): boolean;
  25114. /**
  25115. * Makes a duplicate of the material, and gives it a new name
  25116. * @param name defines the new name for the duplicated material
  25117. * @returns the cloned material
  25118. */
  25119. clone(name: string): Nullable<Material>;
  25120. /**
  25121. * Gets the meshes bound to the material
  25122. * @returns an array of meshes bound to the material
  25123. */
  25124. getBindedMeshes(): AbstractMesh[];
  25125. /**
  25126. * Force shader compilation
  25127. * @param mesh defines the mesh associated with this material
  25128. * @param onCompiled defines a function to execute once the material is compiled
  25129. * @param options defines the options to configure the compilation
  25130. * @param onError defines a function to execute if the material fails compiling
  25131. */
  25132. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25133. /**
  25134. * Force shader compilation
  25135. * @param mesh defines the mesh that will use this material
  25136. * @param options defines additional options for compiling the shaders
  25137. * @returns a promise that resolves when the compilation completes
  25138. */
  25139. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25140. private static readonly _AllDirtyCallBack;
  25141. private static readonly _ImageProcessingDirtyCallBack;
  25142. private static readonly _TextureDirtyCallBack;
  25143. private static readonly _FresnelDirtyCallBack;
  25144. private static readonly _MiscDirtyCallBack;
  25145. private static readonly _LightsDirtyCallBack;
  25146. private static readonly _AttributeDirtyCallBack;
  25147. private static _FresnelAndMiscDirtyCallBack;
  25148. private static _TextureAndMiscDirtyCallBack;
  25149. private static readonly _DirtyCallbackArray;
  25150. private static readonly _RunDirtyCallBacks;
  25151. /**
  25152. * Marks a define in the material to indicate that it needs to be re-computed
  25153. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25154. */
  25155. markAsDirty(flag: number): void;
  25156. /**
  25157. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25158. * @param func defines a function which checks material defines against the submeshes
  25159. */
  25160. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25161. /**
  25162. * Indicates that we need to re-calculated for all submeshes
  25163. */
  25164. protected _markAllSubMeshesAsAllDirty(): void;
  25165. /**
  25166. * Indicates that image processing needs to be re-calculated for all submeshes
  25167. */
  25168. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25169. /**
  25170. * Indicates that textures need to be re-calculated for all submeshes
  25171. */
  25172. protected _markAllSubMeshesAsTexturesDirty(): void;
  25173. /**
  25174. * Indicates that fresnel needs to be re-calculated for all submeshes
  25175. */
  25176. protected _markAllSubMeshesAsFresnelDirty(): void;
  25177. /**
  25178. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25179. */
  25180. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25181. /**
  25182. * Indicates that lights need to be re-calculated for all submeshes
  25183. */
  25184. protected _markAllSubMeshesAsLightsDirty(): void;
  25185. /**
  25186. * Indicates that attributes need to be re-calculated for all submeshes
  25187. */
  25188. protected _markAllSubMeshesAsAttributesDirty(): void;
  25189. /**
  25190. * Indicates that misc needs to be re-calculated for all submeshes
  25191. */
  25192. protected _markAllSubMeshesAsMiscDirty(): void;
  25193. /**
  25194. * Indicates that textures and misc need to be re-calculated for all submeshes
  25195. */
  25196. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25197. /**
  25198. * Disposes the material
  25199. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25200. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25201. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25202. */
  25203. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25204. /** @hidden */
  25205. private releaseVertexArrayObject;
  25206. /**
  25207. * Serializes this material
  25208. * @returns the serialized material object
  25209. */
  25210. serialize(): any;
  25211. /**
  25212. * Creates a material from parsed material data
  25213. * @param parsedMaterial defines parsed material data
  25214. * @param scene defines the hosting scene
  25215. * @param rootUrl defines the root URL to use to load textures
  25216. * @returns a new material
  25217. */
  25218. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25219. }
  25220. }
  25221. declare module "babylonjs/Materials/multiMaterial" {
  25222. import { Nullable } from "babylonjs/types";
  25223. import { Scene } from "babylonjs/scene";
  25224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25225. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25226. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25227. import { Material } from "babylonjs/Materials/material";
  25228. /**
  25229. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25230. * separate meshes. This can be use to improve performances.
  25231. * @see http://doc.babylonjs.com/how_to/multi_materials
  25232. */
  25233. export class MultiMaterial extends Material {
  25234. private _subMaterials;
  25235. /**
  25236. * Gets or Sets the list of Materials used within the multi material.
  25237. * They need to be ordered according to the submeshes order in the associated mesh
  25238. */
  25239. get subMaterials(): Nullable<Material>[];
  25240. set subMaterials(value: Nullable<Material>[]);
  25241. /**
  25242. * Function used to align with Node.getChildren()
  25243. * @returns the list of Materials used within the multi material
  25244. */
  25245. getChildren(): Nullable<Material>[];
  25246. /**
  25247. * Instantiates a new Multi Material
  25248. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25249. * separate meshes. This can be use to improve performances.
  25250. * @see http://doc.babylonjs.com/how_to/multi_materials
  25251. * @param name Define the name in the scene
  25252. * @param scene Define the scene the material belongs to
  25253. */
  25254. constructor(name: string, scene: Scene);
  25255. private _hookArray;
  25256. /**
  25257. * Get one of the submaterial by its index in the submaterials array
  25258. * @param index The index to look the sub material at
  25259. * @returns The Material if the index has been defined
  25260. */
  25261. getSubMaterial(index: number): Nullable<Material>;
  25262. /**
  25263. * Get the list of active textures for the whole sub materials list.
  25264. * @returns All the textures that will be used during the rendering
  25265. */
  25266. getActiveTextures(): BaseTexture[];
  25267. /**
  25268. * Gets the current class name of the material e.g. "MultiMaterial"
  25269. * Mainly use in serialization.
  25270. * @returns the class name
  25271. */
  25272. getClassName(): string;
  25273. /**
  25274. * Checks if the material is ready to render the requested sub mesh
  25275. * @param mesh Define the mesh the submesh belongs to
  25276. * @param subMesh Define the sub mesh to look readyness for
  25277. * @param useInstances Define whether or not the material is used with instances
  25278. * @returns true if ready, otherwise false
  25279. */
  25280. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25281. /**
  25282. * Clones the current material and its related sub materials
  25283. * @param name Define the name of the newly cloned material
  25284. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25285. * @returns the cloned material
  25286. */
  25287. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25288. /**
  25289. * Serializes the materials into a JSON representation.
  25290. * @returns the JSON representation
  25291. */
  25292. serialize(): any;
  25293. /**
  25294. * Dispose the material and release its associated resources
  25295. * @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)
  25296. * @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)
  25297. * @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)
  25298. */
  25299. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25300. /**
  25301. * Creates a MultiMaterial from parsed MultiMaterial data.
  25302. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25303. * @param scene defines the hosting scene
  25304. * @returns a new MultiMaterial
  25305. */
  25306. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25307. }
  25308. }
  25309. declare module "babylonjs/Meshes/subMesh" {
  25310. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25311. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25312. import { Engine } from "babylonjs/Engines/engine";
  25313. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25314. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25315. import { Effect } from "babylonjs/Materials/effect";
  25316. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25317. import { Plane } from "babylonjs/Maths/math.plane";
  25318. import { Collider } from "babylonjs/Collisions/collider";
  25319. import { Material } from "babylonjs/Materials/material";
  25320. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25322. import { Mesh } from "babylonjs/Meshes/mesh";
  25323. import { Ray } from "babylonjs/Culling/ray";
  25324. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25325. /**
  25326. * Defines a subdivision inside a mesh
  25327. */
  25328. export class SubMesh implements ICullable {
  25329. /** the material index to use */
  25330. materialIndex: number;
  25331. /** vertex index start */
  25332. verticesStart: number;
  25333. /** vertices count */
  25334. verticesCount: number;
  25335. /** index start */
  25336. indexStart: number;
  25337. /** indices count */
  25338. indexCount: number;
  25339. /** @hidden */
  25340. _materialDefines: Nullable<MaterialDefines>;
  25341. /** @hidden */
  25342. _materialEffect: Nullable<Effect>;
  25343. /** @hidden */
  25344. _effectOverride: Nullable<Effect>;
  25345. /**
  25346. * Gets material defines used by the effect associated to the sub mesh
  25347. */
  25348. get materialDefines(): Nullable<MaterialDefines>;
  25349. /**
  25350. * Sets material defines used by the effect associated to the sub mesh
  25351. */
  25352. set materialDefines(defines: Nullable<MaterialDefines>);
  25353. /**
  25354. * Gets associated effect
  25355. */
  25356. get effect(): Nullable<Effect>;
  25357. /**
  25358. * Sets associated effect (effect used to render this submesh)
  25359. * @param effect defines the effect to associate with
  25360. * @param defines defines the set of defines used to compile this effect
  25361. */
  25362. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25363. /** @hidden */
  25364. _linesIndexCount: number;
  25365. private _mesh;
  25366. private _renderingMesh;
  25367. private _boundingInfo;
  25368. private _linesIndexBuffer;
  25369. /** @hidden */
  25370. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25371. /** @hidden */
  25372. _trianglePlanes: Plane[];
  25373. /** @hidden */
  25374. _lastColliderTransformMatrix: Nullable<Matrix>;
  25375. /** @hidden */
  25376. _renderId: number;
  25377. /** @hidden */
  25378. _alphaIndex: number;
  25379. /** @hidden */
  25380. _distanceToCamera: number;
  25381. /** @hidden */
  25382. _id: number;
  25383. private _currentMaterial;
  25384. /**
  25385. * Add a new submesh to a mesh
  25386. * @param materialIndex defines the material index to use
  25387. * @param verticesStart defines vertex index start
  25388. * @param verticesCount defines vertices count
  25389. * @param indexStart defines index start
  25390. * @param indexCount defines indices count
  25391. * @param mesh defines the parent mesh
  25392. * @param renderingMesh defines an optional rendering mesh
  25393. * @param createBoundingBox defines if bounding box should be created for this submesh
  25394. * @returns the new submesh
  25395. */
  25396. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25397. /**
  25398. * Creates a new submesh
  25399. * @param materialIndex defines the material index to use
  25400. * @param verticesStart defines vertex index start
  25401. * @param verticesCount defines vertices count
  25402. * @param indexStart defines index start
  25403. * @param indexCount defines indices count
  25404. * @param mesh defines the parent mesh
  25405. * @param renderingMesh defines an optional rendering mesh
  25406. * @param createBoundingBox defines if bounding box should be created for this submesh
  25407. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25408. */
  25409. constructor(
  25410. /** the material index to use */
  25411. materialIndex: number,
  25412. /** vertex index start */
  25413. verticesStart: number,
  25414. /** vertices count */
  25415. verticesCount: number,
  25416. /** index start */
  25417. indexStart: number,
  25418. /** indices count */
  25419. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25420. /**
  25421. * Returns true if this submesh covers the entire parent mesh
  25422. * @ignorenaming
  25423. */
  25424. get IsGlobal(): boolean;
  25425. /**
  25426. * Returns the submesh BoudingInfo object
  25427. * @returns current bounding info (or mesh's one if the submesh is global)
  25428. */
  25429. getBoundingInfo(): BoundingInfo;
  25430. /**
  25431. * Sets the submesh BoundingInfo
  25432. * @param boundingInfo defines the new bounding info to use
  25433. * @returns the SubMesh
  25434. */
  25435. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25436. /**
  25437. * Returns the mesh of the current submesh
  25438. * @return the parent mesh
  25439. */
  25440. getMesh(): AbstractMesh;
  25441. /**
  25442. * Returns the rendering mesh of the submesh
  25443. * @returns the rendering mesh (could be different from parent mesh)
  25444. */
  25445. getRenderingMesh(): Mesh;
  25446. /**
  25447. * Returns the replacement mesh of the submesh
  25448. * @returns the replacement mesh (could be different from parent mesh)
  25449. */
  25450. getReplacementMesh(): Nullable<AbstractMesh>;
  25451. /**
  25452. * Returns the effective mesh of the submesh
  25453. * @returns the effective mesh (could be different from parent mesh)
  25454. */
  25455. getEffectiveMesh(): AbstractMesh;
  25456. /**
  25457. * Returns the submesh material
  25458. * @returns null or the current material
  25459. */
  25460. getMaterial(): Nullable<Material>;
  25461. private _IsMultiMaterial;
  25462. /**
  25463. * Sets a new updated BoundingInfo object to the submesh
  25464. * @param data defines an optional position array to use to determine the bounding info
  25465. * @returns the SubMesh
  25466. */
  25467. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25468. /** @hidden */
  25469. _checkCollision(collider: Collider): boolean;
  25470. /**
  25471. * Updates the submesh BoundingInfo
  25472. * @param world defines the world matrix to use to update the bounding info
  25473. * @returns the submesh
  25474. */
  25475. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25476. /**
  25477. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25478. * @param frustumPlanes defines the frustum planes
  25479. * @returns true if the submesh is intersecting with the frustum
  25480. */
  25481. isInFrustum(frustumPlanes: Plane[]): boolean;
  25482. /**
  25483. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25484. * @param frustumPlanes defines the frustum planes
  25485. * @returns true if the submesh is inside the frustum
  25486. */
  25487. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25488. /**
  25489. * Renders the submesh
  25490. * @param enableAlphaMode defines if alpha needs to be used
  25491. * @returns the submesh
  25492. */
  25493. render(enableAlphaMode: boolean): SubMesh;
  25494. /**
  25495. * @hidden
  25496. */
  25497. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25498. /**
  25499. * Checks if the submesh intersects with a ray
  25500. * @param ray defines the ray to test
  25501. * @returns true is the passed ray intersects the submesh bounding box
  25502. */
  25503. canIntersects(ray: Ray): boolean;
  25504. /**
  25505. * Intersects current submesh with a ray
  25506. * @param ray defines the ray to test
  25507. * @param positions defines mesh's positions array
  25508. * @param indices defines mesh's indices array
  25509. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25510. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25511. * @returns intersection info or null if no intersection
  25512. */
  25513. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25514. /** @hidden */
  25515. private _intersectLines;
  25516. /** @hidden */
  25517. private _intersectUnIndexedLines;
  25518. /** @hidden */
  25519. private _intersectTriangles;
  25520. /** @hidden */
  25521. private _intersectUnIndexedTriangles;
  25522. /** @hidden */
  25523. _rebuild(): void;
  25524. /**
  25525. * Creates a new submesh from the passed mesh
  25526. * @param newMesh defines the new hosting mesh
  25527. * @param newRenderingMesh defines an optional rendering mesh
  25528. * @returns the new submesh
  25529. */
  25530. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25531. /**
  25532. * Release associated resources
  25533. */
  25534. dispose(): void;
  25535. /**
  25536. * Gets the class name
  25537. * @returns the string "SubMesh".
  25538. */
  25539. getClassName(): string;
  25540. /**
  25541. * Creates a new submesh from indices data
  25542. * @param materialIndex the index of the main mesh material
  25543. * @param startIndex the index where to start the copy in the mesh indices array
  25544. * @param indexCount the number of indices to copy then from the startIndex
  25545. * @param mesh the main mesh to create the submesh from
  25546. * @param renderingMesh the optional rendering mesh
  25547. * @returns a new submesh
  25548. */
  25549. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25550. }
  25551. }
  25552. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25553. /**
  25554. * Class used to represent data loading progression
  25555. */
  25556. export class SceneLoaderFlags {
  25557. private static _ForceFullSceneLoadingForIncremental;
  25558. private static _ShowLoadingScreen;
  25559. private static _CleanBoneMatrixWeights;
  25560. private static _loggingLevel;
  25561. /**
  25562. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25563. */
  25564. static get ForceFullSceneLoadingForIncremental(): boolean;
  25565. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25566. /**
  25567. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25568. */
  25569. static get ShowLoadingScreen(): boolean;
  25570. static set ShowLoadingScreen(value: boolean);
  25571. /**
  25572. * Defines the current logging level (while loading the scene)
  25573. * @ignorenaming
  25574. */
  25575. static get loggingLevel(): number;
  25576. static set loggingLevel(value: number);
  25577. /**
  25578. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25579. */
  25580. static get CleanBoneMatrixWeights(): boolean;
  25581. static set CleanBoneMatrixWeights(value: boolean);
  25582. }
  25583. }
  25584. declare module "babylonjs/Meshes/geometry" {
  25585. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25586. import { Scene } from "babylonjs/scene";
  25587. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25588. import { Engine } from "babylonjs/Engines/engine";
  25589. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25590. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25591. import { Effect } from "babylonjs/Materials/effect";
  25592. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25593. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25594. import { Mesh } from "babylonjs/Meshes/mesh";
  25595. /**
  25596. * Class used to store geometry data (vertex buffers + index buffer)
  25597. */
  25598. export class Geometry implements IGetSetVerticesData {
  25599. /**
  25600. * Gets or sets the ID of the geometry
  25601. */
  25602. id: string;
  25603. /**
  25604. * Gets or sets the unique ID of the geometry
  25605. */
  25606. uniqueId: number;
  25607. /**
  25608. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25609. */
  25610. delayLoadState: number;
  25611. /**
  25612. * Gets the file containing the data to load when running in delay load state
  25613. */
  25614. delayLoadingFile: Nullable<string>;
  25615. /**
  25616. * Callback called when the geometry is updated
  25617. */
  25618. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25619. private _scene;
  25620. private _engine;
  25621. private _meshes;
  25622. private _totalVertices;
  25623. /** @hidden */
  25624. _indices: IndicesArray;
  25625. /** @hidden */
  25626. _vertexBuffers: {
  25627. [key: string]: VertexBuffer;
  25628. };
  25629. private _isDisposed;
  25630. private _extend;
  25631. private _boundingBias;
  25632. /** @hidden */
  25633. _delayInfo: Array<string>;
  25634. private _indexBuffer;
  25635. private _indexBufferIsUpdatable;
  25636. /** @hidden */
  25637. _boundingInfo: Nullable<BoundingInfo>;
  25638. /** @hidden */
  25639. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25640. /** @hidden */
  25641. _softwareSkinningFrameId: number;
  25642. private _vertexArrayObjects;
  25643. private _updatable;
  25644. /** @hidden */
  25645. _positions: Nullable<Vector3[]>;
  25646. /**
  25647. * 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
  25648. */
  25649. get boundingBias(): Vector2;
  25650. /**
  25651. * 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
  25652. */
  25653. set boundingBias(value: Vector2);
  25654. /**
  25655. * Static function used to attach a new empty geometry to a mesh
  25656. * @param mesh defines the mesh to attach the geometry to
  25657. * @returns the new Geometry
  25658. */
  25659. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25660. /** Get the list of meshes using this geometry */
  25661. get meshes(): Mesh[];
  25662. /**
  25663. * Creates a new geometry
  25664. * @param id defines the unique ID
  25665. * @param scene defines the hosting scene
  25666. * @param vertexData defines the VertexData used to get geometry data
  25667. * @param updatable defines if geometry must be updatable (false by default)
  25668. * @param mesh defines the mesh that will be associated with the geometry
  25669. */
  25670. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25671. /**
  25672. * Gets the current extend of the geometry
  25673. */
  25674. get extend(): {
  25675. minimum: Vector3;
  25676. maximum: Vector3;
  25677. };
  25678. /**
  25679. * Gets the hosting scene
  25680. * @returns the hosting Scene
  25681. */
  25682. getScene(): Scene;
  25683. /**
  25684. * Gets the hosting engine
  25685. * @returns the hosting Engine
  25686. */
  25687. getEngine(): Engine;
  25688. /**
  25689. * Defines if the geometry is ready to use
  25690. * @returns true if the geometry is ready to be used
  25691. */
  25692. isReady(): boolean;
  25693. /**
  25694. * Gets a value indicating that the geometry should not be serialized
  25695. */
  25696. get doNotSerialize(): boolean;
  25697. /** @hidden */
  25698. _rebuild(): void;
  25699. /**
  25700. * Affects all geometry data in one call
  25701. * @param vertexData defines the geometry data
  25702. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25703. */
  25704. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25705. /**
  25706. * Set specific vertex data
  25707. * @param kind defines the data kind (Position, normal, etc...)
  25708. * @param data defines the vertex data to use
  25709. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25710. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25711. */
  25712. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25713. /**
  25714. * Removes a specific vertex data
  25715. * @param kind defines the data kind (Position, normal, etc...)
  25716. */
  25717. removeVerticesData(kind: string): void;
  25718. /**
  25719. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25720. * @param buffer defines the vertex buffer to use
  25721. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25722. */
  25723. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25724. /**
  25725. * Update a specific vertex buffer
  25726. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25727. * It will do nothing if the buffer is not updatable
  25728. * @param kind defines the data kind (Position, normal, etc...)
  25729. * @param data defines the data to use
  25730. * @param offset defines the offset in the target buffer where to store the data
  25731. * @param useBytes set to true if the offset is in bytes
  25732. */
  25733. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25734. /**
  25735. * Update a specific vertex buffer
  25736. * This function will create a new buffer if the current one is not updatable
  25737. * @param kind defines the data kind (Position, normal, etc...)
  25738. * @param data defines the data to use
  25739. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25740. */
  25741. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25742. private _updateBoundingInfo;
  25743. /** @hidden */
  25744. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25745. /**
  25746. * Gets total number of vertices
  25747. * @returns the total number of vertices
  25748. */
  25749. getTotalVertices(): number;
  25750. /**
  25751. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25752. * @param kind defines the data kind (Position, normal, etc...)
  25753. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25754. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25755. * @returns a float array containing vertex data
  25756. */
  25757. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25758. /**
  25759. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25760. * @param kind defines the data kind (Position, normal, etc...)
  25761. * @returns true if the vertex buffer with the specified kind is updatable
  25762. */
  25763. isVertexBufferUpdatable(kind: string): boolean;
  25764. /**
  25765. * Gets a specific vertex buffer
  25766. * @param kind defines the data kind (Position, normal, etc...)
  25767. * @returns a VertexBuffer
  25768. */
  25769. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25770. /**
  25771. * Returns all vertex buffers
  25772. * @return an object holding all vertex buffers indexed by kind
  25773. */
  25774. getVertexBuffers(): Nullable<{
  25775. [key: string]: VertexBuffer;
  25776. }>;
  25777. /**
  25778. * Gets a boolean indicating if specific vertex buffer is present
  25779. * @param kind defines the data kind (Position, normal, etc...)
  25780. * @returns true if data is present
  25781. */
  25782. isVerticesDataPresent(kind: string): boolean;
  25783. /**
  25784. * Gets a list of all attached data kinds (Position, normal, etc...)
  25785. * @returns a list of string containing all kinds
  25786. */
  25787. getVerticesDataKinds(): string[];
  25788. /**
  25789. * Update index buffer
  25790. * @param indices defines the indices to store in the index buffer
  25791. * @param offset defines the offset in the target buffer where to store the data
  25792. * @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)
  25793. */
  25794. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25795. /**
  25796. * Creates a new index buffer
  25797. * @param indices defines the indices to store in the index buffer
  25798. * @param totalVertices defines the total number of vertices (could be null)
  25799. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25800. */
  25801. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25802. /**
  25803. * Return the total number of indices
  25804. * @returns the total number of indices
  25805. */
  25806. getTotalIndices(): number;
  25807. /**
  25808. * Gets the index buffer array
  25809. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25810. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25811. * @returns the index buffer array
  25812. */
  25813. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25814. /**
  25815. * Gets the index buffer
  25816. * @return the index buffer
  25817. */
  25818. getIndexBuffer(): Nullable<DataBuffer>;
  25819. /** @hidden */
  25820. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25821. /**
  25822. * Release the associated resources for a specific mesh
  25823. * @param mesh defines the source mesh
  25824. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25825. */
  25826. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25827. /**
  25828. * Apply current geometry to a given mesh
  25829. * @param mesh defines the mesh to apply geometry to
  25830. */
  25831. applyToMesh(mesh: Mesh): void;
  25832. private _updateExtend;
  25833. private _applyToMesh;
  25834. private notifyUpdate;
  25835. /**
  25836. * Load the geometry if it was flagged as delay loaded
  25837. * @param scene defines the hosting scene
  25838. * @param onLoaded defines a callback called when the geometry is loaded
  25839. */
  25840. load(scene: Scene, onLoaded?: () => void): void;
  25841. private _queueLoad;
  25842. /**
  25843. * Invert the geometry to move from a right handed system to a left handed one.
  25844. */
  25845. toLeftHanded(): void;
  25846. /** @hidden */
  25847. _resetPointsArrayCache(): void;
  25848. /** @hidden */
  25849. _generatePointsArray(): boolean;
  25850. /**
  25851. * Gets a value indicating if the geometry is disposed
  25852. * @returns true if the geometry was disposed
  25853. */
  25854. isDisposed(): boolean;
  25855. private _disposeVertexArrayObjects;
  25856. /**
  25857. * Free all associated resources
  25858. */
  25859. dispose(): void;
  25860. /**
  25861. * Clone the current geometry into a new geometry
  25862. * @param id defines the unique ID of the new geometry
  25863. * @returns a new geometry object
  25864. */
  25865. copy(id: string): Geometry;
  25866. /**
  25867. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25868. * @return a JSON representation of the current geometry data (without the vertices data)
  25869. */
  25870. serialize(): any;
  25871. private toNumberArray;
  25872. /**
  25873. * Serialize all vertices data into a JSON oject
  25874. * @returns a JSON representation of the current geometry data
  25875. */
  25876. serializeVerticeData(): any;
  25877. /**
  25878. * Extracts a clone of a mesh geometry
  25879. * @param mesh defines the source mesh
  25880. * @param id defines the unique ID of the new geometry object
  25881. * @returns the new geometry object
  25882. */
  25883. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25884. /**
  25885. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25886. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25887. * Be aware Math.random() could cause collisions, but:
  25888. * "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"
  25889. * @returns a string containing a new GUID
  25890. */
  25891. static RandomId(): string;
  25892. /** @hidden */
  25893. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25894. private static _CleanMatricesWeights;
  25895. /**
  25896. * Create a new geometry from persisted data (Using .babylon file format)
  25897. * @param parsedVertexData defines the persisted data
  25898. * @param scene defines the hosting scene
  25899. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25900. * @returns the new geometry object
  25901. */
  25902. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25903. }
  25904. }
  25905. declare module "babylonjs/Meshes/mesh.vertexData" {
  25906. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25907. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25908. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25909. import { Geometry } from "babylonjs/Meshes/geometry";
  25910. import { Mesh } from "babylonjs/Meshes/mesh";
  25911. /**
  25912. * Define an interface for all classes that will get and set the data on vertices
  25913. */
  25914. export interface IGetSetVerticesData {
  25915. /**
  25916. * Gets a boolean indicating if specific vertex data is present
  25917. * @param kind defines the vertex data kind to use
  25918. * @returns true is data kind is present
  25919. */
  25920. isVerticesDataPresent(kind: string): boolean;
  25921. /**
  25922. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25923. * @param kind defines the data kind (Position, normal, etc...)
  25924. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25925. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25926. * @returns a float array containing vertex data
  25927. */
  25928. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25929. /**
  25930. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25931. * @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.
  25932. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25933. * @returns the indices array or an empty array if the mesh has no geometry
  25934. */
  25935. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25936. /**
  25937. * Set specific vertex data
  25938. * @param kind defines the data kind (Position, normal, etc...)
  25939. * @param data defines the vertex data to use
  25940. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25941. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25942. */
  25943. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25944. /**
  25945. * Update a specific associated vertex buffer
  25946. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25947. * - VertexBuffer.PositionKind
  25948. * - VertexBuffer.UVKind
  25949. * - VertexBuffer.UV2Kind
  25950. * - VertexBuffer.UV3Kind
  25951. * - VertexBuffer.UV4Kind
  25952. * - VertexBuffer.UV5Kind
  25953. * - VertexBuffer.UV6Kind
  25954. * - VertexBuffer.ColorKind
  25955. * - VertexBuffer.MatricesIndicesKind
  25956. * - VertexBuffer.MatricesIndicesExtraKind
  25957. * - VertexBuffer.MatricesWeightsKind
  25958. * - VertexBuffer.MatricesWeightsExtraKind
  25959. * @param data defines the data source
  25960. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25961. * @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)
  25962. */
  25963. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25964. /**
  25965. * Creates a new index buffer
  25966. * @param indices defines the indices to store in the index buffer
  25967. * @param totalVertices defines the total number of vertices (could be null)
  25968. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25969. */
  25970. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25971. }
  25972. /**
  25973. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25974. */
  25975. export class VertexData {
  25976. /**
  25977. * Mesh side orientation : usually the external or front surface
  25978. */
  25979. static readonly FRONTSIDE: number;
  25980. /**
  25981. * Mesh side orientation : usually the internal or back surface
  25982. */
  25983. static readonly BACKSIDE: number;
  25984. /**
  25985. * Mesh side orientation : both internal and external or front and back surfaces
  25986. */
  25987. static readonly DOUBLESIDE: number;
  25988. /**
  25989. * Mesh side orientation : by default, `FRONTSIDE`
  25990. */
  25991. static readonly DEFAULTSIDE: number;
  25992. /**
  25993. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25994. */
  25995. positions: Nullable<FloatArray>;
  25996. /**
  25997. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25998. */
  25999. normals: Nullable<FloatArray>;
  26000. /**
  26001. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26002. */
  26003. tangents: Nullable<FloatArray>;
  26004. /**
  26005. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26006. */
  26007. uvs: Nullable<FloatArray>;
  26008. /**
  26009. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26010. */
  26011. uvs2: Nullable<FloatArray>;
  26012. /**
  26013. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26014. */
  26015. uvs3: Nullable<FloatArray>;
  26016. /**
  26017. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26018. */
  26019. uvs4: Nullable<FloatArray>;
  26020. /**
  26021. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26022. */
  26023. uvs5: Nullable<FloatArray>;
  26024. /**
  26025. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26026. */
  26027. uvs6: Nullable<FloatArray>;
  26028. /**
  26029. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26030. */
  26031. colors: Nullable<FloatArray>;
  26032. /**
  26033. * 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).
  26034. */
  26035. matricesIndices: Nullable<FloatArray>;
  26036. /**
  26037. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26038. */
  26039. matricesWeights: Nullable<FloatArray>;
  26040. /**
  26041. * An array extending the number of possible indices
  26042. */
  26043. matricesIndicesExtra: Nullable<FloatArray>;
  26044. /**
  26045. * An array extending the number of possible weights when the number of indices is extended
  26046. */
  26047. matricesWeightsExtra: Nullable<FloatArray>;
  26048. /**
  26049. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26050. */
  26051. indices: Nullable<IndicesArray>;
  26052. /**
  26053. * Uses the passed data array to set the set the values for the specified kind of data
  26054. * @param data a linear array of floating numbers
  26055. * @param kind the type of data that is being set, eg positions, colors etc
  26056. */
  26057. set(data: FloatArray, kind: string): void;
  26058. /**
  26059. * Associates the vertexData to the passed Mesh.
  26060. * Sets it as updatable or not (default `false`)
  26061. * @param mesh the mesh the vertexData is applied to
  26062. * @param updatable when used and having the value true allows new data to update the vertexData
  26063. * @returns the VertexData
  26064. */
  26065. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26066. /**
  26067. * Associates the vertexData to the passed Geometry.
  26068. * Sets it as updatable or not (default `false`)
  26069. * @param geometry the geometry the vertexData is applied to
  26070. * @param updatable when used and having the value true allows new data to update the vertexData
  26071. * @returns VertexData
  26072. */
  26073. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26074. /**
  26075. * Updates the associated mesh
  26076. * @param mesh the mesh to be updated
  26077. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26078. * @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
  26079. * @returns VertexData
  26080. */
  26081. updateMesh(mesh: Mesh): VertexData;
  26082. /**
  26083. * Updates the associated geometry
  26084. * @param geometry the geometry to be updated
  26085. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26086. * @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
  26087. * @returns VertexData.
  26088. */
  26089. updateGeometry(geometry: Geometry): VertexData;
  26090. private _applyTo;
  26091. private _update;
  26092. /**
  26093. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26094. * @param matrix the transforming matrix
  26095. * @returns the VertexData
  26096. */
  26097. transform(matrix: Matrix): VertexData;
  26098. /**
  26099. * Merges the passed VertexData into the current one
  26100. * @param other the VertexData to be merged into the current one
  26101. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26102. * @returns the modified VertexData
  26103. */
  26104. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26105. private _mergeElement;
  26106. private _validate;
  26107. /**
  26108. * Serializes the VertexData
  26109. * @returns a serialized object
  26110. */
  26111. serialize(): any;
  26112. /**
  26113. * Extracts the vertexData from a mesh
  26114. * @param mesh the mesh from which to extract the VertexData
  26115. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26116. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26117. * @returns the object VertexData associated to the passed mesh
  26118. */
  26119. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26120. /**
  26121. * Extracts the vertexData from the geometry
  26122. * @param geometry the geometry from which to extract the VertexData
  26123. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26124. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26125. * @returns the object VertexData associated to the passed mesh
  26126. */
  26127. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26128. private static _ExtractFrom;
  26129. /**
  26130. * Creates the VertexData for a Ribbon
  26131. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26132. * * pathArray array of paths, each of which an array of successive Vector3
  26133. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26134. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26135. * * 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
  26136. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26137. * * 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)
  26138. * * 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)
  26139. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26140. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26141. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26142. * @returns the VertexData of the ribbon
  26143. */
  26144. static CreateRibbon(options: {
  26145. pathArray: Vector3[][];
  26146. closeArray?: boolean;
  26147. closePath?: boolean;
  26148. offset?: number;
  26149. sideOrientation?: number;
  26150. frontUVs?: Vector4;
  26151. backUVs?: Vector4;
  26152. invertUV?: boolean;
  26153. uvs?: Vector2[];
  26154. colors?: Color4[];
  26155. }): VertexData;
  26156. /**
  26157. * Creates the VertexData for a box
  26158. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26159. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26160. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26161. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26162. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26163. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26164. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26165. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26166. * * 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)
  26167. * * 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)
  26168. * @returns the VertexData of the box
  26169. */
  26170. static CreateBox(options: {
  26171. size?: number;
  26172. width?: number;
  26173. height?: number;
  26174. depth?: number;
  26175. faceUV?: Vector4[];
  26176. faceColors?: Color4[];
  26177. sideOrientation?: number;
  26178. frontUVs?: Vector4;
  26179. backUVs?: Vector4;
  26180. }): VertexData;
  26181. /**
  26182. * Creates the VertexData for a tiled box
  26183. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26184. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26185. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26186. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26187. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26188. * @returns the VertexData of the box
  26189. */
  26190. static CreateTiledBox(options: {
  26191. pattern?: number;
  26192. width?: number;
  26193. height?: number;
  26194. depth?: number;
  26195. tileSize?: number;
  26196. tileWidth?: number;
  26197. tileHeight?: number;
  26198. alignHorizontal?: number;
  26199. alignVertical?: number;
  26200. faceUV?: Vector4[];
  26201. faceColors?: Color4[];
  26202. sideOrientation?: number;
  26203. }): VertexData;
  26204. /**
  26205. * Creates the VertexData for a tiled plane
  26206. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26207. * * pattern a limited pattern arrangement depending on the number
  26208. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26209. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26210. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26211. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26212. * * 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)
  26213. * * 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)
  26214. * @returns the VertexData of the tiled plane
  26215. */
  26216. static CreateTiledPlane(options: {
  26217. pattern?: number;
  26218. tileSize?: number;
  26219. tileWidth?: number;
  26220. tileHeight?: number;
  26221. size?: number;
  26222. width?: number;
  26223. height?: number;
  26224. alignHorizontal?: number;
  26225. alignVertical?: number;
  26226. sideOrientation?: number;
  26227. frontUVs?: Vector4;
  26228. backUVs?: Vector4;
  26229. }): VertexData;
  26230. /**
  26231. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26232. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26233. * * segments sets the number of horizontal strips optional, default 32
  26234. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26235. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26236. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26237. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26238. * * 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
  26239. * * 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
  26240. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26241. * * 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)
  26242. * * 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)
  26243. * @returns the VertexData of the ellipsoid
  26244. */
  26245. static CreateSphere(options: {
  26246. segments?: number;
  26247. diameter?: number;
  26248. diameterX?: number;
  26249. diameterY?: number;
  26250. diameterZ?: number;
  26251. arc?: number;
  26252. slice?: number;
  26253. sideOrientation?: number;
  26254. frontUVs?: Vector4;
  26255. backUVs?: Vector4;
  26256. }): VertexData;
  26257. /**
  26258. * Creates the VertexData for a cylinder, cone or prism
  26259. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26260. * * height sets the height (y direction) of the cylinder, optional, default 2
  26261. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26262. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26263. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26264. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26265. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26266. * * 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
  26267. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26268. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26269. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26270. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26272. * * 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)
  26273. * * 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)
  26274. * @returns the VertexData of the cylinder, cone or prism
  26275. */
  26276. static CreateCylinder(options: {
  26277. height?: number;
  26278. diameterTop?: number;
  26279. diameterBottom?: number;
  26280. diameter?: number;
  26281. tessellation?: number;
  26282. subdivisions?: number;
  26283. arc?: number;
  26284. faceColors?: Color4[];
  26285. faceUV?: Vector4[];
  26286. hasRings?: boolean;
  26287. enclose?: boolean;
  26288. sideOrientation?: number;
  26289. frontUVs?: Vector4;
  26290. backUVs?: Vector4;
  26291. }): VertexData;
  26292. /**
  26293. * Creates the VertexData for a torus
  26294. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26295. * * diameter the diameter of the torus, optional default 1
  26296. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26297. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26298. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26299. * * 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)
  26300. * * 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)
  26301. * @returns the VertexData of the torus
  26302. */
  26303. static CreateTorus(options: {
  26304. diameter?: number;
  26305. thickness?: number;
  26306. tessellation?: number;
  26307. sideOrientation?: number;
  26308. frontUVs?: Vector4;
  26309. backUVs?: Vector4;
  26310. }): VertexData;
  26311. /**
  26312. * Creates the VertexData of the LineSystem
  26313. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26314. * - lines an array of lines, each line being an array of successive Vector3
  26315. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26316. * @returns the VertexData of the LineSystem
  26317. */
  26318. static CreateLineSystem(options: {
  26319. lines: Vector3[][];
  26320. colors?: Nullable<Color4[][]>;
  26321. }): VertexData;
  26322. /**
  26323. * Create the VertexData for a DashedLines
  26324. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26325. * - points an array successive Vector3
  26326. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26327. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26328. * - dashNb the intended total number of dashes, optional, default 200
  26329. * @returns the VertexData for the DashedLines
  26330. */
  26331. static CreateDashedLines(options: {
  26332. points: Vector3[];
  26333. dashSize?: number;
  26334. gapSize?: number;
  26335. dashNb?: number;
  26336. }): VertexData;
  26337. /**
  26338. * Creates the VertexData for a Ground
  26339. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26340. * - width the width (x direction) of the ground, optional, default 1
  26341. * - height the height (z direction) of the ground, optional, default 1
  26342. * - subdivisions the number of subdivisions per side, optional, default 1
  26343. * @returns the VertexData of the Ground
  26344. */
  26345. static CreateGround(options: {
  26346. width?: number;
  26347. height?: number;
  26348. subdivisions?: number;
  26349. subdivisionsX?: number;
  26350. subdivisionsY?: number;
  26351. }): VertexData;
  26352. /**
  26353. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26354. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26355. * * xmin the ground minimum X coordinate, optional, default -1
  26356. * * zmin the ground minimum Z coordinate, optional, default -1
  26357. * * xmax the ground maximum X coordinate, optional, default 1
  26358. * * zmax the ground maximum Z coordinate, optional, default 1
  26359. * * 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}
  26360. * * 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}
  26361. * @returns the VertexData of the TiledGround
  26362. */
  26363. static CreateTiledGround(options: {
  26364. xmin: number;
  26365. zmin: number;
  26366. xmax: number;
  26367. zmax: number;
  26368. subdivisions?: {
  26369. w: number;
  26370. h: number;
  26371. };
  26372. precision?: {
  26373. w: number;
  26374. h: number;
  26375. };
  26376. }): VertexData;
  26377. /**
  26378. * Creates the VertexData of the Ground designed from a heightmap
  26379. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26380. * * width the width (x direction) of the ground
  26381. * * height the height (z direction) of the ground
  26382. * * subdivisions the number of subdivisions per side
  26383. * * minHeight the minimum altitude on the ground, optional, default 0
  26384. * * maxHeight the maximum altitude on the ground, optional default 1
  26385. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26386. * * buffer the array holding the image color data
  26387. * * bufferWidth the width of image
  26388. * * bufferHeight the height of image
  26389. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26390. * @returns the VertexData of the Ground designed from a heightmap
  26391. */
  26392. static CreateGroundFromHeightMap(options: {
  26393. width: number;
  26394. height: number;
  26395. subdivisions: number;
  26396. minHeight: number;
  26397. maxHeight: number;
  26398. colorFilter: Color3;
  26399. buffer: Uint8Array;
  26400. bufferWidth: number;
  26401. bufferHeight: number;
  26402. alphaFilter: number;
  26403. }): VertexData;
  26404. /**
  26405. * Creates the VertexData for a Plane
  26406. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26407. * * size sets the width and height of the plane to the value of size, optional default 1
  26408. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26409. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26410. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26411. * * 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)
  26412. * * 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)
  26413. * @returns the VertexData of the box
  26414. */
  26415. static CreatePlane(options: {
  26416. size?: number;
  26417. width?: number;
  26418. height?: number;
  26419. sideOrientation?: number;
  26420. frontUVs?: Vector4;
  26421. backUVs?: Vector4;
  26422. }): VertexData;
  26423. /**
  26424. * Creates the VertexData of the Disc or regular Polygon
  26425. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26426. * * radius the radius of the disc, optional default 0.5
  26427. * * tessellation the number of polygon sides, optional, default 64
  26428. * * 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
  26429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26430. * * 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)
  26431. * * 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)
  26432. * @returns the VertexData of the box
  26433. */
  26434. static CreateDisc(options: {
  26435. radius?: number;
  26436. tessellation?: number;
  26437. arc?: number;
  26438. sideOrientation?: number;
  26439. frontUVs?: Vector4;
  26440. backUVs?: Vector4;
  26441. }): VertexData;
  26442. /**
  26443. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26444. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26445. * @param polygon a mesh built from polygonTriangulation.build()
  26446. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26447. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26448. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26449. * @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)
  26450. * @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)
  26451. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26452. * @returns the VertexData of the Polygon
  26453. */
  26454. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26455. /**
  26456. * Creates the VertexData of the IcoSphere
  26457. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26458. * * radius the radius of the IcoSphere, optional default 1
  26459. * * radiusX allows stretching in the x direction, optional, default radius
  26460. * * radiusY allows stretching in the y direction, optional, default radius
  26461. * * radiusZ allows stretching in the z direction, optional, default radius
  26462. * * flat when true creates a flat shaded mesh, optional, default true
  26463. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26464. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26465. * * 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)
  26466. * * 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)
  26467. * @returns the VertexData of the IcoSphere
  26468. */
  26469. static CreateIcoSphere(options: {
  26470. radius?: number;
  26471. radiusX?: number;
  26472. radiusY?: number;
  26473. radiusZ?: number;
  26474. flat?: boolean;
  26475. subdivisions?: number;
  26476. sideOrientation?: number;
  26477. frontUVs?: Vector4;
  26478. backUVs?: Vector4;
  26479. }): VertexData;
  26480. /**
  26481. * Creates the VertexData for a Polyhedron
  26482. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26483. * * type provided types are:
  26484. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26485. * * 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)
  26486. * * size the size of the IcoSphere, optional default 1
  26487. * * sizeX allows stretching in the x direction, optional, default size
  26488. * * sizeY allows stretching in the y direction, optional, default size
  26489. * * sizeZ allows stretching in the z direction, optional, default size
  26490. * * 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
  26491. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26492. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26493. * * flat when true creates a flat shaded mesh, optional, default true
  26494. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26495. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26496. * * 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)
  26497. * * 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)
  26498. * @returns the VertexData of the Polyhedron
  26499. */
  26500. static CreatePolyhedron(options: {
  26501. type?: number;
  26502. size?: number;
  26503. sizeX?: number;
  26504. sizeY?: number;
  26505. sizeZ?: number;
  26506. custom?: any;
  26507. faceUV?: Vector4[];
  26508. faceColors?: Color4[];
  26509. flat?: boolean;
  26510. sideOrientation?: number;
  26511. frontUVs?: Vector4;
  26512. backUVs?: Vector4;
  26513. }): VertexData;
  26514. /**
  26515. * Creates the VertexData for a TorusKnot
  26516. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26517. * * radius the radius of the torus knot, optional, default 2
  26518. * * tube the thickness of the tube, optional, default 0.5
  26519. * * radialSegments the number of sides on each tube segments, optional, default 32
  26520. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26521. * * p the number of windings around the z axis, optional, default 2
  26522. * * q the number of windings around the x axis, optional, default 3
  26523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26524. * * 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)
  26525. * * 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)
  26526. * @returns the VertexData of the Torus Knot
  26527. */
  26528. static CreateTorusKnot(options: {
  26529. radius?: number;
  26530. tube?: number;
  26531. radialSegments?: number;
  26532. tubularSegments?: number;
  26533. p?: number;
  26534. q?: number;
  26535. sideOrientation?: number;
  26536. frontUVs?: Vector4;
  26537. backUVs?: Vector4;
  26538. }): VertexData;
  26539. /**
  26540. * Compute normals for given positions and indices
  26541. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26542. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26543. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26544. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26545. * * facetNormals : optional array of facet normals (vector3)
  26546. * * facetPositions : optional array of facet positions (vector3)
  26547. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26548. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26549. * * bInfo : optional bounding info, required for facetPartitioning computation
  26550. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26551. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26552. * * useRightHandedSystem: optional boolean to for right handed system computation
  26553. * * depthSort : optional boolean to enable the facet depth sort computation
  26554. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26555. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26556. */
  26557. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26558. facetNormals?: any;
  26559. facetPositions?: any;
  26560. facetPartitioning?: any;
  26561. ratio?: number;
  26562. bInfo?: any;
  26563. bbSize?: Vector3;
  26564. subDiv?: any;
  26565. useRightHandedSystem?: boolean;
  26566. depthSort?: boolean;
  26567. distanceTo?: Vector3;
  26568. depthSortedFacets?: any;
  26569. }): void;
  26570. /** @hidden */
  26571. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26572. /**
  26573. * Applies VertexData created from the imported parameters to the geometry
  26574. * @param parsedVertexData the parsed data from an imported file
  26575. * @param geometry the geometry to apply the VertexData to
  26576. */
  26577. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26578. }
  26579. }
  26580. declare module "babylonjs/Morph/morphTarget" {
  26581. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26582. import { Observable } from "babylonjs/Misc/observable";
  26583. import { Nullable, FloatArray } from "babylonjs/types";
  26584. import { Scene } from "babylonjs/scene";
  26585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26586. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26587. /**
  26588. * Defines a target to use with MorphTargetManager
  26589. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26590. */
  26591. export class MorphTarget implements IAnimatable {
  26592. /** defines the name of the target */
  26593. name: string;
  26594. /**
  26595. * Gets or sets the list of animations
  26596. */
  26597. animations: import("babylonjs/Animations/animation").Animation[];
  26598. private _scene;
  26599. private _positions;
  26600. private _normals;
  26601. private _tangents;
  26602. private _uvs;
  26603. private _influence;
  26604. private _uniqueId;
  26605. /**
  26606. * Observable raised when the influence changes
  26607. */
  26608. onInfluenceChanged: Observable<boolean>;
  26609. /** @hidden */
  26610. _onDataLayoutChanged: Observable<void>;
  26611. /**
  26612. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26613. */
  26614. get influence(): number;
  26615. set influence(influence: number);
  26616. /**
  26617. * Gets or sets the id of the morph Target
  26618. */
  26619. id: string;
  26620. private _animationPropertiesOverride;
  26621. /**
  26622. * Gets or sets the animation properties override
  26623. */
  26624. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26625. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26626. /**
  26627. * Creates a new MorphTarget
  26628. * @param name defines the name of the target
  26629. * @param influence defines the influence to use
  26630. * @param scene defines the scene the morphtarget belongs to
  26631. */
  26632. constructor(
  26633. /** defines the name of the target */
  26634. name: string, influence?: number, scene?: Nullable<Scene>);
  26635. /**
  26636. * Gets the unique ID of this manager
  26637. */
  26638. get uniqueId(): number;
  26639. /**
  26640. * Gets a boolean defining if the target contains position data
  26641. */
  26642. get hasPositions(): boolean;
  26643. /**
  26644. * Gets a boolean defining if the target contains normal data
  26645. */
  26646. get hasNormals(): boolean;
  26647. /**
  26648. * Gets a boolean defining if the target contains tangent data
  26649. */
  26650. get hasTangents(): boolean;
  26651. /**
  26652. * Gets a boolean defining if the target contains texture coordinates data
  26653. */
  26654. get hasUVs(): boolean;
  26655. /**
  26656. * Affects position data to this target
  26657. * @param data defines the position data to use
  26658. */
  26659. setPositions(data: Nullable<FloatArray>): void;
  26660. /**
  26661. * Gets the position data stored in this target
  26662. * @returns a FloatArray containing the position data (or null if not present)
  26663. */
  26664. getPositions(): Nullable<FloatArray>;
  26665. /**
  26666. * Affects normal data to this target
  26667. * @param data defines the normal data to use
  26668. */
  26669. setNormals(data: Nullable<FloatArray>): void;
  26670. /**
  26671. * Gets the normal data stored in this target
  26672. * @returns a FloatArray containing the normal data (or null if not present)
  26673. */
  26674. getNormals(): Nullable<FloatArray>;
  26675. /**
  26676. * Affects tangent data to this target
  26677. * @param data defines the tangent data to use
  26678. */
  26679. setTangents(data: Nullable<FloatArray>): void;
  26680. /**
  26681. * Gets the tangent data stored in this target
  26682. * @returns a FloatArray containing the tangent data (or null if not present)
  26683. */
  26684. getTangents(): Nullable<FloatArray>;
  26685. /**
  26686. * Affects texture coordinates data to this target
  26687. * @param data defines the texture coordinates data to use
  26688. */
  26689. setUVs(data: Nullable<FloatArray>): void;
  26690. /**
  26691. * Gets the texture coordinates data stored in this target
  26692. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26693. */
  26694. getUVs(): Nullable<FloatArray>;
  26695. /**
  26696. * Clone the current target
  26697. * @returns a new MorphTarget
  26698. */
  26699. clone(): MorphTarget;
  26700. /**
  26701. * Serializes the current target into a Serialization object
  26702. * @returns the serialized object
  26703. */
  26704. serialize(): any;
  26705. /**
  26706. * Returns the string "MorphTarget"
  26707. * @returns "MorphTarget"
  26708. */
  26709. getClassName(): string;
  26710. /**
  26711. * Creates a new target from serialized data
  26712. * @param serializationObject defines the serialized data to use
  26713. * @returns a new MorphTarget
  26714. */
  26715. static Parse(serializationObject: any): MorphTarget;
  26716. /**
  26717. * Creates a MorphTarget from mesh data
  26718. * @param mesh defines the source mesh
  26719. * @param name defines the name to use for the new target
  26720. * @param influence defines the influence to attach to the target
  26721. * @returns a new MorphTarget
  26722. */
  26723. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26724. }
  26725. }
  26726. declare module "babylonjs/Morph/morphTargetManager" {
  26727. import { Nullable } from "babylonjs/types";
  26728. import { Scene } from "babylonjs/scene";
  26729. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26730. /**
  26731. * This class is used to deform meshes using morphing between different targets
  26732. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26733. */
  26734. export class MorphTargetManager {
  26735. private _targets;
  26736. private _targetInfluenceChangedObservers;
  26737. private _targetDataLayoutChangedObservers;
  26738. private _activeTargets;
  26739. private _scene;
  26740. private _influences;
  26741. private _supportsNormals;
  26742. private _supportsTangents;
  26743. private _supportsUVs;
  26744. private _vertexCount;
  26745. private _uniqueId;
  26746. private _tempInfluences;
  26747. /**
  26748. * Gets or sets a boolean indicating if normals must be morphed
  26749. */
  26750. enableNormalMorphing: boolean;
  26751. /**
  26752. * Gets or sets a boolean indicating if tangents must be morphed
  26753. */
  26754. enableTangentMorphing: boolean;
  26755. /**
  26756. * Gets or sets a boolean indicating if UV must be morphed
  26757. */
  26758. enableUVMorphing: boolean;
  26759. /**
  26760. * Creates a new MorphTargetManager
  26761. * @param scene defines the current scene
  26762. */
  26763. constructor(scene?: Nullable<Scene>);
  26764. /**
  26765. * Gets the unique ID of this manager
  26766. */
  26767. get uniqueId(): number;
  26768. /**
  26769. * Gets the number of vertices handled by this manager
  26770. */
  26771. get vertexCount(): number;
  26772. /**
  26773. * Gets a boolean indicating if this manager supports morphing of normals
  26774. */
  26775. get supportsNormals(): boolean;
  26776. /**
  26777. * Gets a boolean indicating if this manager supports morphing of tangents
  26778. */
  26779. get supportsTangents(): boolean;
  26780. /**
  26781. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26782. */
  26783. get supportsUVs(): boolean;
  26784. /**
  26785. * Gets the number of targets stored in this manager
  26786. */
  26787. get numTargets(): number;
  26788. /**
  26789. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26790. */
  26791. get numInfluencers(): number;
  26792. /**
  26793. * Gets the list of influences (one per target)
  26794. */
  26795. get influences(): Float32Array;
  26796. /**
  26797. * Gets the active target at specified index. An active target is a target with an influence > 0
  26798. * @param index defines the index to check
  26799. * @returns the requested target
  26800. */
  26801. getActiveTarget(index: number): MorphTarget;
  26802. /**
  26803. * Gets the target at specified index
  26804. * @param index defines the index to check
  26805. * @returns the requested target
  26806. */
  26807. getTarget(index: number): MorphTarget;
  26808. /**
  26809. * Add a new target to this manager
  26810. * @param target defines the target to add
  26811. */
  26812. addTarget(target: MorphTarget): void;
  26813. /**
  26814. * Removes a target from the manager
  26815. * @param target defines the target to remove
  26816. */
  26817. removeTarget(target: MorphTarget): void;
  26818. /**
  26819. * Clone the current manager
  26820. * @returns a new MorphTargetManager
  26821. */
  26822. clone(): MorphTargetManager;
  26823. /**
  26824. * Serializes the current manager into a Serialization object
  26825. * @returns the serialized object
  26826. */
  26827. serialize(): any;
  26828. private _syncActiveTargets;
  26829. /**
  26830. * Syncrhonize the targets with all the meshes using this morph target manager
  26831. */
  26832. synchronize(): void;
  26833. /**
  26834. * Creates a new MorphTargetManager from serialized data
  26835. * @param serializationObject defines the serialized data
  26836. * @param scene defines the hosting scene
  26837. * @returns the new MorphTargetManager
  26838. */
  26839. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26840. }
  26841. }
  26842. declare module "babylonjs/Meshes/meshLODLevel" {
  26843. import { Mesh } from "babylonjs/Meshes/mesh";
  26844. import { Nullable } from "babylonjs/types";
  26845. /**
  26846. * Class used to represent a specific level of detail of a mesh
  26847. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26848. */
  26849. export class MeshLODLevel {
  26850. /** Defines the distance where this level should start being displayed */
  26851. distance: number;
  26852. /** Defines the mesh to use to render this level */
  26853. mesh: Nullable<Mesh>;
  26854. /**
  26855. * Creates a new LOD level
  26856. * @param distance defines the distance where this level should star being displayed
  26857. * @param mesh defines the mesh to use to render this level
  26858. */
  26859. constructor(
  26860. /** Defines the distance where this level should start being displayed */
  26861. distance: number,
  26862. /** Defines the mesh to use to render this level */
  26863. mesh: Nullable<Mesh>);
  26864. }
  26865. }
  26866. declare module "babylonjs/Meshes/groundMesh" {
  26867. import { Scene } from "babylonjs/scene";
  26868. import { Vector3 } from "babylonjs/Maths/math.vector";
  26869. import { Mesh } from "babylonjs/Meshes/mesh";
  26870. /**
  26871. * Mesh representing the gorund
  26872. */
  26873. export class GroundMesh extends Mesh {
  26874. /** If octree should be generated */
  26875. generateOctree: boolean;
  26876. private _heightQuads;
  26877. /** @hidden */
  26878. _subdivisionsX: number;
  26879. /** @hidden */
  26880. _subdivisionsY: number;
  26881. /** @hidden */
  26882. _width: number;
  26883. /** @hidden */
  26884. _height: number;
  26885. /** @hidden */
  26886. _minX: number;
  26887. /** @hidden */
  26888. _maxX: number;
  26889. /** @hidden */
  26890. _minZ: number;
  26891. /** @hidden */
  26892. _maxZ: number;
  26893. constructor(name: string, scene: Scene);
  26894. /**
  26895. * "GroundMesh"
  26896. * @returns "GroundMesh"
  26897. */
  26898. getClassName(): string;
  26899. /**
  26900. * The minimum of x and y subdivisions
  26901. */
  26902. get subdivisions(): number;
  26903. /**
  26904. * X subdivisions
  26905. */
  26906. get subdivisionsX(): number;
  26907. /**
  26908. * Y subdivisions
  26909. */
  26910. get subdivisionsY(): number;
  26911. /**
  26912. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26913. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26914. * @param chunksCount the number of subdivisions for x and y
  26915. * @param octreeBlocksSize (Default: 32)
  26916. */
  26917. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26918. /**
  26919. * Returns a height (y) value in the Worl system :
  26920. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26921. * @param x x coordinate
  26922. * @param z z coordinate
  26923. * @returns the ground y position if (x, z) are outside the ground surface.
  26924. */
  26925. getHeightAtCoordinates(x: number, z: number): number;
  26926. /**
  26927. * Returns a normalized vector (Vector3) orthogonal to the ground
  26928. * at the ground coordinates (x, z) expressed in the World system.
  26929. * @param x x coordinate
  26930. * @param z z coordinate
  26931. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26932. */
  26933. getNormalAtCoordinates(x: number, z: number): Vector3;
  26934. /**
  26935. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26936. * at the ground coordinates (x, z) expressed in the World system.
  26937. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26938. * @param x x coordinate
  26939. * @param z z coordinate
  26940. * @param ref vector to store the result
  26941. * @returns the GroundMesh.
  26942. */
  26943. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26944. /**
  26945. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26946. * if the ground has been updated.
  26947. * This can be used in the render loop.
  26948. * @returns the GroundMesh.
  26949. */
  26950. updateCoordinateHeights(): GroundMesh;
  26951. private _getFacetAt;
  26952. private _initHeightQuads;
  26953. private _computeHeightQuads;
  26954. /**
  26955. * Serializes this ground mesh
  26956. * @param serializationObject object to write serialization to
  26957. */
  26958. serialize(serializationObject: any): void;
  26959. /**
  26960. * Parses a serialized ground mesh
  26961. * @param parsedMesh the serialized mesh
  26962. * @param scene the scene to create the ground mesh in
  26963. * @returns the created ground mesh
  26964. */
  26965. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26966. }
  26967. }
  26968. declare module "babylonjs/Physics/physicsJoint" {
  26969. import { Vector3 } from "babylonjs/Maths/math.vector";
  26970. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26971. /**
  26972. * Interface for Physics-Joint data
  26973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26974. */
  26975. export interface PhysicsJointData {
  26976. /**
  26977. * The main pivot of the joint
  26978. */
  26979. mainPivot?: Vector3;
  26980. /**
  26981. * The connected pivot of the joint
  26982. */
  26983. connectedPivot?: Vector3;
  26984. /**
  26985. * The main axis of the joint
  26986. */
  26987. mainAxis?: Vector3;
  26988. /**
  26989. * The connected axis of the joint
  26990. */
  26991. connectedAxis?: Vector3;
  26992. /**
  26993. * The collision of the joint
  26994. */
  26995. collision?: boolean;
  26996. /**
  26997. * Native Oimo/Cannon/Energy data
  26998. */
  26999. nativeParams?: any;
  27000. }
  27001. /**
  27002. * This is a holder class for the physics joint created by the physics plugin
  27003. * It holds a set of functions to control the underlying joint
  27004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27005. */
  27006. export class PhysicsJoint {
  27007. /**
  27008. * The type of the physics joint
  27009. */
  27010. type: number;
  27011. /**
  27012. * The data for the physics joint
  27013. */
  27014. jointData: PhysicsJointData;
  27015. private _physicsJoint;
  27016. protected _physicsPlugin: IPhysicsEnginePlugin;
  27017. /**
  27018. * Initializes the physics joint
  27019. * @param type The type of the physics joint
  27020. * @param jointData The data for the physics joint
  27021. */
  27022. constructor(
  27023. /**
  27024. * The type of the physics joint
  27025. */
  27026. type: number,
  27027. /**
  27028. * The data for the physics joint
  27029. */
  27030. jointData: PhysicsJointData);
  27031. /**
  27032. * Gets the physics joint
  27033. */
  27034. get physicsJoint(): any;
  27035. /**
  27036. * Sets the physics joint
  27037. */
  27038. set physicsJoint(newJoint: any);
  27039. /**
  27040. * Sets the physics plugin
  27041. */
  27042. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27043. /**
  27044. * Execute a function that is physics-plugin specific.
  27045. * @param {Function} func the function that will be executed.
  27046. * It accepts two parameters: the physics world and the physics joint
  27047. */
  27048. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27049. /**
  27050. * Distance-Joint type
  27051. */
  27052. static DistanceJoint: number;
  27053. /**
  27054. * Hinge-Joint type
  27055. */
  27056. static HingeJoint: number;
  27057. /**
  27058. * Ball-and-Socket joint type
  27059. */
  27060. static BallAndSocketJoint: number;
  27061. /**
  27062. * Wheel-Joint type
  27063. */
  27064. static WheelJoint: number;
  27065. /**
  27066. * Slider-Joint type
  27067. */
  27068. static SliderJoint: number;
  27069. /**
  27070. * Prismatic-Joint type
  27071. */
  27072. static PrismaticJoint: number;
  27073. /**
  27074. * Universal-Joint type
  27075. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27076. */
  27077. static UniversalJoint: number;
  27078. /**
  27079. * Hinge-Joint 2 type
  27080. */
  27081. static Hinge2Joint: number;
  27082. /**
  27083. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27084. */
  27085. static PointToPointJoint: number;
  27086. /**
  27087. * Spring-Joint type
  27088. */
  27089. static SpringJoint: number;
  27090. /**
  27091. * Lock-Joint type
  27092. */
  27093. static LockJoint: number;
  27094. }
  27095. /**
  27096. * A class representing a physics distance joint
  27097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27098. */
  27099. export class DistanceJoint extends PhysicsJoint {
  27100. /**
  27101. *
  27102. * @param jointData The data for the Distance-Joint
  27103. */
  27104. constructor(jointData: DistanceJointData);
  27105. /**
  27106. * Update the predefined distance.
  27107. * @param maxDistance The maximum preferred distance
  27108. * @param minDistance The minimum preferred distance
  27109. */
  27110. updateDistance(maxDistance: number, minDistance?: number): void;
  27111. }
  27112. /**
  27113. * Represents a Motor-Enabled Joint
  27114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27115. */
  27116. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27117. /**
  27118. * Initializes the Motor-Enabled Joint
  27119. * @param type The type of the joint
  27120. * @param jointData The physica joint data for the joint
  27121. */
  27122. constructor(type: number, jointData: PhysicsJointData);
  27123. /**
  27124. * Set the motor values.
  27125. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27126. * @param force the force to apply
  27127. * @param maxForce max force for this motor.
  27128. */
  27129. setMotor(force?: number, maxForce?: number): void;
  27130. /**
  27131. * Set the motor's limits.
  27132. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27133. * @param upperLimit The upper limit of the motor
  27134. * @param lowerLimit The lower limit of the motor
  27135. */
  27136. setLimit(upperLimit: number, lowerLimit?: number): void;
  27137. }
  27138. /**
  27139. * This class represents a single physics Hinge-Joint
  27140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27141. */
  27142. export class HingeJoint extends MotorEnabledJoint {
  27143. /**
  27144. * Initializes the Hinge-Joint
  27145. * @param jointData The joint data for the Hinge-Joint
  27146. */
  27147. constructor(jointData: PhysicsJointData);
  27148. /**
  27149. * Set the motor values.
  27150. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27151. * @param {number} force the force to apply
  27152. * @param {number} maxForce max force for this motor.
  27153. */
  27154. setMotor(force?: number, maxForce?: number): void;
  27155. /**
  27156. * Set the motor's limits.
  27157. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27158. * @param upperLimit The upper limit of the motor
  27159. * @param lowerLimit The lower limit of the motor
  27160. */
  27161. setLimit(upperLimit: number, lowerLimit?: number): void;
  27162. }
  27163. /**
  27164. * This class represents a dual hinge physics joint (same as wheel joint)
  27165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27166. */
  27167. export class Hinge2Joint extends MotorEnabledJoint {
  27168. /**
  27169. * Initializes the Hinge2-Joint
  27170. * @param jointData The joint data for the Hinge2-Joint
  27171. */
  27172. constructor(jointData: PhysicsJointData);
  27173. /**
  27174. * Set the motor values.
  27175. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27176. * @param {number} targetSpeed the speed the motor is to reach
  27177. * @param {number} maxForce max force for this motor.
  27178. * @param {motorIndex} the motor's index, 0 or 1.
  27179. */
  27180. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27181. /**
  27182. * Set the motor limits.
  27183. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27184. * @param {number} upperLimit the upper limit
  27185. * @param {number} lowerLimit lower limit
  27186. * @param {motorIndex} the motor's index, 0 or 1.
  27187. */
  27188. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27189. }
  27190. /**
  27191. * Interface for a motor enabled joint
  27192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27193. */
  27194. export interface IMotorEnabledJoint {
  27195. /**
  27196. * Physics joint
  27197. */
  27198. physicsJoint: any;
  27199. /**
  27200. * Sets the motor of the motor-enabled joint
  27201. * @param force The force of the motor
  27202. * @param maxForce The maximum force of the motor
  27203. * @param motorIndex The index of the motor
  27204. */
  27205. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27206. /**
  27207. * Sets the limit of the motor
  27208. * @param upperLimit The upper limit of the motor
  27209. * @param lowerLimit The lower limit of the motor
  27210. * @param motorIndex The index of the motor
  27211. */
  27212. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27213. }
  27214. /**
  27215. * Joint data for a Distance-Joint
  27216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27217. */
  27218. export interface DistanceJointData extends PhysicsJointData {
  27219. /**
  27220. * Max distance the 2 joint objects can be apart
  27221. */
  27222. maxDistance: number;
  27223. }
  27224. /**
  27225. * Joint data from a spring joint
  27226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27227. */
  27228. export interface SpringJointData extends PhysicsJointData {
  27229. /**
  27230. * Length of the spring
  27231. */
  27232. length: number;
  27233. /**
  27234. * Stiffness of the spring
  27235. */
  27236. stiffness: number;
  27237. /**
  27238. * Damping of the spring
  27239. */
  27240. damping: number;
  27241. /** this callback will be called when applying the force to the impostors. */
  27242. forceApplicationCallback: () => void;
  27243. }
  27244. }
  27245. declare module "babylonjs/Physics/physicsRaycastResult" {
  27246. import { Vector3 } from "babylonjs/Maths/math.vector";
  27247. /**
  27248. * Holds the data for the raycast result
  27249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27250. */
  27251. export class PhysicsRaycastResult {
  27252. private _hasHit;
  27253. private _hitDistance;
  27254. private _hitNormalWorld;
  27255. private _hitPointWorld;
  27256. private _rayFromWorld;
  27257. private _rayToWorld;
  27258. /**
  27259. * Gets if there was a hit
  27260. */
  27261. get hasHit(): boolean;
  27262. /**
  27263. * Gets the distance from the hit
  27264. */
  27265. get hitDistance(): number;
  27266. /**
  27267. * Gets the hit normal/direction in the world
  27268. */
  27269. get hitNormalWorld(): Vector3;
  27270. /**
  27271. * Gets the hit point in the world
  27272. */
  27273. get hitPointWorld(): Vector3;
  27274. /**
  27275. * Gets the ray "start point" of the ray in the world
  27276. */
  27277. get rayFromWorld(): Vector3;
  27278. /**
  27279. * Gets the ray "end point" of the ray in the world
  27280. */
  27281. get rayToWorld(): Vector3;
  27282. /**
  27283. * Sets the hit data (normal & point in world space)
  27284. * @param hitNormalWorld defines the normal in world space
  27285. * @param hitPointWorld defines the point in world space
  27286. */
  27287. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27288. /**
  27289. * Sets the distance from the start point to the hit point
  27290. * @param distance
  27291. */
  27292. setHitDistance(distance: number): void;
  27293. /**
  27294. * Calculates the distance manually
  27295. */
  27296. calculateHitDistance(): void;
  27297. /**
  27298. * Resets all the values to default
  27299. * @param from The from point on world space
  27300. * @param to The to point on world space
  27301. */
  27302. reset(from?: Vector3, to?: Vector3): void;
  27303. }
  27304. /**
  27305. * Interface for the size containing width and height
  27306. */
  27307. interface IXYZ {
  27308. /**
  27309. * X
  27310. */
  27311. x: number;
  27312. /**
  27313. * Y
  27314. */
  27315. y: number;
  27316. /**
  27317. * Z
  27318. */
  27319. z: number;
  27320. }
  27321. }
  27322. declare module "babylonjs/Physics/IPhysicsEngine" {
  27323. import { Nullable } from "babylonjs/types";
  27324. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27326. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27327. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27328. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27329. /**
  27330. * Interface used to describe a physics joint
  27331. */
  27332. export interface PhysicsImpostorJoint {
  27333. /** Defines the main impostor to which the joint is linked */
  27334. mainImpostor: PhysicsImpostor;
  27335. /** Defines the impostor that is connected to the main impostor using this joint */
  27336. connectedImpostor: PhysicsImpostor;
  27337. /** Defines the joint itself */
  27338. joint: PhysicsJoint;
  27339. }
  27340. /** @hidden */
  27341. export interface IPhysicsEnginePlugin {
  27342. world: any;
  27343. name: string;
  27344. setGravity(gravity: Vector3): void;
  27345. setTimeStep(timeStep: number): void;
  27346. getTimeStep(): number;
  27347. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27348. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27349. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27350. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27351. removePhysicsBody(impostor: PhysicsImpostor): void;
  27352. generateJoint(joint: PhysicsImpostorJoint): void;
  27353. removeJoint(joint: PhysicsImpostorJoint): void;
  27354. isSupported(): boolean;
  27355. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27356. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27357. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27358. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27359. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27360. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27361. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27362. getBodyMass(impostor: PhysicsImpostor): number;
  27363. getBodyFriction(impostor: PhysicsImpostor): number;
  27364. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27365. getBodyRestitution(impostor: PhysicsImpostor): number;
  27366. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27367. getBodyPressure?(impostor: PhysicsImpostor): number;
  27368. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27369. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27370. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27371. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27372. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27373. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27374. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27375. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27376. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27377. sleepBody(impostor: PhysicsImpostor): void;
  27378. wakeUpBody(impostor: PhysicsImpostor): void;
  27379. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27380. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27381. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27382. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27383. getRadius(impostor: PhysicsImpostor): number;
  27384. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27385. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27386. dispose(): void;
  27387. }
  27388. /**
  27389. * Interface used to define a physics engine
  27390. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27391. */
  27392. export interface IPhysicsEngine {
  27393. /**
  27394. * Gets the gravity vector used by the simulation
  27395. */
  27396. gravity: Vector3;
  27397. /**
  27398. * Sets the gravity vector used by the simulation
  27399. * @param gravity defines the gravity vector to use
  27400. */
  27401. setGravity(gravity: Vector3): void;
  27402. /**
  27403. * Set the time step of the physics engine.
  27404. * Default is 1/60.
  27405. * To slow it down, enter 1/600 for example.
  27406. * To speed it up, 1/30
  27407. * @param newTimeStep the new timestep to apply to this world.
  27408. */
  27409. setTimeStep(newTimeStep: number): void;
  27410. /**
  27411. * Get the time step of the physics engine.
  27412. * @returns the current time step
  27413. */
  27414. getTimeStep(): number;
  27415. /**
  27416. * Set the sub time step of the physics engine.
  27417. * Default is 0 meaning there is no sub steps
  27418. * To increase physics resolution precision, set a small value (like 1 ms)
  27419. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27420. */
  27421. setSubTimeStep(subTimeStep: number): void;
  27422. /**
  27423. * Get the sub time step of the physics engine.
  27424. * @returns the current sub time step
  27425. */
  27426. getSubTimeStep(): number;
  27427. /**
  27428. * Release all resources
  27429. */
  27430. dispose(): void;
  27431. /**
  27432. * Gets the name of the current physics plugin
  27433. * @returns the name of the plugin
  27434. */
  27435. getPhysicsPluginName(): string;
  27436. /**
  27437. * Adding a new impostor for the impostor tracking.
  27438. * This will be done by the impostor itself.
  27439. * @param impostor the impostor to add
  27440. */
  27441. addImpostor(impostor: PhysicsImpostor): void;
  27442. /**
  27443. * Remove an impostor from the engine.
  27444. * This impostor and its mesh will not longer be updated by the physics engine.
  27445. * @param impostor the impostor to remove
  27446. */
  27447. removeImpostor(impostor: PhysicsImpostor): void;
  27448. /**
  27449. * Add a joint to the physics engine
  27450. * @param mainImpostor defines the main impostor to which the joint is added.
  27451. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27452. * @param joint defines the joint that will connect both impostors.
  27453. */
  27454. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27455. /**
  27456. * Removes a joint from the simulation
  27457. * @param mainImpostor defines the impostor used with the joint
  27458. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27459. * @param joint defines the joint to remove
  27460. */
  27461. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27462. /**
  27463. * Gets the current plugin used to run the simulation
  27464. * @returns current plugin
  27465. */
  27466. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27467. /**
  27468. * Gets the list of physic impostors
  27469. * @returns an array of PhysicsImpostor
  27470. */
  27471. getImpostors(): Array<PhysicsImpostor>;
  27472. /**
  27473. * Gets the impostor for a physics enabled object
  27474. * @param object defines the object impersonated by the impostor
  27475. * @returns the PhysicsImpostor or null if not found
  27476. */
  27477. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27478. /**
  27479. * Gets the impostor for a physics body object
  27480. * @param body defines physics body used by the impostor
  27481. * @returns the PhysicsImpostor or null if not found
  27482. */
  27483. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27484. /**
  27485. * Does a raycast in the physics world
  27486. * @param from when should the ray start?
  27487. * @param to when should the ray end?
  27488. * @returns PhysicsRaycastResult
  27489. */
  27490. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27491. /**
  27492. * Called by the scene. No need to call it.
  27493. * @param delta defines the timespam between frames
  27494. */
  27495. _step(delta: number): void;
  27496. }
  27497. }
  27498. declare module "babylonjs/Physics/physicsImpostor" {
  27499. import { Nullable, IndicesArray } from "babylonjs/types";
  27500. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27501. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27503. import { Scene } from "babylonjs/scene";
  27504. import { Bone } from "babylonjs/Bones/bone";
  27505. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27506. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27507. import { Space } from "babylonjs/Maths/math.axis";
  27508. /**
  27509. * The interface for the physics imposter parameters
  27510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27511. */
  27512. export interface PhysicsImpostorParameters {
  27513. /**
  27514. * The mass of the physics imposter
  27515. */
  27516. mass: number;
  27517. /**
  27518. * The friction of the physics imposter
  27519. */
  27520. friction?: number;
  27521. /**
  27522. * The coefficient of restitution of the physics imposter
  27523. */
  27524. restitution?: number;
  27525. /**
  27526. * The native options of the physics imposter
  27527. */
  27528. nativeOptions?: any;
  27529. /**
  27530. * Specifies if the parent should be ignored
  27531. */
  27532. ignoreParent?: boolean;
  27533. /**
  27534. * Specifies if bi-directional transformations should be disabled
  27535. */
  27536. disableBidirectionalTransformation?: boolean;
  27537. /**
  27538. * The pressure inside the physics imposter, soft object only
  27539. */
  27540. pressure?: number;
  27541. /**
  27542. * The stiffness the physics imposter, soft object only
  27543. */
  27544. stiffness?: number;
  27545. /**
  27546. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27547. */
  27548. velocityIterations?: number;
  27549. /**
  27550. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27551. */
  27552. positionIterations?: number;
  27553. /**
  27554. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27555. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27556. * Add to fix multiple points
  27557. */
  27558. fixedPoints?: number;
  27559. /**
  27560. * The collision margin around a soft object
  27561. */
  27562. margin?: number;
  27563. /**
  27564. * The collision margin around a soft object
  27565. */
  27566. damping?: number;
  27567. /**
  27568. * The path for a rope based on an extrusion
  27569. */
  27570. path?: any;
  27571. /**
  27572. * The shape of an extrusion used for a rope based on an extrusion
  27573. */
  27574. shape?: any;
  27575. }
  27576. /**
  27577. * Interface for a physics-enabled object
  27578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27579. */
  27580. export interface IPhysicsEnabledObject {
  27581. /**
  27582. * The position of the physics-enabled object
  27583. */
  27584. position: Vector3;
  27585. /**
  27586. * The rotation of the physics-enabled object
  27587. */
  27588. rotationQuaternion: Nullable<Quaternion>;
  27589. /**
  27590. * The scale of the physics-enabled object
  27591. */
  27592. scaling: Vector3;
  27593. /**
  27594. * The rotation of the physics-enabled object
  27595. */
  27596. rotation?: Vector3;
  27597. /**
  27598. * The parent of the physics-enabled object
  27599. */
  27600. parent?: any;
  27601. /**
  27602. * The bounding info of the physics-enabled object
  27603. * @returns The bounding info of the physics-enabled object
  27604. */
  27605. getBoundingInfo(): BoundingInfo;
  27606. /**
  27607. * Computes the world matrix
  27608. * @param force Specifies if the world matrix should be computed by force
  27609. * @returns A world matrix
  27610. */
  27611. computeWorldMatrix(force: boolean): Matrix;
  27612. /**
  27613. * Gets the world matrix
  27614. * @returns A world matrix
  27615. */
  27616. getWorldMatrix?(): Matrix;
  27617. /**
  27618. * Gets the child meshes
  27619. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27620. * @returns An array of abstract meshes
  27621. */
  27622. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27623. /**
  27624. * Gets the vertex data
  27625. * @param kind The type of vertex data
  27626. * @returns A nullable array of numbers, or a float32 array
  27627. */
  27628. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27629. /**
  27630. * Gets the indices from the mesh
  27631. * @returns A nullable array of index arrays
  27632. */
  27633. getIndices?(): Nullable<IndicesArray>;
  27634. /**
  27635. * Gets the scene from the mesh
  27636. * @returns the indices array or null
  27637. */
  27638. getScene?(): Scene;
  27639. /**
  27640. * Gets the absolute position from the mesh
  27641. * @returns the absolute position
  27642. */
  27643. getAbsolutePosition(): Vector3;
  27644. /**
  27645. * Gets the absolute pivot point from the mesh
  27646. * @returns the absolute pivot point
  27647. */
  27648. getAbsolutePivotPoint(): Vector3;
  27649. /**
  27650. * Rotates the mesh
  27651. * @param axis The axis of rotation
  27652. * @param amount The amount of rotation
  27653. * @param space The space of the rotation
  27654. * @returns The rotation transform node
  27655. */
  27656. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27657. /**
  27658. * Translates the mesh
  27659. * @param axis The axis of translation
  27660. * @param distance The distance of translation
  27661. * @param space The space of the translation
  27662. * @returns The transform node
  27663. */
  27664. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27665. /**
  27666. * Sets the absolute position of the mesh
  27667. * @param absolutePosition The absolute position of the mesh
  27668. * @returns The transform node
  27669. */
  27670. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27671. /**
  27672. * Gets the class name of the mesh
  27673. * @returns The class name
  27674. */
  27675. getClassName(): string;
  27676. }
  27677. /**
  27678. * Represents a physics imposter
  27679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27680. */
  27681. export class PhysicsImpostor {
  27682. /**
  27683. * The physics-enabled object used as the physics imposter
  27684. */
  27685. object: IPhysicsEnabledObject;
  27686. /**
  27687. * The type of the physics imposter
  27688. */
  27689. type: number;
  27690. private _options;
  27691. private _scene?;
  27692. /**
  27693. * The default object size of the imposter
  27694. */
  27695. static DEFAULT_OBJECT_SIZE: Vector3;
  27696. /**
  27697. * The identity quaternion of the imposter
  27698. */
  27699. static IDENTITY_QUATERNION: Quaternion;
  27700. /** @hidden */
  27701. _pluginData: any;
  27702. private _physicsEngine;
  27703. private _physicsBody;
  27704. private _bodyUpdateRequired;
  27705. private _onBeforePhysicsStepCallbacks;
  27706. private _onAfterPhysicsStepCallbacks;
  27707. /** @hidden */
  27708. _onPhysicsCollideCallbacks: Array<{
  27709. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27710. otherImpostors: Array<PhysicsImpostor>;
  27711. }>;
  27712. private _deltaPosition;
  27713. private _deltaRotation;
  27714. private _deltaRotationConjugated;
  27715. /** @hidden */
  27716. _isFromLine: boolean;
  27717. private _parent;
  27718. private _isDisposed;
  27719. private static _tmpVecs;
  27720. private static _tmpQuat;
  27721. /**
  27722. * Specifies if the physics imposter is disposed
  27723. */
  27724. get isDisposed(): boolean;
  27725. /**
  27726. * Gets the mass of the physics imposter
  27727. */
  27728. get mass(): number;
  27729. set mass(value: number);
  27730. /**
  27731. * Gets the coefficient of friction
  27732. */
  27733. get friction(): number;
  27734. /**
  27735. * Sets the coefficient of friction
  27736. */
  27737. set friction(value: number);
  27738. /**
  27739. * Gets the coefficient of restitution
  27740. */
  27741. get restitution(): number;
  27742. /**
  27743. * Sets the coefficient of restitution
  27744. */
  27745. set restitution(value: number);
  27746. /**
  27747. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27748. */
  27749. get pressure(): number;
  27750. /**
  27751. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27752. */
  27753. set pressure(value: number);
  27754. /**
  27755. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27756. */
  27757. get stiffness(): number;
  27758. /**
  27759. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27760. */
  27761. set stiffness(value: number);
  27762. /**
  27763. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27764. */
  27765. get velocityIterations(): number;
  27766. /**
  27767. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27768. */
  27769. set velocityIterations(value: number);
  27770. /**
  27771. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27772. */
  27773. get positionIterations(): number;
  27774. /**
  27775. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27776. */
  27777. set positionIterations(value: number);
  27778. /**
  27779. * The unique id of the physics imposter
  27780. * set by the physics engine when adding this impostor to the array
  27781. */
  27782. uniqueId: number;
  27783. /**
  27784. * @hidden
  27785. */
  27786. soft: boolean;
  27787. /**
  27788. * @hidden
  27789. */
  27790. segments: number;
  27791. private _joints;
  27792. /**
  27793. * Initializes the physics imposter
  27794. * @param object The physics-enabled object used as the physics imposter
  27795. * @param type The type of the physics imposter
  27796. * @param _options The options for the physics imposter
  27797. * @param _scene The Babylon scene
  27798. */
  27799. constructor(
  27800. /**
  27801. * The physics-enabled object used as the physics imposter
  27802. */
  27803. object: IPhysicsEnabledObject,
  27804. /**
  27805. * The type of the physics imposter
  27806. */
  27807. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27808. /**
  27809. * This function will completly initialize this impostor.
  27810. * It will create a new body - but only if this mesh has no parent.
  27811. * If it has, this impostor will not be used other than to define the impostor
  27812. * of the child mesh.
  27813. * @hidden
  27814. */
  27815. _init(): void;
  27816. private _getPhysicsParent;
  27817. /**
  27818. * Should a new body be generated.
  27819. * @returns boolean specifying if body initialization is required
  27820. */
  27821. isBodyInitRequired(): boolean;
  27822. /**
  27823. * Sets the updated scaling
  27824. * @param updated Specifies if the scaling is updated
  27825. */
  27826. setScalingUpdated(): void;
  27827. /**
  27828. * Force a regeneration of this or the parent's impostor's body.
  27829. * Use under cautious - This will remove all joints already implemented.
  27830. */
  27831. forceUpdate(): void;
  27832. /**
  27833. * Gets the body that holds this impostor. Either its own, or its parent.
  27834. */
  27835. get physicsBody(): any;
  27836. /**
  27837. * Get the parent of the physics imposter
  27838. * @returns Physics imposter or null
  27839. */
  27840. get parent(): Nullable<PhysicsImpostor>;
  27841. /**
  27842. * Sets the parent of the physics imposter
  27843. */
  27844. set parent(value: Nullable<PhysicsImpostor>);
  27845. /**
  27846. * Set the physics body. Used mainly by the physics engine/plugin
  27847. */
  27848. set physicsBody(physicsBody: any);
  27849. /**
  27850. * Resets the update flags
  27851. */
  27852. resetUpdateFlags(): void;
  27853. /**
  27854. * Gets the object extend size
  27855. * @returns the object extend size
  27856. */
  27857. getObjectExtendSize(): Vector3;
  27858. /**
  27859. * Gets the object center
  27860. * @returns The object center
  27861. */
  27862. getObjectCenter(): Vector3;
  27863. /**
  27864. * Get a specific parameter from the options parameters
  27865. * @param paramName The object parameter name
  27866. * @returns The object parameter
  27867. */
  27868. getParam(paramName: string): any;
  27869. /**
  27870. * Sets a specific parameter in the options given to the physics plugin
  27871. * @param paramName The parameter name
  27872. * @param value The value of the parameter
  27873. */
  27874. setParam(paramName: string, value: number): void;
  27875. /**
  27876. * Specifically change the body's mass option. Won't recreate the physics body object
  27877. * @param mass The mass of the physics imposter
  27878. */
  27879. setMass(mass: number): void;
  27880. /**
  27881. * Gets the linear velocity
  27882. * @returns linear velocity or null
  27883. */
  27884. getLinearVelocity(): Nullable<Vector3>;
  27885. /**
  27886. * Sets the linear velocity
  27887. * @param velocity linear velocity or null
  27888. */
  27889. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27890. /**
  27891. * Gets the angular velocity
  27892. * @returns angular velocity or null
  27893. */
  27894. getAngularVelocity(): Nullable<Vector3>;
  27895. /**
  27896. * Sets the angular velocity
  27897. * @param velocity The velocity or null
  27898. */
  27899. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27900. /**
  27901. * Execute a function with the physics plugin native code
  27902. * Provide a function the will have two variables - the world object and the physics body object
  27903. * @param func The function to execute with the physics plugin native code
  27904. */
  27905. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27906. /**
  27907. * Register a function that will be executed before the physics world is stepping forward
  27908. * @param func The function to execute before the physics world is stepped forward
  27909. */
  27910. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27911. /**
  27912. * Unregister a function that will be executed before the physics world is stepping forward
  27913. * @param func The function to execute before the physics world is stepped forward
  27914. */
  27915. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27916. /**
  27917. * Register a function that will be executed after the physics step
  27918. * @param func The function to execute after physics step
  27919. */
  27920. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27921. /**
  27922. * Unregisters a function that will be executed after the physics step
  27923. * @param func The function to execute after physics step
  27924. */
  27925. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27926. /**
  27927. * register a function that will be executed when this impostor collides against a different body
  27928. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27929. * @param func Callback that is executed on collision
  27930. */
  27931. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27932. /**
  27933. * Unregisters the physics imposter on contact
  27934. * @param collideAgainst The physics object to collide against
  27935. * @param func Callback to execute on collision
  27936. */
  27937. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27938. private _tmpQuat;
  27939. private _tmpQuat2;
  27940. /**
  27941. * Get the parent rotation
  27942. * @returns The parent rotation
  27943. */
  27944. getParentsRotation(): Quaternion;
  27945. /**
  27946. * this function is executed by the physics engine.
  27947. */
  27948. beforeStep: () => void;
  27949. /**
  27950. * this function is executed by the physics engine
  27951. */
  27952. afterStep: () => void;
  27953. /**
  27954. * Legacy collision detection event support
  27955. */
  27956. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27957. /**
  27958. * event and body object due to cannon's event-based architecture.
  27959. */
  27960. onCollide: (e: {
  27961. body: any;
  27962. }) => void;
  27963. /**
  27964. * Apply a force
  27965. * @param force The force to apply
  27966. * @param contactPoint The contact point for the force
  27967. * @returns The physics imposter
  27968. */
  27969. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27970. /**
  27971. * Apply an impulse
  27972. * @param force The impulse force
  27973. * @param contactPoint The contact point for the impulse force
  27974. * @returns The physics imposter
  27975. */
  27976. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27977. /**
  27978. * A help function to create a joint
  27979. * @param otherImpostor A physics imposter used to create a joint
  27980. * @param jointType The type of joint
  27981. * @param jointData The data for the joint
  27982. * @returns The physics imposter
  27983. */
  27984. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27985. /**
  27986. * Add a joint to this impostor with a different impostor
  27987. * @param otherImpostor A physics imposter used to add a joint
  27988. * @param joint The joint to add
  27989. * @returns The physics imposter
  27990. */
  27991. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27992. /**
  27993. * Add an anchor to a cloth impostor
  27994. * @param otherImpostor rigid impostor to anchor to
  27995. * @param width ratio across width from 0 to 1
  27996. * @param height ratio up height from 0 to 1
  27997. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27998. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27999. * @returns impostor the soft imposter
  28000. */
  28001. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28002. /**
  28003. * Add a hook to a rope impostor
  28004. * @param otherImpostor rigid impostor to anchor to
  28005. * @param length ratio across rope from 0 to 1
  28006. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28007. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28008. * @returns impostor the rope imposter
  28009. */
  28010. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28011. /**
  28012. * Will keep this body still, in a sleep mode.
  28013. * @returns the physics imposter
  28014. */
  28015. sleep(): PhysicsImpostor;
  28016. /**
  28017. * Wake the body up.
  28018. * @returns The physics imposter
  28019. */
  28020. wakeUp(): PhysicsImpostor;
  28021. /**
  28022. * Clones the physics imposter
  28023. * @param newObject The physics imposter clones to this physics-enabled object
  28024. * @returns A nullable physics imposter
  28025. */
  28026. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28027. /**
  28028. * Disposes the physics imposter
  28029. */
  28030. dispose(): void;
  28031. /**
  28032. * Sets the delta position
  28033. * @param position The delta position amount
  28034. */
  28035. setDeltaPosition(position: Vector3): void;
  28036. /**
  28037. * Sets the delta rotation
  28038. * @param rotation The delta rotation amount
  28039. */
  28040. setDeltaRotation(rotation: Quaternion): void;
  28041. /**
  28042. * Gets the box size of the physics imposter and stores the result in the input parameter
  28043. * @param result Stores the box size
  28044. * @returns The physics imposter
  28045. */
  28046. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28047. /**
  28048. * Gets the radius of the physics imposter
  28049. * @returns Radius of the physics imposter
  28050. */
  28051. getRadius(): number;
  28052. /**
  28053. * Sync a bone with this impostor
  28054. * @param bone The bone to sync to the impostor.
  28055. * @param boneMesh The mesh that the bone is influencing.
  28056. * @param jointPivot The pivot of the joint / bone in local space.
  28057. * @param distToJoint Optional distance from the impostor to the joint.
  28058. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28059. */
  28060. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28061. /**
  28062. * Sync impostor to a bone
  28063. * @param bone The bone that the impostor will be synced to.
  28064. * @param boneMesh The mesh that the bone is influencing.
  28065. * @param jointPivot The pivot of the joint / bone in local space.
  28066. * @param distToJoint Optional distance from the impostor to the joint.
  28067. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28068. * @param boneAxis Optional vector3 axis the bone is aligned with
  28069. */
  28070. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28071. /**
  28072. * No-Imposter type
  28073. */
  28074. static NoImpostor: number;
  28075. /**
  28076. * Sphere-Imposter type
  28077. */
  28078. static SphereImpostor: number;
  28079. /**
  28080. * Box-Imposter type
  28081. */
  28082. static BoxImpostor: number;
  28083. /**
  28084. * Plane-Imposter type
  28085. */
  28086. static PlaneImpostor: number;
  28087. /**
  28088. * Mesh-imposter type
  28089. */
  28090. static MeshImpostor: number;
  28091. /**
  28092. * Capsule-Impostor type (Ammo.js plugin only)
  28093. */
  28094. static CapsuleImpostor: number;
  28095. /**
  28096. * Cylinder-Imposter type
  28097. */
  28098. static CylinderImpostor: number;
  28099. /**
  28100. * Particle-Imposter type
  28101. */
  28102. static ParticleImpostor: number;
  28103. /**
  28104. * Heightmap-Imposter type
  28105. */
  28106. static HeightmapImpostor: number;
  28107. /**
  28108. * ConvexHull-Impostor type (Ammo.js plugin only)
  28109. */
  28110. static ConvexHullImpostor: number;
  28111. /**
  28112. * Custom-Imposter type (Ammo.js plugin only)
  28113. */
  28114. static CustomImpostor: number;
  28115. /**
  28116. * Rope-Imposter type
  28117. */
  28118. static RopeImpostor: number;
  28119. /**
  28120. * Cloth-Imposter type
  28121. */
  28122. static ClothImpostor: number;
  28123. /**
  28124. * Softbody-Imposter type
  28125. */
  28126. static SoftbodyImpostor: number;
  28127. }
  28128. }
  28129. declare module "babylonjs/Meshes/mesh" {
  28130. import { Observable } from "babylonjs/Misc/observable";
  28131. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28132. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28133. import { Camera } from "babylonjs/Cameras/camera";
  28134. import { Scene } from "babylonjs/scene";
  28135. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28136. import { Color4 } from "babylonjs/Maths/math.color";
  28137. import { Engine } from "babylonjs/Engines/engine";
  28138. import { Node } from "babylonjs/node";
  28139. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28140. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28141. import { Buffer } from "babylonjs/Meshes/buffer";
  28142. import { Geometry } from "babylonjs/Meshes/geometry";
  28143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28144. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28145. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28146. import { Effect } from "babylonjs/Materials/effect";
  28147. import { Material } from "babylonjs/Materials/material";
  28148. import { Skeleton } from "babylonjs/Bones/skeleton";
  28149. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28150. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28151. import { Path3D } from "babylonjs/Maths/math.path";
  28152. import { Plane } from "babylonjs/Maths/math.plane";
  28153. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28154. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28155. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28156. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28157. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28158. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28159. /**
  28160. * @hidden
  28161. **/
  28162. export class _CreationDataStorage {
  28163. closePath?: boolean;
  28164. closeArray?: boolean;
  28165. idx: number[];
  28166. dashSize: number;
  28167. gapSize: number;
  28168. path3D: Path3D;
  28169. pathArray: Vector3[][];
  28170. arc: number;
  28171. radius: number;
  28172. cap: number;
  28173. tessellation: number;
  28174. }
  28175. /**
  28176. * @hidden
  28177. **/
  28178. class _InstanceDataStorage {
  28179. visibleInstances: any;
  28180. batchCache: _InstancesBatch;
  28181. instancesBufferSize: number;
  28182. instancesBuffer: Nullable<Buffer>;
  28183. instancesData: Float32Array;
  28184. overridenInstanceCount: number;
  28185. isFrozen: boolean;
  28186. previousBatch: Nullable<_InstancesBatch>;
  28187. hardwareInstancedRendering: boolean;
  28188. sideOrientation: number;
  28189. manualUpdate: boolean;
  28190. }
  28191. /**
  28192. * @hidden
  28193. **/
  28194. export class _InstancesBatch {
  28195. mustReturn: boolean;
  28196. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28197. renderSelf: boolean[];
  28198. hardwareInstancedRendering: boolean[];
  28199. }
  28200. /**
  28201. * @hidden
  28202. **/
  28203. class _ThinInstanceDataStorage {
  28204. instancesCount: number;
  28205. matrixBuffer: Nullable<Buffer>;
  28206. matrixBufferSize: number;
  28207. matrixData: Nullable<Float32Array>;
  28208. boundingVectors: Array<Vector3>;
  28209. }
  28210. /**
  28211. * Class used to represent renderable models
  28212. */
  28213. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28214. /**
  28215. * Mesh side orientation : usually the external or front surface
  28216. */
  28217. static readonly FRONTSIDE: number;
  28218. /**
  28219. * Mesh side orientation : usually the internal or back surface
  28220. */
  28221. static readonly BACKSIDE: number;
  28222. /**
  28223. * Mesh side orientation : both internal and external or front and back surfaces
  28224. */
  28225. static readonly DOUBLESIDE: number;
  28226. /**
  28227. * Mesh side orientation : by default, `FRONTSIDE`
  28228. */
  28229. static readonly DEFAULTSIDE: number;
  28230. /**
  28231. * Mesh cap setting : no cap
  28232. */
  28233. static readonly NO_CAP: number;
  28234. /**
  28235. * Mesh cap setting : one cap at the beginning of the mesh
  28236. */
  28237. static readonly CAP_START: number;
  28238. /**
  28239. * Mesh cap setting : one cap at the end of the mesh
  28240. */
  28241. static readonly CAP_END: number;
  28242. /**
  28243. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28244. */
  28245. static readonly CAP_ALL: number;
  28246. /**
  28247. * Mesh pattern setting : no flip or rotate
  28248. */
  28249. static readonly NO_FLIP: number;
  28250. /**
  28251. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28252. */
  28253. static readonly FLIP_TILE: number;
  28254. /**
  28255. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28256. */
  28257. static readonly ROTATE_TILE: number;
  28258. /**
  28259. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28260. */
  28261. static readonly FLIP_ROW: number;
  28262. /**
  28263. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28264. */
  28265. static readonly ROTATE_ROW: number;
  28266. /**
  28267. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28268. */
  28269. static readonly FLIP_N_ROTATE_TILE: number;
  28270. /**
  28271. * Mesh pattern setting : rotate pattern and rotate
  28272. */
  28273. static readonly FLIP_N_ROTATE_ROW: number;
  28274. /**
  28275. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28276. */
  28277. static readonly CENTER: number;
  28278. /**
  28279. * Mesh tile positioning : part tiles on left
  28280. */
  28281. static readonly LEFT: number;
  28282. /**
  28283. * Mesh tile positioning : part tiles on right
  28284. */
  28285. static readonly RIGHT: number;
  28286. /**
  28287. * Mesh tile positioning : part tiles on top
  28288. */
  28289. static readonly TOP: number;
  28290. /**
  28291. * Mesh tile positioning : part tiles on bottom
  28292. */
  28293. static readonly BOTTOM: number;
  28294. /**
  28295. * Gets the default side orientation.
  28296. * @param orientation the orientation to value to attempt to get
  28297. * @returns the default orientation
  28298. * @hidden
  28299. */
  28300. static _GetDefaultSideOrientation(orientation?: number): number;
  28301. private _internalMeshDataInfo;
  28302. /**
  28303. * An event triggered before rendering the mesh
  28304. */
  28305. get onBeforeRenderObservable(): Observable<Mesh>;
  28306. /**
  28307. * An event triggered before binding the mesh
  28308. */
  28309. get onBeforeBindObservable(): Observable<Mesh>;
  28310. /**
  28311. * An event triggered after rendering the mesh
  28312. */
  28313. get onAfterRenderObservable(): Observable<Mesh>;
  28314. /**
  28315. * An event triggered before drawing the mesh
  28316. */
  28317. get onBeforeDrawObservable(): Observable<Mesh>;
  28318. private _onBeforeDrawObserver;
  28319. /**
  28320. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28321. */
  28322. set onBeforeDraw(callback: () => void);
  28323. get hasInstances(): boolean;
  28324. get hasThinInstances(): boolean;
  28325. /**
  28326. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28327. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28328. */
  28329. delayLoadState: number;
  28330. /**
  28331. * Gets the list of instances created from this mesh
  28332. * it is not supposed to be modified manually.
  28333. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28334. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28335. */
  28336. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28337. /**
  28338. * Gets the file containing delay loading data for this mesh
  28339. */
  28340. delayLoadingFile: string;
  28341. /** @hidden */
  28342. _binaryInfo: any;
  28343. /**
  28344. * User defined function used to change how LOD level selection is done
  28345. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28346. */
  28347. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28348. /**
  28349. * Gets or sets the morph target manager
  28350. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28351. */
  28352. get morphTargetManager(): Nullable<MorphTargetManager>;
  28353. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28354. /** @hidden */
  28355. _creationDataStorage: Nullable<_CreationDataStorage>;
  28356. /** @hidden */
  28357. _geometry: Nullable<Geometry>;
  28358. /** @hidden */
  28359. _delayInfo: Array<string>;
  28360. /** @hidden */
  28361. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28362. /** @hidden */
  28363. _instanceDataStorage: _InstanceDataStorage;
  28364. /** @hidden */
  28365. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28366. private _effectiveMaterial;
  28367. /** @hidden */
  28368. _shouldGenerateFlatShading: boolean;
  28369. /** @hidden */
  28370. _originalBuilderSideOrientation: number;
  28371. /**
  28372. * Use this property to change the original side orientation defined at construction time
  28373. */
  28374. overrideMaterialSideOrientation: Nullable<number>;
  28375. /**
  28376. * Gets the source mesh (the one used to clone this one from)
  28377. */
  28378. get source(): Nullable<Mesh>;
  28379. /**
  28380. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28381. */
  28382. get isUnIndexed(): boolean;
  28383. set isUnIndexed(value: boolean);
  28384. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28385. get worldMatrixInstancedBuffer(): Float32Array;
  28386. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28387. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28388. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28389. /**
  28390. * @constructor
  28391. * @param name The value used by scene.getMeshByName() to do a lookup.
  28392. * @param scene The scene to add this mesh to.
  28393. * @param parent The parent of this mesh, if it has one
  28394. * @param source An optional Mesh from which geometry is shared, cloned.
  28395. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28396. * When false, achieved by calling a clone(), also passing False.
  28397. * This will make creation of children, recursive.
  28398. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28399. */
  28400. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28401. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28402. doNotInstantiate: boolean;
  28403. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28404. /**
  28405. * Gets the class name
  28406. * @returns the string "Mesh".
  28407. */
  28408. getClassName(): string;
  28409. /** @hidden */
  28410. get _isMesh(): boolean;
  28411. /**
  28412. * Returns a description of this mesh
  28413. * @param fullDetails define if full details about this mesh must be used
  28414. * @returns a descriptive string representing this mesh
  28415. */
  28416. toString(fullDetails?: boolean): string;
  28417. /** @hidden */
  28418. _unBindEffect(): void;
  28419. /**
  28420. * Gets a boolean indicating if this mesh has LOD
  28421. */
  28422. get hasLODLevels(): boolean;
  28423. /**
  28424. * Gets the list of MeshLODLevel associated with the current mesh
  28425. * @returns an array of MeshLODLevel
  28426. */
  28427. getLODLevels(): MeshLODLevel[];
  28428. private _sortLODLevels;
  28429. /**
  28430. * Add a mesh as LOD level triggered at the given distance.
  28431. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28432. * @param distance The distance from the center of the object to show this level
  28433. * @param mesh The mesh to be added as LOD level (can be null)
  28434. * @return This mesh (for chaining)
  28435. */
  28436. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28437. /**
  28438. * Returns the LOD level mesh at the passed distance or null if not found.
  28439. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28440. * @param distance The distance from the center of the object to show this level
  28441. * @returns a Mesh or `null`
  28442. */
  28443. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28444. /**
  28445. * Remove a mesh from the LOD array
  28446. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28447. * @param mesh defines the mesh to be removed
  28448. * @return This mesh (for chaining)
  28449. */
  28450. removeLODLevel(mesh: Mesh): Mesh;
  28451. /**
  28452. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28453. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28454. * @param camera defines the camera to use to compute distance
  28455. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28456. * @return This mesh (for chaining)
  28457. */
  28458. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28459. /**
  28460. * Gets the mesh internal Geometry object
  28461. */
  28462. get geometry(): Nullable<Geometry>;
  28463. /**
  28464. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28465. * @returns the total number of vertices
  28466. */
  28467. getTotalVertices(): number;
  28468. /**
  28469. * Returns the content of an associated vertex buffer
  28470. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28471. * - VertexBuffer.PositionKind
  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. * @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
  28484. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28485. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28486. */
  28487. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28488. /**
  28489. * Returns the mesh VertexBuffer object from the requested `kind`
  28490. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28491. * - VertexBuffer.PositionKind
  28492. * - VertexBuffer.NormalKind
  28493. * - VertexBuffer.UVKind
  28494. * - VertexBuffer.UV2Kind
  28495. * - VertexBuffer.UV3Kind
  28496. * - VertexBuffer.UV4Kind
  28497. * - VertexBuffer.UV5Kind
  28498. * - VertexBuffer.UV6Kind
  28499. * - VertexBuffer.ColorKind
  28500. * - VertexBuffer.MatricesIndicesKind
  28501. * - VertexBuffer.MatricesIndicesExtraKind
  28502. * - VertexBuffer.MatricesWeightsKind
  28503. * - VertexBuffer.MatricesWeightsExtraKind
  28504. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28505. */
  28506. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28507. /**
  28508. * Tests if a specific vertex buffer is associated with this mesh
  28509. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28510. * - VertexBuffer.PositionKind
  28511. * - VertexBuffer.NormalKind
  28512. * - VertexBuffer.UVKind
  28513. * - VertexBuffer.UV2Kind
  28514. * - VertexBuffer.UV3Kind
  28515. * - VertexBuffer.UV4Kind
  28516. * - VertexBuffer.UV5Kind
  28517. * - VertexBuffer.UV6Kind
  28518. * - VertexBuffer.ColorKind
  28519. * - VertexBuffer.MatricesIndicesKind
  28520. * - VertexBuffer.MatricesIndicesExtraKind
  28521. * - VertexBuffer.MatricesWeightsKind
  28522. * - VertexBuffer.MatricesWeightsExtraKind
  28523. * @returns a boolean
  28524. */
  28525. isVerticesDataPresent(kind: string): boolean;
  28526. /**
  28527. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28528. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28529. * - VertexBuffer.PositionKind
  28530. * - VertexBuffer.UVKind
  28531. * - VertexBuffer.UV2Kind
  28532. * - VertexBuffer.UV3Kind
  28533. * - VertexBuffer.UV4Kind
  28534. * - VertexBuffer.UV5Kind
  28535. * - VertexBuffer.UV6Kind
  28536. * - VertexBuffer.ColorKind
  28537. * - VertexBuffer.MatricesIndicesKind
  28538. * - VertexBuffer.MatricesIndicesExtraKind
  28539. * - VertexBuffer.MatricesWeightsKind
  28540. * - VertexBuffer.MatricesWeightsExtraKind
  28541. * @returns a boolean
  28542. */
  28543. isVertexBufferUpdatable(kind: string): boolean;
  28544. /**
  28545. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28546. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28547. * - VertexBuffer.PositionKind
  28548. * - VertexBuffer.NormalKind
  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. * @returns an array of strings
  28561. */
  28562. getVerticesDataKinds(): string[];
  28563. /**
  28564. * Returns a positive integer : the total number of indices in this mesh geometry.
  28565. * @returns the numner of indices or zero if the mesh has no geometry.
  28566. */
  28567. getTotalIndices(): number;
  28568. /**
  28569. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28570. * @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.
  28571. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28572. * @returns the indices array or an empty array if the mesh has no geometry
  28573. */
  28574. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28575. get isBlocked(): boolean;
  28576. /**
  28577. * Determine if the current mesh is ready to be rendered
  28578. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28579. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28580. * @returns true if all associated assets are ready (material, textures, shaders)
  28581. */
  28582. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28583. /**
  28584. * 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.
  28585. */
  28586. get areNormalsFrozen(): boolean;
  28587. /**
  28588. * 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.
  28589. * @returns the current mesh
  28590. */
  28591. freezeNormals(): Mesh;
  28592. /**
  28593. * 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
  28594. * @returns the current mesh
  28595. */
  28596. unfreezeNormals(): Mesh;
  28597. /**
  28598. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28599. */
  28600. set overridenInstanceCount(count: number);
  28601. /** @hidden */
  28602. _preActivate(): Mesh;
  28603. /** @hidden */
  28604. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28605. /** @hidden */
  28606. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28607. protected _afterComputeWorldMatrix(): void;
  28608. /** @hidden */
  28609. _postActivate(): void;
  28610. /**
  28611. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28612. * This means the mesh underlying bounding box and sphere are recomputed.
  28613. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28614. * @returns the current mesh
  28615. */
  28616. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28617. /** @hidden */
  28618. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28619. /**
  28620. * This function will subdivide the mesh into multiple submeshes
  28621. * @param count defines the expected number of submeshes
  28622. */
  28623. subdivide(count: number): void;
  28624. /**
  28625. * Copy a FloatArray into a specific associated vertex buffer
  28626. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28627. * - VertexBuffer.PositionKind
  28628. * - VertexBuffer.UVKind
  28629. * - VertexBuffer.UV2Kind
  28630. * - VertexBuffer.UV3Kind
  28631. * - VertexBuffer.UV4Kind
  28632. * - VertexBuffer.UV5Kind
  28633. * - VertexBuffer.UV6Kind
  28634. * - VertexBuffer.ColorKind
  28635. * - VertexBuffer.MatricesIndicesKind
  28636. * - VertexBuffer.MatricesIndicesExtraKind
  28637. * - VertexBuffer.MatricesWeightsKind
  28638. * - VertexBuffer.MatricesWeightsExtraKind
  28639. * @param data defines the data source
  28640. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28641. * @param stride defines the data stride size (can be null)
  28642. * @returns the current mesh
  28643. */
  28644. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28645. /**
  28646. * Delete a vertex buffer associated with this mesh
  28647. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28648. * - VertexBuffer.PositionKind
  28649. * - VertexBuffer.UVKind
  28650. * - VertexBuffer.UV2Kind
  28651. * - VertexBuffer.UV3Kind
  28652. * - VertexBuffer.UV4Kind
  28653. * - VertexBuffer.UV5Kind
  28654. * - VertexBuffer.UV6Kind
  28655. * - VertexBuffer.ColorKind
  28656. * - VertexBuffer.MatricesIndicesKind
  28657. * - VertexBuffer.MatricesIndicesExtraKind
  28658. * - VertexBuffer.MatricesWeightsKind
  28659. * - VertexBuffer.MatricesWeightsExtraKind
  28660. */
  28661. removeVerticesData(kind: string): void;
  28662. /**
  28663. * Flags an associated vertex buffer as updatable
  28664. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28665. * - VertexBuffer.PositionKind
  28666. * - VertexBuffer.UVKind
  28667. * - VertexBuffer.UV2Kind
  28668. * - VertexBuffer.UV3Kind
  28669. * - VertexBuffer.UV4Kind
  28670. * - VertexBuffer.UV5Kind
  28671. * - VertexBuffer.UV6Kind
  28672. * - VertexBuffer.ColorKind
  28673. * - VertexBuffer.MatricesIndicesKind
  28674. * - VertexBuffer.MatricesIndicesExtraKind
  28675. * - VertexBuffer.MatricesWeightsKind
  28676. * - VertexBuffer.MatricesWeightsExtraKind
  28677. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28678. */
  28679. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28680. /**
  28681. * Sets the mesh global Vertex Buffer
  28682. * @param buffer defines the buffer to use
  28683. * @returns the current mesh
  28684. */
  28685. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28686. /**
  28687. * Update a specific associated vertex buffer
  28688. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28689. * - VertexBuffer.PositionKind
  28690. * - VertexBuffer.UVKind
  28691. * - VertexBuffer.UV2Kind
  28692. * - VertexBuffer.UV3Kind
  28693. * - VertexBuffer.UV4Kind
  28694. * - VertexBuffer.UV5Kind
  28695. * - VertexBuffer.UV6Kind
  28696. * - VertexBuffer.ColorKind
  28697. * - VertexBuffer.MatricesIndicesKind
  28698. * - VertexBuffer.MatricesIndicesExtraKind
  28699. * - VertexBuffer.MatricesWeightsKind
  28700. * - VertexBuffer.MatricesWeightsExtraKind
  28701. * @param data defines the data source
  28702. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28703. * @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)
  28704. * @returns the current mesh
  28705. */
  28706. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28707. /**
  28708. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28709. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28710. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28711. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28712. * @returns the current mesh
  28713. */
  28714. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28715. /**
  28716. * Creates a un-shared specific occurence of the geometry for the mesh.
  28717. * @returns the current mesh
  28718. */
  28719. makeGeometryUnique(): Mesh;
  28720. /**
  28721. * Set the index buffer of this mesh
  28722. * @param indices defines the source data
  28723. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28724. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28725. * @returns the current mesh
  28726. */
  28727. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28728. /**
  28729. * Update the current index buffer
  28730. * @param indices defines the source data
  28731. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28732. * @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)
  28733. * @returns the current mesh
  28734. */
  28735. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28736. /**
  28737. * Invert the geometry to move from a right handed system to a left handed one.
  28738. * @returns the current mesh
  28739. */
  28740. toLeftHanded(): Mesh;
  28741. /** @hidden */
  28742. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28743. /** @hidden */
  28744. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28745. /**
  28746. * Registers for this mesh a javascript function called just before the rendering process
  28747. * @param func defines the function to call before rendering this mesh
  28748. * @returns the current mesh
  28749. */
  28750. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28751. /**
  28752. * Disposes a previously registered javascript function called before the rendering
  28753. * @param func defines the function to remove
  28754. * @returns the current mesh
  28755. */
  28756. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28757. /**
  28758. * Registers for this mesh a javascript function called just after the rendering is complete
  28759. * @param func defines the function to call after rendering this mesh
  28760. * @returns the current mesh
  28761. */
  28762. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28763. /**
  28764. * Disposes a previously registered javascript function called after the rendering.
  28765. * @param func defines the function to remove
  28766. * @returns the current mesh
  28767. */
  28768. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28769. /** @hidden */
  28770. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28771. /** @hidden */
  28772. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28773. /** @hidden */
  28774. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28775. /** @hidden */
  28776. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28777. /** @hidden */
  28778. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28779. /** @hidden */
  28780. _rebuild(): void;
  28781. /** @hidden */
  28782. _freeze(): void;
  28783. /** @hidden */
  28784. _unFreeze(): void;
  28785. /**
  28786. * 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
  28787. * @param subMesh defines the subMesh to render
  28788. * @param enableAlphaMode defines if alpha mode can be changed
  28789. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28790. * @returns the current mesh
  28791. */
  28792. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28793. private _onBeforeDraw;
  28794. /**
  28795. * Renormalize the mesh and patch it up if there are no weights
  28796. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28797. * However in the case of zero weights then we set just a single influence to 1.
  28798. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28799. */
  28800. cleanMatrixWeights(): void;
  28801. private normalizeSkinFourWeights;
  28802. private normalizeSkinWeightsAndExtra;
  28803. /**
  28804. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28805. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28806. * the user know there was an issue with importing the mesh
  28807. * @returns a validation object with skinned, valid and report string
  28808. */
  28809. validateSkinning(): {
  28810. skinned: boolean;
  28811. valid: boolean;
  28812. report: string;
  28813. };
  28814. /** @hidden */
  28815. _checkDelayState(): Mesh;
  28816. private _queueLoad;
  28817. /**
  28818. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28819. * A mesh is in the frustum if its bounding box intersects the frustum
  28820. * @param frustumPlanes defines the frustum to test
  28821. * @returns true if the mesh is in the frustum planes
  28822. */
  28823. isInFrustum(frustumPlanes: Plane[]): boolean;
  28824. /**
  28825. * Sets the mesh material by the material or multiMaterial `id` property
  28826. * @param id is a string identifying the material or the multiMaterial
  28827. * @returns the current mesh
  28828. */
  28829. setMaterialByID(id: string): Mesh;
  28830. /**
  28831. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28832. * @returns an array of IAnimatable
  28833. */
  28834. getAnimatables(): IAnimatable[];
  28835. /**
  28836. * Modifies the mesh geometry according to the passed transformation matrix.
  28837. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28838. * The mesh normals are modified using the same transformation.
  28839. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28840. * @param transform defines the transform matrix to use
  28841. * @see http://doc.babylonjs.com/resources/baking_transformations
  28842. * @returns the current mesh
  28843. */
  28844. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28845. /**
  28846. * Modifies the mesh geometry according to its own current World Matrix.
  28847. * The mesh World Matrix is then reset.
  28848. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28849. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28850. * @see http://doc.babylonjs.com/resources/baking_transformations
  28851. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28852. * @returns the current mesh
  28853. */
  28854. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28855. /** @hidden */
  28856. get _positions(): Nullable<Vector3[]>;
  28857. /** @hidden */
  28858. _resetPointsArrayCache(): Mesh;
  28859. /** @hidden */
  28860. _generatePointsArray(): boolean;
  28861. /**
  28862. * Returns a new Mesh object generated from the current mesh properties.
  28863. * This method must not get confused with createInstance()
  28864. * @param name is a string, the name given to the new mesh
  28865. * @param newParent can be any Node object (default `null`)
  28866. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28867. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28868. * @returns a new mesh
  28869. */
  28870. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28871. /**
  28872. * Releases resources associated with this mesh.
  28873. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28874. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28875. */
  28876. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28877. /** @hidden */
  28878. _disposeInstanceSpecificData(): void;
  28879. /** @hidden */
  28880. _disposeThinInstanceSpecificData(): void;
  28881. /**
  28882. * Modifies the mesh geometry according to a displacement map.
  28883. * 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.
  28884. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28885. * @param url is a string, the URL from the image file is to be downloaded.
  28886. * @param minHeight is the lower limit of the displacement.
  28887. * @param maxHeight is the upper limit of the displacement.
  28888. * @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.
  28889. * @param uvOffset is an optional vector2 used to offset UV.
  28890. * @param uvScale is an optional vector2 used to scale UV.
  28891. * @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.
  28892. * @returns the Mesh.
  28893. */
  28894. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28895. /**
  28896. * Modifies the mesh geometry according to a displacementMap buffer.
  28897. * 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.
  28898. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28899. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28900. * @param heightMapWidth is the width of the buffer image.
  28901. * @param heightMapHeight is the height of the buffer image.
  28902. * @param minHeight is the lower limit of the displacement.
  28903. * @param maxHeight is the upper limit of the displacement.
  28904. * @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.
  28905. * @param uvOffset is an optional vector2 used to offset UV.
  28906. * @param uvScale is an optional vector2 used to scale UV.
  28907. * @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.
  28908. * @returns the Mesh.
  28909. */
  28910. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28911. /**
  28912. * Modify the mesh to get a flat shading rendering.
  28913. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28914. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28915. * @returns current mesh
  28916. */
  28917. convertToFlatShadedMesh(): Mesh;
  28918. /**
  28919. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28920. * In other words, more vertices, no more indices and a single bigger VBO.
  28921. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28922. * @returns current mesh
  28923. */
  28924. convertToUnIndexedMesh(): Mesh;
  28925. /**
  28926. * Inverses facet orientations.
  28927. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28928. * @param flipNormals will also inverts the normals
  28929. * @returns current mesh
  28930. */
  28931. flipFaces(flipNormals?: boolean): Mesh;
  28932. /**
  28933. * Increase the number of facets and hence vertices in a mesh
  28934. * Vertex normals are interpolated from existing vertex normals
  28935. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28936. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28937. */
  28938. increaseVertices(numberPerEdge: number): void;
  28939. /**
  28940. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28941. * This will undo any application of covertToFlatShadedMesh
  28942. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28943. */
  28944. forceSharedVertices(): void;
  28945. /** @hidden */
  28946. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28947. /** @hidden */
  28948. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28949. /**
  28950. * Creates a new InstancedMesh object from the mesh model.
  28951. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28952. * @param name defines the name of the new instance
  28953. * @returns a new InstancedMesh
  28954. */
  28955. createInstance(name: string): InstancedMesh;
  28956. /**
  28957. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28958. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28959. * @returns the current mesh
  28960. */
  28961. synchronizeInstances(): Mesh;
  28962. /**
  28963. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28964. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28965. * This should be used together with the simplification to avoid disappearing triangles.
  28966. * @param successCallback an optional success callback to be called after the optimization finished.
  28967. * @returns the current mesh
  28968. */
  28969. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28970. /**
  28971. * Serialize current mesh
  28972. * @param serializationObject defines the object which will receive the serialization data
  28973. */
  28974. serialize(serializationObject: any): void;
  28975. /** @hidden */
  28976. _syncGeometryWithMorphTargetManager(): void;
  28977. /** @hidden */
  28978. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28979. /**
  28980. * Returns a new Mesh object parsed from the source provided.
  28981. * @param parsedMesh is the source
  28982. * @param scene defines the hosting scene
  28983. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28984. * @returns a new Mesh
  28985. */
  28986. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28987. /**
  28988. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28989. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28990. * @param name defines the name of the mesh to create
  28991. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28992. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28993. * @param closePath creates a seam between the first and the last points of each path of the path array
  28994. * @param offset is taken in account only if the `pathArray` is containing a single path
  28995. * @param scene defines the hosting scene
  28996. * @param updatable defines if the mesh must be flagged as updatable
  28997. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28998. * @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)
  28999. * @returns a new Mesh
  29000. */
  29001. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29002. /**
  29003. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29004. * @param name defines the name of the mesh to create
  29005. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29006. * @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
  29007. * @param scene defines the hosting scene
  29008. * @param updatable defines if the mesh must be flagged as updatable
  29009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29010. * @returns a new Mesh
  29011. */
  29012. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29013. /**
  29014. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29015. * @param name defines the name of the mesh to create
  29016. * @param size sets the size (float) of each box side (default 1)
  29017. * @param scene defines the hosting scene
  29018. * @param updatable defines if the mesh must be flagged as updatable
  29019. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29020. * @returns a new Mesh
  29021. */
  29022. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29023. /**
  29024. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29025. * @param name defines the name of the mesh to create
  29026. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29027. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29028. * @param scene defines the hosting scene
  29029. * @param updatable defines if the mesh must be flagged as updatable
  29030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29031. * @returns a new Mesh
  29032. */
  29033. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29034. /**
  29035. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29036. * @param name defines the name of the mesh to create
  29037. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29038. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29039. * @param scene defines the hosting scene
  29040. * @returns a new Mesh
  29041. */
  29042. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29043. /**
  29044. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29045. * @param name defines the name of the mesh to create
  29046. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29047. * @param diameterTop set the top cap diameter (floats, default 1)
  29048. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29049. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29050. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29051. * @param scene defines the hosting scene
  29052. * @param updatable defines if the mesh must be flagged as updatable
  29053. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29054. * @returns a new Mesh
  29055. */
  29056. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29057. /**
  29058. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29059. * @param name defines the name of the mesh to create
  29060. * @param diameter sets the diameter size (float) of the torus (default 1)
  29061. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29062. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29063. * @param scene defines the hosting scene
  29064. * @param updatable defines if the mesh must be flagged as updatable
  29065. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29066. * @returns a new Mesh
  29067. */
  29068. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29069. /**
  29070. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29071. * @param name defines the name of the mesh to create
  29072. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29073. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29074. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29075. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29076. * @param p the number of windings on X axis (positive integers, default 2)
  29077. * @param q the number of windings on Y axis (positive integers, default 3)
  29078. * @param scene defines the hosting scene
  29079. * @param updatable defines if the mesh must be flagged as updatable
  29080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29081. * @returns a new Mesh
  29082. */
  29083. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29084. /**
  29085. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29086. * @param name defines the name of the mesh to create
  29087. * @param points is an array successive Vector3
  29088. * @param scene defines the hosting scene
  29089. * @param updatable defines if the mesh must be flagged as updatable
  29090. * @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).
  29091. * @returns a new Mesh
  29092. */
  29093. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29094. /**
  29095. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29096. * @param name defines the name of the mesh to create
  29097. * @param points is an array successive Vector3
  29098. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29099. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29100. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29101. * @param scene defines the hosting scene
  29102. * @param updatable defines if the mesh must be flagged as updatable
  29103. * @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)
  29104. * @returns a new Mesh
  29105. */
  29106. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29107. /**
  29108. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29109. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29110. * 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.
  29111. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29112. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29113. * Remember you can only change the shape positions, not their number when updating a polygon.
  29114. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29115. * @param name defines the name of the mesh to create
  29116. * @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
  29117. * @param scene defines the hosting scene
  29118. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29119. * @param updatable defines if the mesh must be flagged as updatable
  29120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29121. * @param earcutInjection can be used to inject your own earcut reference
  29122. * @returns a new Mesh
  29123. */
  29124. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29125. /**
  29126. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29127. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29128. * @param name defines the name of the mesh to create
  29129. * @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
  29130. * @param depth defines the height of extrusion
  29131. * @param scene defines the hosting scene
  29132. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29133. * @param updatable defines if the mesh must be flagged as updatable
  29134. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29135. * @param earcutInjection can be used to inject your own earcut reference
  29136. * @returns a new Mesh
  29137. */
  29138. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29139. /**
  29140. * Creates an extruded shape mesh.
  29141. * 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
  29142. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29143. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29144. * @param name defines the name of the mesh to create
  29145. * @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
  29146. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29147. * @param scale is the value to scale the shape
  29148. * @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
  29149. * @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
  29150. * @param scene defines the hosting scene
  29151. * @param updatable defines if the mesh must be flagged as updatable
  29152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29153. * @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)
  29154. * @returns a new Mesh
  29155. */
  29156. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29157. /**
  29158. * Creates an custom extruded shape mesh.
  29159. * The custom extrusion is a parametric shape.
  29160. * It has no predefined shape. Its final shape will depend on the input parameters.
  29161. * Please consider using the same method from the MeshBuilder class instead
  29162. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29163. * @param name defines the name of the mesh to create
  29164. * @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
  29165. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29166. * @param scaleFunction is a custom Javascript function called on each path point
  29167. * @param rotationFunction is a custom Javascript function called on each path point
  29168. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29169. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29170. * @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
  29171. * @param scene defines the hosting scene
  29172. * @param updatable defines if the mesh must be flagged as updatable
  29173. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29174. * @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)
  29175. * @returns a new Mesh
  29176. */
  29177. 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;
  29178. /**
  29179. * Creates lathe mesh.
  29180. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29181. * Please consider using the same method from the MeshBuilder class instead
  29182. * @param name defines the name of the mesh to create
  29183. * @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
  29184. * @param radius is the radius value of the lathe
  29185. * @param tessellation is the side number of the lathe.
  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. * @returns a new Mesh
  29190. */
  29191. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29192. /**
  29193. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29194. * @param name defines the name of the mesh to create
  29195. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29196. * @param scene defines the hosting scene
  29197. * @param updatable defines if the mesh must be flagged as updatable
  29198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29199. * @returns a new Mesh
  29200. */
  29201. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29202. /**
  29203. * Creates a ground mesh.
  29204. * Please consider using the same method from the MeshBuilder class instead
  29205. * @param name defines the name of the mesh to create
  29206. * @param width set the width of the ground
  29207. * @param height set the height of the ground
  29208. * @param subdivisions sets the number of subdivisions per side
  29209. * @param scene defines the hosting scene
  29210. * @param updatable defines if the mesh must be flagged as updatable
  29211. * @returns a new Mesh
  29212. */
  29213. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29214. /**
  29215. * Creates a tiled ground mesh.
  29216. * Please consider using the same method from the MeshBuilder class instead
  29217. * @param name defines the name of the mesh to create
  29218. * @param xmin set the ground minimum X coordinate
  29219. * @param zmin set the ground minimum Y coordinate
  29220. * @param xmax set the ground maximum X coordinate
  29221. * @param zmax set the ground maximum Z coordinate
  29222. * @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
  29223. * @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
  29224. * @param scene defines the hosting scene
  29225. * @param updatable defines if the mesh must be flagged as updatable
  29226. * @returns a new Mesh
  29227. */
  29228. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29229. w: number;
  29230. h: number;
  29231. }, precision: {
  29232. w: number;
  29233. h: number;
  29234. }, scene: Scene, updatable?: boolean): Mesh;
  29235. /**
  29236. * Creates a ground mesh from a height map.
  29237. * Please consider using the same method from the MeshBuilder class instead
  29238. * @see http://doc.babylonjs.com/babylon101/height_map
  29239. * @param name defines the name of the mesh to create
  29240. * @param url sets the URL of the height map image resource
  29241. * @param width set the ground width size
  29242. * @param height set the ground height size
  29243. * @param subdivisions sets the number of subdivision per side
  29244. * @param minHeight is the minimum altitude on the ground
  29245. * @param maxHeight is the maximum altitude on the ground
  29246. * @param scene defines the hosting scene
  29247. * @param updatable defines if the mesh must be flagged as updatable
  29248. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29249. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29250. * @returns a new Mesh
  29251. */
  29252. 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;
  29253. /**
  29254. * Creates a tube mesh.
  29255. * The tube is a parametric shape.
  29256. * It has no predefined shape. Its final shape will depend on the input parameters.
  29257. * Please consider using the same method from the MeshBuilder class instead
  29258. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29259. * @param name defines the name of the mesh to create
  29260. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29261. * @param radius sets the tube radius size
  29262. * @param tessellation is the number of sides on the tubular surface
  29263. * @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
  29264. * @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
  29265. * @param scene defines the hosting scene
  29266. * @param updatable defines if the mesh must be flagged as updatable
  29267. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29268. * @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)
  29269. * @returns a new Mesh
  29270. */
  29271. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29272. (i: number, distance: number): number;
  29273. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29274. /**
  29275. * Creates a polyhedron mesh.
  29276. * Please consider using the same method from the MeshBuilder class instead.
  29277. * * 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
  29278. * * The parameter `size` (positive float, default 1) sets the polygon size
  29279. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29280. * * 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`
  29281. * * 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
  29282. * * 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)`)
  29283. * * 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
  29284. * * 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
  29285. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29286. * * If you create a double-sided mesh, you can choose what parts of 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
  29287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29288. * @param name defines the name of the mesh to create
  29289. * @param options defines the options used to create the mesh
  29290. * @param scene defines the hosting scene
  29291. * @returns a new Mesh
  29292. */
  29293. static CreatePolyhedron(name: string, options: {
  29294. type?: number;
  29295. size?: number;
  29296. sizeX?: number;
  29297. sizeY?: number;
  29298. sizeZ?: number;
  29299. custom?: any;
  29300. faceUV?: Vector4[];
  29301. faceColors?: Color4[];
  29302. updatable?: boolean;
  29303. sideOrientation?: number;
  29304. }, scene: Scene): Mesh;
  29305. /**
  29306. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29307. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29308. * * 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`)
  29309. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29310. * * 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
  29311. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29312. * * If you create a double-sided mesh, you can choose what parts of 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
  29313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29314. * @param name defines the name of the mesh
  29315. * @param options defines the options used to create the mesh
  29316. * @param scene defines the hosting scene
  29317. * @returns a new Mesh
  29318. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29319. */
  29320. static CreateIcoSphere(name: string, options: {
  29321. radius?: number;
  29322. flat?: boolean;
  29323. subdivisions?: number;
  29324. sideOrientation?: number;
  29325. updatable?: boolean;
  29326. }, scene: Scene): Mesh;
  29327. /**
  29328. * Creates a decal mesh.
  29329. * Please consider using the same method from the MeshBuilder class instead.
  29330. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29331. * @param name defines the name of the mesh
  29332. * @param sourceMesh defines the mesh receiving the decal
  29333. * @param position sets the position of the decal in world coordinates
  29334. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29335. * @param size sets the decal scaling
  29336. * @param angle sets the angle to rotate the decal
  29337. * @returns a new Mesh
  29338. */
  29339. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29340. /**
  29341. * Prepare internal position array for software CPU skinning
  29342. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29343. */
  29344. setPositionsForCPUSkinning(): Float32Array;
  29345. /**
  29346. * Prepare internal normal array for software CPU skinning
  29347. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29348. */
  29349. setNormalsForCPUSkinning(): Float32Array;
  29350. /**
  29351. * Updates the vertex buffer by applying transformation from the bones
  29352. * @param skeleton defines the skeleton to apply to current mesh
  29353. * @returns the current mesh
  29354. */
  29355. applySkeleton(skeleton: Skeleton): Mesh;
  29356. /**
  29357. * 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
  29358. * @param meshes defines the list of meshes to scan
  29359. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29360. */
  29361. static MinMax(meshes: AbstractMesh[]): {
  29362. min: Vector3;
  29363. max: Vector3;
  29364. };
  29365. /**
  29366. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29367. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29368. * @returns a vector3
  29369. */
  29370. static Center(meshesOrMinMaxVector: {
  29371. min: Vector3;
  29372. max: Vector3;
  29373. } | AbstractMesh[]): Vector3;
  29374. /**
  29375. * Merge the array of meshes into a single mesh for performance reasons.
  29376. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29377. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29378. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29379. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29380. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29381. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29382. * @returns a new mesh
  29383. */
  29384. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29385. /** @hidden */
  29386. addInstance(instance: InstancedMesh): void;
  29387. /** @hidden */
  29388. removeInstance(instance: InstancedMesh): void;
  29389. }
  29390. }
  29391. declare module "babylonjs/Cameras/camera" {
  29392. import { SmartArray } from "babylonjs/Misc/smartArray";
  29393. import { Observable } from "babylonjs/Misc/observable";
  29394. import { Nullable } from "babylonjs/types";
  29395. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29396. import { Scene } from "babylonjs/scene";
  29397. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29398. import { Node } from "babylonjs/node";
  29399. import { Mesh } from "babylonjs/Meshes/mesh";
  29400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29401. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29402. import { Viewport } from "babylonjs/Maths/math.viewport";
  29403. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29404. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29405. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29406. import { Ray } from "babylonjs/Culling/ray";
  29407. /**
  29408. * This is the base class of all the camera used in the application.
  29409. * @see http://doc.babylonjs.com/features/cameras
  29410. */
  29411. export class Camera extends Node {
  29412. /** @hidden */
  29413. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29414. /**
  29415. * This is the default projection mode used by the cameras.
  29416. * It helps recreating a feeling of perspective and better appreciate depth.
  29417. * This is the best way to simulate real life cameras.
  29418. */
  29419. static readonly PERSPECTIVE_CAMERA: number;
  29420. /**
  29421. * This helps creating camera with an orthographic mode.
  29422. * 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.
  29423. */
  29424. static readonly ORTHOGRAPHIC_CAMERA: number;
  29425. /**
  29426. * This is the default FOV mode for perspective cameras.
  29427. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29428. */
  29429. static readonly FOVMODE_VERTICAL_FIXED: number;
  29430. /**
  29431. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29432. */
  29433. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29434. /**
  29435. * This specifies ther is no need for a camera rig.
  29436. * Basically only one eye is rendered corresponding to the camera.
  29437. */
  29438. static readonly RIG_MODE_NONE: number;
  29439. /**
  29440. * Simulates a camera Rig with one blue eye and one red eye.
  29441. * This can be use with 3d blue and red glasses.
  29442. */
  29443. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29444. /**
  29445. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29446. */
  29447. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29448. /**
  29449. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29450. */
  29451. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29452. /**
  29453. * Defines that both eyes of the camera will be rendered over under each other.
  29454. */
  29455. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29456. /**
  29457. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29458. */
  29459. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29460. /**
  29461. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29462. */
  29463. static readonly RIG_MODE_VR: number;
  29464. /**
  29465. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29466. */
  29467. static readonly RIG_MODE_WEBVR: number;
  29468. /**
  29469. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29470. */
  29471. static readonly RIG_MODE_CUSTOM: number;
  29472. /**
  29473. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29474. */
  29475. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29476. /**
  29477. * Define the input manager associated with the camera.
  29478. */
  29479. inputs: CameraInputsManager<Camera>;
  29480. /** @hidden */
  29481. _position: Vector3;
  29482. /**
  29483. * Define the current local position of the camera in the scene
  29484. */
  29485. get position(): Vector3;
  29486. set position(newPosition: Vector3);
  29487. /**
  29488. * The vector the camera should consider as up.
  29489. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29490. */
  29491. upVector: Vector3;
  29492. /**
  29493. * Define the current limit on the left side for an orthographic camera
  29494. * In scene unit
  29495. */
  29496. orthoLeft: Nullable<number>;
  29497. /**
  29498. * Define the current limit on the right side for an orthographic camera
  29499. * In scene unit
  29500. */
  29501. orthoRight: Nullable<number>;
  29502. /**
  29503. * Define the current limit on the bottom side for an orthographic camera
  29504. * In scene unit
  29505. */
  29506. orthoBottom: Nullable<number>;
  29507. /**
  29508. * Define the current limit on the top side for an orthographic camera
  29509. * In scene unit
  29510. */
  29511. orthoTop: Nullable<number>;
  29512. /**
  29513. * Field Of View is set in Radians. (default is 0.8)
  29514. */
  29515. fov: number;
  29516. /**
  29517. * Define the minimum distance the camera can see from.
  29518. * This is important to note that the depth buffer are not infinite and the closer it starts
  29519. * the more your scene might encounter depth fighting issue.
  29520. */
  29521. minZ: number;
  29522. /**
  29523. * Define the maximum distance the camera can see to.
  29524. * This is important to note that the depth buffer are not infinite and the further it end
  29525. * the more your scene might encounter depth fighting issue.
  29526. */
  29527. maxZ: number;
  29528. /**
  29529. * Define the default inertia of the camera.
  29530. * This helps giving a smooth feeling to the camera movement.
  29531. */
  29532. inertia: number;
  29533. /**
  29534. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29535. */
  29536. mode: number;
  29537. /**
  29538. * Define whether the camera is intermediate.
  29539. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29540. */
  29541. isIntermediate: boolean;
  29542. /**
  29543. * Define the viewport of the camera.
  29544. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29545. */
  29546. viewport: Viewport;
  29547. /**
  29548. * Restricts the camera to viewing objects with the same layerMask.
  29549. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29550. */
  29551. layerMask: number;
  29552. /**
  29553. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29554. */
  29555. fovMode: number;
  29556. /**
  29557. * Rig mode of the camera.
  29558. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29559. * This is normally controlled byt the camera themselves as internal use.
  29560. */
  29561. cameraRigMode: number;
  29562. /**
  29563. * Defines the distance between both "eyes" in case of a RIG
  29564. */
  29565. interaxialDistance: number;
  29566. /**
  29567. * Defines if stereoscopic rendering is done side by side or over under.
  29568. */
  29569. isStereoscopicSideBySide: boolean;
  29570. /**
  29571. * 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
  29572. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29573. * else in the scene. (Eg. security camera)
  29574. *
  29575. * 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)
  29576. */
  29577. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29578. /**
  29579. * When set, the camera will render to this render target instead of the default canvas
  29580. *
  29581. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29582. */
  29583. outputRenderTarget: Nullable<RenderTargetTexture>;
  29584. /**
  29585. * Observable triggered when the camera view matrix has changed.
  29586. */
  29587. onViewMatrixChangedObservable: Observable<Camera>;
  29588. /**
  29589. * Observable triggered when the camera Projection matrix has changed.
  29590. */
  29591. onProjectionMatrixChangedObservable: Observable<Camera>;
  29592. /**
  29593. * Observable triggered when the inputs have been processed.
  29594. */
  29595. onAfterCheckInputsObservable: Observable<Camera>;
  29596. /**
  29597. * Observable triggered when reset has been called and applied to the camera.
  29598. */
  29599. onRestoreStateObservable: Observable<Camera>;
  29600. /**
  29601. * Is this camera a part of a rig system?
  29602. */
  29603. isRigCamera: boolean;
  29604. /**
  29605. * If isRigCamera set to true this will be set with the parent camera.
  29606. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29607. */
  29608. rigParent?: Camera;
  29609. /** @hidden */
  29610. _cameraRigParams: any;
  29611. /** @hidden */
  29612. _rigCameras: Camera[];
  29613. /** @hidden */
  29614. _rigPostProcess: Nullable<PostProcess>;
  29615. protected _webvrViewMatrix: Matrix;
  29616. /** @hidden */
  29617. _skipRendering: boolean;
  29618. /** @hidden */
  29619. _projectionMatrix: Matrix;
  29620. /** @hidden */
  29621. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29622. /** @hidden */
  29623. _activeMeshes: SmartArray<AbstractMesh>;
  29624. protected _globalPosition: Vector3;
  29625. /** @hidden */
  29626. _computedViewMatrix: Matrix;
  29627. private _doNotComputeProjectionMatrix;
  29628. private _transformMatrix;
  29629. private _frustumPlanes;
  29630. private _refreshFrustumPlanes;
  29631. private _storedFov;
  29632. private _stateStored;
  29633. /**
  29634. * Instantiates a new camera object.
  29635. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29636. * @see http://doc.babylonjs.com/features/cameras
  29637. * @param name Defines the name of the camera in the scene
  29638. * @param position Defines the position of the camera
  29639. * @param scene Defines the scene the camera belongs too
  29640. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29641. */
  29642. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29643. /**
  29644. * Store current camera state (fov, position, etc..)
  29645. * @returns the camera
  29646. */
  29647. storeState(): Camera;
  29648. /**
  29649. * Restores the camera state values if it has been stored. You must call storeState() first
  29650. */
  29651. protected _restoreStateValues(): boolean;
  29652. /**
  29653. * Restored camera state. You must call storeState() first.
  29654. * @returns true if restored and false otherwise
  29655. */
  29656. restoreState(): boolean;
  29657. /**
  29658. * Gets the class name of the camera.
  29659. * @returns the class name
  29660. */
  29661. getClassName(): string;
  29662. /** @hidden */
  29663. readonly _isCamera: boolean;
  29664. /**
  29665. * Gets a string representation of the camera useful for debug purpose.
  29666. * @param fullDetails Defines that a more verboe level of logging is required
  29667. * @returns the string representation
  29668. */
  29669. toString(fullDetails?: boolean): string;
  29670. /**
  29671. * Gets the current world space position of the camera.
  29672. */
  29673. get globalPosition(): Vector3;
  29674. /**
  29675. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29676. * @returns the active meshe list
  29677. */
  29678. getActiveMeshes(): SmartArray<AbstractMesh>;
  29679. /**
  29680. * Check whether a mesh is part of the current active mesh list of the camera
  29681. * @param mesh Defines the mesh to check
  29682. * @returns true if active, false otherwise
  29683. */
  29684. isActiveMesh(mesh: Mesh): boolean;
  29685. /**
  29686. * Is this camera ready to be used/rendered
  29687. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29688. * @return true if the camera is ready
  29689. */
  29690. isReady(completeCheck?: boolean): boolean;
  29691. /** @hidden */
  29692. _initCache(): void;
  29693. /** @hidden */
  29694. _updateCache(ignoreParentClass?: boolean): void;
  29695. /** @hidden */
  29696. _isSynchronized(): boolean;
  29697. /** @hidden */
  29698. _isSynchronizedViewMatrix(): boolean;
  29699. /** @hidden */
  29700. _isSynchronizedProjectionMatrix(): boolean;
  29701. /**
  29702. * Attach the input controls to a specific dom element to get the input from.
  29703. * @param element Defines the element the controls should be listened from
  29704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29705. */
  29706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29707. /**
  29708. * Detach the current controls from the specified dom element.
  29709. * @param element Defines the element to stop listening the inputs from
  29710. */
  29711. detachControl(element: HTMLElement): void;
  29712. /**
  29713. * Update the camera state according to the different inputs gathered during the frame.
  29714. */
  29715. update(): void;
  29716. /** @hidden */
  29717. _checkInputs(): void;
  29718. /** @hidden */
  29719. get rigCameras(): Camera[];
  29720. /**
  29721. * Gets the post process used by the rig cameras
  29722. */
  29723. get rigPostProcess(): Nullable<PostProcess>;
  29724. /**
  29725. * Internal, gets the first post proces.
  29726. * @returns the first post process to be run on this camera.
  29727. */
  29728. _getFirstPostProcess(): Nullable<PostProcess>;
  29729. private _cascadePostProcessesToRigCams;
  29730. /**
  29731. * Attach a post process to the camera.
  29732. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29733. * @param postProcess The post process to attach to the camera
  29734. * @param insertAt The position of the post process in case several of them are in use in the scene
  29735. * @returns the position the post process has been inserted at
  29736. */
  29737. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29738. /**
  29739. * Detach a post process to the camera.
  29740. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29741. * @param postProcess The post process to detach from the camera
  29742. */
  29743. detachPostProcess(postProcess: PostProcess): void;
  29744. /**
  29745. * Gets the current world matrix of the camera
  29746. */
  29747. getWorldMatrix(): Matrix;
  29748. /** @hidden */
  29749. _getViewMatrix(): Matrix;
  29750. /**
  29751. * Gets the current view matrix of the camera.
  29752. * @param force forces the camera to recompute the matrix without looking at the cached state
  29753. * @returns the view matrix
  29754. */
  29755. getViewMatrix(force?: boolean): Matrix;
  29756. /**
  29757. * Freeze the projection matrix.
  29758. * It will prevent the cache check of the camera projection compute and can speed up perf
  29759. * if no parameter of the camera are meant to change
  29760. * @param projection Defines manually a projection if necessary
  29761. */
  29762. freezeProjectionMatrix(projection?: Matrix): void;
  29763. /**
  29764. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29765. */
  29766. unfreezeProjectionMatrix(): void;
  29767. /**
  29768. * Gets the current projection matrix of the camera.
  29769. * @param force forces the camera to recompute the matrix without looking at the cached state
  29770. * @returns the projection matrix
  29771. */
  29772. getProjectionMatrix(force?: boolean): Matrix;
  29773. /**
  29774. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29775. * @returns a Matrix
  29776. */
  29777. getTransformationMatrix(): Matrix;
  29778. private _updateFrustumPlanes;
  29779. /**
  29780. * Checks if a cullable object (mesh...) is in the camera frustum
  29781. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29782. * @param target The object to check
  29783. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29784. * @returns true if the object is in frustum otherwise false
  29785. */
  29786. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29787. /**
  29788. * Checks if a cullable object (mesh...) is in the camera frustum
  29789. * Unlike isInFrustum this cheks the full bounding box
  29790. * @param target The object to check
  29791. * @returns true if the object is in frustum otherwise false
  29792. */
  29793. isCompletelyInFrustum(target: ICullable): boolean;
  29794. /**
  29795. * Gets a ray in the forward direction from the camera.
  29796. * @param length Defines the length of the ray to create
  29797. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29798. * @param origin Defines the start point of the ray which defaults to the camera position
  29799. * @returns the forward ray
  29800. */
  29801. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29802. /**
  29803. * Releases resources associated with this node.
  29804. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29805. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29806. */
  29807. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29808. /** @hidden */
  29809. _isLeftCamera: boolean;
  29810. /**
  29811. * Gets the left camera of a rig setup in case of Rigged Camera
  29812. */
  29813. get isLeftCamera(): boolean;
  29814. /** @hidden */
  29815. _isRightCamera: boolean;
  29816. /**
  29817. * Gets the right camera of a rig setup in case of Rigged Camera
  29818. */
  29819. get isRightCamera(): boolean;
  29820. /**
  29821. * Gets the left camera of a rig setup in case of Rigged Camera
  29822. */
  29823. get leftCamera(): Nullable<FreeCamera>;
  29824. /**
  29825. * Gets the right camera of a rig setup in case of Rigged Camera
  29826. */
  29827. get rightCamera(): Nullable<FreeCamera>;
  29828. /**
  29829. * Gets the left camera target of a rig setup in case of Rigged Camera
  29830. * @returns the target position
  29831. */
  29832. getLeftTarget(): Nullable<Vector3>;
  29833. /**
  29834. * Gets the right camera target of a rig setup in case of Rigged Camera
  29835. * @returns the target position
  29836. */
  29837. getRightTarget(): Nullable<Vector3>;
  29838. /**
  29839. * @hidden
  29840. */
  29841. setCameraRigMode(mode: number, rigParams: any): void;
  29842. /** @hidden */
  29843. static _setStereoscopicRigMode(camera: Camera): void;
  29844. /** @hidden */
  29845. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29846. /** @hidden */
  29847. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29848. /** @hidden */
  29849. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29850. /** @hidden */
  29851. _getVRProjectionMatrix(): Matrix;
  29852. protected _updateCameraRotationMatrix(): void;
  29853. protected _updateWebVRCameraRotationMatrix(): void;
  29854. /**
  29855. * This function MUST be overwritten by the different WebVR cameras available.
  29856. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29857. * @hidden
  29858. */
  29859. _getWebVRProjectionMatrix(): Matrix;
  29860. /**
  29861. * This function MUST be overwritten by the different WebVR cameras available.
  29862. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29863. * @hidden
  29864. */
  29865. _getWebVRViewMatrix(): Matrix;
  29866. /** @hidden */
  29867. setCameraRigParameter(name: string, value: any): void;
  29868. /**
  29869. * needs to be overridden by children so sub has required properties to be copied
  29870. * @hidden
  29871. */
  29872. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29873. /**
  29874. * May need to be overridden by children
  29875. * @hidden
  29876. */
  29877. _updateRigCameras(): void;
  29878. /** @hidden */
  29879. _setupInputs(): void;
  29880. /**
  29881. * Serialiaze the camera setup to a json represention
  29882. * @returns the JSON representation
  29883. */
  29884. serialize(): any;
  29885. /**
  29886. * Clones the current camera.
  29887. * @param name The cloned camera name
  29888. * @returns the cloned camera
  29889. */
  29890. clone(name: string): Camera;
  29891. /**
  29892. * Gets the direction of the camera relative to a given local axis.
  29893. * @param localAxis Defines the reference axis to provide a relative direction.
  29894. * @return the direction
  29895. */
  29896. getDirection(localAxis: Vector3): Vector3;
  29897. /**
  29898. * Returns the current camera absolute rotation
  29899. */
  29900. get absoluteRotation(): Quaternion;
  29901. /**
  29902. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29903. * @param localAxis Defines the reference axis to provide a relative direction.
  29904. * @param result Defines the vector to store the result in
  29905. */
  29906. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29907. /**
  29908. * Gets a camera constructor for a given camera type
  29909. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29910. * @param name The name of the camera the result will be able to instantiate
  29911. * @param scene The scene the result will construct the camera in
  29912. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29913. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29914. * @returns a factory method to construc the camera
  29915. */
  29916. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29917. /**
  29918. * Compute the world matrix of the camera.
  29919. * @returns the camera world matrix
  29920. */
  29921. computeWorldMatrix(): Matrix;
  29922. /**
  29923. * Parse a JSON and creates the camera from the parsed information
  29924. * @param parsedCamera The JSON to parse
  29925. * @param scene The scene to instantiate the camera in
  29926. * @returns the newly constructed camera
  29927. */
  29928. static Parse(parsedCamera: any, scene: Scene): Camera;
  29929. }
  29930. }
  29931. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29932. import { Nullable } from "babylonjs/types";
  29933. import { Scene } from "babylonjs/scene";
  29934. import { Vector4 } from "babylonjs/Maths/math.vector";
  29935. import { Mesh } from "babylonjs/Meshes/mesh";
  29936. /**
  29937. * Class containing static functions to help procedurally build meshes
  29938. */
  29939. export class DiscBuilder {
  29940. /**
  29941. * Creates a plane polygonal mesh. By default, this is a disc
  29942. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29943. * * 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
  29944. * * 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
  29945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29948. * @param name defines the name of the mesh
  29949. * @param options defines the options used to create the mesh
  29950. * @param scene defines the hosting scene
  29951. * @returns the plane polygonal mesh
  29952. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29953. */
  29954. static CreateDisc(name: string, options: {
  29955. radius?: number;
  29956. tessellation?: number;
  29957. arc?: number;
  29958. updatable?: boolean;
  29959. sideOrientation?: number;
  29960. frontUVs?: Vector4;
  29961. backUVs?: Vector4;
  29962. }, scene?: Nullable<Scene>): Mesh;
  29963. }
  29964. }
  29965. declare module "babylonjs/Materials/fresnelParameters" {
  29966. import { DeepImmutable } from "babylonjs/types";
  29967. import { Color3 } from "babylonjs/Maths/math.color";
  29968. /**
  29969. * Options to be used when creating a FresnelParameters.
  29970. */
  29971. export type IFresnelParametersCreationOptions = {
  29972. /**
  29973. * Define the color used on edges (grazing angle)
  29974. */
  29975. leftColor?: Color3;
  29976. /**
  29977. * Define the color used on center
  29978. */
  29979. rightColor?: Color3;
  29980. /**
  29981. * Define bias applied to computed fresnel term
  29982. */
  29983. bias?: number;
  29984. /**
  29985. * Defined the power exponent applied to fresnel term
  29986. */
  29987. power?: number;
  29988. /**
  29989. * Define if the fresnel effect is enable or not.
  29990. */
  29991. isEnabled?: boolean;
  29992. };
  29993. /**
  29994. * Serialized format for FresnelParameters.
  29995. */
  29996. export type IFresnelParametersSerialized = {
  29997. /**
  29998. * Define the color used on edges (grazing angle) [as an array]
  29999. */
  30000. leftColor: number[];
  30001. /**
  30002. * Define the color used on center [as an array]
  30003. */
  30004. rightColor: number[];
  30005. /**
  30006. * Define bias applied to computed fresnel term
  30007. */
  30008. bias: number;
  30009. /**
  30010. * Defined the power exponent applied to fresnel term
  30011. */
  30012. power?: number;
  30013. /**
  30014. * Define if the fresnel effect is enable or not.
  30015. */
  30016. isEnabled: boolean;
  30017. };
  30018. /**
  30019. * This represents all the required information to add a fresnel effect on a material:
  30020. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30021. */
  30022. export class FresnelParameters {
  30023. private _isEnabled;
  30024. /**
  30025. * Define if the fresnel effect is enable or not.
  30026. */
  30027. get isEnabled(): boolean;
  30028. set isEnabled(value: boolean);
  30029. /**
  30030. * Define the color used on edges (grazing angle)
  30031. */
  30032. leftColor: Color3;
  30033. /**
  30034. * Define the color used on center
  30035. */
  30036. rightColor: Color3;
  30037. /**
  30038. * Define bias applied to computed fresnel term
  30039. */
  30040. bias: number;
  30041. /**
  30042. * Defined the power exponent applied to fresnel term
  30043. */
  30044. power: number;
  30045. /**
  30046. * Creates a new FresnelParameters object.
  30047. *
  30048. * @param options provide your own settings to optionally to override defaults
  30049. */
  30050. constructor(options?: IFresnelParametersCreationOptions);
  30051. /**
  30052. * Clones the current fresnel and its valuues
  30053. * @returns a clone fresnel configuration
  30054. */
  30055. clone(): FresnelParameters;
  30056. /**
  30057. * Determines equality between FresnelParameters objects
  30058. * @param otherFresnelParameters defines the second operand
  30059. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30060. */
  30061. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30062. /**
  30063. * Serializes the current fresnel parameters to a JSON representation.
  30064. * @return the JSON serialization
  30065. */
  30066. serialize(): IFresnelParametersSerialized;
  30067. /**
  30068. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30069. * @param parsedFresnelParameters Define the JSON representation
  30070. * @returns the parsed parameters
  30071. */
  30072. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30073. }
  30074. }
  30075. declare module "babylonjs/Materials/materialFlags" {
  30076. /**
  30077. * This groups all the flags used to control the materials channel.
  30078. */
  30079. export class MaterialFlags {
  30080. private static _DiffuseTextureEnabled;
  30081. /**
  30082. * Are diffuse textures enabled in the application.
  30083. */
  30084. static get DiffuseTextureEnabled(): boolean;
  30085. static set DiffuseTextureEnabled(value: boolean);
  30086. private static _DetailTextureEnabled;
  30087. /**
  30088. * Are detail textures enabled in the application.
  30089. */
  30090. static get DetailTextureEnabled(): boolean;
  30091. static set DetailTextureEnabled(value: boolean);
  30092. private static _AmbientTextureEnabled;
  30093. /**
  30094. * Are ambient textures enabled in the application.
  30095. */
  30096. static get AmbientTextureEnabled(): boolean;
  30097. static set AmbientTextureEnabled(value: boolean);
  30098. private static _OpacityTextureEnabled;
  30099. /**
  30100. * Are opacity textures enabled in the application.
  30101. */
  30102. static get OpacityTextureEnabled(): boolean;
  30103. static set OpacityTextureEnabled(value: boolean);
  30104. private static _ReflectionTextureEnabled;
  30105. /**
  30106. * Are reflection textures enabled in the application.
  30107. */
  30108. static get ReflectionTextureEnabled(): boolean;
  30109. static set ReflectionTextureEnabled(value: boolean);
  30110. private static _EmissiveTextureEnabled;
  30111. /**
  30112. * Are emissive textures enabled in the application.
  30113. */
  30114. static get EmissiveTextureEnabled(): boolean;
  30115. static set EmissiveTextureEnabled(value: boolean);
  30116. private static _SpecularTextureEnabled;
  30117. /**
  30118. * Are specular textures enabled in the application.
  30119. */
  30120. static get SpecularTextureEnabled(): boolean;
  30121. static set SpecularTextureEnabled(value: boolean);
  30122. private static _BumpTextureEnabled;
  30123. /**
  30124. * Are bump textures enabled in the application.
  30125. */
  30126. static get BumpTextureEnabled(): boolean;
  30127. static set BumpTextureEnabled(value: boolean);
  30128. private static _LightmapTextureEnabled;
  30129. /**
  30130. * Are lightmap textures enabled in the application.
  30131. */
  30132. static get LightmapTextureEnabled(): boolean;
  30133. static set LightmapTextureEnabled(value: boolean);
  30134. private static _RefractionTextureEnabled;
  30135. /**
  30136. * Are refraction textures enabled in the application.
  30137. */
  30138. static get RefractionTextureEnabled(): boolean;
  30139. static set RefractionTextureEnabled(value: boolean);
  30140. private static _ColorGradingTextureEnabled;
  30141. /**
  30142. * Are color grading textures enabled in the application.
  30143. */
  30144. static get ColorGradingTextureEnabled(): boolean;
  30145. static set ColorGradingTextureEnabled(value: boolean);
  30146. private static _FresnelEnabled;
  30147. /**
  30148. * Are fresnels enabled in the application.
  30149. */
  30150. static get FresnelEnabled(): boolean;
  30151. static set FresnelEnabled(value: boolean);
  30152. private static _ClearCoatTextureEnabled;
  30153. /**
  30154. * Are clear coat textures enabled in the application.
  30155. */
  30156. static get ClearCoatTextureEnabled(): boolean;
  30157. static set ClearCoatTextureEnabled(value: boolean);
  30158. private static _ClearCoatBumpTextureEnabled;
  30159. /**
  30160. * Are clear coat bump textures enabled in the application.
  30161. */
  30162. static get ClearCoatBumpTextureEnabled(): boolean;
  30163. static set ClearCoatBumpTextureEnabled(value: boolean);
  30164. private static _ClearCoatTintTextureEnabled;
  30165. /**
  30166. * Are clear coat tint textures enabled in the application.
  30167. */
  30168. static get ClearCoatTintTextureEnabled(): boolean;
  30169. static set ClearCoatTintTextureEnabled(value: boolean);
  30170. private static _SheenTextureEnabled;
  30171. /**
  30172. * Are sheen textures enabled in the application.
  30173. */
  30174. static get SheenTextureEnabled(): boolean;
  30175. static set SheenTextureEnabled(value: boolean);
  30176. private static _AnisotropicTextureEnabled;
  30177. /**
  30178. * Are anisotropic textures enabled in the application.
  30179. */
  30180. static get AnisotropicTextureEnabled(): boolean;
  30181. static set AnisotropicTextureEnabled(value: boolean);
  30182. private static _ThicknessTextureEnabled;
  30183. /**
  30184. * Are thickness textures enabled in the application.
  30185. */
  30186. static get ThicknessTextureEnabled(): boolean;
  30187. static set ThicknessTextureEnabled(value: boolean);
  30188. }
  30189. }
  30190. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30191. /** @hidden */
  30192. export var defaultFragmentDeclaration: {
  30193. name: string;
  30194. shader: string;
  30195. };
  30196. }
  30197. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30198. /** @hidden */
  30199. export var defaultUboDeclaration: {
  30200. name: string;
  30201. shader: string;
  30202. };
  30203. }
  30204. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30205. /** @hidden */
  30206. export var lightFragmentDeclaration: {
  30207. name: string;
  30208. shader: string;
  30209. };
  30210. }
  30211. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30212. /** @hidden */
  30213. export var lightUboDeclaration: {
  30214. name: string;
  30215. shader: string;
  30216. };
  30217. }
  30218. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30219. /** @hidden */
  30220. export var lightsFragmentFunctions: {
  30221. name: string;
  30222. shader: string;
  30223. };
  30224. }
  30225. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30226. /** @hidden */
  30227. export var shadowsFragmentFunctions: {
  30228. name: string;
  30229. shader: string;
  30230. };
  30231. }
  30232. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30233. /** @hidden */
  30234. export var fresnelFunction: {
  30235. name: string;
  30236. shader: string;
  30237. };
  30238. }
  30239. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30240. /** @hidden */
  30241. export var bumpFragmentMainFunctions: {
  30242. name: string;
  30243. shader: string;
  30244. };
  30245. }
  30246. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30247. /** @hidden */
  30248. export var bumpFragmentFunctions: {
  30249. name: string;
  30250. shader: string;
  30251. };
  30252. }
  30253. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30254. /** @hidden */
  30255. export var logDepthDeclaration: {
  30256. name: string;
  30257. shader: string;
  30258. };
  30259. }
  30260. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30261. /** @hidden */
  30262. export var bumpFragment: {
  30263. name: string;
  30264. shader: string;
  30265. };
  30266. }
  30267. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30268. /** @hidden */
  30269. export var depthPrePass: {
  30270. name: string;
  30271. shader: string;
  30272. };
  30273. }
  30274. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30275. /** @hidden */
  30276. export var lightFragment: {
  30277. name: string;
  30278. shader: string;
  30279. };
  30280. }
  30281. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30282. /** @hidden */
  30283. export var logDepthFragment: {
  30284. name: string;
  30285. shader: string;
  30286. };
  30287. }
  30288. declare module "babylonjs/Shaders/default.fragment" {
  30289. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30290. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30291. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30292. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30293. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30294. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30295. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30296. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30297. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30298. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30299. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30300. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30301. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30302. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30303. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30304. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30305. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30306. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30307. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30308. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30309. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30310. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30311. /** @hidden */
  30312. export var defaultPixelShader: {
  30313. name: string;
  30314. shader: string;
  30315. };
  30316. }
  30317. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30318. /** @hidden */
  30319. export var defaultVertexDeclaration: {
  30320. name: string;
  30321. shader: string;
  30322. };
  30323. }
  30324. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30325. /** @hidden */
  30326. export var bumpVertexDeclaration: {
  30327. name: string;
  30328. shader: string;
  30329. };
  30330. }
  30331. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30332. /** @hidden */
  30333. export var bumpVertex: {
  30334. name: string;
  30335. shader: string;
  30336. };
  30337. }
  30338. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30339. /** @hidden */
  30340. export var fogVertex: {
  30341. name: string;
  30342. shader: string;
  30343. };
  30344. }
  30345. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30346. /** @hidden */
  30347. export var shadowsVertex: {
  30348. name: string;
  30349. shader: string;
  30350. };
  30351. }
  30352. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30353. /** @hidden */
  30354. export var pointCloudVertex: {
  30355. name: string;
  30356. shader: string;
  30357. };
  30358. }
  30359. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30360. /** @hidden */
  30361. export var logDepthVertex: {
  30362. name: string;
  30363. shader: string;
  30364. };
  30365. }
  30366. declare module "babylonjs/Shaders/default.vertex" {
  30367. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30368. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30369. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30370. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30371. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30372. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30373. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30374. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30375. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30376. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30377. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30378. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30379. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30380. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30381. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30382. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30383. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30384. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30385. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30386. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30387. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30388. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30389. /** @hidden */
  30390. export var defaultVertexShader: {
  30391. name: string;
  30392. shader: string;
  30393. };
  30394. }
  30395. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  30396. import { Nullable } from "babylonjs/types";
  30397. import { Scene } from "babylonjs/scene";
  30398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30399. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30400. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30401. /**
  30402. * @hidden
  30403. */
  30404. export interface IMaterialDetailMapDefines {
  30405. DETAIL: boolean;
  30406. DETAILDIRECTUV: number;
  30407. DETAIL_NORMALBLENDMETHOD: number;
  30408. /** @hidden */
  30409. _areTexturesDirty: boolean;
  30410. }
  30411. /**
  30412. * Define the code related to the detail map parameters of a material
  30413. *
  30414. * Inspired from:
  30415. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  30416. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30417. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30418. */
  30419. export class DetailMapConfiguration {
  30420. private _texture;
  30421. /**
  30422. * The detail texture of the material.
  30423. */
  30424. texture: Nullable<BaseTexture>;
  30425. /**
  30426. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30427. * Bigger values mean stronger blending
  30428. */
  30429. diffuseBlendLevel: number;
  30430. /**
  30431. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30432. * Bigger values mean stronger blending. Only used with PBR materials
  30433. */
  30434. roughnessBlendLevel: number;
  30435. /**
  30436. * Defines how strong the bump effect from the detail map is
  30437. * Bigger values mean stronger effect
  30438. */
  30439. bumpLevel: number;
  30440. private _normalBlendMethod;
  30441. /**
  30442. * The method used to blend the bump and detail normals together
  30443. */
  30444. normalBlendMethod: number;
  30445. private _isEnabled;
  30446. /**
  30447. * Enable or disable the detail map on this material
  30448. */
  30449. isEnabled: boolean;
  30450. /** @hidden */
  30451. private _internalMarkAllSubMeshesAsTexturesDirty;
  30452. /** @hidden */
  30453. _markAllSubMeshesAsTexturesDirty(): void;
  30454. /**
  30455. * Instantiate a new detail map
  30456. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30457. */
  30458. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30459. /**
  30460. * Gets whether the submesh is ready to be used or not.
  30461. * @param defines the list of "defines" to update.
  30462. * @param scene defines the scene the material belongs to.
  30463. * @returns - boolean indicating that the submesh is ready or not.
  30464. */
  30465. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30466. /**
  30467. * Update the defines for detail map usage
  30468. * @param defines the list of "defines" to update.
  30469. * @param scene defines the scene the material belongs to.
  30470. */
  30471. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30472. /**
  30473. * Binds the material data.
  30474. * @param uniformBuffer defines the Uniform buffer to fill in.
  30475. * @param scene defines the scene the material belongs to.
  30476. * @param isFrozen defines whether the material is frozen or not.
  30477. */
  30478. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30479. /**
  30480. * Checks to see if a texture is used in the material.
  30481. * @param texture - Base texture to use.
  30482. * @returns - Boolean specifying if a texture is used in the material.
  30483. */
  30484. hasTexture(texture: BaseTexture): boolean;
  30485. /**
  30486. * Returns an array of the actively used textures.
  30487. * @param activeTextures Array of BaseTextures
  30488. */
  30489. getActiveTextures(activeTextures: BaseTexture[]): void;
  30490. /**
  30491. * Returns the animatable textures.
  30492. * @param animatables Array of animatable textures.
  30493. */
  30494. getAnimatables(animatables: IAnimatable[]): void;
  30495. /**
  30496. * Disposes the resources of the material.
  30497. * @param forceDisposeTextures - Forces the disposal of all textures.
  30498. */
  30499. dispose(forceDisposeTextures?: boolean): void;
  30500. /**
  30501. * Get the current class name useful for serialization or dynamic coding.
  30502. * @returns "DetailMap"
  30503. */
  30504. getClassName(): string;
  30505. /**
  30506. * Add the required uniforms to the current list.
  30507. * @param uniforms defines the current uniform list.
  30508. */
  30509. static AddUniforms(uniforms: string[]): void;
  30510. /**
  30511. * Add the required samplers to the current list.
  30512. * @param samplers defines the current sampler list.
  30513. */
  30514. static AddSamplers(samplers: string[]): void;
  30515. /**
  30516. * Add the required uniforms to the current buffer.
  30517. * @param uniformBuffer defines the current uniform buffer.
  30518. */
  30519. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30520. /**
  30521. * Makes a duplicate of the current instance into another one.
  30522. * @param detailMap define the instance where to copy the info
  30523. */
  30524. copyTo(detailMap: DetailMapConfiguration): void;
  30525. /**
  30526. * Serializes this detail map instance
  30527. * @returns - An object with the serialized instance.
  30528. */
  30529. serialize(): any;
  30530. /**
  30531. * Parses a detail map setting from a serialized object.
  30532. * @param source - Serialized object.
  30533. * @param scene Defines the scene we are parsing for
  30534. * @param rootUrl Defines the rootUrl to load from
  30535. */
  30536. parse(source: any, scene: Scene, rootUrl: string): void;
  30537. }
  30538. }
  30539. declare module "babylonjs/Materials/standardMaterial" {
  30540. import { SmartArray } from "babylonjs/Misc/smartArray";
  30541. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30542. import { Nullable } from "babylonjs/types";
  30543. import { Scene } from "babylonjs/scene";
  30544. import { Matrix } from "babylonjs/Maths/math.vector";
  30545. import { Color3 } from "babylonjs/Maths/math.color";
  30546. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30548. import { Mesh } from "babylonjs/Meshes/mesh";
  30549. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30550. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30551. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30552. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30553. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30554. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30555. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30556. import "babylonjs/Shaders/default.fragment";
  30557. import "babylonjs/Shaders/default.vertex";
  30558. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  30559. /** @hidden */
  30560. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30561. MAINUV1: boolean;
  30562. MAINUV2: boolean;
  30563. DIFFUSE: boolean;
  30564. DIFFUSEDIRECTUV: number;
  30565. DETAIL: boolean;
  30566. DETAILDIRECTUV: number;
  30567. DETAIL_NORMALBLENDMETHOD: number;
  30568. AMBIENT: boolean;
  30569. AMBIENTDIRECTUV: number;
  30570. OPACITY: boolean;
  30571. OPACITYDIRECTUV: number;
  30572. OPACITYRGB: boolean;
  30573. REFLECTION: boolean;
  30574. EMISSIVE: boolean;
  30575. EMISSIVEDIRECTUV: number;
  30576. SPECULAR: boolean;
  30577. SPECULARDIRECTUV: number;
  30578. BUMP: boolean;
  30579. BUMPDIRECTUV: number;
  30580. PARALLAX: boolean;
  30581. PARALLAXOCCLUSION: boolean;
  30582. SPECULAROVERALPHA: boolean;
  30583. CLIPPLANE: boolean;
  30584. CLIPPLANE2: boolean;
  30585. CLIPPLANE3: boolean;
  30586. CLIPPLANE4: boolean;
  30587. CLIPPLANE5: boolean;
  30588. CLIPPLANE6: boolean;
  30589. ALPHATEST: boolean;
  30590. DEPTHPREPASS: boolean;
  30591. ALPHAFROMDIFFUSE: boolean;
  30592. POINTSIZE: boolean;
  30593. FOG: boolean;
  30594. SPECULARTERM: boolean;
  30595. DIFFUSEFRESNEL: boolean;
  30596. OPACITYFRESNEL: boolean;
  30597. REFLECTIONFRESNEL: boolean;
  30598. REFRACTIONFRESNEL: boolean;
  30599. EMISSIVEFRESNEL: boolean;
  30600. FRESNEL: boolean;
  30601. NORMAL: boolean;
  30602. UV1: boolean;
  30603. UV2: boolean;
  30604. VERTEXCOLOR: boolean;
  30605. VERTEXALPHA: boolean;
  30606. NUM_BONE_INFLUENCERS: number;
  30607. BonesPerMesh: number;
  30608. BONETEXTURE: boolean;
  30609. INSTANCES: boolean;
  30610. THIN_INSTANCES: boolean;
  30611. GLOSSINESS: boolean;
  30612. ROUGHNESS: boolean;
  30613. EMISSIVEASILLUMINATION: boolean;
  30614. LINKEMISSIVEWITHDIFFUSE: boolean;
  30615. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30616. LIGHTMAP: boolean;
  30617. LIGHTMAPDIRECTUV: number;
  30618. OBJECTSPACE_NORMALMAP: boolean;
  30619. USELIGHTMAPASSHADOWMAP: boolean;
  30620. REFLECTIONMAP_3D: boolean;
  30621. REFLECTIONMAP_SPHERICAL: boolean;
  30622. REFLECTIONMAP_PLANAR: boolean;
  30623. REFLECTIONMAP_CUBIC: boolean;
  30624. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30625. REFLECTIONMAP_PROJECTION: boolean;
  30626. REFLECTIONMAP_SKYBOX: boolean;
  30627. REFLECTIONMAP_EXPLICIT: boolean;
  30628. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30629. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30630. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30631. INVERTCUBICMAP: boolean;
  30632. LOGARITHMICDEPTH: boolean;
  30633. REFRACTION: boolean;
  30634. REFRACTIONMAP_3D: boolean;
  30635. REFLECTIONOVERALPHA: boolean;
  30636. TWOSIDEDLIGHTING: boolean;
  30637. SHADOWFLOAT: boolean;
  30638. MORPHTARGETS: boolean;
  30639. MORPHTARGETS_NORMAL: boolean;
  30640. MORPHTARGETS_TANGENT: boolean;
  30641. MORPHTARGETS_UV: boolean;
  30642. NUM_MORPH_INFLUENCERS: number;
  30643. NONUNIFORMSCALING: boolean;
  30644. PREMULTIPLYALPHA: boolean;
  30645. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30646. ALPHABLEND: boolean;
  30647. RGBDLIGHTMAP: boolean;
  30648. RGBDREFLECTION: boolean;
  30649. RGBDREFRACTION: boolean;
  30650. IMAGEPROCESSING: boolean;
  30651. VIGNETTE: boolean;
  30652. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30653. VIGNETTEBLENDMODEOPAQUE: boolean;
  30654. TONEMAPPING: boolean;
  30655. TONEMAPPING_ACES: boolean;
  30656. CONTRAST: boolean;
  30657. COLORCURVES: boolean;
  30658. COLORGRADING: boolean;
  30659. COLORGRADING3D: boolean;
  30660. SAMPLER3DGREENDEPTH: boolean;
  30661. SAMPLER3DBGRMAP: boolean;
  30662. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30663. MULTIVIEW: boolean;
  30664. /**
  30665. * If the reflection texture on this material is in linear color space
  30666. * @hidden
  30667. */
  30668. IS_REFLECTION_LINEAR: boolean;
  30669. /**
  30670. * If the refraction texture on this material is in linear color space
  30671. * @hidden
  30672. */
  30673. IS_REFRACTION_LINEAR: boolean;
  30674. EXPOSURE: boolean;
  30675. constructor();
  30676. setReflectionMode(modeToEnable: string): void;
  30677. }
  30678. /**
  30679. * This is the default material used in Babylon. It is the best trade off between quality
  30680. * and performances.
  30681. * @see http://doc.babylonjs.com/babylon101/materials
  30682. */
  30683. export class StandardMaterial extends PushMaterial {
  30684. private _diffuseTexture;
  30685. /**
  30686. * The basic texture of the material as viewed under a light.
  30687. */
  30688. diffuseTexture: Nullable<BaseTexture>;
  30689. private _ambientTexture;
  30690. /**
  30691. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30692. */
  30693. ambientTexture: Nullable<BaseTexture>;
  30694. private _opacityTexture;
  30695. /**
  30696. * Define the transparency of the material from a texture.
  30697. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30698. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30699. */
  30700. opacityTexture: Nullable<BaseTexture>;
  30701. private _reflectionTexture;
  30702. /**
  30703. * Define the texture used to display the reflection.
  30704. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30705. */
  30706. reflectionTexture: Nullable<BaseTexture>;
  30707. private _emissiveTexture;
  30708. /**
  30709. * Define texture of the material as if self lit.
  30710. * This will be mixed in the final result even in the absence of light.
  30711. */
  30712. emissiveTexture: Nullable<BaseTexture>;
  30713. private _specularTexture;
  30714. /**
  30715. * Define how the color and intensity of the highlight given by the light in the material.
  30716. */
  30717. specularTexture: Nullable<BaseTexture>;
  30718. private _bumpTexture;
  30719. /**
  30720. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30721. * 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.
  30722. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30723. */
  30724. bumpTexture: Nullable<BaseTexture>;
  30725. private _lightmapTexture;
  30726. /**
  30727. * Complex lighting can be computationally expensive to compute at runtime.
  30728. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30729. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30730. */
  30731. lightmapTexture: Nullable<BaseTexture>;
  30732. private _refractionTexture;
  30733. /**
  30734. * Define the texture used to display the refraction.
  30735. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30736. */
  30737. refractionTexture: Nullable<BaseTexture>;
  30738. /**
  30739. * The color of the material lit by the environmental background lighting.
  30740. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30741. */
  30742. ambientColor: Color3;
  30743. /**
  30744. * The basic color of the material as viewed under a light.
  30745. */
  30746. diffuseColor: Color3;
  30747. /**
  30748. * Define how the color and intensity of the highlight given by the light in the material.
  30749. */
  30750. specularColor: Color3;
  30751. /**
  30752. * Define the color of the material as if self lit.
  30753. * This will be mixed in the final result even in the absence of light.
  30754. */
  30755. emissiveColor: Color3;
  30756. /**
  30757. * Defines how sharp are the highlights in the material.
  30758. * The bigger the value the sharper giving a more glossy feeling to the result.
  30759. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30760. */
  30761. specularPower: number;
  30762. private _useAlphaFromDiffuseTexture;
  30763. /**
  30764. * Does the transparency come from the diffuse texture alpha channel.
  30765. */
  30766. useAlphaFromDiffuseTexture: boolean;
  30767. private _useEmissiveAsIllumination;
  30768. /**
  30769. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30770. */
  30771. useEmissiveAsIllumination: boolean;
  30772. private _linkEmissiveWithDiffuse;
  30773. /**
  30774. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30775. * the emissive level when the final color is close to one.
  30776. */
  30777. linkEmissiveWithDiffuse: boolean;
  30778. private _useSpecularOverAlpha;
  30779. /**
  30780. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30781. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30782. */
  30783. useSpecularOverAlpha: boolean;
  30784. private _useReflectionOverAlpha;
  30785. /**
  30786. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30787. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30788. */
  30789. useReflectionOverAlpha: boolean;
  30790. private _disableLighting;
  30791. /**
  30792. * Does lights from the scene impacts this material.
  30793. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30794. */
  30795. disableLighting: boolean;
  30796. private _useObjectSpaceNormalMap;
  30797. /**
  30798. * Allows using an object space normal map (instead of tangent space).
  30799. */
  30800. useObjectSpaceNormalMap: boolean;
  30801. private _useParallax;
  30802. /**
  30803. * Is parallax enabled or not.
  30804. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30805. */
  30806. useParallax: boolean;
  30807. private _useParallaxOcclusion;
  30808. /**
  30809. * Is parallax occlusion enabled or not.
  30810. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30811. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30812. */
  30813. useParallaxOcclusion: boolean;
  30814. /**
  30815. * 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.
  30816. */
  30817. parallaxScaleBias: number;
  30818. private _roughness;
  30819. /**
  30820. * Helps to define how blurry the reflections should appears in the material.
  30821. */
  30822. roughness: number;
  30823. /**
  30824. * In case of refraction, define the value of the index of refraction.
  30825. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30826. */
  30827. indexOfRefraction: number;
  30828. /**
  30829. * Invert the refraction texture alongside the y axis.
  30830. * It can be useful with procedural textures or probe for instance.
  30831. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30832. */
  30833. invertRefractionY: boolean;
  30834. /**
  30835. * Defines the alpha limits in alpha test mode.
  30836. */
  30837. alphaCutOff: number;
  30838. private _useLightmapAsShadowmap;
  30839. /**
  30840. * In case of light mapping, define whether the map contains light or shadow informations.
  30841. */
  30842. useLightmapAsShadowmap: boolean;
  30843. private _diffuseFresnelParameters;
  30844. /**
  30845. * Define the diffuse fresnel parameters of the material.
  30846. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30847. */
  30848. diffuseFresnelParameters: FresnelParameters;
  30849. private _opacityFresnelParameters;
  30850. /**
  30851. * Define the opacity fresnel parameters of the material.
  30852. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30853. */
  30854. opacityFresnelParameters: FresnelParameters;
  30855. private _reflectionFresnelParameters;
  30856. /**
  30857. * Define the reflection fresnel parameters of the material.
  30858. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30859. */
  30860. reflectionFresnelParameters: FresnelParameters;
  30861. private _refractionFresnelParameters;
  30862. /**
  30863. * Define the refraction fresnel parameters of the material.
  30864. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30865. */
  30866. refractionFresnelParameters: FresnelParameters;
  30867. private _emissiveFresnelParameters;
  30868. /**
  30869. * Define the emissive fresnel parameters of the material.
  30870. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30871. */
  30872. emissiveFresnelParameters: FresnelParameters;
  30873. private _useReflectionFresnelFromSpecular;
  30874. /**
  30875. * If true automatically deducts the fresnels values from the material specularity.
  30876. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30877. */
  30878. useReflectionFresnelFromSpecular: boolean;
  30879. private _useGlossinessFromSpecularMapAlpha;
  30880. /**
  30881. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30882. */
  30883. useGlossinessFromSpecularMapAlpha: boolean;
  30884. private _maxSimultaneousLights;
  30885. /**
  30886. * Defines the maximum number of lights that can be used in the material
  30887. */
  30888. maxSimultaneousLights: number;
  30889. private _invertNormalMapX;
  30890. /**
  30891. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30892. */
  30893. invertNormalMapX: boolean;
  30894. private _invertNormalMapY;
  30895. /**
  30896. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30897. */
  30898. invertNormalMapY: boolean;
  30899. private _twoSidedLighting;
  30900. /**
  30901. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30902. */
  30903. twoSidedLighting: boolean;
  30904. /**
  30905. * Default configuration related to image processing available in the standard Material.
  30906. */
  30907. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30908. /**
  30909. * Gets the image processing configuration used either in this material.
  30910. */
  30911. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30912. /**
  30913. * Sets the Default image processing configuration used either in the this material.
  30914. *
  30915. * If sets to null, the scene one is in use.
  30916. */
  30917. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30918. /**
  30919. * Keep track of the image processing observer to allow dispose and replace.
  30920. */
  30921. private _imageProcessingObserver;
  30922. /**
  30923. * Attaches a new image processing configuration to the Standard Material.
  30924. * @param configuration
  30925. */
  30926. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30927. /**
  30928. * Gets wether the color curves effect is enabled.
  30929. */
  30930. get cameraColorCurvesEnabled(): boolean;
  30931. /**
  30932. * Sets wether the color curves effect is enabled.
  30933. */
  30934. set cameraColorCurvesEnabled(value: boolean);
  30935. /**
  30936. * Gets wether the color grading effect is enabled.
  30937. */
  30938. get cameraColorGradingEnabled(): boolean;
  30939. /**
  30940. * Gets wether the color grading effect is enabled.
  30941. */
  30942. set cameraColorGradingEnabled(value: boolean);
  30943. /**
  30944. * Gets wether tonemapping is enabled or not.
  30945. */
  30946. get cameraToneMappingEnabled(): boolean;
  30947. /**
  30948. * Sets wether tonemapping is enabled or not
  30949. */
  30950. set cameraToneMappingEnabled(value: boolean);
  30951. /**
  30952. * The camera exposure used on this material.
  30953. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30954. * This corresponds to a photographic exposure.
  30955. */
  30956. get cameraExposure(): number;
  30957. /**
  30958. * The camera exposure used on this material.
  30959. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30960. * This corresponds to a photographic exposure.
  30961. */
  30962. set cameraExposure(value: number);
  30963. /**
  30964. * Gets The camera contrast used on this material.
  30965. */
  30966. get cameraContrast(): number;
  30967. /**
  30968. * Sets The camera contrast used on this material.
  30969. */
  30970. set cameraContrast(value: number);
  30971. /**
  30972. * Gets the Color Grading 2D Lookup Texture.
  30973. */
  30974. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30975. /**
  30976. * Sets the Color Grading 2D Lookup Texture.
  30977. */
  30978. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30979. /**
  30980. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30981. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30982. * 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;
  30983. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30984. */
  30985. get cameraColorCurves(): Nullable<ColorCurves>;
  30986. /**
  30987. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30988. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30989. * 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;
  30990. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30991. */
  30992. set cameraColorCurves(value: Nullable<ColorCurves>);
  30993. /**
  30994. * Defines the detail map parameters for the material.
  30995. */
  30996. readonly detailMap: DetailMapConfiguration;
  30997. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30998. protected _worldViewProjectionMatrix: Matrix;
  30999. protected _globalAmbientColor: Color3;
  31000. protected _useLogarithmicDepth: boolean;
  31001. protected _rebuildInParallel: boolean;
  31002. /**
  31003. * Instantiates a new standard material.
  31004. * This is the default material used in Babylon. It is the best trade off between quality
  31005. * and performances.
  31006. * @see http://doc.babylonjs.com/babylon101/materials
  31007. * @param name Define the name of the material in the scene
  31008. * @param scene Define the scene the material belong to
  31009. */
  31010. constructor(name: string, scene: Scene);
  31011. /**
  31012. * Gets a boolean indicating that current material needs to register RTT
  31013. */
  31014. get hasRenderTargetTextures(): boolean;
  31015. /**
  31016. * Gets the current class name of the material e.g. "StandardMaterial"
  31017. * Mainly use in serialization.
  31018. * @returns the class name
  31019. */
  31020. getClassName(): string;
  31021. /**
  31022. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31023. * You can try switching to logarithmic depth.
  31024. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31025. */
  31026. get useLogarithmicDepth(): boolean;
  31027. set useLogarithmicDepth(value: boolean);
  31028. /**
  31029. * Specifies if the material will require alpha blending
  31030. * @returns a boolean specifying if alpha blending is needed
  31031. */
  31032. needAlphaBlending(): boolean;
  31033. /**
  31034. * Specifies if this material should be rendered in alpha test mode
  31035. * @returns a boolean specifying if an alpha test is needed.
  31036. */
  31037. needAlphaTesting(): boolean;
  31038. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31039. /**
  31040. * Get the texture used for alpha test purpose.
  31041. * @returns the diffuse texture in case of the standard material.
  31042. */
  31043. getAlphaTestTexture(): Nullable<BaseTexture>;
  31044. /**
  31045. * Get if the submesh is ready to be used and all its information available.
  31046. * Child classes can use it to update shaders
  31047. * @param mesh defines the mesh to check
  31048. * @param subMesh defines which submesh to check
  31049. * @param useInstances specifies that instances should be used
  31050. * @returns a boolean indicating that the submesh is ready or not
  31051. */
  31052. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31053. /**
  31054. * Builds the material UBO layouts.
  31055. * Used internally during the effect preparation.
  31056. */
  31057. buildUniformLayout(): void;
  31058. /**
  31059. * Unbinds the material from the mesh
  31060. */
  31061. unbind(): void;
  31062. /**
  31063. * Binds the submesh to this material by preparing the effect and shader to draw
  31064. * @param world defines the world transformation matrix
  31065. * @param mesh defines the mesh containing the submesh
  31066. * @param subMesh defines the submesh to bind the material to
  31067. */
  31068. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31069. /**
  31070. * Get the list of animatables in the material.
  31071. * @returns the list of animatables object used in the material
  31072. */
  31073. getAnimatables(): IAnimatable[];
  31074. /**
  31075. * Gets the active textures from the material
  31076. * @returns an array of textures
  31077. */
  31078. getActiveTextures(): BaseTexture[];
  31079. /**
  31080. * Specifies if the material uses a texture
  31081. * @param texture defines the texture to check against the material
  31082. * @returns a boolean specifying if the material uses the texture
  31083. */
  31084. hasTexture(texture: BaseTexture): boolean;
  31085. /**
  31086. * Disposes the material
  31087. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31088. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31089. */
  31090. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31091. /**
  31092. * Makes a duplicate of the material, and gives it a new name
  31093. * @param name defines the new name for the duplicated material
  31094. * @returns the cloned material
  31095. */
  31096. clone(name: string): StandardMaterial;
  31097. /**
  31098. * Serializes this material in a JSON representation
  31099. * @returns the serialized material object
  31100. */
  31101. serialize(): any;
  31102. /**
  31103. * Creates a standard material from parsed material data
  31104. * @param source defines the JSON representation of the material
  31105. * @param scene defines the hosting scene
  31106. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31107. * @returns a new standard material
  31108. */
  31109. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31110. /**
  31111. * Are diffuse textures enabled in the application.
  31112. */
  31113. static get DiffuseTextureEnabled(): boolean;
  31114. static set DiffuseTextureEnabled(value: boolean);
  31115. /**
  31116. * Are detail textures enabled in the application.
  31117. */
  31118. static get DetailTextureEnabled(): boolean;
  31119. static set DetailTextureEnabled(value: boolean);
  31120. /**
  31121. * Are ambient textures enabled in the application.
  31122. */
  31123. static get AmbientTextureEnabled(): boolean;
  31124. static set AmbientTextureEnabled(value: boolean);
  31125. /**
  31126. * Are opacity textures enabled in the application.
  31127. */
  31128. static get OpacityTextureEnabled(): boolean;
  31129. static set OpacityTextureEnabled(value: boolean);
  31130. /**
  31131. * Are reflection textures enabled in the application.
  31132. */
  31133. static get ReflectionTextureEnabled(): boolean;
  31134. static set ReflectionTextureEnabled(value: boolean);
  31135. /**
  31136. * Are emissive textures enabled in the application.
  31137. */
  31138. static get EmissiveTextureEnabled(): boolean;
  31139. static set EmissiveTextureEnabled(value: boolean);
  31140. /**
  31141. * Are specular textures enabled in the application.
  31142. */
  31143. static get SpecularTextureEnabled(): boolean;
  31144. static set SpecularTextureEnabled(value: boolean);
  31145. /**
  31146. * Are bump textures enabled in the application.
  31147. */
  31148. static get BumpTextureEnabled(): boolean;
  31149. static set BumpTextureEnabled(value: boolean);
  31150. /**
  31151. * Are lightmap textures enabled in the application.
  31152. */
  31153. static get LightmapTextureEnabled(): boolean;
  31154. static set LightmapTextureEnabled(value: boolean);
  31155. /**
  31156. * Are refraction textures enabled in the application.
  31157. */
  31158. static get RefractionTextureEnabled(): boolean;
  31159. static set RefractionTextureEnabled(value: boolean);
  31160. /**
  31161. * Are color grading textures enabled in the application.
  31162. */
  31163. static get ColorGradingTextureEnabled(): boolean;
  31164. static set ColorGradingTextureEnabled(value: boolean);
  31165. /**
  31166. * Are fresnels enabled in the application.
  31167. */
  31168. static get FresnelEnabled(): boolean;
  31169. static set FresnelEnabled(value: boolean);
  31170. }
  31171. }
  31172. declare module "babylonjs/Particles/solidParticleSystem" {
  31173. import { Nullable } from "babylonjs/types";
  31174. import { Mesh } from "babylonjs/Meshes/mesh";
  31175. import { Scene, IDisposable } from "babylonjs/scene";
  31176. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31177. import { Material } from "babylonjs/Materials/material";
  31178. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31179. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31180. /**
  31181. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31182. *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.
  31183. * The SPS is also a particle system. It provides some methods to manage the particles.
  31184. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31185. *
  31186. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  31187. */
  31188. export class SolidParticleSystem implements IDisposable {
  31189. /**
  31190. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31191. * Example : var p = SPS.particles[i];
  31192. */
  31193. particles: SolidParticle[];
  31194. /**
  31195. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31196. */
  31197. nbParticles: number;
  31198. /**
  31199. * If the particles must ever face the camera (default false). Useful for planar particles.
  31200. */
  31201. billboard: boolean;
  31202. /**
  31203. * Recompute normals when adding a shape
  31204. */
  31205. recomputeNormals: boolean;
  31206. /**
  31207. * This a counter ofr your own usage. It's not set by any SPS functions.
  31208. */
  31209. counter: number;
  31210. /**
  31211. * The SPS name. This name is also given to the underlying mesh.
  31212. */
  31213. name: string;
  31214. /**
  31215. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31216. */
  31217. mesh: Mesh;
  31218. /**
  31219. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31220. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31221. */
  31222. vars: any;
  31223. /**
  31224. * This array is populated when the SPS is set as 'pickable'.
  31225. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31226. * Each element of this array is an object `{idx: int, faceId: int}`.
  31227. * `idx` is the picked particle index in the `SPS.particles` array
  31228. * `faceId` is the picked face index counted within this particle.
  31229. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31230. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31231. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31232. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31233. */
  31234. pickedParticles: {
  31235. idx: number;
  31236. faceId: number;
  31237. }[];
  31238. /**
  31239. * This array is populated when the SPS is set as 'pickable'
  31240. * Each key of this array is a submesh index.
  31241. * Each element of this array is a second array defined like this :
  31242. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31243. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31244. * `idx` is the picked particle index in the `SPS.particles` array
  31245. * `faceId` is the picked face index counted within this particle.
  31246. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31247. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31248. */
  31249. pickedBySubMesh: {
  31250. idx: number;
  31251. faceId: number;
  31252. }[][];
  31253. /**
  31254. * This array is populated when `enableDepthSort` is set to true.
  31255. * Each element of this array is an instance of the class DepthSortedParticle.
  31256. */
  31257. depthSortedParticles: DepthSortedParticle[];
  31258. /**
  31259. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31260. * @hidden
  31261. */
  31262. _bSphereOnly: boolean;
  31263. /**
  31264. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31265. * @hidden
  31266. */
  31267. _bSphereRadiusFactor: number;
  31268. private _scene;
  31269. private _positions;
  31270. private _indices;
  31271. private _normals;
  31272. private _colors;
  31273. private _uvs;
  31274. private _indices32;
  31275. private _positions32;
  31276. private _normals32;
  31277. private _fixedNormal32;
  31278. private _colors32;
  31279. private _uvs32;
  31280. private _index;
  31281. private _updatable;
  31282. private _pickable;
  31283. private _isVisibilityBoxLocked;
  31284. private _alwaysVisible;
  31285. private _depthSort;
  31286. private _expandable;
  31287. private _shapeCounter;
  31288. private _copy;
  31289. private _color;
  31290. private _computeParticleColor;
  31291. private _computeParticleTexture;
  31292. private _computeParticleRotation;
  31293. private _computeParticleVertex;
  31294. private _computeBoundingBox;
  31295. private _depthSortParticles;
  31296. private _camera;
  31297. private _mustUnrotateFixedNormals;
  31298. private _particlesIntersect;
  31299. private _needs32Bits;
  31300. private _isNotBuilt;
  31301. private _lastParticleId;
  31302. private _idxOfId;
  31303. private _multimaterialEnabled;
  31304. private _useModelMaterial;
  31305. private _indicesByMaterial;
  31306. private _materialIndexes;
  31307. private _depthSortFunction;
  31308. private _materialSortFunction;
  31309. private _materials;
  31310. private _multimaterial;
  31311. private _materialIndexesById;
  31312. private _defaultMaterial;
  31313. private _autoUpdateSubMeshes;
  31314. private _tmpVertex;
  31315. /**
  31316. * Creates a SPS (Solid Particle System) object.
  31317. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31318. * @param scene (Scene) is the scene in which the SPS is added.
  31319. * @param options defines the options of the sps e.g.
  31320. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31321. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31322. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31323. * * 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.
  31324. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31325. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31326. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31327. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31328. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31329. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31330. */
  31331. constructor(name: string, scene: Scene, options?: {
  31332. updatable?: boolean;
  31333. isPickable?: boolean;
  31334. enableDepthSort?: boolean;
  31335. particleIntersection?: boolean;
  31336. boundingSphereOnly?: boolean;
  31337. bSphereRadiusFactor?: number;
  31338. expandable?: boolean;
  31339. useModelMaterial?: boolean;
  31340. enableMultiMaterial?: boolean;
  31341. });
  31342. /**
  31343. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31344. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31345. * @returns the created mesh
  31346. */
  31347. buildMesh(): Mesh;
  31348. /**
  31349. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31350. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31351. * Thus the particles generated from `digest()` have their property `position` set yet.
  31352. * @param mesh ( Mesh ) is the mesh to be digested
  31353. * @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
  31354. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31355. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31356. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31357. * @returns the current SPS
  31358. */
  31359. digest(mesh: Mesh, options?: {
  31360. facetNb?: number;
  31361. number?: number;
  31362. delta?: number;
  31363. storage?: [];
  31364. }): SolidParticleSystem;
  31365. /**
  31366. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31367. * @hidden
  31368. */
  31369. private _unrotateFixedNormals;
  31370. /**
  31371. * Resets the temporary working copy particle
  31372. * @hidden
  31373. */
  31374. private _resetCopy;
  31375. /**
  31376. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31377. * @param p the current index in the positions array to be updated
  31378. * @param ind the current index in the indices array
  31379. * @param shape a Vector3 array, the shape geometry
  31380. * @param positions the positions array to be updated
  31381. * @param meshInd the shape indices array
  31382. * @param indices the indices array to be updated
  31383. * @param meshUV the shape uv array
  31384. * @param uvs the uv array to be updated
  31385. * @param meshCol the shape color array
  31386. * @param colors the color array to be updated
  31387. * @param meshNor the shape normals array
  31388. * @param normals the normals array to be updated
  31389. * @param idx the particle index
  31390. * @param idxInShape the particle index in its shape
  31391. * @param options the addShape() method passed options
  31392. * @model the particle model
  31393. * @hidden
  31394. */
  31395. private _meshBuilder;
  31396. /**
  31397. * Returns a shape Vector3 array from positions float array
  31398. * @param positions float array
  31399. * @returns a vector3 array
  31400. * @hidden
  31401. */
  31402. private _posToShape;
  31403. /**
  31404. * Returns a shapeUV array from a float uvs (array deep copy)
  31405. * @param uvs as a float array
  31406. * @returns a shapeUV array
  31407. * @hidden
  31408. */
  31409. private _uvsToShapeUV;
  31410. /**
  31411. * Adds a new particle object in the particles array
  31412. * @param idx particle index in particles array
  31413. * @param id particle id
  31414. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31415. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31416. * @param model particle ModelShape object
  31417. * @param shapeId model shape identifier
  31418. * @param idxInShape index of the particle in the current model
  31419. * @param bInfo model bounding info object
  31420. * @param storage target storage array, if any
  31421. * @hidden
  31422. */
  31423. private _addParticle;
  31424. /**
  31425. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31426. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31427. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31428. * @param nb (positive integer) the number of particles to be created from this model
  31429. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31430. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31431. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31432. * @returns the number of shapes in the system
  31433. */
  31434. addShape(mesh: Mesh, nb: number, options?: {
  31435. positionFunction?: any;
  31436. vertexFunction?: any;
  31437. storage?: [];
  31438. }): number;
  31439. /**
  31440. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31441. * @hidden
  31442. */
  31443. private _rebuildParticle;
  31444. /**
  31445. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31446. * @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.
  31447. * @returns the SPS.
  31448. */
  31449. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31450. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31451. * Returns an array with the removed particles.
  31452. * 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.
  31453. * The SPS can't be empty so at least one particle needs to remain in place.
  31454. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31455. * @param start index of the first particle to remove
  31456. * @param end index of the last particle to remove (included)
  31457. * @returns an array populated with the removed particles
  31458. */
  31459. removeParticles(start: number, end: number): SolidParticle[];
  31460. /**
  31461. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31462. * @param solidParticleArray an array populated with Solid Particles objects
  31463. * @returns the SPS
  31464. */
  31465. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31466. /**
  31467. * Creates a new particle and modifies the SPS mesh geometry :
  31468. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31469. * - calls _addParticle() to populate the particle array
  31470. * factorized code from addShape() and insertParticlesFromArray()
  31471. * @param idx particle index in the particles array
  31472. * @param i particle index in its shape
  31473. * @param modelShape particle ModelShape object
  31474. * @param shape shape vertex array
  31475. * @param meshInd shape indices array
  31476. * @param meshUV shape uv array
  31477. * @param meshCol shape color array
  31478. * @param meshNor shape normals array
  31479. * @param bbInfo shape bounding info
  31480. * @param storage target particle storage
  31481. * @options addShape() passed options
  31482. * @hidden
  31483. */
  31484. private _insertNewParticle;
  31485. /**
  31486. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31487. * This method calls `updateParticle()` for each particle of the SPS.
  31488. * For an animated SPS, it is usually called within the render loop.
  31489. * 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.
  31490. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31491. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31492. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31493. * @returns the SPS.
  31494. */
  31495. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31496. /**
  31497. * Disposes the SPS.
  31498. */
  31499. dispose(): void;
  31500. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31501. * idx is the particle index in the SPS
  31502. * faceId is the picked face index counted within this particle.
  31503. * Returns null if the pickInfo can't identify a picked particle.
  31504. * @param pickingInfo (PickingInfo object)
  31505. * @returns {idx: number, faceId: number} or null
  31506. */
  31507. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31508. idx: number;
  31509. faceId: number;
  31510. }>;
  31511. /**
  31512. * Returns a SolidParticle object from its identifier : particle.id
  31513. * @param id (integer) the particle Id
  31514. * @returns the searched particle or null if not found in the SPS.
  31515. */
  31516. getParticleById(id: number): Nullable<SolidParticle>;
  31517. /**
  31518. * Returns a new array populated with the particles having the passed shapeId.
  31519. * @param shapeId (integer) the shape identifier
  31520. * @returns a new solid particle array
  31521. */
  31522. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31523. /**
  31524. * Populates the passed array "ref" with the particles having the passed shapeId.
  31525. * @param shapeId the shape identifier
  31526. * @returns the SPS
  31527. * @param ref
  31528. */
  31529. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31530. /**
  31531. * Computes the required SubMeshes according the materials assigned to the particles.
  31532. * @returns the solid particle system.
  31533. * Does nothing if called before the SPS mesh is built.
  31534. */
  31535. computeSubMeshes(): SolidParticleSystem;
  31536. /**
  31537. * Sorts the solid particles by material when MultiMaterial is enabled.
  31538. * Updates the indices32 array.
  31539. * Updates the indicesByMaterial array.
  31540. * Updates the mesh indices array.
  31541. * @returns the SPS
  31542. * @hidden
  31543. */
  31544. private _sortParticlesByMaterial;
  31545. /**
  31546. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31547. * @hidden
  31548. */
  31549. private _setMaterialIndexesById;
  31550. /**
  31551. * Returns an array with unique values of Materials from the passed array
  31552. * @param array the material array to be checked and filtered
  31553. * @hidden
  31554. */
  31555. private _filterUniqueMaterialId;
  31556. /**
  31557. * Sets a new Standard Material as _defaultMaterial if not already set.
  31558. * @hidden
  31559. */
  31560. private _setDefaultMaterial;
  31561. /**
  31562. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31563. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31564. * @returns the SPS.
  31565. */
  31566. refreshVisibleSize(): SolidParticleSystem;
  31567. /**
  31568. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31569. * @param size the size (float) of the visibility box
  31570. * note : this doesn't lock the SPS mesh bounding box.
  31571. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31572. */
  31573. setVisibilityBox(size: number): void;
  31574. /**
  31575. * Gets whether the SPS as always visible or not
  31576. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31577. */
  31578. get isAlwaysVisible(): boolean;
  31579. /**
  31580. * Sets the SPS as always visible or not
  31581. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31582. */
  31583. set isAlwaysVisible(val: boolean);
  31584. /**
  31585. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31586. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31587. */
  31588. set isVisibilityBoxLocked(val: boolean);
  31589. /**
  31590. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31591. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31592. */
  31593. get isVisibilityBoxLocked(): boolean;
  31594. /**
  31595. * Tells to `setParticles()` to compute the particle rotations or not.
  31596. * Default value : true. The SPS is faster when it's set to false.
  31597. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31598. */
  31599. set computeParticleRotation(val: boolean);
  31600. /**
  31601. * Tells to `setParticles()` to compute the particle colors or not.
  31602. * Default value : true. The SPS is faster when it's set to false.
  31603. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31604. */
  31605. set computeParticleColor(val: boolean);
  31606. set computeParticleTexture(val: boolean);
  31607. /**
  31608. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31609. * Default value : false. The SPS is faster when it's set to false.
  31610. * Note : the particle custom vertex positions aren't stored values.
  31611. */
  31612. set computeParticleVertex(val: boolean);
  31613. /**
  31614. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31615. */
  31616. set computeBoundingBox(val: boolean);
  31617. /**
  31618. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31619. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31620. * Default : `true`
  31621. */
  31622. set depthSortParticles(val: boolean);
  31623. /**
  31624. * Gets if `setParticles()` computes the particle rotations or not.
  31625. * Default value : true. The SPS is faster when it's set to false.
  31626. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31627. */
  31628. get computeParticleRotation(): boolean;
  31629. /**
  31630. * Gets if `setParticles()` computes the particle colors or not.
  31631. * Default value : true. The SPS is faster when it's set to false.
  31632. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31633. */
  31634. get computeParticleColor(): boolean;
  31635. /**
  31636. * Gets if `setParticles()` computes the particle textures or not.
  31637. * Default value : true. The SPS is faster when it's set to false.
  31638. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31639. */
  31640. get computeParticleTexture(): boolean;
  31641. /**
  31642. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31643. * Default value : false. The SPS is faster when it's set to false.
  31644. * Note : the particle custom vertex positions aren't stored values.
  31645. */
  31646. get computeParticleVertex(): boolean;
  31647. /**
  31648. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31649. */
  31650. get computeBoundingBox(): boolean;
  31651. /**
  31652. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31653. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31654. * Default : `true`
  31655. */
  31656. get depthSortParticles(): boolean;
  31657. /**
  31658. * Gets if the SPS is created as expandable at construction time.
  31659. * Default : `false`
  31660. */
  31661. get expandable(): boolean;
  31662. /**
  31663. * Gets if the SPS supports the Multi Materials
  31664. */
  31665. get multimaterialEnabled(): boolean;
  31666. /**
  31667. * Gets if the SPS uses the model materials for its own multimaterial.
  31668. */
  31669. get useModelMaterial(): boolean;
  31670. /**
  31671. * The SPS used material array.
  31672. */
  31673. get materials(): Material[];
  31674. /**
  31675. * Sets the SPS MultiMaterial from the passed materials.
  31676. * Note : the passed array is internally copied and not used then by reference.
  31677. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31678. */
  31679. setMultiMaterial(materials: Material[]): void;
  31680. /**
  31681. * The SPS computed multimaterial object
  31682. */
  31683. get multimaterial(): MultiMaterial;
  31684. set multimaterial(mm: MultiMaterial);
  31685. /**
  31686. * If the subMeshes must be updated on the next call to setParticles()
  31687. */
  31688. get autoUpdateSubMeshes(): boolean;
  31689. set autoUpdateSubMeshes(val: boolean);
  31690. /**
  31691. * This function does nothing. It may be overwritten to set all the particle first values.
  31692. * The SPS doesn't call this function, you may have to call it by your own.
  31693. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31694. */
  31695. initParticles(): void;
  31696. /**
  31697. * This function does nothing. It may be overwritten to recycle a particle.
  31698. * The SPS doesn't call this function, you may have to call it by your own.
  31699. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31700. * @param particle The particle to recycle
  31701. * @returns the recycled particle
  31702. */
  31703. recycleParticle(particle: SolidParticle): SolidParticle;
  31704. /**
  31705. * Updates a particle : this function should be overwritten by the user.
  31706. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31707. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31708. * @example : just set a particle position or velocity and recycle conditions
  31709. * @param particle The particle to update
  31710. * @returns the updated particle
  31711. */
  31712. updateParticle(particle: SolidParticle): SolidParticle;
  31713. /**
  31714. * Updates a vertex of a particle : it can be overwritten by the user.
  31715. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31716. * @param particle the current particle
  31717. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31718. * @param pt the index of the current vertex in the particle shape
  31719. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31720. * @example : just set a vertex particle position or color
  31721. * @returns the sps
  31722. */
  31723. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31724. /**
  31725. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31726. * This does nothing and may be overwritten by the user.
  31727. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31728. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31729. * @param update the boolean update value actually passed to setParticles()
  31730. */
  31731. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31732. /**
  31733. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31734. * This will be passed three parameters.
  31735. * This does nothing and may be overwritten by the user.
  31736. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31737. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31738. * @param update the boolean update value actually passed to setParticles()
  31739. */
  31740. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31741. }
  31742. }
  31743. declare module "babylonjs/Particles/solidParticle" {
  31744. import { Nullable } from "babylonjs/types";
  31745. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31746. import { Color4 } from "babylonjs/Maths/math.color";
  31747. import { Mesh } from "babylonjs/Meshes/mesh";
  31748. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31749. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31750. import { Plane } from "babylonjs/Maths/math.plane";
  31751. import { Material } from "babylonjs/Materials/material";
  31752. /**
  31753. * Represents one particle of a solid particle system.
  31754. */
  31755. export class SolidParticle {
  31756. /**
  31757. * particle global index
  31758. */
  31759. idx: number;
  31760. /**
  31761. * particle identifier
  31762. */
  31763. id: number;
  31764. /**
  31765. * The color of the particle
  31766. */
  31767. color: Nullable<Color4>;
  31768. /**
  31769. * The world space position of the particle.
  31770. */
  31771. position: Vector3;
  31772. /**
  31773. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31774. */
  31775. rotation: Vector3;
  31776. /**
  31777. * The world space rotation quaternion of the particle.
  31778. */
  31779. rotationQuaternion: Nullable<Quaternion>;
  31780. /**
  31781. * The scaling of the particle.
  31782. */
  31783. scaling: Vector3;
  31784. /**
  31785. * The uvs of the particle.
  31786. */
  31787. uvs: Vector4;
  31788. /**
  31789. * The current speed of the particle.
  31790. */
  31791. velocity: Vector3;
  31792. /**
  31793. * The pivot point in the particle local space.
  31794. */
  31795. pivot: Vector3;
  31796. /**
  31797. * Must the particle be translated from its pivot point in its local space ?
  31798. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31799. * Default : false
  31800. */
  31801. translateFromPivot: boolean;
  31802. /**
  31803. * Is the particle active or not ?
  31804. */
  31805. alive: boolean;
  31806. /**
  31807. * Is the particle visible or not ?
  31808. */
  31809. isVisible: boolean;
  31810. /**
  31811. * Index of this particle in the global "positions" array (Internal use)
  31812. * @hidden
  31813. */
  31814. _pos: number;
  31815. /**
  31816. * @hidden Index of this particle in the global "indices" array (Internal use)
  31817. */
  31818. _ind: number;
  31819. /**
  31820. * @hidden ModelShape of this particle (Internal use)
  31821. */
  31822. _model: ModelShape;
  31823. /**
  31824. * ModelShape id of this particle
  31825. */
  31826. shapeId: number;
  31827. /**
  31828. * Index of the particle in its shape id
  31829. */
  31830. idxInShape: number;
  31831. /**
  31832. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31833. */
  31834. _modelBoundingInfo: BoundingInfo;
  31835. /**
  31836. * @hidden Particle BoundingInfo object (Internal use)
  31837. */
  31838. _boundingInfo: BoundingInfo;
  31839. /**
  31840. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31841. */
  31842. _sps: SolidParticleSystem;
  31843. /**
  31844. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31845. */
  31846. _stillInvisible: boolean;
  31847. /**
  31848. * @hidden Last computed particle rotation matrix
  31849. */
  31850. _rotationMatrix: number[];
  31851. /**
  31852. * Parent particle Id, if any.
  31853. * Default null.
  31854. */
  31855. parentId: Nullable<number>;
  31856. /**
  31857. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31858. */
  31859. materialIndex: Nullable<number>;
  31860. /**
  31861. * Custom object or properties.
  31862. */
  31863. props: Nullable<any>;
  31864. /**
  31865. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31866. * The possible values are :
  31867. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31868. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31869. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31870. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31871. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31872. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31873. * */
  31874. cullingStrategy: number;
  31875. /**
  31876. * @hidden Internal global position in the SPS.
  31877. */
  31878. _globalPosition: Vector3;
  31879. /**
  31880. * Creates a Solid Particle object.
  31881. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31882. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31883. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31884. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31885. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31886. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31887. * @param shapeId (integer) is the model shape identifier in the SPS.
  31888. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31889. * @param sps defines the sps it is associated to
  31890. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31891. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31892. */
  31893. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31894. /**
  31895. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31896. * @param target the particle target
  31897. * @returns the current particle
  31898. */
  31899. copyToRef(target: SolidParticle): SolidParticle;
  31900. /**
  31901. * Legacy support, changed scale to scaling
  31902. */
  31903. get scale(): Vector3;
  31904. /**
  31905. * Legacy support, changed scale to scaling
  31906. */
  31907. set scale(scale: Vector3);
  31908. /**
  31909. * Legacy support, changed quaternion to rotationQuaternion
  31910. */
  31911. get quaternion(): Nullable<Quaternion>;
  31912. /**
  31913. * Legacy support, changed quaternion to rotationQuaternion
  31914. */
  31915. set quaternion(q: Nullable<Quaternion>);
  31916. /**
  31917. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31918. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31919. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31920. * @returns true if it intersects
  31921. */
  31922. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31923. /**
  31924. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31925. * A particle is in the frustum if its bounding box intersects the frustum
  31926. * @param frustumPlanes defines the frustum to test
  31927. * @returns true if the particle is in the frustum planes
  31928. */
  31929. isInFrustum(frustumPlanes: Plane[]): boolean;
  31930. /**
  31931. * get the rotation matrix of the particle
  31932. * @hidden
  31933. */
  31934. getRotationMatrix(m: Matrix): void;
  31935. }
  31936. /**
  31937. * Represents the shape of the model used by one particle of a solid particle system.
  31938. * SPS internal tool, don't use it manually.
  31939. */
  31940. export class ModelShape {
  31941. /**
  31942. * The shape id
  31943. * @hidden
  31944. */
  31945. shapeID: number;
  31946. /**
  31947. * flat array of model positions (internal use)
  31948. * @hidden
  31949. */
  31950. _shape: Vector3[];
  31951. /**
  31952. * flat array of model UVs (internal use)
  31953. * @hidden
  31954. */
  31955. _shapeUV: number[];
  31956. /**
  31957. * color array of the model
  31958. * @hidden
  31959. */
  31960. _shapeColors: number[];
  31961. /**
  31962. * indices array of the model
  31963. * @hidden
  31964. */
  31965. _indices: number[];
  31966. /**
  31967. * normals array of the model
  31968. * @hidden
  31969. */
  31970. _normals: number[];
  31971. /**
  31972. * length of the shape in the model indices array (internal use)
  31973. * @hidden
  31974. */
  31975. _indicesLength: number;
  31976. /**
  31977. * Custom position function (internal use)
  31978. * @hidden
  31979. */
  31980. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31981. /**
  31982. * Custom vertex function (internal use)
  31983. * @hidden
  31984. */
  31985. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31986. /**
  31987. * Model material (internal use)
  31988. * @hidden
  31989. */
  31990. _material: Nullable<Material>;
  31991. /**
  31992. * 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.
  31993. * SPS internal tool, don't use it manually.
  31994. * @hidden
  31995. */
  31996. 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>);
  31997. }
  31998. /**
  31999. * Represents a Depth Sorted Particle in the solid particle system.
  32000. * @hidden
  32001. */
  32002. export class DepthSortedParticle {
  32003. /**
  32004. * Particle index
  32005. */
  32006. idx: number;
  32007. /**
  32008. * Index of the particle in the "indices" array
  32009. */
  32010. ind: number;
  32011. /**
  32012. * Length of the particle shape in the "indices" array
  32013. */
  32014. indicesLength: number;
  32015. /**
  32016. * Squared distance from the particle to the camera
  32017. */
  32018. sqDistance: number;
  32019. /**
  32020. * Material index when used with MultiMaterials
  32021. */
  32022. materialIndex: number;
  32023. /**
  32024. * Creates a new sorted particle
  32025. * @param materialIndex
  32026. */
  32027. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32028. }
  32029. /**
  32030. * Represents a solid particle vertex
  32031. */
  32032. export class SolidParticleVertex {
  32033. /**
  32034. * Vertex position
  32035. */
  32036. position: Vector3;
  32037. /**
  32038. * Vertex color
  32039. */
  32040. color: Color4;
  32041. /**
  32042. * Vertex UV
  32043. */
  32044. uv: Vector2;
  32045. /**
  32046. * Creates a new solid particle vertex
  32047. */
  32048. constructor();
  32049. /** Vertex x coordinate */
  32050. get x(): number;
  32051. set x(val: number);
  32052. /** Vertex y coordinate */
  32053. get y(): number;
  32054. set y(val: number);
  32055. /** Vertex z coordinate */
  32056. get z(): number;
  32057. set z(val: number);
  32058. }
  32059. }
  32060. declare module "babylonjs/Collisions/meshCollisionData" {
  32061. import { Collider } from "babylonjs/Collisions/collider";
  32062. import { Vector3 } from "babylonjs/Maths/math.vector";
  32063. import { Nullable } from "babylonjs/types";
  32064. import { Observer } from "babylonjs/Misc/observable";
  32065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32066. /**
  32067. * @hidden
  32068. */
  32069. export class _MeshCollisionData {
  32070. _checkCollisions: boolean;
  32071. _collisionMask: number;
  32072. _collisionGroup: number;
  32073. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32074. _collider: Nullable<Collider>;
  32075. _oldPositionForCollisions: Vector3;
  32076. _diffPositionForCollisions: Vector3;
  32077. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32078. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32079. }
  32080. }
  32081. declare module "babylonjs/Meshes/abstractMesh" {
  32082. import { Observable } from "babylonjs/Misc/observable";
  32083. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32084. import { Camera } from "babylonjs/Cameras/camera";
  32085. import { Scene, IDisposable } from "babylonjs/scene";
  32086. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32087. import { Node } from "babylonjs/node";
  32088. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32089. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32090. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32091. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32092. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32093. import { Material } from "babylonjs/Materials/material";
  32094. import { Light } from "babylonjs/Lights/light";
  32095. import { Skeleton } from "babylonjs/Bones/skeleton";
  32096. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32097. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32098. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32099. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32100. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32101. import { Plane } from "babylonjs/Maths/math.plane";
  32102. import { Ray } from "babylonjs/Culling/ray";
  32103. import { Collider } from "babylonjs/Collisions/collider";
  32104. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32105. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32106. /** @hidden */
  32107. class _FacetDataStorage {
  32108. facetPositions: Vector3[];
  32109. facetNormals: Vector3[];
  32110. facetPartitioning: number[][];
  32111. facetNb: number;
  32112. partitioningSubdivisions: number;
  32113. partitioningBBoxRatio: number;
  32114. facetDataEnabled: boolean;
  32115. facetParameters: any;
  32116. bbSize: Vector3;
  32117. subDiv: {
  32118. max: number;
  32119. X: number;
  32120. Y: number;
  32121. Z: number;
  32122. };
  32123. facetDepthSort: boolean;
  32124. facetDepthSortEnabled: boolean;
  32125. depthSortedIndices: IndicesArray;
  32126. depthSortedFacets: {
  32127. ind: number;
  32128. sqDistance: number;
  32129. }[];
  32130. facetDepthSortFunction: (f1: {
  32131. ind: number;
  32132. sqDistance: number;
  32133. }, f2: {
  32134. ind: number;
  32135. sqDistance: number;
  32136. }) => number;
  32137. facetDepthSortFrom: Vector3;
  32138. facetDepthSortOrigin: Vector3;
  32139. invertedMatrix: Matrix;
  32140. }
  32141. /**
  32142. * @hidden
  32143. **/
  32144. class _InternalAbstractMeshDataInfo {
  32145. _hasVertexAlpha: boolean;
  32146. _useVertexColors: boolean;
  32147. _numBoneInfluencers: number;
  32148. _applyFog: boolean;
  32149. _receiveShadows: boolean;
  32150. _facetData: _FacetDataStorage;
  32151. _visibility: number;
  32152. _skeleton: Nullable<Skeleton>;
  32153. _layerMask: number;
  32154. _computeBonesUsingShaders: boolean;
  32155. _isActive: boolean;
  32156. _onlyForInstances: boolean;
  32157. _isActiveIntermediate: boolean;
  32158. _onlyForInstancesIntermediate: boolean;
  32159. _actAsRegularMesh: boolean;
  32160. }
  32161. /**
  32162. * Class used to store all common mesh properties
  32163. */
  32164. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32165. /** No occlusion */
  32166. static OCCLUSION_TYPE_NONE: number;
  32167. /** Occlusion set to optimisitic */
  32168. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32169. /** Occlusion set to strict */
  32170. static OCCLUSION_TYPE_STRICT: number;
  32171. /** Use an accurante occlusion algorithm */
  32172. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32173. /** Use a conservative occlusion algorithm */
  32174. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32175. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32176. * Test order :
  32177. * Is the bounding sphere outside the frustum ?
  32178. * If not, are the bounding box vertices outside the frustum ?
  32179. * It not, then the cullable object is in the frustum.
  32180. */
  32181. static readonly CULLINGSTRATEGY_STANDARD: number;
  32182. /** Culling strategy : Bounding Sphere Only.
  32183. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32184. * It's also less accurate than the standard because some not visible objects can still be selected.
  32185. * Test : is the bounding sphere outside the frustum ?
  32186. * If not, then the cullable object is in the frustum.
  32187. */
  32188. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32189. /** Culling strategy : Optimistic Inclusion.
  32190. * This in an inclusion test first, then the standard exclusion test.
  32191. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32192. * 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.
  32193. * Anyway, it's as accurate as the standard strategy.
  32194. * Test :
  32195. * Is the cullable object bounding sphere center in the frustum ?
  32196. * If not, apply the default culling strategy.
  32197. */
  32198. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32199. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32200. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32201. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32202. * 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.
  32203. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32204. * Test :
  32205. * Is the cullable object bounding sphere center in the frustum ?
  32206. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32207. */
  32208. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32209. /**
  32210. * No billboard
  32211. */
  32212. static get BILLBOARDMODE_NONE(): number;
  32213. /** Billboard on X axis */
  32214. static get BILLBOARDMODE_X(): number;
  32215. /** Billboard on Y axis */
  32216. static get BILLBOARDMODE_Y(): number;
  32217. /** Billboard on Z axis */
  32218. static get BILLBOARDMODE_Z(): number;
  32219. /** Billboard on all axes */
  32220. static get BILLBOARDMODE_ALL(): number;
  32221. /** Billboard on using position instead of orientation */
  32222. static get BILLBOARDMODE_USE_POSITION(): number;
  32223. /** @hidden */
  32224. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32225. /**
  32226. * The culling strategy to use to check whether the mesh must be rendered or not.
  32227. * This value can be changed at any time and will be used on the next render mesh selection.
  32228. * The possible values are :
  32229. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32230. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32231. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32232. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32233. * Please read each static variable documentation to get details about the culling process.
  32234. * */
  32235. cullingStrategy: number;
  32236. /**
  32237. * Gets the number of facets in the mesh
  32238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32239. */
  32240. get facetNb(): number;
  32241. /**
  32242. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32243. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32244. */
  32245. get partitioningSubdivisions(): number;
  32246. set partitioningSubdivisions(nb: number);
  32247. /**
  32248. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32249. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32251. */
  32252. get partitioningBBoxRatio(): number;
  32253. set partitioningBBoxRatio(ratio: number);
  32254. /**
  32255. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32256. * Works only for updatable meshes.
  32257. * Doesn't work with multi-materials
  32258. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32259. */
  32260. get mustDepthSortFacets(): boolean;
  32261. set mustDepthSortFacets(sort: boolean);
  32262. /**
  32263. * The location (Vector3) where the facet depth sort must be computed from.
  32264. * By default, the active camera position.
  32265. * Used only when facet depth sort is enabled
  32266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32267. */
  32268. get facetDepthSortFrom(): Vector3;
  32269. set facetDepthSortFrom(location: Vector3);
  32270. /**
  32271. * gets a boolean indicating if facetData is enabled
  32272. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32273. */
  32274. get isFacetDataEnabled(): boolean;
  32275. /** @hidden */
  32276. _updateNonUniformScalingState(value: boolean): boolean;
  32277. /**
  32278. * An event triggered when this mesh collides with another one
  32279. */
  32280. onCollideObservable: Observable<AbstractMesh>;
  32281. /** Set a function to call when this mesh collides with another one */
  32282. set onCollide(callback: () => void);
  32283. /**
  32284. * An event triggered when the collision's position changes
  32285. */
  32286. onCollisionPositionChangeObservable: Observable<Vector3>;
  32287. /** Set a function to call when the collision's position changes */
  32288. set onCollisionPositionChange(callback: () => void);
  32289. /**
  32290. * An event triggered when material is changed
  32291. */
  32292. onMaterialChangedObservable: Observable<AbstractMesh>;
  32293. /**
  32294. * Gets or sets the orientation for POV movement & rotation
  32295. */
  32296. definedFacingForward: boolean;
  32297. /** @hidden */
  32298. _occlusionQuery: Nullable<WebGLQuery>;
  32299. /** @hidden */
  32300. _renderingGroup: Nullable<RenderingGroup>;
  32301. /**
  32302. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32303. */
  32304. get visibility(): number;
  32305. /**
  32306. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32307. */
  32308. set visibility(value: number);
  32309. /** Gets or sets the alpha index used to sort transparent meshes
  32310. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32311. */
  32312. alphaIndex: number;
  32313. /**
  32314. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32315. */
  32316. isVisible: boolean;
  32317. /**
  32318. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32319. */
  32320. isPickable: boolean;
  32321. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32322. showSubMeshesBoundingBox: boolean;
  32323. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32324. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32325. */
  32326. isBlocker: boolean;
  32327. /**
  32328. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32329. */
  32330. enablePointerMoveEvents: boolean;
  32331. /**
  32332. * Specifies the rendering group id for this mesh (0 by default)
  32333. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32334. */
  32335. renderingGroupId: number;
  32336. private _material;
  32337. /** Gets or sets current material */
  32338. get material(): Nullable<Material>;
  32339. set material(value: Nullable<Material>);
  32340. /**
  32341. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32342. * @see http://doc.babylonjs.com/babylon101/shadows
  32343. */
  32344. get receiveShadows(): boolean;
  32345. set receiveShadows(value: boolean);
  32346. /** Defines color to use when rendering outline */
  32347. outlineColor: Color3;
  32348. /** Define width to use when rendering outline */
  32349. outlineWidth: number;
  32350. /** Defines color to use when rendering overlay */
  32351. overlayColor: Color3;
  32352. /** Defines alpha to use when rendering overlay */
  32353. overlayAlpha: number;
  32354. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32355. get hasVertexAlpha(): boolean;
  32356. set hasVertexAlpha(value: boolean);
  32357. /** 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) */
  32358. get useVertexColors(): boolean;
  32359. set useVertexColors(value: boolean);
  32360. /**
  32361. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32362. */
  32363. get computeBonesUsingShaders(): boolean;
  32364. set computeBonesUsingShaders(value: boolean);
  32365. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32366. get numBoneInfluencers(): number;
  32367. set numBoneInfluencers(value: number);
  32368. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32369. get applyFog(): boolean;
  32370. set applyFog(value: boolean);
  32371. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32372. useOctreeForRenderingSelection: boolean;
  32373. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32374. useOctreeForPicking: boolean;
  32375. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32376. useOctreeForCollisions: boolean;
  32377. /**
  32378. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32379. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32380. */
  32381. get layerMask(): number;
  32382. set layerMask(value: number);
  32383. /**
  32384. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32385. */
  32386. alwaysSelectAsActiveMesh: boolean;
  32387. /**
  32388. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32389. */
  32390. doNotSyncBoundingInfo: boolean;
  32391. /**
  32392. * Gets or sets the current action manager
  32393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32394. */
  32395. actionManager: Nullable<AbstractActionManager>;
  32396. private _meshCollisionData;
  32397. /**
  32398. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32399. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32400. */
  32401. ellipsoid: Vector3;
  32402. /**
  32403. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32404. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32405. */
  32406. ellipsoidOffset: Vector3;
  32407. /**
  32408. * Gets or sets a collision mask used to mask collisions (default is -1).
  32409. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32410. */
  32411. get collisionMask(): number;
  32412. set collisionMask(mask: number);
  32413. /**
  32414. * Gets or sets the current collision group mask (-1 by default).
  32415. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32416. */
  32417. get collisionGroup(): number;
  32418. set collisionGroup(mask: number);
  32419. /**
  32420. * Gets or sets current surrounding meshes (null by default).
  32421. *
  32422. * By default collision detection is tested against every mesh in the scene.
  32423. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32424. * meshes will be tested for the collision.
  32425. *
  32426. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32427. */
  32428. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32429. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32430. /**
  32431. * Defines edge width used when edgesRenderer is enabled
  32432. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32433. */
  32434. edgesWidth: number;
  32435. /**
  32436. * Defines edge color used when edgesRenderer is enabled
  32437. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32438. */
  32439. edgesColor: Color4;
  32440. /** @hidden */
  32441. _edgesRenderer: Nullable<IEdgesRenderer>;
  32442. /** @hidden */
  32443. _masterMesh: Nullable<AbstractMesh>;
  32444. /** @hidden */
  32445. _boundingInfo: Nullable<BoundingInfo>;
  32446. /** @hidden */
  32447. _renderId: number;
  32448. /**
  32449. * Gets or sets the list of subMeshes
  32450. * @see http://doc.babylonjs.com/how_to/multi_materials
  32451. */
  32452. subMeshes: SubMesh[];
  32453. /** @hidden */
  32454. _intersectionsInProgress: AbstractMesh[];
  32455. /** @hidden */
  32456. _unIndexed: boolean;
  32457. /** @hidden */
  32458. _lightSources: Light[];
  32459. /** Gets the list of lights affecting that mesh */
  32460. get lightSources(): Light[];
  32461. /** @hidden */
  32462. get _positions(): Nullable<Vector3[]>;
  32463. /** @hidden */
  32464. _waitingData: {
  32465. lods: Nullable<any>;
  32466. actions: Nullable<any>;
  32467. freezeWorldMatrix: Nullable<boolean>;
  32468. };
  32469. /** @hidden */
  32470. _bonesTransformMatrices: Nullable<Float32Array>;
  32471. /** @hidden */
  32472. _transformMatrixTexture: Nullable<RawTexture>;
  32473. /**
  32474. * Gets or sets a skeleton to apply skining transformations
  32475. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32476. */
  32477. set skeleton(value: Nullable<Skeleton>);
  32478. get skeleton(): Nullable<Skeleton>;
  32479. /**
  32480. * An event triggered when the mesh is rebuilt.
  32481. */
  32482. onRebuildObservable: Observable<AbstractMesh>;
  32483. /**
  32484. * Creates a new AbstractMesh
  32485. * @param name defines the name of the mesh
  32486. * @param scene defines the hosting scene
  32487. */
  32488. constructor(name: string, scene?: Nullable<Scene>);
  32489. /**
  32490. * Returns the string "AbstractMesh"
  32491. * @returns "AbstractMesh"
  32492. */
  32493. getClassName(): string;
  32494. /**
  32495. * Gets a string representation of the current mesh
  32496. * @param fullDetails defines a boolean indicating if full details must be included
  32497. * @returns a string representation of the current mesh
  32498. */
  32499. toString(fullDetails?: boolean): string;
  32500. /**
  32501. * @hidden
  32502. */
  32503. protected _getEffectiveParent(): Nullable<Node>;
  32504. /** @hidden */
  32505. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32506. /** @hidden */
  32507. _rebuild(): void;
  32508. /** @hidden */
  32509. _resyncLightSources(): void;
  32510. /** @hidden */
  32511. _resyncLightSource(light: Light): void;
  32512. /** @hidden */
  32513. _unBindEffect(): void;
  32514. /** @hidden */
  32515. _removeLightSource(light: Light, dispose: boolean): void;
  32516. private _markSubMeshesAsDirty;
  32517. /** @hidden */
  32518. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32519. /** @hidden */
  32520. _markSubMeshesAsAttributesDirty(): void;
  32521. /** @hidden */
  32522. _markSubMeshesAsMiscDirty(): void;
  32523. /**
  32524. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32525. */
  32526. get scaling(): Vector3;
  32527. set scaling(newScaling: Vector3);
  32528. /**
  32529. * Returns true if the mesh is blocked. Implemented by child classes
  32530. */
  32531. get isBlocked(): boolean;
  32532. /**
  32533. * Returns the mesh itself by default. Implemented by child classes
  32534. * @param camera defines the camera to use to pick the right LOD level
  32535. * @returns the currentAbstractMesh
  32536. */
  32537. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32538. /**
  32539. * Returns 0 by default. Implemented by child classes
  32540. * @returns an integer
  32541. */
  32542. getTotalVertices(): number;
  32543. /**
  32544. * Returns a positive integer : the total number of indices in this mesh geometry.
  32545. * @returns the numner of indices or zero if the mesh has no geometry.
  32546. */
  32547. getTotalIndices(): number;
  32548. /**
  32549. * Returns null by default. Implemented by child classes
  32550. * @returns null
  32551. */
  32552. getIndices(): Nullable<IndicesArray>;
  32553. /**
  32554. * Returns the array of the requested vertex data kind. Implemented by child classes
  32555. * @param kind defines the vertex data kind to use
  32556. * @returns null
  32557. */
  32558. getVerticesData(kind: string): Nullable<FloatArray>;
  32559. /**
  32560. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32561. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32562. * Note that a new underlying VertexBuffer object is created each call.
  32563. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32564. * @param kind defines vertex data kind:
  32565. * * VertexBuffer.PositionKind
  32566. * * VertexBuffer.UVKind
  32567. * * VertexBuffer.UV2Kind
  32568. * * VertexBuffer.UV3Kind
  32569. * * VertexBuffer.UV4Kind
  32570. * * VertexBuffer.UV5Kind
  32571. * * VertexBuffer.UV6Kind
  32572. * * VertexBuffer.ColorKind
  32573. * * VertexBuffer.MatricesIndicesKind
  32574. * * VertexBuffer.MatricesIndicesExtraKind
  32575. * * VertexBuffer.MatricesWeightsKind
  32576. * * VertexBuffer.MatricesWeightsExtraKind
  32577. * @param data defines the data source
  32578. * @param updatable defines if the data must be flagged as updatable (or static)
  32579. * @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
  32580. * @returns the current mesh
  32581. */
  32582. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32583. /**
  32584. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32585. * If the mesh has no geometry, it is simply returned as it is.
  32586. * @param kind defines vertex data kind:
  32587. * * VertexBuffer.PositionKind
  32588. * * VertexBuffer.UVKind
  32589. * * VertexBuffer.UV2Kind
  32590. * * VertexBuffer.UV3Kind
  32591. * * VertexBuffer.UV4Kind
  32592. * * VertexBuffer.UV5Kind
  32593. * * VertexBuffer.UV6Kind
  32594. * * VertexBuffer.ColorKind
  32595. * * VertexBuffer.MatricesIndicesKind
  32596. * * VertexBuffer.MatricesIndicesExtraKind
  32597. * * VertexBuffer.MatricesWeightsKind
  32598. * * VertexBuffer.MatricesWeightsExtraKind
  32599. * @param data defines the data source
  32600. * @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
  32601. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32602. * @returns the current mesh
  32603. */
  32604. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32605. /**
  32606. * Sets the mesh indices,
  32607. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32608. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32609. * @param totalVertices Defines the total number of vertices
  32610. * @returns the current mesh
  32611. */
  32612. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32613. /**
  32614. * Gets a boolean indicating if specific vertex data is present
  32615. * @param kind defines the vertex data kind to use
  32616. * @returns true is data kind is present
  32617. */
  32618. isVerticesDataPresent(kind: string): boolean;
  32619. /**
  32620. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32621. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32622. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32623. * @returns a BoundingInfo
  32624. */
  32625. getBoundingInfo(): BoundingInfo;
  32626. /**
  32627. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32628. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32629. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32630. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32631. * @returns the current mesh
  32632. */
  32633. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32634. /**
  32635. * Overwrite the current bounding info
  32636. * @param boundingInfo defines the new bounding info
  32637. * @returns the current mesh
  32638. */
  32639. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32640. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32641. get useBones(): boolean;
  32642. /** @hidden */
  32643. _preActivate(): void;
  32644. /** @hidden */
  32645. _preActivateForIntermediateRendering(renderId: number): void;
  32646. /** @hidden */
  32647. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32648. /** @hidden */
  32649. _postActivate(): void;
  32650. /** @hidden */
  32651. _freeze(): void;
  32652. /** @hidden */
  32653. _unFreeze(): void;
  32654. /**
  32655. * Gets the current world matrix
  32656. * @returns a Matrix
  32657. */
  32658. getWorldMatrix(): Matrix;
  32659. /** @hidden */
  32660. _getWorldMatrixDeterminant(): number;
  32661. /**
  32662. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32663. */
  32664. get isAnInstance(): boolean;
  32665. /**
  32666. * Gets a boolean indicating if this mesh has instances
  32667. */
  32668. get hasInstances(): boolean;
  32669. /**
  32670. * Gets a boolean indicating if this mesh has thin instances
  32671. */
  32672. get hasThinInstances(): boolean;
  32673. /**
  32674. * Perform relative position change from the point of view of behind the front of the mesh.
  32675. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32676. * Supports definition of mesh facing forward or backward
  32677. * @param amountRight defines the distance on the right axis
  32678. * @param amountUp defines the distance on the up axis
  32679. * @param amountForward defines the distance on the forward axis
  32680. * @returns the current mesh
  32681. */
  32682. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32683. /**
  32684. * Calculate relative position change from the point of view of behind the front of the mesh.
  32685. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32686. * Supports definition of mesh facing forward or backward
  32687. * @param amountRight defines the distance on the right axis
  32688. * @param amountUp defines the distance on the up axis
  32689. * @param amountForward defines the distance on the forward axis
  32690. * @returns the new displacement vector
  32691. */
  32692. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32693. /**
  32694. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32695. * Supports definition of mesh facing forward or backward
  32696. * @param flipBack defines the flip
  32697. * @param twirlClockwise defines the twirl
  32698. * @param tiltRight defines the tilt
  32699. * @returns the current mesh
  32700. */
  32701. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32702. /**
  32703. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32704. * Supports definition of mesh facing forward or backward.
  32705. * @param flipBack defines the flip
  32706. * @param twirlClockwise defines the twirl
  32707. * @param tiltRight defines the tilt
  32708. * @returns the new rotation vector
  32709. */
  32710. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32711. /**
  32712. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32713. * This means the mesh underlying bounding box and sphere are recomputed.
  32714. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32715. * @returns the current mesh
  32716. */
  32717. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32718. /** @hidden */
  32719. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32720. /** @hidden */
  32721. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32722. /** @hidden */
  32723. _updateBoundingInfo(): AbstractMesh;
  32724. /** @hidden */
  32725. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32726. /** @hidden */
  32727. protected _afterComputeWorldMatrix(): void;
  32728. /** @hidden */
  32729. get _effectiveMesh(): AbstractMesh;
  32730. /**
  32731. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32732. * A mesh is in the frustum if its bounding box intersects the frustum
  32733. * @param frustumPlanes defines the frustum to test
  32734. * @returns true if the mesh is in the frustum planes
  32735. */
  32736. isInFrustum(frustumPlanes: Plane[]): boolean;
  32737. /**
  32738. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32739. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32740. * @param frustumPlanes defines the frustum to test
  32741. * @returns true if the mesh is completely in the frustum planes
  32742. */
  32743. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32744. /**
  32745. * True if the mesh intersects another mesh or a SolidParticle object
  32746. * @param mesh defines a target mesh or SolidParticle to test
  32747. * @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)
  32748. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32749. * @returns true if there is an intersection
  32750. */
  32751. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32752. /**
  32753. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32754. * @param point defines the point to test
  32755. * @returns true if there is an intersection
  32756. */
  32757. intersectsPoint(point: Vector3): boolean;
  32758. /**
  32759. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32760. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32761. */
  32762. get checkCollisions(): boolean;
  32763. set checkCollisions(collisionEnabled: boolean);
  32764. /**
  32765. * Gets Collider object used to compute collisions (not physics)
  32766. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32767. */
  32768. get collider(): Nullable<Collider>;
  32769. /**
  32770. * Move the mesh using collision engine
  32771. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32772. * @param displacement defines the requested displacement vector
  32773. * @returns the current mesh
  32774. */
  32775. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32776. private _onCollisionPositionChange;
  32777. /** @hidden */
  32778. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32779. /** @hidden */
  32780. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32781. /** @hidden */
  32782. _checkCollision(collider: Collider): AbstractMesh;
  32783. /** @hidden */
  32784. _generatePointsArray(): boolean;
  32785. /**
  32786. * Checks if the passed Ray intersects with the mesh
  32787. * @param ray defines the ray to use
  32788. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32789. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32790. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32791. * @returns the picking info
  32792. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32793. */
  32794. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32795. /**
  32796. * Clones the current mesh
  32797. * @param name defines the mesh name
  32798. * @param newParent defines the new mesh parent
  32799. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32800. * @returns the new mesh
  32801. */
  32802. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32803. /**
  32804. * Disposes all the submeshes of the current meshnp
  32805. * @returns the current mesh
  32806. */
  32807. releaseSubMeshes(): AbstractMesh;
  32808. /**
  32809. * Releases resources associated with this abstract mesh.
  32810. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32811. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32812. */
  32813. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32814. /**
  32815. * Adds the passed mesh as a child to the current mesh
  32816. * @param mesh defines the child mesh
  32817. * @returns the current mesh
  32818. */
  32819. addChild(mesh: AbstractMesh): AbstractMesh;
  32820. /**
  32821. * Removes the passed mesh from the current mesh children list
  32822. * @param mesh defines the child mesh
  32823. * @returns the current mesh
  32824. */
  32825. removeChild(mesh: AbstractMesh): AbstractMesh;
  32826. /** @hidden */
  32827. private _initFacetData;
  32828. /**
  32829. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32830. * This method can be called within the render loop.
  32831. * 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
  32832. * @returns the current mesh
  32833. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32834. */
  32835. updateFacetData(): AbstractMesh;
  32836. /**
  32837. * Returns the facetLocalNormals array.
  32838. * The normals are expressed in the mesh local spac
  32839. * @returns an array of Vector3
  32840. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32841. */
  32842. getFacetLocalNormals(): Vector3[];
  32843. /**
  32844. * Returns the facetLocalPositions array.
  32845. * The facet positions are expressed in the mesh local space
  32846. * @returns an array of Vector3
  32847. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32848. */
  32849. getFacetLocalPositions(): Vector3[];
  32850. /**
  32851. * Returns the facetLocalPartioning array
  32852. * @returns an array of array of numbers
  32853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32854. */
  32855. getFacetLocalPartitioning(): number[][];
  32856. /**
  32857. * Returns the i-th facet position in the world system.
  32858. * This method allocates a new Vector3 per call
  32859. * @param i defines the facet index
  32860. * @returns a new Vector3
  32861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32862. */
  32863. getFacetPosition(i: number): Vector3;
  32864. /**
  32865. * Sets the reference Vector3 with the i-th facet position in the world system
  32866. * @param i defines the facet index
  32867. * @param ref defines the target vector
  32868. * @returns the current mesh
  32869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32870. */
  32871. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32872. /**
  32873. * Returns the i-th facet normal in the world system.
  32874. * This method allocates a new Vector3 per call
  32875. * @param i defines the facet index
  32876. * @returns a new Vector3
  32877. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32878. */
  32879. getFacetNormal(i: number): Vector3;
  32880. /**
  32881. * Sets the reference Vector3 with the i-th facet normal in the world system
  32882. * @param i defines the facet index
  32883. * @param ref defines the target vector
  32884. * @returns the current mesh
  32885. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32886. */
  32887. getFacetNormalToRef(i: number, ref: Vector3): this;
  32888. /**
  32889. * 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)
  32890. * @param x defines x coordinate
  32891. * @param y defines y coordinate
  32892. * @param z defines z coordinate
  32893. * @returns the array of facet indexes
  32894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32895. */
  32896. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32897. /**
  32898. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32899. * @param projected sets as the (x,y,z) world projection on the facet
  32900. * @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
  32901. * @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
  32902. * @param x defines x coordinate
  32903. * @param y defines y coordinate
  32904. * @param z defines z coordinate
  32905. * @returns the face index if found (or null instead)
  32906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32907. */
  32908. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32909. /**
  32910. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32911. * @param projected sets as the (x,y,z) local projection on the facet
  32912. * @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
  32913. * @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
  32914. * @param x defines x coordinate
  32915. * @param y defines y coordinate
  32916. * @param z defines z coordinate
  32917. * @returns the face index if found (or null instead)
  32918. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32919. */
  32920. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32921. /**
  32922. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32923. * @returns the parameters
  32924. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32925. */
  32926. getFacetDataParameters(): any;
  32927. /**
  32928. * Disables the feature FacetData and frees the related memory
  32929. * @returns the current mesh
  32930. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32931. */
  32932. disableFacetData(): AbstractMesh;
  32933. /**
  32934. * Updates the AbstractMesh indices array
  32935. * @param indices defines the data source
  32936. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32937. * @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)
  32938. * @returns the current mesh
  32939. */
  32940. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32941. /**
  32942. * Creates new normals data for the mesh
  32943. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32944. * @returns the current mesh
  32945. */
  32946. createNormals(updatable: boolean): AbstractMesh;
  32947. /**
  32948. * Align the mesh with a normal
  32949. * @param normal defines the normal to use
  32950. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32951. * @returns the current mesh
  32952. */
  32953. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32954. /** @hidden */
  32955. _checkOcclusionQuery(): boolean;
  32956. /**
  32957. * Disables the mesh edge rendering mode
  32958. * @returns the currentAbstractMesh
  32959. */
  32960. disableEdgesRendering(): AbstractMesh;
  32961. /**
  32962. * Enables the edge rendering mode on the mesh.
  32963. * This mode makes the mesh edges visible
  32964. * @param epsilon defines the maximal distance between two angles to detect a face
  32965. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32966. * @returns the currentAbstractMesh
  32967. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32968. */
  32969. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32970. }
  32971. }
  32972. declare module "babylonjs/Actions/actionEvent" {
  32973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32974. import { Nullable } from "babylonjs/types";
  32975. import { Sprite } from "babylonjs/Sprites/sprite";
  32976. import { Scene } from "babylonjs/scene";
  32977. import { Vector2 } from "babylonjs/Maths/math.vector";
  32978. /**
  32979. * Interface used to define ActionEvent
  32980. */
  32981. export interface IActionEvent {
  32982. /** The mesh or sprite that triggered the action */
  32983. source: any;
  32984. /** The X mouse cursor position at the time of the event */
  32985. pointerX: number;
  32986. /** The Y mouse cursor position at the time of the event */
  32987. pointerY: number;
  32988. /** The mesh that is currently pointed at (can be null) */
  32989. meshUnderPointer: Nullable<AbstractMesh>;
  32990. /** the original (browser) event that triggered the ActionEvent */
  32991. sourceEvent?: any;
  32992. /** additional data for the event */
  32993. additionalData?: any;
  32994. }
  32995. /**
  32996. * ActionEvent is the event being sent when an action is triggered.
  32997. */
  32998. export class ActionEvent implements IActionEvent {
  32999. /** The mesh or sprite that triggered the action */
  33000. source: any;
  33001. /** The X mouse cursor position at the time of the event */
  33002. pointerX: number;
  33003. /** The Y mouse cursor position at the time of the event */
  33004. pointerY: number;
  33005. /** The mesh that is currently pointed at (can be null) */
  33006. meshUnderPointer: Nullable<AbstractMesh>;
  33007. /** the original (browser) event that triggered the ActionEvent */
  33008. sourceEvent?: any;
  33009. /** additional data for the event */
  33010. additionalData?: any;
  33011. /**
  33012. * Creates a new ActionEvent
  33013. * @param source The mesh or sprite that triggered the action
  33014. * @param pointerX The X mouse cursor position at the time of the event
  33015. * @param pointerY The Y mouse cursor position at the time of the event
  33016. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33017. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33018. * @param additionalData additional data for the event
  33019. */
  33020. constructor(
  33021. /** The mesh or sprite that triggered the action */
  33022. source: any,
  33023. /** The X mouse cursor position at the time of the event */
  33024. pointerX: number,
  33025. /** The Y mouse cursor position at the time of the event */
  33026. pointerY: number,
  33027. /** The mesh that is currently pointed at (can be null) */
  33028. meshUnderPointer: Nullable<AbstractMesh>,
  33029. /** the original (browser) event that triggered the ActionEvent */
  33030. sourceEvent?: any,
  33031. /** additional data for the event */
  33032. additionalData?: any);
  33033. /**
  33034. * Helper function to auto-create an ActionEvent from a source mesh.
  33035. * @param source The source mesh that triggered the event
  33036. * @param evt The original (browser) event
  33037. * @param additionalData additional data for the event
  33038. * @returns the new ActionEvent
  33039. */
  33040. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33041. /**
  33042. * Helper function to auto-create an ActionEvent from a source sprite
  33043. * @param source The source sprite that triggered the event
  33044. * @param scene Scene associated with the sprite
  33045. * @param evt The original (browser) event
  33046. * @param additionalData additional data for the event
  33047. * @returns the new ActionEvent
  33048. */
  33049. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33050. /**
  33051. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33052. * @param scene the scene where the event occurred
  33053. * @param evt The original (browser) event
  33054. * @returns the new ActionEvent
  33055. */
  33056. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33057. /**
  33058. * Helper function to auto-create an ActionEvent from a primitive
  33059. * @param prim defines the target primitive
  33060. * @param pointerPos defines the pointer position
  33061. * @param evt The original (browser) event
  33062. * @param additionalData additional data for the event
  33063. * @returns the new ActionEvent
  33064. */
  33065. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33066. }
  33067. }
  33068. declare module "babylonjs/Actions/abstractActionManager" {
  33069. import { IDisposable } from "babylonjs/scene";
  33070. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33071. import { IAction } from "babylonjs/Actions/action";
  33072. import { Nullable } from "babylonjs/types";
  33073. /**
  33074. * Abstract class used to decouple action Manager from scene and meshes.
  33075. * Do not instantiate.
  33076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33077. */
  33078. export abstract class AbstractActionManager implements IDisposable {
  33079. /** Gets the list of active triggers */
  33080. static Triggers: {
  33081. [key: string]: number;
  33082. };
  33083. /** Gets the cursor to use when hovering items */
  33084. hoverCursor: string;
  33085. /** Gets the list of actions */
  33086. actions: IAction[];
  33087. /**
  33088. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33089. */
  33090. isRecursive: boolean;
  33091. /**
  33092. * Releases all associated resources
  33093. */
  33094. abstract dispose(): void;
  33095. /**
  33096. * Does this action manager has pointer triggers
  33097. */
  33098. abstract get hasPointerTriggers(): boolean;
  33099. /**
  33100. * Does this action manager has pick triggers
  33101. */
  33102. abstract get hasPickTriggers(): boolean;
  33103. /**
  33104. * Process a specific trigger
  33105. * @param trigger defines the trigger to process
  33106. * @param evt defines the event details to be processed
  33107. */
  33108. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33109. /**
  33110. * Does this action manager handles actions of any of the given triggers
  33111. * @param triggers defines the triggers to be tested
  33112. * @return a boolean indicating whether one (or more) of the triggers is handled
  33113. */
  33114. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33115. /**
  33116. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33117. * speed.
  33118. * @param triggerA defines the trigger to be tested
  33119. * @param triggerB defines the trigger to be tested
  33120. * @return a boolean indicating whether one (or more) of the triggers is handled
  33121. */
  33122. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33123. /**
  33124. * Does this action manager handles actions of a given trigger
  33125. * @param trigger defines the trigger to be tested
  33126. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33127. * @return whether the trigger is handled
  33128. */
  33129. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33130. /**
  33131. * Serialize this manager to a JSON object
  33132. * @param name defines the property name to store this manager
  33133. * @returns a JSON representation of this manager
  33134. */
  33135. abstract serialize(name: string): any;
  33136. /**
  33137. * Registers an action to this action manager
  33138. * @param action defines the action to be registered
  33139. * @return the action amended (prepared) after registration
  33140. */
  33141. abstract registerAction(action: IAction): Nullable<IAction>;
  33142. /**
  33143. * Unregisters an action to this action manager
  33144. * @param action defines the action to be unregistered
  33145. * @return a boolean indicating whether the action has been unregistered
  33146. */
  33147. abstract unregisterAction(action: IAction): Boolean;
  33148. /**
  33149. * Does exist one action manager with at least one trigger
  33150. **/
  33151. static get HasTriggers(): boolean;
  33152. /**
  33153. * Does exist one action manager with at least one pick trigger
  33154. **/
  33155. static get HasPickTriggers(): boolean;
  33156. /**
  33157. * Does exist one action manager that handles actions of a given trigger
  33158. * @param trigger defines the trigger to be tested
  33159. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33160. **/
  33161. static HasSpecificTrigger(trigger: number): boolean;
  33162. }
  33163. }
  33164. declare module "babylonjs/node" {
  33165. import { Scene } from "babylonjs/scene";
  33166. import { Nullable } from "babylonjs/types";
  33167. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33168. import { Engine } from "babylonjs/Engines/engine";
  33169. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33170. import { Observable } from "babylonjs/Misc/observable";
  33171. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33172. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33173. import { Animatable } from "babylonjs/Animations/animatable";
  33174. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33175. import { Animation } from "babylonjs/Animations/animation";
  33176. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33178. /**
  33179. * Defines how a node can be built from a string name.
  33180. */
  33181. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33182. /**
  33183. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33184. */
  33185. export class Node implements IBehaviorAware<Node> {
  33186. /** @hidden */
  33187. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  33188. private static _NodeConstructors;
  33189. /**
  33190. * Add a new node constructor
  33191. * @param type defines the type name of the node to construct
  33192. * @param constructorFunc defines the constructor function
  33193. */
  33194. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33195. /**
  33196. * Returns a node constructor based on type name
  33197. * @param type defines the type name
  33198. * @param name defines the new node name
  33199. * @param scene defines the hosting scene
  33200. * @param options defines optional options to transmit to constructors
  33201. * @returns the new constructor or null
  33202. */
  33203. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33204. /**
  33205. * Gets or sets the name of the node
  33206. */
  33207. name: string;
  33208. /**
  33209. * Gets or sets the id of the node
  33210. */
  33211. id: string;
  33212. /**
  33213. * Gets or sets the unique id of the node
  33214. */
  33215. uniqueId: number;
  33216. /**
  33217. * Gets or sets a string used to store user defined state for the node
  33218. */
  33219. state: string;
  33220. /**
  33221. * Gets or sets an object used to store user defined information for the node
  33222. */
  33223. metadata: any;
  33224. /**
  33225. * For internal use only. Please do not use.
  33226. */
  33227. reservedDataStore: any;
  33228. /**
  33229. * List of inspectable custom properties (used by the Inspector)
  33230. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33231. */
  33232. inspectableCustomProperties: IInspectable[];
  33233. private _doNotSerialize;
  33234. /**
  33235. * Gets or sets a boolean used to define if the node must be serialized
  33236. */
  33237. get doNotSerialize(): boolean;
  33238. set doNotSerialize(value: boolean);
  33239. /** @hidden */
  33240. _isDisposed: boolean;
  33241. /**
  33242. * Gets a list of Animations associated with the node
  33243. */
  33244. animations: import("babylonjs/Animations/animation").Animation[];
  33245. protected _ranges: {
  33246. [name: string]: Nullable<AnimationRange>;
  33247. };
  33248. /**
  33249. * Callback raised when the node is ready to be used
  33250. */
  33251. onReady: Nullable<(node: Node) => void>;
  33252. private _isEnabled;
  33253. private _isParentEnabled;
  33254. private _isReady;
  33255. /** @hidden */
  33256. _currentRenderId: number;
  33257. private _parentUpdateId;
  33258. /** @hidden */
  33259. _childUpdateId: number;
  33260. /** @hidden */
  33261. _waitingParentId: Nullable<string>;
  33262. /** @hidden */
  33263. _scene: Scene;
  33264. /** @hidden */
  33265. _cache: any;
  33266. private _parentNode;
  33267. private _children;
  33268. /** @hidden */
  33269. _worldMatrix: Matrix;
  33270. /** @hidden */
  33271. _worldMatrixDeterminant: number;
  33272. /** @hidden */
  33273. _worldMatrixDeterminantIsDirty: boolean;
  33274. /** @hidden */
  33275. private _sceneRootNodesIndex;
  33276. /**
  33277. * Gets a boolean indicating if the node has been disposed
  33278. * @returns true if the node was disposed
  33279. */
  33280. isDisposed(): boolean;
  33281. /**
  33282. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33283. * @see https://doc.babylonjs.com/how_to/parenting
  33284. */
  33285. set parent(parent: Nullable<Node>);
  33286. get parent(): Nullable<Node>;
  33287. /** @hidden */
  33288. _addToSceneRootNodes(): void;
  33289. /** @hidden */
  33290. _removeFromSceneRootNodes(): void;
  33291. private _animationPropertiesOverride;
  33292. /**
  33293. * Gets or sets the animation properties override
  33294. */
  33295. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33296. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33297. /**
  33298. * Gets a string idenfifying the name of the class
  33299. * @returns "Node" string
  33300. */
  33301. getClassName(): string;
  33302. /** @hidden */
  33303. readonly _isNode: boolean;
  33304. /**
  33305. * An event triggered when the mesh is disposed
  33306. */
  33307. onDisposeObservable: Observable<Node>;
  33308. private _onDisposeObserver;
  33309. /**
  33310. * Sets a callback that will be raised when the node will be disposed
  33311. */
  33312. set onDispose(callback: () => void);
  33313. /**
  33314. * Creates a new Node
  33315. * @param name the name and id to be given to this node
  33316. * @param scene the scene this node will be added to
  33317. */
  33318. constructor(name: string, scene?: Nullable<Scene>);
  33319. /**
  33320. * Gets the scene of the node
  33321. * @returns a scene
  33322. */
  33323. getScene(): Scene;
  33324. /**
  33325. * Gets the engine of the node
  33326. * @returns a Engine
  33327. */
  33328. getEngine(): Engine;
  33329. private _behaviors;
  33330. /**
  33331. * Attach a behavior to the node
  33332. * @see http://doc.babylonjs.com/features/behaviour
  33333. * @param behavior defines the behavior to attach
  33334. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33335. * @returns the current Node
  33336. */
  33337. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33338. /**
  33339. * Remove an attached behavior
  33340. * @see http://doc.babylonjs.com/features/behaviour
  33341. * @param behavior defines the behavior to attach
  33342. * @returns the current Node
  33343. */
  33344. removeBehavior(behavior: Behavior<Node>): Node;
  33345. /**
  33346. * Gets the list of attached behaviors
  33347. * @see http://doc.babylonjs.com/features/behaviour
  33348. */
  33349. get behaviors(): Behavior<Node>[];
  33350. /**
  33351. * Gets an attached behavior by name
  33352. * @param name defines the name of the behavior to look for
  33353. * @see http://doc.babylonjs.com/features/behaviour
  33354. * @returns null if behavior was not found else the requested behavior
  33355. */
  33356. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33357. /**
  33358. * Returns the latest update of the World matrix
  33359. * @returns a Matrix
  33360. */
  33361. getWorldMatrix(): Matrix;
  33362. /** @hidden */
  33363. _getWorldMatrixDeterminant(): number;
  33364. /**
  33365. * Returns directly the latest state of the mesh World matrix.
  33366. * A Matrix is returned.
  33367. */
  33368. get worldMatrixFromCache(): Matrix;
  33369. /** @hidden */
  33370. _initCache(): void;
  33371. /** @hidden */
  33372. updateCache(force?: boolean): void;
  33373. /** @hidden */
  33374. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33375. /** @hidden */
  33376. _updateCache(ignoreParentClass?: boolean): void;
  33377. /** @hidden */
  33378. _isSynchronized(): boolean;
  33379. /** @hidden */
  33380. _markSyncedWithParent(): void;
  33381. /** @hidden */
  33382. isSynchronizedWithParent(): boolean;
  33383. /** @hidden */
  33384. isSynchronized(): boolean;
  33385. /**
  33386. * Is this node ready to be used/rendered
  33387. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33388. * @return true if the node is ready
  33389. */
  33390. isReady(completeCheck?: boolean): boolean;
  33391. /**
  33392. * Is this node enabled?
  33393. * 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
  33394. * @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
  33395. * @return whether this node (and its parent) is enabled
  33396. */
  33397. isEnabled(checkAncestors?: boolean): boolean;
  33398. /** @hidden */
  33399. protected _syncParentEnabledState(): void;
  33400. /**
  33401. * Set the enabled state of this node
  33402. * @param value defines the new enabled state
  33403. */
  33404. setEnabled(value: boolean): void;
  33405. /**
  33406. * Is this node a descendant of the given node?
  33407. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33408. * @param ancestor defines the parent node to inspect
  33409. * @returns a boolean indicating if this node is a descendant of the given node
  33410. */
  33411. isDescendantOf(ancestor: Node): boolean;
  33412. /** @hidden */
  33413. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33414. /**
  33415. * Will return all nodes that have this node as ascendant
  33416. * @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
  33417. * @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
  33418. * @return all children nodes of all types
  33419. */
  33420. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33421. /**
  33422. * Get all child-meshes of this node
  33423. * @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)
  33424. * @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
  33425. * @returns an array of AbstractMesh
  33426. */
  33427. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33428. /**
  33429. * Get all direct children of this node
  33430. * @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
  33431. * @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)
  33432. * @returns an array of Node
  33433. */
  33434. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33435. /** @hidden */
  33436. _setReady(state: boolean): void;
  33437. /**
  33438. * Get an animation by name
  33439. * @param name defines the name of the animation to look for
  33440. * @returns null if not found else the requested animation
  33441. */
  33442. getAnimationByName(name: string): Nullable<Animation>;
  33443. /**
  33444. * Creates an animation range for this node
  33445. * @param name defines the name of the range
  33446. * @param from defines the starting key
  33447. * @param to defines the end key
  33448. */
  33449. createAnimationRange(name: string, from: number, to: number): void;
  33450. /**
  33451. * Delete a specific animation range
  33452. * @param name defines the name of the range to delete
  33453. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33454. */
  33455. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33456. /**
  33457. * Get an animation range by name
  33458. * @param name defines the name of the animation range to look for
  33459. * @returns null if not found else the requested animation range
  33460. */
  33461. getAnimationRange(name: string): Nullable<AnimationRange>;
  33462. /**
  33463. * Gets the list of all animation ranges defined on this node
  33464. * @returns an array
  33465. */
  33466. getAnimationRanges(): Nullable<AnimationRange>[];
  33467. /**
  33468. * Will start the animation sequence
  33469. * @param name defines the range frames for animation sequence
  33470. * @param loop defines if the animation should loop (false by default)
  33471. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33472. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33473. * @returns the object created for this animation. If range does not exist, it will return null
  33474. */
  33475. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33476. /**
  33477. * Serialize animation ranges into a JSON compatible object
  33478. * @returns serialization object
  33479. */
  33480. serializeAnimationRanges(): any;
  33481. /**
  33482. * Computes the world matrix of the node
  33483. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33484. * @returns the world matrix
  33485. */
  33486. computeWorldMatrix(force?: boolean): Matrix;
  33487. /**
  33488. * Releases resources associated with this node.
  33489. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33490. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33491. */
  33492. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33493. /**
  33494. * Parse animation range data from a serialization object and store them into a given node
  33495. * @param node defines where to store the animation ranges
  33496. * @param parsedNode defines the serialization object to read data from
  33497. * @param scene defines the hosting scene
  33498. */
  33499. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33500. /**
  33501. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33502. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33503. * @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
  33504. * @returns the new bounding vectors
  33505. */
  33506. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33507. min: Vector3;
  33508. max: Vector3;
  33509. };
  33510. }
  33511. }
  33512. declare module "babylonjs/Animations/animation" {
  33513. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33514. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33515. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33516. import { Nullable } from "babylonjs/types";
  33517. import { Scene } from "babylonjs/scene";
  33518. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33519. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33520. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33521. import { Node } from "babylonjs/node";
  33522. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33523. import { Size } from "babylonjs/Maths/math.size";
  33524. import { Animatable } from "babylonjs/Animations/animatable";
  33525. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33526. /**
  33527. * @hidden
  33528. */
  33529. export class _IAnimationState {
  33530. key: number;
  33531. repeatCount: number;
  33532. workValue?: any;
  33533. loopMode?: number;
  33534. offsetValue?: any;
  33535. highLimitValue?: any;
  33536. }
  33537. /**
  33538. * Class used to store any kind of animation
  33539. */
  33540. export class Animation {
  33541. /**Name of the animation */
  33542. name: string;
  33543. /**Property to animate */
  33544. targetProperty: string;
  33545. /**The frames per second of the animation */
  33546. framePerSecond: number;
  33547. /**The data type of the animation */
  33548. dataType: number;
  33549. /**The loop mode of the animation */
  33550. loopMode?: number | undefined;
  33551. /**Specifies if blending should be enabled */
  33552. enableBlending?: boolean | undefined;
  33553. /**
  33554. * Use matrix interpolation instead of using direct key value when animating matrices
  33555. */
  33556. static AllowMatricesInterpolation: boolean;
  33557. /**
  33558. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33559. */
  33560. static AllowMatrixDecomposeForInterpolation: boolean;
  33561. /** Define the Url to load snippets */
  33562. static SnippetUrl: string;
  33563. /** Snippet ID if the animation was created from the snippet server */
  33564. snippetId: string;
  33565. /**
  33566. * Stores the key frames of the animation
  33567. */
  33568. private _keys;
  33569. /**
  33570. * Stores the easing function of the animation
  33571. */
  33572. private _easingFunction;
  33573. /**
  33574. * @hidden Internal use only
  33575. */
  33576. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33577. /**
  33578. * The set of event that will be linked to this animation
  33579. */
  33580. private _events;
  33581. /**
  33582. * Stores an array of target property paths
  33583. */
  33584. targetPropertyPath: string[];
  33585. /**
  33586. * Stores the blending speed of the animation
  33587. */
  33588. blendingSpeed: number;
  33589. /**
  33590. * Stores the animation ranges for the animation
  33591. */
  33592. private _ranges;
  33593. /**
  33594. * @hidden Internal use
  33595. */
  33596. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33597. /**
  33598. * Sets up an animation
  33599. * @param property The property to animate
  33600. * @param animationType The animation type to apply
  33601. * @param framePerSecond The frames per second of the animation
  33602. * @param easingFunction The easing function used in the animation
  33603. * @returns The created animation
  33604. */
  33605. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33606. /**
  33607. * Create and start an animation on a node
  33608. * @param name defines the name of the global animation that will be run on all nodes
  33609. * @param node defines the root node where the animation will take place
  33610. * @param targetProperty defines property to animate
  33611. * @param framePerSecond defines the number of frame per second yo use
  33612. * @param totalFrame defines the number of frames in total
  33613. * @param from defines the initial value
  33614. * @param to defines the final value
  33615. * @param loopMode defines which loop mode you want to use (off by default)
  33616. * @param easingFunction defines the easing function to use (linear by default)
  33617. * @param onAnimationEnd defines the callback to call when animation end
  33618. * @returns the animatable created for this animation
  33619. */
  33620. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33621. /**
  33622. * Create and start an animation on a node and its descendants
  33623. * @param name defines the name of the global animation that will be run on all nodes
  33624. * @param node defines the root node where the animation will take place
  33625. * @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
  33626. * @param targetProperty defines property to animate
  33627. * @param framePerSecond defines the number of frame per second to use
  33628. * @param totalFrame defines the number of frames in total
  33629. * @param from defines the initial value
  33630. * @param to defines the final value
  33631. * @param loopMode defines which loop mode you want to use (off by default)
  33632. * @param easingFunction defines the easing function to use (linear by default)
  33633. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33634. * @returns the list of animatables created for all nodes
  33635. * @example https://www.babylonjs-playground.com/#MH0VLI
  33636. */
  33637. 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[]>;
  33638. /**
  33639. * Creates a new animation, merges it with the existing animations and starts it
  33640. * @param name Name of the animation
  33641. * @param node Node which contains the scene that begins the animations
  33642. * @param targetProperty Specifies which property to animate
  33643. * @param framePerSecond The frames per second of the animation
  33644. * @param totalFrame The total number of frames
  33645. * @param from The frame at the beginning of the animation
  33646. * @param to The frame at the end of the animation
  33647. * @param loopMode Specifies the loop mode of the animation
  33648. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33649. * @param onAnimationEnd Callback to run once the animation is complete
  33650. * @returns Nullable animation
  33651. */
  33652. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33653. /**
  33654. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33655. * @param sourceAnimation defines the Animation containing keyframes to convert
  33656. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33657. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33658. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33659. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33660. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33661. */
  33662. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33663. /**
  33664. * Transition property of an host to the target Value
  33665. * @param property The property to transition
  33666. * @param targetValue The target Value of the property
  33667. * @param host The object where the property to animate belongs
  33668. * @param scene Scene used to run the animation
  33669. * @param frameRate Framerate (in frame/s) to use
  33670. * @param transition The transition type we want to use
  33671. * @param duration The duration of the animation, in milliseconds
  33672. * @param onAnimationEnd Callback trigger at the end of the animation
  33673. * @returns Nullable animation
  33674. */
  33675. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33676. /**
  33677. * Return the array of runtime animations currently using this animation
  33678. */
  33679. get runtimeAnimations(): RuntimeAnimation[];
  33680. /**
  33681. * Specifies if any of the runtime animations are currently running
  33682. */
  33683. get hasRunningRuntimeAnimations(): boolean;
  33684. /**
  33685. * Initializes the animation
  33686. * @param name Name of the animation
  33687. * @param targetProperty Property to animate
  33688. * @param framePerSecond The frames per second of the animation
  33689. * @param dataType The data type of the animation
  33690. * @param loopMode The loop mode of the animation
  33691. * @param enableBlending Specifies if blending should be enabled
  33692. */
  33693. constructor(
  33694. /**Name of the animation */
  33695. name: string,
  33696. /**Property to animate */
  33697. targetProperty: string,
  33698. /**The frames per second of the animation */
  33699. framePerSecond: number,
  33700. /**The data type of the animation */
  33701. dataType: number,
  33702. /**The loop mode of the animation */
  33703. loopMode?: number | undefined,
  33704. /**Specifies if blending should be enabled */
  33705. enableBlending?: boolean | undefined);
  33706. /**
  33707. * Converts the animation to a string
  33708. * @param fullDetails support for multiple levels of logging within scene loading
  33709. * @returns String form of the animation
  33710. */
  33711. toString(fullDetails?: boolean): string;
  33712. /**
  33713. * Add an event to this animation
  33714. * @param event Event to add
  33715. */
  33716. addEvent(event: AnimationEvent): void;
  33717. /**
  33718. * Remove all events found at the given frame
  33719. * @param frame The frame to remove events from
  33720. */
  33721. removeEvents(frame: number): void;
  33722. /**
  33723. * Retrieves all the events from the animation
  33724. * @returns Events from the animation
  33725. */
  33726. getEvents(): AnimationEvent[];
  33727. /**
  33728. * Creates an animation range
  33729. * @param name Name of the animation range
  33730. * @param from Starting frame of the animation range
  33731. * @param to Ending frame of the animation
  33732. */
  33733. createRange(name: string, from: number, to: number): void;
  33734. /**
  33735. * Deletes an animation range by name
  33736. * @param name Name of the animation range to delete
  33737. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33738. */
  33739. deleteRange(name: string, deleteFrames?: boolean): void;
  33740. /**
  33741. * Gets the animation range by name, or null if not defined
  33742. * @param name Name of the animation range
  33743. * @returns Nullable animation range
  33744. */
  33745. getRange(name: string): Nullable<AnimationRange>;
  33746. /**
  33747. * Gets the key frames from the animation
  33748. * @returns The key frames of the animation
  33749. */
  33750. getKeys(): Array<IAnimationKey>;
  33751. /**
  33752. * Gets the highest frame rate of the animation
  33753. * @returns Highest frame rate of the animation
  33754. */
  33755. getHighestFrame(): number;
  33756. /**
  33757. * Gets the easing function of the animation
  33758. * @returns Easing function of the animation
  33759. */
  33760. getEasingFunction(): IEasingFunction;
  33761. /**
  33762. * Sets the easing function of the animation
  33763. * @param easingFunction A custom mathematical formula for animation
  33764. */
  33765. setEasingFunction(easingFunction: EasingFunction): void;
  33766. /**
  33767. * Interpolates a scalar linearly
  33768. * @param startValue Start value of the animation curve
  33769. * @param endValue End value of the animation curve
  33770. * @param gradient Scalar amount to interpolate
  33771. * @returns Interpolated scalar value
  33772. */
  33773. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33774. /**
  33775. * Interpolates a scalar cubically
  33776. * @param startValue Start value of the animation curve
  33777. * @param outTangent End tangent of the animation
  33778. * @param endValue End value of the animation curve
  33779. * @param inTangent Start tangent of the animation curve
  33780. * @param gradient Scalar amount to interpolate
  33781. * @returns Interpolated scalar value
  33782. */
  33783. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33784. /**
  33785. * Interpolates a quaternion using a spherical linear interpolation
  33786. * @param startValue Start value of the animation curve
  33787. * @param endValue End value of the animation curve
  33788. * @param gradient Scalar amount to interpolate
  33789. * @returns Interpolated quaternion value
  33790. */
  33791. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33792. /**
  33793. * Interpolates a quaternion cubically
  33794. * @param startValue Start value of the animation curve
  33795. * @param outTangent End tangent of the animation curve
  33796. * @param endValue End value of the animation curve
  33797. * @param inTangent Start tangent of the animation curve
  33798. * @param gradient Scalar amount to interpolate
  33799. * @returns Interpolated quaternion value
  33800. */
  33801. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33802. /**
  33803. * Interpolates a Vector3 linearl
  33804. * @param startValue Start value of the animation curve
  33805. * @param endValue End value of the animation curve
  33806. * @param gradient Scalar amount to interpolate
  33807. * @returns Interpolated scalar value
  33808. */
  33809. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33810. /**
  33811. * Interpolates a Vector3 cubically
  33812. * @param startValue Start value of the animation curve
  33813. * @param outTangent End tangent of the animation
  33814. * @param endValue End value of the animation curve
  33815. * @param inTangent Start tangent of the animation curve
  33816. * @param gradient Scalar amount to interpolate
  33817. * @returns InterpolatedVector3 value
  33818. */
  33819. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33820. /**
  33821. * Interpolates a Vector2 linearly
  33822. * @param startValue Start value of the animation curve
  33823. * @param endValue End value of the animation curve
  33824. * @param gradient Scalar amount to interpolate
  33825. * @returns Interpolated Vector2 value
  33826. */
  33827. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33828. /**
  33829. * Interpolates a Vector2 cubically
  33830. * @param startValue Start value of the animation curve
  33831. * @param outTangent End tangent of the animation
  33832. * @param endValue End value of the animation curve
  33833. * @param inTangent Start tangent of the animation curve
  33834. * @param gradient Scalar amount to interpolate
  33835. * @returns Interpolated Vector2 value
  33836. */
  33837. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33838. /**
  33839. * Interpolates a size linearly
  33840. * @param startValue Start value of the animation curve
  33841. * @param endValue End value of the animation curve
  33842. * @param gradient Scalar amount to interpolate
  33843. * @returns Interpolated Size value
  33844. */
  33845. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33846. /**
  33847. * Interpolates a Color3 linearly
  33848. * @param startValue Start value of the animation curve
  33849. * @param endValue End value of the animation curve
  33850. * @param gradient Scalar amount to interpolate
  33851. * @returns Interpolated Color3 value
  33852. */
  33853. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33854. /**
  33855. * Interpolates a Color4 linearly
  33856. * @param startValue Start value of the animation curve
  33857. * @param endValue End value of the animation curve
  33858. * @param gradient Scalar amount to interpolate
  33859. * @returns Interpolated Color3 value
  33860. */
  33861. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33862. /**
  33863. * @hidden Internal use only
  33864. */
  33865. _getKeyValue(value: any): any;
  33866. /**
  33867. * @hidden Internal use only
  33868. */
  33869. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33870. /**
  33871. * Defines the function to use to interpolate matrices
  33872. * @param startValue defines the start matrix
  33873. * @param endValue defines the end matrix
  33874. * @param gradient defines the gradient between both matrices
  33875. * @param result defines an optional target matrix where to store the interpolation
  33876. * @returns the interpolated matrix
  33877. */
  33878. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33879. /**
  33880. * Makes a copy of the animation
  33881. * @returns Cloned animation
  33882. */
  33883. clone(): Animation;
  33884. /**
  33885. * Sets the key frames of the animation
  33886. * @param values The animation key frames to set
  33887. */
  33888. setKeys(values: Array<IAnimationKey>): void;
  33889. /**
  33890. * Serializes the animation to an object
  33891. * @returns Serialized object
  33892. */
  33893. serialize(): any;
  33894. /**
  33895. * Float animation type
  33896. */
  33897. static readonly ANIMATIONTYPE_FLOAT: number;
  33898. /**
  33899. * Vector3 animation type
  33900. */
  33901. static readonly ANIMATIONTYPE_VECTOR3: number;
  33902. /**
  33903. * Quaternion animation type
  33904. */
  33905. static readonly ANIMATIONTYPE_QUATERNION: number;
  33906. /**
  33907. * Matrix animation type
  33908. */
  33909. static readonly ANIMATIONTYPE_MATRIX: number;
  33910. /**
  33911. * Color3 animation type
  33912. */
  33913. static readonly ANIMATIONTYPE_COLOR3: number;
  33914. /**
  33915. * Color3 animation type
  33916. */
  33917. static readonly ANIMATIONTYPE_COLOR4: number;
  33918. /**
  33919. * Vector2 animation type
  33920. */
  33921. static readonly ANIMATIONTYPE_VECTOR2: number;
  33922. /**
  33923. * Size animation type
  33924. */
  33925. static readonly ANIMATIONTYPE_SIZE: number;
  33926. /**
  33927. * Relative Loop Mode
  33928. */
  33929. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33930. /**
  33931. * Cycle Loop Mode
  33932. */
  33933. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33934. /**
  33935. * Constant Loop Mode
  33936. */
  33937. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33938. /** @hidden */
  33939. static _UniversalLerp(left: any, right: any, amount: number): any;
  33940. /**
  33941. * Parses an animation object and creates an animation
  33942. * @param parsedAnimation Parsed animation object
  33943. * @returns Animation object
  33944. */
  33945. static Parse(parsedAnimation: any): Animation;
  33946. /**
  33947. * Appends the serialized animations from the source animations
  33948. * @param source Source containing the animations
  33949. * @param destination Target to store the animations
  33950. */
  33951. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33952. /**
  33953. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33954. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33955. * @param url defines the url to load from
  33956. * @returns a promise that will resolve to the new animation or an array of animations
  33957. */
  33958. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33959. /**
  33960. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33961. * @param snippetId defines the snippet to load
  33962. * @returns a promise that will resolve to the new animation or a new array of animations
  33963. */
  33964. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33965. }
  33966. }
  33967. declare module "babylonjs/Animations/animatable.interface" {
  33968. import { Nullable } from "babylonjs/types";
  33969. import { Animation } from "babylonjs/Animations/animation";
  33970. /**
  33971. * Interface containing an array of animations
  33972. */
  33973. export interface IAnimatable {
  33974. /**
  33975. * Array of animations
  33976. */
  33977. animations: Nullable<Array<Animation>>;
  33978. }
  33979. }
  33980. declare module "babylonjs/Misc/decorators" {
  33981. import { Nullable } from "babylonjs/types";
  33982. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33983. import { Scene } from "babylonjs/scene";
  33984. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33985. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33986. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33987. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33988. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33989. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33990. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33991. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33992. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33993. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33994. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33995. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33996. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33997. /**
  33998. * Decorator used to define property that can be serialized as reference to a camera
  33999. * @param sourceName defines the name of the property to decorate
  34000. */
  34001. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34002. /**
  34003. * Class used to help serialization objects
  34004. */
  34005. export class SerializationHelper {
  34006. /** @hidden */
  34007. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  34008. /** @hidden */
  34009. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  34010. /** @hidden */
  34011. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  34012. /** @hidden */
  34013. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  34014. /**
  34015. * Appends the serialized animations from the source animations
  34016. * @param source Source containing the animations
  34017. * @param destination Target to store the animations
  34018. */
  34019. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34020. /**
  34021. * Static function used to serialized a specific entity
  34022. * @param entity defines the entity to serialize
  34023. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34024. * @returns a JSON compatible object representing the serialization of the entity
  34025. */
  34026. static Serialize<T>(entity: T, serializationObject?: any): any;
  34027. /**
  34028. * Creates a new entity from a serialization data object
  34029. * @param creationFunction defines a function used to instanciated the new entity
  34030. * @param source defines the source serialization data
  34031. * @param scene defines the hosting scene
  34032. * @param rootUrl defines the root url for resources
  34033. * @returns a new entity
  34034. */
  34035. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34036. /**
  34037. * Clones an object
  34038. * @param creationFunction defines the function used to instanciate the new object
  34039. * @param source defines the source object
  34040. * @returns the cloned object
  34041. */
  34042. static Clone<T>(creationFunction: () => T, source: T): T;
  34043. /**
  34044. * Instanciates a new object based on a source one (some data will be shared between both object)
  34045. * @param creationFunction defines the function used to instanciate the new object
  34046. * @param source defines the source object
  34047. * @returns the new object
  34048. */
  34049. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34050. }
  34051. }
  34052. declare module "babylonjs/Materials/Textures/baseTexture" {
  34053. import { Observable } from "babylonjs/Misc/observable";
  34054. import { Nullable } from "babylonjs/types";
  34055. import { Scene } from "babylonjs/scene";
  34056. import { Matrix } from "babylonjs/Maths/math.vector";
  34057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34058. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34059. import { ISize } from "babylonjs/Maths/math.size";
  34060. import "babylonjs/Misc/fileTools";
  34061. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34062. /**
  34063. * Base class of all the textures in babylon.
  34064. * It groups all the common properties the materials, post process, lights... might need
  34065. * in order to make a correct use of the texture.
  34066. */
  34067. export class BaseTexture implements IAnimatable {
  34068. /**
  34069. * Default anisotropic filtering level for the application.
  34070. * It is set to 4 as a good tradeoff between perf and quality.
  34071. */
  34072. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34073. /**
  34074. * Gets or sets the unique id of the texture
  34075. */
  34076. uniqueId: number;
  34077. /**
  34078. * Define the name of the texture.
  34079. */
  34080. name: string;
  34081. /**
  34082. * Gets or sets an object used to store user defined information.
  34083. */
  34084. metadata: any;
  34085. /**
  34086. * For internal use only. Please do not use.
  34087. */
  34088. reservedDataStore: any;
  34089. private _hasAlpha;
  34090. /**
  34091. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34092. */
  34093. set hasAlpha(value: boolean);
  34094. get hasAlpha(): boolean;
  34095. /**
  34096. * Defines if the alpha value should be determined via the rgb values.
  34097. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34098. */
  34099. getAlphaFromRGB: boolean;
  34100. /**
  34101. * Intensity or strength of the texture.
  34102. * It is commonly used by materials to fine tune the intensity of the texture
  34103. */
  34104. level: number;
  34105. /**
  34106. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34107. * This is part of the texture as textures usually maps to one uv set.
  34108. */
  34109. coordinatesIndex: number;
  34110. private _coordinatesMode;
  34111. /**
  34112. * How a texture is mapped.
  34113. *
  34114. * | Value | Type | Description |
  34115. * | ----- | ----------------------------------- | ----------- |
  34116. * | 0 | EXPLICIT_MODE | |
  34117. * | 1 | SPHERICAL_MODE | |
  34118. * | 2 | PLANAR_MODE | |
  34119. * | 3 | CUBIC_MODE | |
  34120. * | 4 | PROJECTION_MODE | |
  34121. * | 5 | SKYBOX_MODE | |
  34122. * | 6 | INVCUBIC_MODE | |
  34123. * | 7 | EQUIRECTANGULAR_MODE | |
  34124. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34125. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34126. */
  34127. set coordinatesMode(value: number);
  34128. get coordinatesMode(): number;
  34129. /**
  34130. * | Value | Type | Description |
  34131. * | ----- | ------------------ | ----------- |
  34132. * | 0 | CLAMP_ADDRESSMODE | |
  34133. * | 1 | WRAP_ADDRESSMODE | |
  34134. * | 2 | MIRROR_ADDRESSMODE | |
  34135. */
  34136. wrapU: number;
  34137. /**
  34138. * | Value | Type | Description |
  34139. * | ----- | ------------------ | ----------- |
  34140. * | 0 | CLAMP_ADDRESSMODE | |
  34141. * | 1 | WRAP_ADDRESSMODE | |
  34142. * | 2 | MIRROR_ADDRESSMODE | |
  34143. */
  34144. wrapV: number;
  34145. /**
  34146. * | Value | Type | Description |
  34147. * | ----- | ------------------ | ----------- |
  34148. * | 0 | CLAMP_ADDRESSMODE | |
  34149. * | 1 | WRAP_ADDRESSMODE | |
  34150. * | 2 | MIRROR_ADDRESSMODE | |
  34151. */
  34152. wrapR: number;
  34153. /**
  34154. * With compliant hardware and browser (supporting anisotropic filtering)
  34155. * this defines the level of anisotropic filtering in the texture.
  34156. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34157. */
  34158. anisotropicFilteringLevel: number;
  34159. /**
  34160. * Define if the texture is a cube texture or if false a 2d texture.
  34161. */
  34162. get isCube(): boolean;
  34163. set isCube(value: boolean);
  34164. /**
  34165. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34166. */
  34167. get is3D(): boolean;
  34168. set is3D(value: boolean);
  34169. /**
  34170. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34171. */
  34172. get is2DArray(): boolean;
  34173. set is2DArray(value: boolean);
  34174. /**
  34175. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34176. * HDR texture are usually stored in linear space.
  34177. * This only impacts the PBR and Background materials
  34178. */
  34179. gammaSpace: boolean;
  34180. /**
  34181. * Gets or sets whether or not the texture contains RGBD data.
  34182. */
  34183. get isRGBD(): boolean;
  34184. set isRGBD(value: boolean);
  34185. /**
  34186. * Is Z inverted in the texture (useful in a cube texture).
  34187. */
  34188. invertZ: boolean;
  34189. /**
  34190. * Are mip maps generated for this texture or not.
  34191. */
  34192. get noMipmap(): boolean;
  34193. /**
  34194. * @hidden
  34195. */
  34196. lodLevelInAlpha: boolean;
  34197. /**
  34198. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34199. */
  34200. get lodGenerationOffset(): number;
  34201. set lodGenerationOffset(value: number);
  34202. /**
  34203. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34204. */
  34205. get lodGenerationScale(): number;
  34206. set lodGenerationScale(value: number);
  34207. /**
  34208. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34209. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34210. * average roughness values.
  34211. */
  34212. get linearSpecularLOD(): boolean;
  34213. set linearSpecularLOD(value: boolean);
  34214. /**
  34215. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34216. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34217. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34218. */
  34219. get irradianceTexture(): Nullable<BaseTexture>;
  34220. set irradianceTexture(value: Nullable<BaseTexture>);
  34221. /**
  34222. * Define if the texture is a render target.
  34223. */
  34224. isRenderTarget: boolean;
  34225. /**
  34226. * Define the unique id of the texture in the scene.
  34227. */
  34228. get uid(): string;
  34229. /** @hidden */
  34230. _prefiltered: boolean;
  34231. /**
  34232. * Return a string representation of the texture.
  34233. * @returns the texture as a string
  34234. */
  34235. toString(): string;
  34236. /**
  34237. * Get the class name of the texture.
  34238. * @returns "BaseTexture"
  34239. */
  34240. getClassName(): string;
  34241. /**
  34242. * Define the list of animation attached to the texture.
  34243. */
  34244. animations: import("babylonjs/Animations/animation").Animation[];
  34245. /**
  34246. * An event triggered when the texture is disposed.
  34247. */
  34248. onDisposeObservable: Observable<BaseTexture>;
  34249. private _onDisposeObserver;
  34250. /**
  34251. * Callback triggered when the texture has been disposed.
  34252. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34253. */
  34254. set onDispose(callback: () => void);
  34255. /**
  34256. * Define the current state of the loading sequence when in delayed load mode.
  34257. */
  34258. delayLoadState: number;
  34259. private _scene;
  34260. private _engine;
  34261. /** @hidden */
  34262. _texture: Nullable<InternalTexture>;
  34263. private _uid;
  34264. /**
  34265. * Define if the texture is preventinga material to render or not.
  34266. * If not and the texture is not ready, the engine will use a default black texture instead.
  34267. */
  34268. get isBlocking(): boolean;
  34269. /**
  34270. * Instantiates a new BaseTexture.
  34271. * Base class of all the textures in babylon.
  34272. * It groups all the common properties the materials, post process, lights... might need
  34273. * in order to make a correct use of the texture.
  34274. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34275. */
  34276. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34277. /**
  34278. * Get the scene the texture belongs to.
  34279. * @returns the scene or null if undefined
  34280. */
  34281. getScene(): Nullable<Scene>;
  34282. /** @hidden */
  34283. protected _getEngine(): Nullable<ThinEngine>;
  34284. /**
  34285. * Get the texture transform matrix used to offset tile the texture for istance.
  34286. * @returns the transformation matrix
  34287. */
  34288. getTextureMatrix(): Matrix;
  34289. /**
  34290. * Get the texture reflection matrix used to rotate/transform the reflection.
  34291. * @returns the reflection matrix
  34292. */
  34293. getReflectionTextureMatrix(): Matrix;
  34294. /**
  34295. * Get the underlying lower level texture from Babylon.
  34296. * @returns the insternal texture
  34297. */
  34298. getInternalTexture(): Nullable<InternalTexture>;
  34299. /**
  34300. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34301. * @returns true if ready or not blocking
  34302. */
  34303. isReadyOrNotBlocking(): boolean;
  34304. /**
  34305. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34306. * @returns true if fully ready
  34307. */
  34308. isReady(): boolean;
  34309. private _cachedSize;
  34310. /**
  34311. * Get the size of the texture.
  34312. * @returns the texture size.
  34313. */
  34314. getSize(): ISize;
  34315. /**
  34316. * Get the base size of the texture.
  34317. * It can be different from the size if the texture has been resized for POT for instance
  34318. * @returns the base size
  34319. */
  34320. getBaseSize(): ISize;
  34321. /**
  34322. * Update the sampling mode of the texture.
  34323. * Default is Trilinear mode.
  34324. *
  34325. * | Value | Type | Description |
  34326. * | ----- | ------------------ | ----------- |
  34327. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34328. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34329. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34330. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34331. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34332. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34333. * | 7 | NEAREST_LINEAR | |
  34334. * | 8 | NEAREST_NEAREST | |
  34335. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34336. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34337. * | 11 | LINEAR_LINEAR | |
  34338. * | 12 | LINEAR_NEAREST | |
  34339. *
  34340. * > _mag_: magnification filter (close to the viewer)
  34341. * > _min_: minification filter (far from the viewer)
  34342. * > _mip_: filter used between mip map levels
  34343. *@param samplingMode Define the new sampling mode of the texture
  34344. */
  34345. updateSamplingMode(samplingMode: number): void;
  34346. /**
  34347. * Scales the texture if is `canRescale()`
  34348. * @param ratio the resize factor we want to use to rescale
  34349. */
  34350. scale(ratio: number): void;
  34351. /**
  34352. * Get if the texture can rescale.
  34353. */
  34354. get canRescale(): boolean;
  34355. /** @hidden */
  34356. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34357. /** @hidden */
  34358. _rebuild(): void;
  34359. /**
  34360. * Triggers the load sequence in delayed load mode.
  34361. */
  34362. delayLoad(): void;
  34363. /**
  34364. * Clones the texture.
  34365. * @returns the cloned texture
  34366. */
  34367. clone(): Nullable<BaseTexture>;
  34368. /**
  34369. * Get the texture underlying type (INT, FLOAT...)
  34370. */
  34371. get textureType(): number;
  34372. /**
  34373. * Get the texture underlying format (RGB, RGBA...)
  34374. */
  34375. get textureFormat(): number;
  34376. /**
  34377. * Indicates that textures need to be re-calculated for all materials
  34378. */
  34379. protected _markAllSubMeshesAsTexturesDirty(): void;
  34380. /**
  34381. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34382. * This will returns an RGBA array buffer containing either in values (0-255) or
  34383. * float values (0-1) depending of the underlying buffer type.
  34384. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34385. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34386. * @param buffer defines a user defined buffer to fill with data (can be null)
  34387. * @returns The Array buffer containing the pixels data.
  34388. */
  34389. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34390. /**
  34391. * Release and destroy the underlying lower level texture aka internalTexture.
  34392. */
  34393. releaseInternalTexture(): void;
  34394. /** @hidden */
  34395. get _lodTextureHigh(): Nullable<BaseTexture>;
  34396. /** @hidden */
  34397. get _lodTextureMid(): Nullable<BaseTexture>;
  34398. /** @hidden */
  34399. get _lodTextureLow(): Nullable<BaseTexture>;
  34400. /**
  34401. * Dispose the texture and release its associated resources.
  34402. */
  34403. dispose(): void;
  34404. /**
  34405. * Serialize the texture into a JSON representation that can be parsed later on.
  34406. * @returns the JSON representation of the texture
  34407. */
  34408. serialize(): any;
  34409. /**
  34410. * Helper function to be called back once a list of texture contains only ready textures.
  34411. * @param textures Define the list of textures to wait for
  34412. * @param callback Define the callback triggered once the entire list will be ready
  34413. */
  34414. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34415. private static _isScene;
  34416. }
  34417. }
  34418. declare module "babylonjs/Materials/effect" {
  34419. import { Observable } from "babylonjs/Misc/observable";
  34420. import { Nullable } from "babylonjs/types";
  34421. import { IDisposable } from "babylonjs/scene";
  34422. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34423. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34424. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34425. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34426. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34427. import { Engine } from "babylonjs/Engines/engine";
  34428. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34429. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34430. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34431. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34432. /**
  34433. * Options to be used when creating an effect.
  34434. */
  34435. export interface IEffectCreationOptions {
  34436. /**
  34437. * Atrributes that will be used in the shader.
  34438. */
  34439. attributes: string[];
  34440. /**
  34441. * Uniform varible names that will be set in the shader.
  34442. */
  34443. uniformsNames: string[];
  34444. /**
  34445. * Uniform buffer variable names that will be set in the shader.
  34446. */
  34447. uniformBuffersNames: string[];
  34448. /**
  34449. * Sampler texture variable names that will be set in the shader.
  34450. */
  34451. samplers: string[];
  34452. /**
  34453. * Define statements that will be set in the shader.
  34454. */
  34455. defines: any;
  34456. /**
  34457. * Possible fallbacks for this effect to improve performance when needed.
  34458. */
  34459. fallbacks: Nullable<IEffectFallbacks>;
  34460. /**
  34461. * Callback that will be called when the shader is compiled.
  34462. */
  34463. onCompiled: Nullable<(effect: Effect) => void>;
  34464. /**
  34465. * Callback that will be called if an error occurs during shader compilation.
  34466. */
  34467. onError: Nullable<(effect: Effect, errors: string) => void>;
  34468. /**
  34469. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34470. */
  34471. indexParameters?: any;
  34472. /**
  34473. * Max number of lights that can be used in the shader.
  34474. */
  34475. maxSimultaneousLights?: number;
  34476. /**
  34477. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34478. */
  34479. transformFeedbackVaryings?: Nullable<string[]>;
  34480. /**
  34481. * 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
  34482. */
  34483. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34484. }
  34485. /**
  34486. * Effect containing vertex and fragment shader that can be executed on an object.
  34487. */
  34488. export class Effect implements IDisposable {
  34489. /**
  34490. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34491. */
  34492. static ShadersRepository: string;
  34493. /**
  34494. * Enable logging of the shader code when a compilation error occurs
  34495. */
  34496. static LogShaderCodeOnCompilationError: boolean;
  34497. /**
  34498. * Name of the effect.
  34499. */
  34500. name: any;
  34501. /**
  34502. * String container all the define statements that should be set on the shader.
  34503. */
  34504. defines: string;
  34505. /**
  34506. * Callback that will be called when the shader is compiled.
  34507. */
  34508. onCompiled: Nullable<(effect: Effect) => void>;
  34509. /**
  34510. * Callback that will be called if an error occurs during shader compilation.
  34511. */
  34512. onError: Nullable<(effect: Effect, errors: string) => void>;
  34513. /**
  34514. * Callback that will be called when effect is bound.
  34515. */
  34516. onBind: Nullable<(effect: Effect) => void>;
  34517. /**
  34518. * Unique ID of the effect.
  34519. */
  34520. uniqueId: number;
  34521. /**
  34522. * Observable that will be called when the shader is compiled.
  34523. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34524. */
  34525. onCompileObservable: Observable<Effect>;
  34526. /**
  34527. * Observable that will be called if an error occurs during shader compilation.
  34528. */
  34529. onErrorObservable: Observable<Effect>;
  34530. /** @hidden */
  34531. _onBindObservable: Nullable<Observable<Effect>>;
  34532. /**
  34533. * @hidden
  34534. * Specifies if the effect was previously ready
  34535. */
  34536. _wasPreviouslyReady: boolean;
  34537. /**
  34538. * Observable that will be called when effect is bound.
  34539. */
  34540. get onBindObservable(): Observable<Effect>;
  34541. /** @hidden */
  34542. _bonesComputationForcedToCPU: boolean;
  34543. private static _uniqueIdSeed;
  34544. private _engine;
  34545. private _uniformBuffersNames;
  34546. private _uniformBuffersNamesList;
  34547. private _uniformsNames;
  34548. private _samplerList;
  34549. private _samplers;
  34550. private _isReady;
  34551. private _compilationError;
  34552. private _allFallbacksProcessed;
  34553. private _attributesNames;
  34554. private _attributes;
  34555. private _attributeLocationByName;
  34556. private _uniforms;
  34557. /**
  34558. * Key for the effect.
  34559. * @hidden
  34560. */
  34561. _key: string;
  34562. private _indexParameters;
  34563. private _fallbacks;
  34564. private _vertexSourceCode;
  34565. private _fragmentSourceCode;
  34566. private _vertexSourceCodeOverride;
  34567. private _fragmentSourceCodeOverride;
  34568. private _transformFeedbackVaryings;
  34569. /**
  34570. * Compiled shader to webGL program.
  34571. * @hidden
  34572. */
  34573. _pipelineContext: Nullable<IPipelineContext>;
  34574. private _valueCache;
  34575. private static _baseCache;
  34576. /**
  34577. * Instantiates an effect.
  34578. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34579. * @param baseName Name of the effect.
  34580. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34581. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34582. * @param samplers List of sampler variables that will be passed to the shader.
  34583. * @param engine Engine to be used to render the effect
  34584. * @param defines Define statements to be added to the shader.
  34585. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34586. * @param onCompiled Callback that will be called when the shader is compiled.
  34587. * @param onError Callback that will be called if an error occurs during shader compilation.
  34588. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34589. */
  34590. 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);
  34591. private _useFinalCode;
  34592. /**
  34593. * Unique key for this effect
  34594. */
  34595. get key(): string;
  34596. /**
  34597. * If the effect has been compiled and prepared.
  34598. * @returns if the effect is compiled and prepared.
  34599. */
  34600. isReady(): boolean;
  34601. private _isReadyInternal;
  34602. /**
  34603. * The engine the effect was initialized with.
  34604. * @returns the engine.
  34605. */
  34606. getEngine(): Engine;
  34607. /**
  34608. * The pipeline context for this effect
  34609. * @returns the associated pipeline context
  34610. */
  34611. getPipelineContext(): Nullable<IPipelineContext>;
  34612. /**
  34613. * The set of names of attribute variables for the shader.
  34614. * @returns An array of attribute names.
  34615. */
  34616. getAttributesNames(): string[];
  34617. /**
  34618. * Returns the attribute at the given index.
  34619. * @param index The index of the attribute.
  34620. * @returns The location of the attribute.
  34621. */
  34622. getAttributeLocation(index: number): number;
  34623. /**
  34624. * Returns the attribute based on the name of the variable.
  34625. * @param name of the attribute to look up.
  34626. * @returns the attribute location.
  34627. */
  34628. getAttributeLocationByName(name: string): number;
  34629. /**
  34630. * The number of attributes.
  34631. * @returns the numnber of attributes.
  34632. */
  34633. getAttributesCount(): number;
  34634. /**
  34635. * Gets the index of a uniform variable.
  34636. * @param uniformName of the uniform to look up.
  34637. * @returns the index.
  34638. */
  34639. getUniformIndex(uniformName: string): number;
  34640. /**
  34641. * Returns the attribute based on the name of the variable.
  34642. * @param uniformName of the uniform to look up.
  34643. * @returns the location of the uniform.
  34644. */
  34645. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34646. /**
  34647. * Returns an array of sampler variable names
  34648. * @returns The array of sampler variable names.
  34649. */
  34650. getSamplers(): string[];
  34651. /**
  34652. * Returns an array of uniform variable names
  34653. * @returns The array of uniform variable names.
  34654. */
  34655. getUniformNames(): string[];
  34656. /**
  34657. * Returns an array of uniform buffer variable names
  34658. * @returns The array of uniform buffer variable names.
  34659. */
  34660. getUniformBuffersNames(): string[];
  34661. /**
  34662. * Returns the index parameters used to create the effect
  34663. * @returns The index parameters object
  34664. */
  34665. getIndexParameters(): any;
  34666. /**
  34667. * The error from the last compilation.
  34668. * @returns the error string.
  34669. */
  34670. getCompilationError(): string;
  34671. /**
  34672. * Gets a boolean indicating that all fallbacks were used during compilation
  34673. * @returns true if all fallbacks were used
  34674. */
  34675. allFallbacksProcessed(): boolean;
  34676. /**
  34677. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34678. * @param func The callback to be used.
  34679. */
  34680. executeWhenCompiled(func: (effect: Effect) => void): void;
  34681. private _checkIsReady;
  34682. private _loadShader;
  34683. /**
  34684. * Gets the vertex shader source code of this effect
  34685. */
  34686. get vertexSourceCode(): string;
  34687. /**
  34688. * Gets the fragment shader source code of this effect
  34689. */
  34690. get fragmentSourceCode(): string;
  34691. /**
  34692. * Recompiles the webGL program
  34693. * @param vertexSourceCode The source code for the vertex shader.
  34694. * @param fragmentSourceCode The source code for the fragment shader.
  34695. * @param onCompiled Callback called when completed.
  34696. * @param onError Callback called on error.
  34697. * @hidden
  34698. */
  34699. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34700. /**
  34701. * Prepares the effect
  34702. * @hidden
  34703. */
  34704. _prepareEffect(): void;
  34705. private _getShaderCodeAndErrorLine;
  34706. private _processCompilationErrors;
  34707. /**
  34708. * Checks if the effect is supported. (Must be called after compilation)
  34709. */
  34710. get isSupported(): boolean;
  34711. /**
  34712. * Binds a texture to the engine to be used as output of the shader.
  34713. * @param channel Name of the output variable.
  34714. * @param texture Texture to bind.
  34715. * @hidden
  34716. */
  34717. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34718. /**
  34719. * Sets a texture on the engine to be used in the shader.
  34720. * @param channel Name of the sampler variable.
  34721. * @param texture Texture to set.
  34722. */
  34723. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34724. /**
  34725. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34726. * @param channel Name of the sampler variable.
  34727. * @param texture Texture to set.
  34728. */
  34729. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34730. /**
  34731. * Sets an array of textures on the engine to be used in the shader.
  34732. * @param channel Name of the variable.
  34733. * @param textures Textures to set.
  34734. */
  34735. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34736. /**
  34737. * 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)
  34738. * @param channel Name of the sampler variable.
  34739. * @param postProcess Post process to get the input texture from.
  34740. */
  34741. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34742. /**
  34743. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34744. * 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)
  34745. * @param channel Name of the sampler variable.
  34746. * @param postProcess Post process to get the output texture from.
  34747. */
  34748. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34749. /** @hidden */
  34750. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34751. /** @hidden */
  34752. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34753. /** @hidden */
  34754. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34755. /** @hidden */
  34756. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34757. /**
  34758. * Binds a buffer to a uniform.
  34759. * @param buffer Buffer to bind.
  34760. * @param name Name of the uniform variable to bind to.
  34761. */
  34762. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34763. /**
  34764. * Binds block to a uniform.
  34765. * @param blockName Name of the block to bind.
  34766. * @param index Index to bind.
  34767. */
  34768. bindUniformBlock(blockName: string, index: number): void;
  34769. /**
  34770. * Sets an interger value on a uniform variable.
  34771. * @param uniformName Name of the variable.
  34772. * @param value Value to be set.
  34773. * @returns this effect.
  34774. */
  34775. setInt(uniformName: string, value: number): Effect;
  34776. /**
  34777. * Sets an int array on a uniform variable.
  34778. * @param uniformName Name of the variable.
  34779. * @param array array to be set.
  34780. * @returns this effect.
  34781. */
  34782. setIntArray(uniformName: string, array: Int32Array): Effect;
  34783. /**
  34784. * 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)
  34785. * @param uniformName Name of the variable.
  34786. * @param array array to be set.
  34787. * @returns this effect.
  34788. */
  34789. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34790. /**
  34791. * 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)
  34792. * @param uniformName Name of the variable.
  34793. * @param array array to be set.
  34794. * @returns this effect.
  34795. */
  34796. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34797. /**
  34798. * 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)
  34799. * @param uniformName Name of the variable.
  34800. * @param array array to be set.
  34801. * @returns this effect.
  34802. */
  34803. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34804. /**
  34805. * Sets an float array on a uniform variable.
  34806. * @param uniformName Name of the variable.
  34807. * @param array array to be set.
  34808. * @returns this effect.
  34809. */
  34810. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34811. /**
  34812. * 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)
  34813. * @param uniformName Name of the variable.
  34814. * @param array array to be set.
  34815. * @returns this effect.
  34816. */
  34817. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34818. /**
  34819. * 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)
  34820. * @param uniformName Name of the variable.
  34821. * @param array array to be set.
  34822. * @returns this effect.
  34823. */
  34824. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34825. /**
  34826. * 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)
  34827. * @param uniformName Name of the variable.
  34828. * @param array array to be set.
  34829. * @returns this effect.
  34830. */
  34831. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34832. /**
  34833. * Sets an array on a uniform variable.
  34834. * @param uniformName Name of the variable.
  34835. * @param array array to be set.
  34836. * @returns this effect.
  34837. */
  34838. setArray(uniformName: string, array: number[]): Effect;
  34839. /**
  34840. * 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)
  34841. * @param uniformName Name of the variable.
  34842. * @param array array to be set.
  34843. * @returns this effect.
  34844. */
  34845. setArray2(uniformName: string, array: number[]): Effect;
  34846. /**
  34847. * 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)
  34848. * @param uniformName Name of the variable.
  34849. * @param array array to be set.
  34850. * @returns this effect.
  34851. */
  34852. setArray3(uniformName: string, array: number[]): Effect;
  34853. /**
  34854. * 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)
  34855. * @param uniformName Name of the variable.
  34856. * @param array array to be set.
  34857. * @returns this effect.
  34858. */
  34859. setArray4(uniformName: string, array: number[]): Effect;
  34860. /**
  34861. * Sets matrices on a uniform variable.
  34862. * @param uniformName Name of the variable.
  34863. * @param matrices matrices to be set.
  34864. * @returns this effect.
  34865. */
  34866. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34867. /**
  34868. * Sets matrix on a uniform variable.
  34869. * @param uniformName Name of the variable.
  34870. * @param matrix matrix to be set.
  34871. * @returns this effect.
  34872. */
  34873. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34874. /**
  34875. * 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)
  34876. * @param uniformName Name of the variable.
  34877. * @param matrix matrix to be set.
  34878. * @returns this effect.
  34879. */
  34880. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34881. /**
  34882. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34883. * @param uniformName Name of the variable.
  34884. * @param matrix matrix to be set.
  34885. * @returns this effect.
  34886. */
  34887. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34888. /**
  34889. * Sets a float on a uniform variable.
  34890. * @param uniformName Name of the variable.
  34891. * @param value value to be set.
  34892. * @returns this effect.
  34893. */
  34894. setFloat(uniformName: string, value: number): Effect;
  34895. /**
  34896. * Sets a boolean on a uniform variable.
  34897. * @param uniformName Name of the variable.
  34898. * @param bool value to be set.
  34899. * @returns this effect.
  34900. */
  34901. setBool(uniformName: string, bool: boolean): Effect;
  34902. /**
  34903. * Sets a Vector2 on a uniform variable.
  34904. * @param uniformName Name of the variable.
  34905. * @param vector2 vector2 to be set.
  34906. * @returns this effect.
  34907. */
  34908. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34909. /**
  34910. * Sets a float2 on a uniform variable.
  34911. * @param uniformName Name of the variable.
  34912. * @param x First float in float2.
  34913. * @param y Second float in float2.
  34914. * @returns this effect.
  34915. */
  34916. setFloat2(uniformName: string, x: number, y: number): Effect;
  34917. /**
  34918. * Sets a Vector3 on a uniform variable.
  34919. * @param uniformName Name of the variable.
  34920. * @param vector3 Value to be set.
  34921. * @returns this effect.
  34922. */
  34923. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34924. /**
  34925. * Sets a float3 on a uniform variable.
  34926. * @param uniformName Name of the variable.
  34927. * @param x First float in float3.
  34928. * @param y Second float in float3.
  34929. * @param z Third float in float3.
  34930. * @returns this effect.
  34931. */
  34932. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34933. /**
  34934. * Sets a Vector4 on a uniform variable.
  34935. * @param uniformName Name of the variable.
  34936. * @param vector4 Value to be set.
  34937. * @returns this effect.
  34938. */
  34939. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34940. /**
  34941. * Sets a float4 on a uniform variable.
  34942. * @param uniformName Name of the variable.
  34943. * @param x First float in float4.
  34944. * @param y Second float in float4.
  34945. * @param z Third float in float4.
  34946. * @param w Fourth float in float4.
  34947. * @returns this effect.
  34948. */
  34949. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34950. /**
  34951. * Sets a Color3 on a uniform variable.
  34952. * @param uniformName Name of the variable.
  34953. * @param color3 Value to be set.
  34954. * @returns this effect.
  34955. */
  34956. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34957. /**
  34958. * Sets a Color4 on a uniform variable.
  34959. * @param uniformName Name of the variable.
  34960. * @param color3 Value to be set.
  34961. * @param alpha Alpha value to be set.
  34962. * @returns this effect.
  34963. */
  34964. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34965. /**
  34966. * Sets a Color4 on a uniform variable
  34967. * @param uniformName defines the name of the variable
  34968. * @param color4 defines the value to be set
  34969. * @returns this effect.
  34970. */
  34971. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34972. /** Release all associated resources */
  34973. dispose(): void;
  34974. /**
  34975. * This function will add a new shader to the shader store
  34976. * @param name the name of the shader
  34977. * @param pixelShader optional pixel shader content
  34978. * @param vertexShader optional vertex shader content
  34979. */
  34980. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34981. /**
  34982. * Store of each shader (The can be looked up using effect.key)
  34983. */
  34984. static ShadersStore: {
  34985. [key: string]: string;
  34986. };
  34987. /**
  34988. * Store of each included file for a shader (The can be looked up using effect.key)
  34989. */
  34990. static IncludesShadersStore: {
  34991. [key: string]: string;
  34992. };
  34993. /**
  34994. * Resets the cache of effects.
  34995. */
  34996. static ResetCache(): void;
  34997. }
  34998. }
  34999. declare module "babylonjs/Engines/engineCapabilities" {
  35000. /**
  35001. * Interface used to describe the capabilities of the engine relatively to the current browser
  35002. */
  35003. export interface EngineCapabilities {
  35004. /** Maximum textures units per fragment shader */
  35005. maxTexturesImageUnits: number;
  35006. /** Maximum texture units per vertex shader */
  35007. maxVertexTextureImageUnits: number;
  35008. /** Maximum textures units in the entire pipeline */
  35009. maxCombinedTexturesImageUnits: number;
  35010. /** Maximum texture size */
  35011. maxTextureSize: number;
  35012. /** Maximum texture samples */
  35013. maxSamples?: number;
  35014. /** Maximum cube texture size */
  35015. maxCubemapTextureSize: number;
  35016. /** Maximum render texture size */
  35017. maxRenderTextureSize: number;
  35018. /** Maximum number of vertex attributes */
  35019. maxVertexAttribs: number;
  35020. /** Maximum number of varyings */
  35021. maxVaryingVectors: number;
  35022. /** Maximum number of uniforms per vertex shader */
  35023. maxVertexUniformVectors: number;
  35024. /** Maximum number of uniforms per fragment shader */
  35025. maxFragmentUniformVectors: number;
  35026. /** Defines if standard derivates (dx/dy) are supported */
  35027. standardDerivatives: boolean;
  35028. /** Defines if s3tc texture compression is supported */
  35029. s3tc?: WEBGL_compressed_texture_s3tc;
  35030. /** Defines if pvrtc texture compression is supported */
  35031. pvrtc: any;
  35032. /** Defines if etc1 texture compression is supported */
  35033. etc1: any;
  35034. /** Defines if etc2 texture compression is supported */
  35035. etc2: any;
  35036. /** Defines if astc texture compression is supported */
  35037. astc: any;
  35038. /** Defines if float textures are supported */
  35039. textureFloat: boolean;
  35040. /** Defines if vertex array objects are supported */
  35041. vertexArrayObject: boolean;
  35042. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35043. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35044. /** Gets the maximum level of anisotropy supported */
  35045. maxAnisotropy: number;
  35046. /** Defines if instancing is supported */
  35047. instancedArrays: boolean;
  35048. /** Defines if 32 bits indices are supported */
  35049. uintIndices: boolean;
  35050. /** Defines if high precision shaders are supported */
  35051. highPrecisionShaderSupported: boolean;
  35052. /** Defines if depth reading in the fragment shader is supported */
  35053. fragmentDepthSupported: boolean;
  35054. /** Defines if float texture linear filtering is supported*/
  35055. textureFloatLinearFiltering: boolean;
  35056. /** Defines if rendering to float textures is supported */
  35057. textureFloatRender: boolean;
  35058. /** Defines if half float textures are supported*/
  35059. textureHalfFloat: boolean;
  35060. /** Defines if half float texture linear filtering is supported*/
  35061. textureHalfFloatLinearFiltering: boolean;
  35062. /** Defines if rendering to half float textures is supported */
  35063. textureHalfFloatRender: boolean;
  35064. /** Defines if textureLOD shader command is supported */
  35065. textureLOD: boolean;
  35066. /** Defines if draw buffers extension is supported */
  35067. drawBuffersExtension: boolean;
  35068. /** Defines if depth textures are supported */
  35069. depthTextureExtension: boolean;
  35070. /** Defines if float color buffer are supported */
  35071. colorBufferFloat: boolean;
  35072. /** Gets disjoint timer query extension (null if not supported) */
  35073. timerQuery?: EXT_disjoint_timer_query;
  35074. /** Defines if timestamp can be used with timer query */
  35075. canUseTimestampForTimerQuery: boolean;
  35076. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35077. multiview?: any;
  35078. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35079. oculusMultiview?: any;
  35080. /** Function used to let the system compiles shaders in background */
  35081. parallelShaderCompile?: {
  35082. COMPLETION_STATUS_KHR: number;
  35083. };
  35084. /** Max number of texture samples for MSAA */
  35085. maxMSAASamples: number;
  35086. /** Defines if the blend min max extension is supported */
  35087. blendMinMax: boolean;
  35088. }
  35089. }
  35090. declare module "babylonjs/States/depthCullingState" {
  35091. import { Nullable } from "babylonjs/types";
  35092. /**
  35093. * @hidden
  35094. **/
  35095. export class DepthCullingState {
  35096. private _isDepthTestDirty;
  35097. private _isDepthMaskDirty;
  35098. private _isDepthFuncDirty;
  35099. private _isCullFaceDirty;
  35100. private _isCullDirty;
  35101. private _isZOffsetDirty;
  35102. private _isFrontFaceDirty;
  35103. private _depthTest;
  35104. private _depthMask;
  35105. private _depthFunc;
  35106. private _cull;
  35107. private _cullFace;
  35108. private _zOffset;
  35109. private _frontFace;
  35110. /**
  35111. * Initializes the state.
  35112. */
  35113. constructor();
  35114. get isDirty(): boolean;
  35115. get zOffset(): number;
  35116. set zOffset(value: number);
  35117. get cullFace(): Nullable<number>;
  35118. set cullFace(value: Nullable<number>);
  35119. get cull(): Nullable<boolean>;
  35120. set cull(value: Nullable<boolean>);
  35121. get depthFunc(): Nullable<number>;
  35122. set depthFunc(value: Nullable<number>);
  35123. get depthMask(): boolean;
  35124. set depthMask(value: boolean);
  35125. get depthTest(): boolean;
  35126. set depthTest(value: boolean);
  35127. get frontFace(): Nullable<number>;
  35128. set frontFace(value: Nullable<number>);
  35129. reset(): void;
  35130. apply(gl: WebGLRenderingContext): void;
  35131. }
  35132. }
  35133. declare module "babylonjs/States/stencilState" {
  35134. /**
  35135. * @hidden
  35136. **/
  35137. export class StencilState {
  35138. /** 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 */
  35139. static readonly ALWAYS: number;
  35140. /** Passed to stencilOperation to specify that stencil value must be kept */
  35141. static readonly KEEP: number;
  35142. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35143. static readonly REPLACE: number;
  35144. private _isStencilTestDirty;
  35145. private _isStencilMaskDirty;
  35146. private _isStencilFuncDirty;
  35147. private _isStencilOpDirty;
  35148. private _stencilTest;
  35149. private _stencilMask;
  35150. private _stencilFunc;
  35151. private _stencilFuncRef;
  35152. private _stencilFuncMask;
  35153. private _stencilOpStencilFail;
  35154. private _stencilOpDepthFail;
  35155. private _stencilOpStencilDepthPass;
  35156. get isDirty(): boolean;
  35157. get stencilFunc(): number;
  35158. set stencilFunc(value: number);
  35159. get stencilFuncRef(): number;
  35160. set stencilFuncRef(value: number);
  35161. get stencilFuncMask(): number;
  35162. set stencilFuncMask(value: number);
  35163. get stencilOpStencilFail(): number;
  35164. set stencilOpStencilFail(value: number);
  35165. get stencilOpDepthFail(): number;
  35166. set stencilOpDepthFail(value: number);
  35167. get stencilOpStencilDepthPass(): number;
  35168. set stencilOpStencilDepthPass(value: number);
  35169. get stencilMask(): number;
  35170. set stencilMask(value: number);
  35171. get stencilTest(): boolean;
  35172. set stencilTest(value: boolean);
  35173. constructor();
  35174. reset(): void;
  35175. apply(gl: WebGLRenderingContext): void;
  35176. }
  35177. }
  35178. declare module "babylonjs/States/alphaCullingState" {
  35179. /**
  35180. * @hidden
  35181. **/
  35182. export class AlphaState {
  35183. private _isAlphaBlendDirty;
  35184. private _isBlendFunctionParametersDirty;
  35185. private _isBlendEquationParametersDirty;
  35186. private _isBlendConstantsDirty;
  35187. private _alphaBlend;
  35188. private _blendFunctionParameters;
  35189. private _blendEquationParameters;
  35190. private _blendConstants;
  35191. /**
  35192. * Initializes the state.
  35193. */
  35194. constructor();
  35195. get isDirty(): boolean;
  35196. get alphaBlend(): boolean;
  35197. set alphaBlend(value: boolean);
  35198. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35199. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35200. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35201. reset(): void;
  35202. apply(gl: WebGLRenderingContext): void;
  35203. }
  35204. }
  35205. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35206. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35207. /** @hidden */
  35208. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35209. attributeProcessor(attribute: string): string;
  35210. varyingProcessor(varying: string, isFragment: boolean): string;
  35211. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35212. }
  35213. }
  35214. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35215. /**
  35216. * Interface for attribute information associated with buffer instanciation
  35217. */
  35218. export interface InstancingAttributeInfo {
  35219. /**
  35220. * Name of the GLSL attribute
  35221. * if attribute index is not specified, this is used to retrieve the index from the effect
  35222. */
  35223. attributeName: string;
  35224. /**
  35225. * Index/offset of the attribute in the vertex shader
  35226. * if not specified, this will be computes from the name.
  35227. */
  35228. index?: number;
  35229. /**
  35230. * size of the attribute, 1, 2, 3 or 4
  35231. */
  35232. attributeSize: number;
  35233. /**
  35234. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35235. */
  35236. offset: number;
  35237. /**
  35238. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35239. * default to 1
  35240. */
  35241. divisor?: number;
  35242. /**
  35243. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35244. * default is FLOAT
  35245. */
  35246. attributeType?: number;
  35247. /**
  35248. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35249. */
  35250. normalized?: boolean;
  35251. }
  35252. }
  35253. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35254. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35255. import { Nullable } from "babylonjs/types";
  35256. module "babylonjs/Engines/thinEngine" {
  35257. interface ThinEngine {
  35258. /**
  35259. * Update a video texture
  35260. * @param texture defines the texture to update
  35261. * @param video defines the video element to use
  35262. * @param invertY defines if data must be stored with Y axis inverted
  35263. */
  35264. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35265. }
  35266. }
  35267. }
  35268. declare module "babylonjs/Materials/Textures/videoTexture" {
  35269. import { Observable } from "babylonjs/Misc/observable";
  35270. import { Nullable } from "babylonjs/types";
  35271. import { Scene } from "babylonjs/scene";
  35272. import { Texture } from "babylonjs/Materials/Textures/texture";
  35273. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35274. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35275. /**
  35276. * Settings for finer control over video usage
  35277. */
  35278. export interface VideoTextureSettings {
  35279. /**
  35280. * Applies `autoplay` to video, if specified
  35281. */
  35282. autoPlay?: boolean;
  35283. /**
  35284. * Applies `loop` to video, if specified
  35285. */
  35286. loop?: boolean;
  35287. /**
  35288. * Automatically updates internal texture from video at every frame in the render loop
  35289. */
  35290. autoUpdateTexture: boolean;
  35291. /**
  35292. * Image src displayed during the video loading or until the user interacts with the video.
  35293. */
  35294. poster?: string;
  35295. }
  35296. /**
  35297. * If you want to display a video in your scene, this is the special texture for that.
  35298. * This special texture works similar to other textures, with the exception of a few parameters.
  35299. * @see https://doc.babylonjs.com/how_to/video_texture
  35300. */
  35301. export class VideoTexture extends Texture {
  35302. /**
  35303. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35304. */
  35305. readonly autoUpdateTexture: boolean;
  35306. /**
  35307. * The video instance used by the texture internally
  35308. */
  35309. readonly video: HTMLVideoElement;
  35310. private _onUserActionRequestedObservable;
  35311. /**
  35312. * Event triggerd when a dom action is required by the user to play the video.
  35313. * This happens due to recent changes in browser policies preventing video to auto start.
  35314. */
  35315. get onUserActionRequestedObservable(): Observable<Texture>;
  35316. private _generateMipMaps;
  35317. private _stillImageCaptured;
  35318. private _displayingPosterTexture;
  35319. private _settings;
  35320. private _createInternalTextureOnEvent;
  35321. private _frameId;
  35322. private _currentSrc;
  35323. /**
  35324. * Creates a video texture.
  35325. * If you want to display a video in your scene, this is the special texture for that.
  35326. * This special texture works similar to other textures, with the exception of a few parameters.
  35327. * @see https://doc.babylonjs.com/how_to/video_texture
  35328. * @param name optional name, will detect from video source, if not defined
  35329. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35330. * @param scene is obviously the current scene.
  35331. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35332. * @param invertY is false by default but can be used to invert video on Y axis
  35333. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35334. * @param settings allows finer control over video usage
  35335. */
  35336. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35337. private _getName;
  35338. private _getVideo;
  35339. private _createInternalTexture;
  35340. private reset;
  35341. /**
  35342. * @hidden Internal method to initiate `update`.
  35343. */
  35344. _rebuild(): void;
  35345. /**
  35346. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35347. */
  35348. update(): void;
  35349. /**
  35350. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35351. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35352. */
  35353. updateTexture(isVisible: boolean): void;
  35354. protected _updateInternalTexture: () => void;
  35355. /**
  35356. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35357. * @param url New url.
  35358. */
  35359. updateURL(url: string): void;
  35360. /**
  35361. * Clones the texture.
  35362. * @returns the cloned texture
  35363. */
  35364. clone(): VideoTexture;
  35365. /**
  35366. * Dispose the texture and release its associated resources.
  35367. */
  35368. dispose(): void;
  35369. /**
  35370. * Creates a video texture straight from a stream.
  35371. * @param scene Define the scene the texture should be created in
  35372. * @param stream Define the stream the texture should be created from
  35373. * @returns The created video texture as a promise
  35374. */
  35375. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35376. /**
  35377. * Creates a video texture straight from your WebCam video feed.
  35378. * @param scene Define the scene the texture should be created in
  35379. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35380. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35381. * @returns The created video texture as a promise
  35382. */
  35383. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35384. minWidth: number;
  35385. maxWidth: number;
  35386. minHeight: number;
  35387. maxHeight: number;
  35388. deviceId: string;
  35389. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35390. /**
  35391. * Creates a video texture straight from your WebCam video feed.
  35392. * @param scene Define the scene the texture should be created in
  35393. * @param onReady Define a callback to triggered once the texture will be ready
  35394. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35395. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35396. */
  35397. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35398. minWidth: number;
  35399. maxWidth: number;
  35400. minHeight: number;
  35401. maxHeight: number;
  35402. deviceId: string;
  35403. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35404. }
  35405. }
  35406. declare module "babylonjs/Engines/thinEngine" {
  35407. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35408. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35409. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35410. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35411. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35412. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35413. import { Observable } from "babylonjs/Misc/observable";
  35414. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35415. import { StencilState } from "babylonjs/States/stencilState";
  35416. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35417. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35418. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35419. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35420. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35421. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35422. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35423. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35424. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35425. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35426. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35427. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35428. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35429. import { WebRequest } from "babylonjs/Misc/webRequest";
  35430. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35431. /**
  35432. * Defines the interface used by objects working like Scene
  35433. * @hidden
  35434. */
  35435. export interface ISceneLike {
  35436. _addPendingData(data: any): void;
  35437. _removePendingData(data: any): void;
  35438. offlineProvider: IOfflineProvider;
  35439. }
  35440. /** Interface defining initialization parameters for Engine class */
  35441. export interface EngineOptions extends WebGLContextAttributes {
  35442. /**
  35443. * Defines if the engine should no exceed a specified device ratio
  35444. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35445. */
  35446. limitDeviceRatio?: number;
  35447. /**
  35448. * Defines if webvr should be enabled automatically
  35449. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35450. */
  35451. autoEnableWebVR?: boolean;
  35452. /**
  35453. * Defines if webgl2 should be turned off even if supported
  35454. * @see http://doc.babylonjs.com/features/webgl2
  35455. */
  35456. disableWebGL2Support?: boolean;
  35457. /**
  35458. * Defines if webaudio should be initialized as well
  35459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35460. */
  35461. audioEngine?: boolean;
  35462. /**
  35463. * Defines if animations should run using a deterministic lock step
  35464. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35465. */
  35466. deterministicLockstep?: boolean;
  35467. /** Defines the maximum steps to use with deterministic lock step mode */
  35468. lockstepMaxSteps?: number;
  35469. /** Defines the seconds between each deterministic lock step */
  35470. timeStep?: number;
  35471. /**
  35472. * Defines that engine should ignore context lost events
  35473. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35474. */
  35475. doNotHandleContextLost?: boolean;
  35476. /**
  35477. * Defines that engine should ignore modifying touch action attribute and style
  35478. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35479. */
  35480. doNotHandleTouchAction?: boolean;
  35481. /**
  35482. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35483. */
  35484. useHighPrecisionFloats?: boolean;
  35485. /**
  35486. * Make the canvas XR Compatible for XR sessions
  35487. */
  35488. xrCompatible?: boolean;
  35489. }
  35490. /**
  35491. * The base engine class (root of all engines)
  35492. */
  35493. export class ThinEngine {
  35494. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35495. static ExceptionList: ({
  35496. key: string;
  35497. capture: string;
  35498. captureConstraint: number;
  35499. targets: string[];
  35500. } | {
  35501. key: string;
  35502. capture: null;
  35503. captureConstraint: null;
  35504. targets: string[];
  35505. })[];
  35506. /** @hidden */
  35507. static _TextureLoaders: IInternalTextureLoader[];
  35508. /**
  35509. * Returns the current npm package of the sdk
  35510. */
  35511. static get NpmPackage(): string;
  35512. /**
  35513. * Returns the current version of the framework
  35514. */
  35515. static get Version(): string;
  35516. /**
  35517. * Returns a string describing the current engine
  35518. */
  35519. get description(): string;
  35520. /**
  35521. * Gets or sets the epsilon value used by collision engine
  35522. */
  35523. static CollisionsEpsilon: number;
  35524. /**
  35525. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35526. */
  35527. static get ShadersRepository(): string;
  35528. static set ShadersRepository(value: string);
  35529. /** @hidden */
  35530. _shaderProcessor: IShaderProcessor;
  35531. /**
  35532. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35533. */
  35534. forcePOTTextures: boolean;
  35535. /**
  35536. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35537. */
  35538. isFullscreen: boolean;
  35539. /**
  35540. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35541. */
  35542. cullBackFaces: boolean;
  35543. /**
  35544. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35545. */
  35546. renderEvenInBackground: boolean;
  35547. /**
  35548. * Gets or sets a boolean indicating that cache can be kept between frames
  35549. */
  35550. preventCacheWipeBetweenFrames: boolean;
  35551. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35552. validateShaderPrograms: boolean;
  35553. /**
  35554. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35555. * This can provide greater z depth for distant objects.
  35556. */
  35557. useReverseDepthBuffer: boolean;
  35558. /**
  35559. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35560. */
  35561. disableUniformBuffers: boolean;
  35562. /** @hidden */
  35563. _uniformBuffers: UniformBuffer[];
  35564. /**
  35565. * Gets a boolean indicating that the engine supports uniform buffers
  35566. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35567. */
  35568. get supportsUniformBuffers(): boolean;
  35569. /** @hidden */
  35570. _gl: WebGLRenderingContext;
  35571. /** @hidden */
  35572. _webGLVersion: number;
  35573. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35574. protected _windowIsBackground: boolean;
  35575. protected _creationOptions: EngineOptions;
  35576. protected _highPrecisionShadersAllowed: boolean;
  35577. /** @hidden */
  35578. get _shouldUseHighPrecisionShader(): boolean;
  35579. /**
  35580. * Gets a boolean indicating that only power of 2 textures are supported
  35581. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35582. */
  35583. get needPOTTextures(): boolean;
  35584. /** @hidden */
  35585. _badOS: boolean;
  35586. /** @hidden */
  35587. _badDesktopOS: boolean;
  35588. private _hardwareScalingLevel;
  35589. /** @hidden */
  35590. _caps: EngineCapabilities;
  35591. private _isStencilEnable;
  35592. private _glVersion;
  35593. private _glRenderer;
  35594. private _glVendor;
  35595. /** @hidden */
  35596. _videoTextureSupported: boolean;
  35597. protected _renderingQueueLaunched: boolean;
  35598. protected _activeRenderLoops: (() => void)[];
  35599. /**
  35600. * Observable signaled when a context lost event is raised
  35601. */
  35602. onContextLostObservable: Observable<ThinEngine>;
  35603. /**
  35604. * Observable signaled when a context restored event is raised
  35605. */
  35606. onContextRestoredObservable: Observable<ThinEngine>;
  35607. private _onContextLost;
  35608. private _onContextRestored;
  35609. protected _contextWasLost: boolean;
  35610. /** @hidden */
  35611. _doNotHandleContextLost: boolean;
  35612. /**
  35613. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35615. */
  35616. get doNotHandleContextLost(): boolean;
  35617. set doNotHandleContextLost(value: boolean);
  35618. /**
  35619. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35620. */
  35621. disableVertexArrayObjects: boolean;
  35622. /** @hidden */
  35623. protected _colorWrite: boolean;
  35624. /** @hidden */
  35625. protected _colorWriteChanged: boolean;
  35626. /** @hidden */
  35627. protected _depthCullingState: DepthCullingState;
  35628. /** @hidden */
  35629. protected _stencilState: StencilState;
  35630. /** @hidden */
  35631. _alphaState: AlphaState;
  35632. /** @hidden */
  35633. _alphaMode: number;
  35634. /** @hidden */
  35635. _alphaEquation: number;
  35636. /** @hidden */
  35637. _internalTexturesCache: InternalTexture[];
  35638. /** @hidden */
  35639. protected _activeChannel: number;
  35640. private _currentTextureChannel;
  35641. /** @hidden */
  35642. protected _boundTexturesCache: {
  35643. [key: string]: Nullable<InternalTexture>;
  35644. };
  35645. /** @hidden */
  35646. protected _currentEffect: Nullable<Effect>;
  35647. /** @hidden */
  35648. protected _currentProgram: Nullable<WebGLProgram>;
  35649. private _compiledEffects;
  35650. private _vertexAttribArraysEnabled;
  35651. /** @hidden */
  35652. protected _cachedViewport: Nullable<IViewportLike>;
  35653. private _cachedVertexArrayObject;
  35654. /** @hidden */
  35655. protected _cachedVertexBuffers: any;
  35656. /** @hidden */
  35657. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35658. /** @hidden */
  35659. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35660. /** @hidden */
  35661. _currentRenderTarget: Nullable<InternalTexture>;
  35662. private _uintIndicesCurrentlySet;
  35663. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35664. /** @hidden */
  35665. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35666. /** @hidden */
  35667. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35668. private _currentBufferPointers;
  35669. private _currentInstanceLocations;
  35670. private _currentInstanceBuffers;
  35671. private _textureUnits;
  35672. /** @hidden */
  35673. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35674. /** @hidden */
  35675. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35676. /** @hidden */
  35677. _boundRenderFunction: any;
  35678. private _vaoRecordInProgress;
  35679. private _mustWipeVertexAttributes;
  35680. private _emptyTexture;
  35681. private _emptyCubeTexture;
  35682. private _emptyTexture3D;
  35683. private _emptyTexture2DArray;
  35684. /** @hidden */
  35685. _frameHandler: number;
  35686. private _nextFreeTextureSlots;
  35687. private _maxSimultaneousTextures;
  35688. private _activeRequests;
  35689. /** @hidden */
  35690. _transformTextureUrl: Nullable<(url: string) => string>;
  35691. protected get _supportsHardwareTextureRescaling(): boolean;
  35692. private _framebufferDimensionsObject;
  35693. /**
  35694. * sets the object from which width and height will be taken from when getting render width and height
  35695. * Will fallback to the gl object
  35696. * @param dimensions the framebuffer width and height that will be used.
  35697. */
  35698. set framebufferDimensionsObject(dimensions: Nullable<{
  35699. framebufferWidth: number;
  35700. framebufferHeight: number;
  35701. }>);
  35702. /**
  35703. * Gets the current viewport
  35704. */
  35705. get currentViewport(): Nullable<IViewportLike>;
  35706. /**
  35707. * Gets the default empty texture
  35708. */
  35709. get emptyTexture(): InternalTexture;
  35710. /**
  35711. * Gets the default empty 3D texture
  35712. */
  35713. get emptyTexture3D(): InternalTexture;
  35714. /**
  35715. * Gets the default empty 2D array texture
  35716. */
  35717. get emptyTexture2DArray(): InternalTexture;
  35718. /**
  35719. * Gets the default empty cube texture
  35720. */
  35721. get emptyCubeTexture(): InternalTexture;
  35722. /**
  35723. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35724. */
  35725. readonly premultipliedAlpha: boolean;
  35726. /**
  35727. * Observable event triggered before each texture is initialized
  35728. */
  35729. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35730. /**
  35731. * Creates a new engine
  35732. * @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
  35733. * @param antialias defines enable antialiasing (default: false)
  35734. * @param options defines further options to be sent to the getContext() function
  35735. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35736. */
  35737. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35738. private _rebuildInternalTextures;
  35739. private _rebuildEffects;
  35740. /**
  35741. * Gets a boolean indicating if all created effects are ready
  35742. * @returns true if all effects are ready
  35743. */
  35744. areAllEffectsReady(): boolean;
  35745. protected _rebuildBuffers(): void;
  35746. protected _initGLContext(): void;
  35747. /**
  35748. * Gets version of the current webGL context
  35749. */
  35750. get webGLVersion(): number;
  35751. /**
  35752. * Gets a string idenfifying the name of the class
  35753. * @returns "Engine" string
  35754. */
  35755. getClassName(): string;
  35756. /**
  35757. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35758. */
  35759. get isStencilEnable(): boolean;
  35760. /** @hidden */
  35761. _prepareWorkingCanvas(): void;
  35762. /**
  35763. * Reset the texture cache to empty state
  35764. */
  35765. resetTextureCache(): void;
  35766. /**
  35767. * Gets an object containing information about the current webGL context
  35768. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35769. */
  35770. getGlInfo(): {
  35771. vendor: string;
  35772. renderer: string;
  35773. version: string;
  35774. };
  35775. /**
  35776. * Defines the hardware scaling level.
  35777. * By default the hardware scaling level is computed from the window device ratio.
  35778. * 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.
  35779. * @param level defines the level to use
  35780. */
  35781. setHardwareScalingLevel(level: number): void;
  35782. /**
  35783. * Gets the current hardware scaling level.
  35784. * By default the hardware scaling level is computed from the window device ratio.
  35785. * 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.
  35786. * @returns a number indicating the current hardware scaling level
  35787. */
  35788. getHardwareScalingLevel(): number;
  35789. /**
  35790. * Gets the list of loaded textures
  35791. * @returns an array containing all loaded textures
  35792. */
  35793. getLoadedTexturesCache(): InternalTexture[];
  35794. /**
  35795. * Gets the object containing all engine capabilities
  35796. * @returns the EngineCapabilities object
  35797. */
  35798. getCaps(): EngineCapabilities;
  35799. /**
  35800. * stop executing a render loop function and remove it from the execution array
  35801. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35802. */
  35803. stopRenderLoop(renderFunction?: () => void): void;
  35804. /** @hidden */
  35805. _renderLoop(): void;
  35806. /**
  35807. * Gets the HTML canvas attached with the current webGL context
  35808. * @returns a HTML canvas
  35809. */
  35810. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35811. /**
  35812. * Gets host window
  35813. * @returns the host window object
  35814. */
  35815. getHostWindow(): Nullable<Window>;
  35816. /**
  35817. * Gets the current render width
  35818. * @param useScreen defines if screen size must be used (or the current render target if any)
  35819. * @returns a number defining the current render width
  35820. */
  35821. getRenderWidth(useScreen?: boolean): number;
  35822. /**
  35823. * Gets the current render height
  35824. * @param useScreen defines if screen size must be used (or the current render target if any)
  35825. * @returns a number defining the current render height
  35826. */
  35827. getRenderHeight(useScreen?: boolean): number;
  35828. /**
  35829. * Can be used to override the current requestAnimationFrame requester.
  35830. * @hidden
  35831. */
  35832. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35833. /**
  35834. * Register and execute a render loop. The engine can have more than one render function
  35835. * @param renderFunction defines the function to continuously execute
  35836. */
  35837. runRenderLoop(renderFunction: () => void): void;
  35838. /**
  35839. * Clear the current render buffer or the current render target (if any is set up)
  35840. * @param color defines the color to use
  35841. * @param backBuffer defines if the back buffer must be cleared
  35842. * @param depth defines if the depth buffer must be cleared
  35843. * @param stencil defines if the stencil buffer must be cleared
  35844. */
  35845. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35846. private _viewportCached;
  35847. /** @hidden */
  35848. _viewport(x: number, y: number, width: number, height: number): void;
  35849. /**
  35850. * Set the WebGL's viewport
  35851. * @param viewport defines the viewport element to be used
  35852. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35853. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35854. */
  35855. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35856. /**
  35857. * Begin a new frame
  35858. */
  35859. beginFrame(): void;
  35860. /**
  35861. * Enf the current frame
  35862. */
  35863. endFrame(): void;
  35864. /**
  35865. * Resize the view according to the canvas' size
  35866. */
  35867. resize(): void;
  35868. /**
  35869. * Force a specific size of the canvas
  35870. * @param width defines the new canvas' width
  35871. * @param height defines the new canvas' height
  35872. */
  35873. setSize(width: number, height: number): void;
  35874. /**
  35875. * Binds the frame buffer to the specified texture.
  35876. * @param texture The texture to render to or null for the default canvas
  35877. * @param faceIndex The face of the texture to render to in case of cube texture
  35878. * @param requiredWidth The width of the target to render to
  35879. * @param requiredHeight The height of the target to render to
  35880. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35881. * @param lodLevel defines the lod level to bind to the frame buffer
  35882. * @param layer defines the 2d array index to bind to frame buffer to
  35883. */
  35884. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35885. /** @hidden */
  35886. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35887. /**
  35888. * Unbind the current render target texture from the webGL context
  35889. * @param texture defines the render target texture to unbind
  35890. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35891. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35892. */
  35893. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35894. /**
  35895. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35896. */
  35897. flushFramebuffer(): void;
  35898. /**
  35899. * Unbind the current render target and bind the default framebuffer
  35900. */
  35901. restoreDefaultFramebuffer(): void;
  35902. /** @hidden */
  35903. protected _resetVertexBufferBinding(): void;
  35904. /**
  35905. * Creates a vertex buffer
  35906. * @param data the data for the vertex buffer
  35907. * @returns the new WebGL static buffer
  35908. */
  35909. createVertexBuffer(data: DataArray): DataBuffer;
  35910. private _createVertexBuffer;
  35911. /**
  35912. * Creates a dynamic vertex buffer
  35913. * @param data the data for the dynamic vertex buffer
  35914. * @returns the new WebGL dynamic buffer
  35915. */
  35916. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35917. protected _resetIndexBufferBinding(): void;
  35918. /**
  35919. * Creates a new index buffer
  35920. * @param indices defines the content of the index buffer
  35921. * @param updatable defines if the index buffer must be updatable
  35922. * @returns a new webGL buffer
  35923. */
  35924. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35925. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35926. /**
  35927. * Bind a webGL buffer to the webGL context
  35928. * @param buffer defines the buffer to bind
  35929. */
  35930. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35931. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35932. private bindBuffer;
  35933. /**
  35934. * update the bound buffer with the given data
  35935. * @param data defines the data to update
  35936. */
  35937. updateArrayBuffer(data: Float32Array): void;
  35938. private _vertexAttribPointer;
  35939. /** @hidden */
  35940. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35941. private _bindVertexBuffersAttributes;
  35942. /**
  35943. * Records a vertex array object
  35944. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35945. * @param vertexBuffers defines the list of vertex buffers to store
  35946. * @param indexBuffer defines the index buffer to store
  35947. * @param effect defines the effect to store
  35948. * @returns the new vertex array object
  35949. */
  35950. recordVertexArrayObject(vertexBuffers: {
  35951. [key: string]: VertexBuffer;
  35952. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35953. /**
  35954. * Bind a specific vertex array object
  35955. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35956. * @param vertexArrayObject defines the vertex array object to bind
  35957. * @param indexBuffer defines the index buffer to bind
  35958. */
  35959. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35960. /**
  35961. * Bind webGl buffers directly to the webGL context
  35962. * @param vertexBuffer defines the vertex buffer to bind
  35963. * @param indexBuffer defines the index buffer to bind
  35964. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35965. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35966. * @param effect defines the effect associated with the vertex buffer
  35967. */
  35968. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35969. private _unbindVertexArrayObject;
  35970. /**
  35971. * Bind a list of vertex buffers to the webGL context
  35972. * @param vertexBuffers defines the list of vertex buffers to bind
  35973. * @param indexBuffer defines the index buffer to bind
  35974. * @param effect defines the effect associated with the vertex buffers
  35975. */
  35976. bindBuffers(vertexBuffers: {
  35977. [key: string]: Nullable<VertexBuffer>;
  35978. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35979. /**
  35980. * Unbind all instance attributes
  35981. */
  35982. unbindInstanceAttributes(): void;
  35983. /**
  35984. * Release and free the memory of a vertex array object
  35985. * @param vao defines the vertex array object to delete
  35986. */
  35987. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35988. /** @hidden */
  35989. _releaseBuffer(buffer: DataBuffer): boolean;
  35990. protected _deleteBuffer(buffer: DataBuffer): void;
  35991. /**
  35992. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35993. * @param instancesBuffer defines the webGL buffer to update and bind
  35994. * @param data defines the data to store in the buffer
  35995. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35996. */
  35997. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35998. /**
  35999. * Bind the content of a webGL buffer used with instantiation
  36000. * @param instancesBuffer defines the webGL buffer to bind
  36001. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36002. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36003. */
  36004. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  36005. /**
  36006. * Disable the instance attribute corresponding to the name in parameter
  36007. * @param name defines the name of the attribute to disable
  36008. */
  36009. disableInstanceAttributeByName(name: string): void;
  36010. /**
  36011. * Disable the instance attribute corresponding to the location in parameter
  36012. * @param attributeLocation defines the attribute location of the attribute to disable
  36013. */
  36014. disableInstanceAttribute(attributeLocation: number): void;
  36015. /**
  36016. * Disable the attribute corresponding to the location in parameter
  36017. * @param attributeLocation defines the attribute location of the attribute to disable
  36018. */
  36019. disableAttributeByIndex(attributeLocation: number): void;
  36020. /**
  36021. * Send a draw order
  36022. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36023. * @param indexStart defines the starting index
  36024. * @param indexCount defines the number of index to draw
  36025. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36026. */
  36027. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36028. /**
  36029. * Draw a list of points
  36030. * @param verticesStart defines the index of first vertex to draw
  36031. * @param verticesCount defines the count of vertices to draw
  36032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36033. */
  36034. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36035. /**
  36036. * Draw a list of unindexed primitives
  36037. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36038. * @param verticesStart defines the index of first vertex to draw
  36039. * @param verticesCount defines the count of vertices to draw
  36040. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36041. */
  36042. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36043. /**
  36044. * Draw a list of indexed primitives
  36045. * @param fillMode defines the primitive to use
  36046. * @param indexStart defines the starting index
  36047. * @param indexCount defines the number of index to draw
  36048. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36049. */
  36050. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36051. /**
  36052. * Draw a list of unindexed primitives
  36053. * @param fillMode defines the primitive to use
  36054. * @param verticesStart defines the index of first vertex to draw
  36055. * @param verticesCount defines the count of vertices to draw
  36056. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36057. */
  36058. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36059. private _drawMode;
  36060. /** @hidden */
  36061. protected _reportDrawCall(): void;
  36062. /** @hidden */
  36063. _releaseEffect(effect: Effect): void;
  36064. /** @hidden */
  36065. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36066. /**
  36067. * Create a new effect (used to store vertex/fragment shaders)
  36068. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36069. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36070. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36071. * @param samplers defines an array of string used to represent textures
  36072. * @param defines defines the string containing the defines to use to compile the shaders
  36073. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36074. * @param onCompiled defines a function to call when the effect creation is successful
  36075. * @param onError defines a function to call when the effect creation has failed
  36076. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36077. * @returns the new Effect
  36078. */
  36079. 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;
  36080. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36081. private _compileShader;
  36082. private _compileRawShader;
  36083. /** @hidden */
  36084. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36085. /**
  36086. * Directly creates a webGL program
  36087. * @param pipelineContext defines the pipeline context to attach to
  36088. * @param vertexCode defines the vertex shader code to use
  36089. * @param fragmentCode defines the fragment shader code to use
  36090. * @param context defines the webGL context to use (if not set, the current one will be used)
  36091. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36092. * @returns the new webGL program
  36093. */
  36094. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36095. /**
  36096. * Creates a webGL program
  36097. * @param pipelineContext defines the pipeline context to attach to
  36098. * @param vertexCode defines the vertex shader code to use
  36099. * @param fragmentCode defines the fragment shader code to use
  36100. * @param defines defines the string containing the defines to use to compile the shaders
  36101. * @param context defines the webGL context to use (if not set, the current one will be used)
  36102. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36103. * @returns the new webGL program
  36104. */
  36105. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36106. /**
  36107. * Creates a new pipeline context
  36108. * @returns the new pipeline
  36109. */
  36110. createPipelineContext(): IPipelineContext;
  36111. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36112. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36113. /** @hidden */
  36114. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36115. /** @hidden */
  36116. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36117. /** @hidden */
  36118. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36119. /**
  36120. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36121. * @param pipelineContext defines the pipeline context to use
  36122. * @param uniformsNames defines the list of uniform names
  36123. * @returns an array of webGL uniform locations
  36124. */
  36125. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36126. /**
  36127. * Gets the lsit of active attributes for a given webGL program
  36128. * @param pipelineContext defines the pipeline context to use
  36129. * @param attributesNames defines the list of attribute names to get
  36130. * @returns an array of indices indicating the offset of each attribute
  36131. */
  36132. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36133. /**
  36134. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36135. * @param effect defines the effect to activate
  36136. */
  36137. enableEffect(effect: Nullable<Effect>): void;
  36138. /**
  36139. * Set the value of an uniform to a number (int)
  36140. * @param uniform defines the webGL uniform location where to store the value
  36141. * @param value defines the int number to store
  36142. */
  36143. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36144. /**
  36145. * Set the value of an uniform to an array of int32
  36146. * @param uniform defines the webGL uniform location where to store the value
  36147. * @param array defines the array of int32 to store
  36148. */
  36149. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36150. /**
  36151. * Set the value of an uniform to an array of int32 (stored as vec2)
  36152. * @param uniform defines the webGL uniform location where to store the value
  36153. * @param array defines the array of int32 to store
  36154. */
  36155. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36156. /**
  36157. * Set the value of an uniform to an array of int32 (stored as vec3)
  36158. * @param uniform defines the webGL uniform location where to store the value
  36159. * @param array defines the array of int32 to store
  36160. */
  36161. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36162. /**
  36163. * Set the value of an uniform to an array of int32 (stored as vec4)
  36164. * @param uniform defines the webGL uniform location where to store the value
  36165. * @param array defines the array of int32 to store
  36166. */
  36167. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36168. /**
  36169. * Set the value of an uniform to an array of number
  36170. * @param uniform defines the webGL uniform location where to store the value
  36171. * @param array defines the array of number to store
  36172. */
  36173. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36174. /**
  36175. * Set the value of an uniform to an array of number (stored as vec2)
  36176. * @param uniform defines the webGL uniform location where to store the value
  36177. * @param array defines the array of number to store
  36178. */
  36179. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36180. /**
  36181. * Set the value of an uniform to an array of number (stored as vec3)
  36182. * @param uniform defines the webGL uniform location where to store the value
  36183. * @param array defines the array of number to store
  36184. */
  36185. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36186. /**
  36187. * Set the value of an uniform to an array of number (stored as vec4)
  36188. * @param uniform defines the webGL uniform location where to store the value
  36189. * @param array defines the array of number to store
  36190. */
  36191. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36192. /**
  36193. * Set the value of an uniform to an array of float32 (stored as matrices)
  36194. * @param uniform defines the webGL uniform location where to store the value
  36195. * @param matrices defines the array of float32 to store
  36196. */
  36197. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36198. /**
  36199. * Set the value of an uniform to a matrix (3x3)
  36200. * @param uniform defines the webGL uniform location where to store the value
  36201. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36202. */
  36203. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36204. /**
  36205. * Set the value of an uniform to a matrix (2x2)
  36206. * @param uniform defines the webGL uniform location where to store the value
  36207. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36208. */
  36209. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36210. /**
  36211. * Set the value of an uniform to a number (float)
  36212. * @param uniform defines the webGL uniform location where to store the value
  36213. * @param value defines the float number to store
  36214. */
  36215. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36216. /**
  36217. * Set the value of an uniform to a vec2
  36218. * @param uniform defines the webGL uniform location where to store the value
  36219. * @param x defines the 1st component of the value
  36220. * @param y defines the 2nd component of the value
  36221. */
  36222. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36223. /**
  36224. * Set the value of an uniform to a vec3
  36225. * @param uniform defines the webGL uniform location where to store the value
  36226. * @param x defines the 1st component of the value
  36227. * @param y defines the 2nd component of the value
  36228. * @param z defines the 3rd component of the value
  36229. */
  36230. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36231. /**
  36232. * Set the value of an uniform to a vec4
  36233. * @param uniform defines the webGL uniform location where to store the value
  36234. * @param x defines the 1st component of the value
  36235. * @param y defines the 2nd component of the value
  36236. * @param z defines the 3rd component of the value
  36237. * @param w defines the 4th component of the value
  36238. */
  36239. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36240. /**
  36241. * Apply all cached states (depth, culling, stencil and alpha)
  36242. */
  36243. applyStates(): void;
  36244. /**
  36245. * Enable or disable color writing
  36246. * @param enable defines the state to set
  36247. */
  36248. setColorWrite(enable: boolean): void;
  36249. /**
  36250. * Gets a boolean indicating if color writing is enabled
  36251. * @returns the current color writing state
  36252. */
  36253. getColorWrite(): boolean;
  36254. /**
  36255. * Gets the depth culling state manager
  36256. */
  36257. get depthCullingState(): DepthCullingState;
  36258. /**
  36259. * Gets the alpha state manager
  36260. */
  36261. get alphaState(): AlphaState;
  36262. /**
  36263. * Gets the stencil state manager
  36264. */
  36265. get stencilState(): StencilState;
  36266. /**
  36267. * Clears the list of texture accessible through engine.
  36268. * This can help preventing texture load conflict due to name collision.
  36269. */
  36270. clearInternalTexturesCache(): void;
  36271. /**
  36272. * Force the entire cache to be cleared
  36273. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36274. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36275. */
  36276. wipeCaches(bruteForce?: boolean): void;
  36277. /** @hidden */
  36278. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36279. min: number;
  36280. mag: number;
  36281. };
  36282. /** @hidden */
  36283. _createTexture(): WebGLTexture;
  36284. /**
  36285. * Usually called from Texture.ts.
  36286. * Passed information to create a WebGLTexture
  36287. * @param url defines a value which contains one of the following:
  36288. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36289. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36290. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36291. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36292. * @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)
  36293. * @param scene needed for loading to the correct scene
  36294. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36295. * @param onLoad optional callback to be called upon successful completion
  36296. * @param onError optional callback to be called upon failure
  36297. * @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
  36298. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36299. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36300. * @param forcedExtension defines the extension to use to pick the right loader
  36301. * @param mimeType defines an optional mime type
  36302. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36303. */
  36304. 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;
  36305. /**
  36306. * Loads an image as an HTMLImageElement.
  36307. * @param input url string, ArrayBuffer, or Blob to load
  36308. * @param onLoad callback called when the image successfully loads
  36309. * @param onError callback called when the image fails to load
  36310. * @param offlineProvider offline provider for caching
  36311. * @param mimeType optional mime type
  36312. * @returns the HTMLImageElement of the loaded image
  36313. * @hidden
  36314. */
  36315. 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>;
  36316. /**
  36317. * @hidden
  36318. */
  36319. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36320. private _unpackFlipYCached;
  36321. /**
  36322. * In case you are sharing the context with other applications, it might
  36323. * be interested to not cache the unpack flip y state to ensure a consistent
  36324. * value would be set.
  36325. */
  36326. enableUnpackFlipYCached: boolean;
  36327. /** @hidden */
  36328. _unpackFlipY(value: boolean): void;
  36329. /** @hidden */
  36330. _getUnpackAlignement(): number;
  36331. private _getTextureTarget;
  36332. /**
  36333. * Update the sampling mode of a given texture
  36334. * @param samplingMode defines the required sampling mode
  36335. * @param texture defines the texture to update
  36336. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36337. */
  36338. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36339. /**
  36340. * Update the sampling mode of a given texture
  36341. * @param texture defines the texture to update
  36342. * @param wrapU defines the texture wrap mode of the u coordinates
  36343. * @param wrapV defines the texture wrap mode of the v coordinates
  36344. * @param wrapR defines the texture wrap mode of the r coordinates
  36345. */
  36346. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36347. /** @hidden */
  36348. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36349. width: number;
  36350. height: number;
  36351. layers?: number;
  36352. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36353. /** @hidden */
  36354. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36355. /** @hidden */
  36356. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36357. /**
  36358. * Update a portion of an internal texture
  36359. * @param texture defines the texture to update
  36360. * @param imageData defines the data to store into the texture
  36361. * @param xOffset defines the x coordinates of the update rectangle
  36362. * @param yOffset defines the y coordinates of the update rectangle
  36363. * @param width defines the width of the update rectangle
  36364. * @param height defines the height of the update rectangle
  36365. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36366. * @param lod defines the lod level to update (0 by default)
  36367. */
  36368. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36369. /** @hidden */
  36370. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36371. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36372. private _prepareWebGLTexture;
  36373. /** @hidden */
  36374. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36375. private _getDepthStencilBuffer;
  36376. /** @hidden */
  36377. _releaseFramebufferObjects(texture: InternalTexture): void;
  36378. /** @hidden */
  36379. _releaseTexture(texture: InternalTexture): void;
  36380. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36381. protected _setProgram(program: WebGLProgram): void;
  36382. protected _boundUniforms: {
  36383. [key: number]: WebGLUniformLocation;
  36384. };
  36385. /**
  36386. * Binds an effect to the webGL context
  36387. * @param effect defines the effect to bind
  36388. */
  36389. bindSamplers(effect: Effect): void;
  36390. private _activateCurrentTexture;
  36391. /** @hidden */
  36392. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36393. /** @hidden */
  36394. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36395. /**
  36396. * Unbind all textures from the webGL context
  36397. */
  36398. unbindAllTextures(): void;
  36399. /**
  36400. * Sets a texture to the according uniform.
  36401. * @param channel The texture channel
  36402. * @param uniform The uniform to set
  36403. * @param texture The texture to apply
  36404. */
  36405. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36406. private _bindSamplerUniformToChannel;
  36407. private _getTextureWrapMode;
  36408. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36409. /**
  36410. * Sets an array of texture to the webGL context
  36411. * @param channel defines the channel where the texture array must be set
  36412. * @param uniform defines the associated uniform location
  36413. * @param textures defines the array of textures to bind
  36414. */
  36415. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36416. /** @hidden */
  36417. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36418. private _setTextureParameterFloat;
  36419. private _setTextureParameterInteger;
  36420. /**
  36421. * Unbind all vertex attributes from the webGL context
  36422. */
  36423. unbindAllAttributes(): void;
  36424. /**
  36425. * 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
  36426. */
  36427. releaseEffects(): void;
  36428. /**
  36429. * Dispose and release all associated resources
  36430. */
  36431. dispose(): void;
  36432. /**
  36433. * Attach a new callback raised when context lost event is fired
  36434. * @param callback defines the callback to call
  36435. */
  36436. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36437. /**
  36438. * Attach a new callback raised when context restored event is fired
  36439. * @param callback defines the callback to call
  36440. */
  36441. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36442. /**
  36443. * Get the current error code of the webGL context
  36444. * @returns the error code
  36445. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36446. */
  36447. getError(): number;
  36448. private _canRenderToFloatFramebuffer;
  36449. private _canRenderToHalfFloatFramebuffer;
  36450. private _canRenderToFramebuffer;
  36451. /** @hidden */
  36452. _getWebGLTextureType(type: number): number;
  36453. /** @hidden */
  36454. _getInternalFormat(format: number): number;
  36455. /** @hidden */
  36456. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36457. /** @hidden */
  36458. _getRGBAMultiSampleBufferFormat(type: number): number;
  36459. /** @hidden */
  36460. _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;
  36461. /**
  36462. * Loads a file from a url
  36463. * @param url url to load
  36464. * @param onSuccess callback called when the file successfully loads
  36465. * @param onProgress callback called while file is loading (if the server supports this mode)
  36466. * @param offlineProvider defines the offline provider for caching
  36467. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36468. * @param onError callback called when the file fails to load
  36469. * @returns a file request object
  36470. * @hidden
  36471. */
  36472. 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;
  36473. /**
  36474. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36475. * @param x defines the x coordinate of the rectangle where pixels must be read
  36476. * @param y defines the y coordinate of the rectangle where pixels must be read
  36477. * @param width defines the width of the rectangle where pixels must be read
  36478. * @param height defines the height of the rectangle where pixels must be read
  36479. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36480. * @returns a Uint8Array containing RGBA colors
  36481. */
  36482. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36483. private static _isSupported;
  36484. /**
  36485. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36486. * @returns true if the engine can be created
  36487. * @ignorenaming
  36488. */
  36489. static isSupported(): boolean;
  36490. /**
  36491. * Find the next highest power of two.
  36492. * @param x Number to start search from.
  36493. * @return Next highest power of two.
  36494. */
  36495. static CeilingPOT(x: number): number;
  36496. /**
  36497. * Find the next lowest power of two.
  36498. * @param x Number to start search from.
  36499. * @return Next lowest power of two.
  36500. */
  36501. static FloorPOT(x: number): number;
  36502. /**
  36503. * Find the nearest power of two.
  36504. * @param x Number to start search from.
  36505. * @return Next nearest power of two.
  36506. */
  36507. static NearestPOT(x: number): number;
  36508. /**
  36509. * Get the closest exponent of two
  36510. * @param value defines the value to approximate
  36511. * @param max defines the maximum value to return
  36512. * @param mode defines how to define the closest value
  36513. * @returns closest exponent of two of the given value
  36514. */
  36515. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36516. /**
  36517. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36518. * @param func - the function to be called
  36519. * @param requester - the object that will request the next frame. Falls back to window.
  36520. * @returns frame number
  36521. */
  36522. static QueueNewFrame(func: () => void, requester?: any): number;
  36523. /**
  36524. * Gets host document
  36525. * @returns the host document object
  36526. */
  36527. getHostDocument(): Nullable<Document>;
  36528. }
  36529. }
  36530. declare module "babylonjs/Maths/sphericalPolynomial" {
  36531. import { Vector3 } from "babylonjs/Maths/math.vector";
  36532. import { Color3 } from "babylonjs/Maths/math.color";
  36533. /**
  36534. * Class representing spherical harmonics coefficients to the 3rd degree
  36535. */
  36536. export class SphericalHarmonics {
  36537. /**
  36538. * Defines whether or not the harmonics have been prescaled for rendering.
  36539. */
  36540. preScaled: boolean;
  36541. /**
  36542. * The l0,0 coefficients of the spherical harmonics
  36543. */
  36544. l00: Vector3;
  36545. /**
  36546. * The l1,-1 coefficients of the spherical harmonics
  36547. */
  36548. l1_1: Vector3;
  36549. /**
  36550. * The l1,0 coefficients of the spherical harmonics
  36551. */
  36552. l10: Vector3;
  36553. /**
  36554. * The l1,1 coefficients of the spherical harmonics
  36555. */
  36556. l11: Vector3;
  36557. /**
  36558. * The l2,-2 coefficients of the spherical harmonics
  36559. */
  36560. l2_2: Vector3;
  36561. /**
  36562. * The l2,-1 coefficients of the spherical harmonics
  36563. */
  36564. l2_1: Vector3;
  36565. /**
  36566. * The l2,0 coefficients of the spherical harmonics
  36567. */
  36568. l20: Vector3;
  36569. /**
  36570. * The l2,1 coefficients of the spherical harmonics
  36571. */
  36572. l21: Vector3;
  36573. /**
  36574. * The l2,2 coefficients of the spherical harmonics
  36575. */
  36576. l22: Vector3;
  36577. /**
  36578. * Adds a light to the spherical harmonics
  36579. * @param direction the direction of the light
  36580. * @param color the color of the light
  36581. * @param deltaSolidAngle the delta solid angle of the light
  36582. */
  36583. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36584. /**
  36585. * Scales the spherical harmonics by the given amount
  36586. * @param scale the amount to scale
  36587. */
  36588. scaleInPlace(scale: number): void;
  36589. /**
  36590. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36591. *
  36592. * ```
  36593. * E_lm = A_l * L_lm
  36594. * ```
  36595. *
  36596. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36597. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36598. * the scaling factors are given in equation 9.
  36599. */
  36600. convertIncidentRadianceToIrradiance(): void;
  36601. /**
  36602. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36603. *
  36604. * ```
  36605. * L = (1/pi) * E * rho
  36606. * ```
  36607. *
  36608. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36609. */
  36610. convertIrradianceToLambertianRadiance(): void;
  36611. /**
  36612. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36613. * required operations at run time.
  36614. *
  36615. * This is simply done by scaling back the SH with Ylm constants parameter.
  36616. * The trigonometric part being applied by the shader at run time.
  36617. */
  36618. preScaleForRendering(): void;
  36619. /**
  36620. * Constructs a spherical harmonics from an array.
  36621. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36622. * @returns the spherical harmonics
  36623. */
  36624. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36625. /**
  36626. * Gets the spherical harmonics from polynomial
  36627. * @param polynomial the spherical polynomial
  36628. * @returns the spherical harmonics
  36629. */
  36630. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36631. }
  36632. /**
  36633. * Class representing spherical polynomial coefficients to the 3rd degree
  36634. */
  36635. export class SphericalPolynomial {
  36636. private _harmonics;
  36637. /**
  36638. * The spherical harmonics used to create the polynomials.
  36639. */
  36640. get preScaledHarmonics(): SphericalHarmonics;
  36641. /**
  36642. * The x coefficients of the spherical polynomial
  36643. */
  36644. x: Vector3;
  36645. /**
  36646. * The y coefficients of the spherical polynomial
  36647. */
  36648. y: Vector3;
  36649. /**
  36650. * The z coefficients of the spherical polynomial
  36651. */
  36652. z: Vector3;
  36653. /**
  36654. * The xx coefficients of the spherical polynomial
  36655. */
  36656. xx: Vector3;
  36657. /**
  36658. * The yy coefficients of the spherical polynomial
  36659. */
  36660. yy: Vector3;
  36661. /**
  36662. * The zz coefficients of the spherical polynomial
  36663. */
  36664. zz: Vector3;
  36665. /**
  36666. * The xy coefficients of the spherical polynomial
  36667. */
  36668. xy: Vector3;
  36669. /**
  36670. * The yz coefficients of the spherical polynomial
  36671. */
  36672. yz: Vector3;
  36673. /**
  36674. * The zx coefficients of the spherical polynomial
  36675. */
  36676. zx: Vector3;
  36677. /**
  36678. * Adds an ambient color to the spherical polynomial
  36679. * @param color the color to add
  36680. */
  36681. addAmbient(color: Color3): void;
  36682. /**
  36683. * Scales the spherical polynomial by the given amount
  36684. * @param scale the amount to scale
  36685. */
  36686. scaleInPlace(scale: number): void;
  36687. /**
  36688. * Gets the spherical polynomial from harmonics
  36689. * @param harmonics the spherical harmonics
  36690. * @returns the spherical polynomial
  36691. */
  36692. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36693. /**
  36694. * Constructs a spherical polynomial from an array.
  36695. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36696. * @returns the spherical polynomial
  36697. */
  36698. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36699. }
  36700. }
  36701. declare module "babylonjs/Materials/Textures/internalTexture" {
  36702. import { Observable } from "babylonjs/Misc/observable";
  36703. import { Nullable, int } from "babylonjs/types";
  36704. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36706. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36707. /**
  36708. * Defines the source of the internal texture
  36709. */
  36710. export enum InternalTextureSource {
  36711. /**
  36712. * The source of the texture data is unknown
  36713. */
  36714. Unknown = 0,
  36715. /**
  36716. * Texture data comes from an URL
  36717. */
  36718. Url = 1,
  36719. /**
  36720. * Texture data is only used for temporary storage
  36721. */
  36722. Temp = 2,
  36723. /**
  36724. * Texture data comes from raw data (ArrayBuffer)
  36725. */
  36726. Raw = 3,
  36727. /**
  36728. * Texture content is dynamic (video or dynamic texture)
  36729. */
  36730. Dynamic = 4,
  36731. /**
  36732. * Texture content is generated by rendering to it
  36733. */
  36734. RenderTarget = 5,
  36735. /**
  36736. * Texture content is part of a multi render target process
  36737. */
  36738. MultiRenderTarget = 6,
  36739. /**
  36740. * Texture data comes from a cube data file
  36741. */
  36742. Cube = 7,
  36743. /**
  36744. * Texture data comes from a raw cube data
  36745. */
  36746. CubeRaw = 8,
  36747. /**
  36748. * Texture data come from a prefiltered cube data file
  36749. */
  36750. CubePrefiltered = 9,
  36751. /**
  36752. * Texture content is raw 3D data
  36753. */
  36754. Raw3D = 10,
  36755. /**
  36756. * Texture content is raw 2D array data
  36757. */
  36758. Raw2DArray = 11,
  36759. /**
  36760. * Texture content is a depth texture
  36761. */
  36762. Depth = 12,
  36763. /**
  36764. * Texture data comes from a raw cube data encoded with RGBD
  36765. */
  36766. CubeRawRGBD = 13
  36767. }
  36768. /**
  36769. * Class used to store data associated with WebGL texture data for the engine
  36770. * This class should not be used directly
  36771. */
  36772. export class InternalTexture {
  36773. /** @hidden */
  36774. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36775. /**
  36776. * Defines if the texture is ready
  36777. */
  36778. isReady: boolean;
  36779. /**
  36780. * Defines if the texture is a cube texture
  36781. */
  36782. isCube: boolean;
  36783. /**
  36784. * Defines if the texture contains 3D data
  36785. */
  36786. is3D: boolean;
  36787. /**
  36788. * Defines if the texture contains 2D array data
  36789. */
  36790. is2DArray: boolean;
  36791. /**
  36792. * Defines if the texture contains multiview data
  36793. */
  36794. isMultiview: boolean;
  36795. /**
  36796. * Gets the URL used to load this texture
  36797. */
  36798. url: string;
  36799. /**
  36800. * Gets the sampling mode of the texture
  36801. */
  36802. samplingMode: number;
  36803. /**
  36804. * Gets a boolean indicating if the texture needs mipmaps generation
  36805. */
  36806. generateMipMaps: boolean;
  36807. /**
  36808. * Gets the number of samples used by the texture (WebGL2+ only)
  36809. */
  36810. samples: number;
  36811. /**
  36812. * Gets the type of the texture (int, float...)
  36813. */
  36814. type: number;
  36815. /**
  36816. * Gets the format of the texture (RGB, RGBA...)
  36817. */
  36818. format: number;
  36819. /**
  36820. * Observable called when the texture is loaded
  36821. */
  36822. onLoadedObservable: Observable<InternalTexture>;
  36823. /**
  36824. * Gets the width of the texture
  36825. */
  36826. width: number;
  36827. /**
  36828. * Gets the height of the texture
  36829. */
  36830. height: number;
  36831. /**
  36832. * Gets the depth of the texture
  36833. */
  36834. depth: number;
  36835. /**
  36836. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36837. */
  36838. baseWidth: number;
  36839. /**
  36840. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36841. */
  36842. baseHeight: number;
  36843. /**
  36844. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36845. */
  36846. baseDepth: number;
  36847. /**
  36848. * Gets a boolean indicating if the texture is inverted on Y axis
  36849. */
  36850. invertY: boolean;
  36851. /** @hidden */
  36852. _invertVScale: boolean;
  36853. /** @hidden */
  36854. _associatedChannel: number;
  36855. /** @hidden */
  36856. _source: InternalTextureSource;
  36857. /** @hidden */
  36858. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36859. /** @hidden */
  36860. _bufferView: Nullable<ArrayBufferView>;
  36861. /** @hidden */
  36862. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36863. /** @hidden */
  36864. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36865. /** @hidden */
  36866. _size: number;
  36867. /** @hidden */
  36868. _extension: string;
  36869. /** @hidden */
  36870. _files: Nullable<string[]>;
  36871. /** @hidden */
  36872. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36873. /** @hidden */
  36874. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36875. /** @hidden */
  36876. _framebuffer: Nullable<WebGLFramebuffer>;
  36877. /** @hidden */
  36878. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36879. /** @hidden */
  36880. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36881. /** @hidden */
  36882. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36883. /** @hidden */
  36884. _attachments: Nullable<number[]>;
  36885. /** @hidden */
  36886. _cachedCoordinatesMode: Nullable<number>;
  36887. /** @hidden */
  36888. _cachedWrapU: Nullable<number>;
  36889. /** @hidden */
  36890. _cachedWrapV: Nullable<number>;
  36891. /** @hidden */
  36892. _cachedWrapR: Nullable<number>;
  36893. /** @hidden */
  36894. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36895. /** @hidden */
  36896. _isDisabled: boolean;
  36897. /** @hidden */
  36898. _compression: Nullable<string>;
  36899. /** @hidden */
  36900. _generateStencilBuffer: boolean;
  36901. /** @hidden */
  36902. _generateDepthBuffer: boolean;
  36903. /** @hidden */
  36904. _comparisonFunction: number;
  36905. /** @hidden */
  36906. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36907. /** @hidden */
  36908. _lodGenerationScale: number;
  36909. /** @hidden */
  36910. _lodGenerationOffset: number;
  36911. /** @hidden */
  36912. _depthStencilTexture: Nullable<InternalTexture>;
  36913. /** @hidden */
  36914. _colorTextureArray: Nullable<WebGLTexture>;
  36915. /** @hidden */
  36916. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36917. /** @hidden */
  36918. _lodTextureHigh: Nullable<BaseTexture>;
  36919. /** @hidden */
  36920. _lodTextureMid: Nullable<BaseTexture>;
  36921. /** @hidden */
  36922. _lodTextureLow: Nullable<BaseTexture>;
  36923. /** @hidden */
  36924. _isRGBD: boolean;
  36925. /** @hidden */
  36926. _linearSpecularLOD: boolean;
  36927. /** @hidden */
  36928. _irradianceTexture: Nullable<BaseTexture>;
  36929. /** @hidden */
  36930. _webGLTexture: Nullable<WebGLTexture>;
  36931. /** @hidden */
  36932. _references: number;
  36933. private _engine;
  36934. /**
  36935. * Gets the Engine the texture belongs to.
  36936. * @returns The babylon engine
  36937. */
  36938. getEngine(): ThinEngine;
  36939. /**
  36940. * Gets the data source type of the texture
  36941. */
  36942. get source(): InternalTextureSource;
  36943. /**
  36944. * Creates a new InternalTexture
  36945. * @param engine defines the engine to use
  36946. * @param source defines the type of data that will be used
  36947. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36948. */
  36949. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36950. /**
  36951. * Increments the number of references (ie. the number of Texture that point to it)
  36952. */
  36953. incrementReferences(): void;
  36954. /**
  36955. * Change the size of the texture (not the size of the content)
  36956. * @param width defines the new width
  36957. * @param height defines the new height
  36958. * @param depth defines the new depth (1 by default)
  36959. */
  36960. updateSize(width: int, height: int, depth?: int): void;
  36961. /** @hidden */
  36962. _rebuild(): void;
  36963. /** @hidden */
  36964. _swapAndDie(target: InternalTexture): void;
  36965. /**
  36966. * Dispose the current allocated resources
  36967. */
  36968. dispose(): void;
  36969. }
  36970. }
  36971. declare module "babylonjs/Audio/analyser" {
  36972. import { Scene } from "babylonjs/scene";
  36973. /**
  36974. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36976. */
  36977. export class Analyser {
  36978. /**
  36979. * Gets or sets the smoothing
  36980. * @ignorenaming
  36981. */
  36982. SMOOTHING: number;
  36983. /**
  36984. * Gets or sets the FFT table size
  36985. * @ignorenaming
  36986. */
  36987. FFT_SIZE: number;
  36988. /**
  36989. * Gets or sets the bar graph amplitude
  36990. * @ignorenaming
  36991. */
  36992. BARGRAPHAMPLITUDE: number;
  36993. /**
  36994. * Gets or sets the position of the debug canvas
  36995. * @ignorenaming
  36996. */
  36997. DEBUGCANVASPOS: {
  36998. x: number;
  36999. y: number;
  37000. };
  37001. /**
  37002. * Gets or sets the debug canvas size
  37003. * @ignorenaming
  37004. */
  37005. DEBUGCANVASSIZE: {
  37006. width: number;
  37007. height: number;
  37008. };
  37009. private _byteFreqs;
  37010. private _byteTime;
  37011. private _floatFreqs;
  37012. private _webAudioAnalyser;
  37013. private _debugCanvas;
  37014. private _debugCanvasContext;
  37015. private _scene;
  37016. private _registerFunc;
  37017. private _audioEngine;
  37018. /**
  37019. * Creates a new analyser
  37020. * @param scene defines hosting scene
  37021. */
  37022. constructor(scene: Scene);
  37023. /**
  37024. * Get the number of data values you will have to play with for the visualization
  37025. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37026. * @returns a number
  37027. */
  37028. getFrequencyBinCount(): number;
  37029. /**
  37030. * Gets the current frequency data as a byte array
  37031. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37032. * @returns a Uint8Array
  37033. */
  37034. getByteFrequencyData(): Uint8Array;
  37035. /**
  37036. * Gets the current waveform as a byte array
  37037. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37038. * @returns a Uint8Array
  37039. */
  37040. getByteTimeDomainData(): Uint8Array;
  37041. /**
  37042. * Gets the current frequency data as a float array
  37043. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37044. * @returns a Float32Array
  37045. */
  37046. getFloatFrequencyData(): Float32Array;
  37047. /**
  37048. * Renders the debug canvas
  37049. */
  37050. drawDebugCanvas(): void;
  37051. /**
  37052. * Stops rendering the debug canvas and removes it
  37053. */
  37054. stopDebugCanvas(): void;
  37055. /**
  37056. * Connects two audio nodes
  37057. * @param inputAudioNode defines first node to connect
  37058. * @param outputAudioNode defines second node to connect
  37059. */
  37060. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37061. /**
  37062. * Releases all associated resources
  37063. */
  37064. dispose(): void;
  37065. }
  37066. }
  37067. declare module "babylonjs/Audio/audioEngine" {
  37068. import { IDisposable } from "babylonjs/scene";
  37069. import { Analyser } from "babylonjs/Audio/analyser";
  37070. import { Nullable } from "babylonjs/types";
  37071. import { Observable } from "babylonjs/Misc/observable";
  37072. /**
  37073. * This represents an audio engine and it is responsible
  37074. * to play, synchronize and analyse sounds throughout the application.
  37075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37076. */
  37077. export interface IAudioEngine extends IDisposable {
  37078. /**
  37079. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37080. */
  37081. readonly canUseWebAudio: boolean;
  37082. /**
  37083. * Gets the current AudioContext if available.
  37084. */
  37085. readonly audioContext: Nullable<AudioContext>;
  37086. /**
  37087. * The master gain node defines the global audio volume of your audio engine.
  37088. */
  37089. readonly masterGain: GainNode;
  37090. /**
  37091. * Gets whether or not mp3 are supported by your browser.
  37092. */
  37093. readonly isMP3supported: boolean;
  37094. /**
  37095. * Gets whether or not ogg are supported by your browser.
  37096. */
  37097. readonly isOGGsupported: boolean;
  37098. /**
  37099. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37100. * @ignoreNaming
  37101. */
  37102. WarnedWebAudioUnsupported: boolean;
  37103. /**
  37104. * Defines if the audio engine relies on a custom unlocked button.
  37105. * In this case, the embedded button will not be displayed.
  37106. */
  37107. useCustomUnlockedButton: boolean;
  37108. /**
  37109. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37110. */
  37111. readonly unlocked: boolean;
  37112. /**
  37113. * Event raised when audio has been unlocked on the browser.
  37114. */
  37115. onAudioUnlockedObservable: Observable<AudioEngine>;
  37116. /**
  37117. * Event raised when audio has been locked on the browser.
  37118. */
  37119. onAudioLockedObservable: Observable<AudioEngine>;
  37120. /**
  37121. * Flags the audio engine in Locked state.
  37122. * This happens due to new browser policies preventing audio to autoplay.
  37123. */
  37124. lock(): void;
  37125. /**
  37126. * Unlocks the audio engine once a user action has been done on the dom.
  37127. * This is helpful to resume play once browser policies have been satisfied.
  37128. */
  37129. unlock(): void;
  37130. /**
  37131. * Gets the global volume sets on the master gain.
  37132. * @returns the global volume if set or -1 otherwise
  37133. */
  37134. getGlobalVolume(): number;
  37135. /**
  37136. * Sets the global volume of your experience (sets on the master gain).
  37137. * @param newVolume Defines the new global volume of the application
  37138. */
  37139. setGlobalVolume(newVolume: number): void;
  37140. /**
  37141. * Connect the audio engine to an audio analyser allowing some amazing
  37142. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37144. * @param analyser The analyser to connect to the engine
  37145. */
  37146. connectToAnalyser(analyser: Analyser): void;
  37147. }
  37148. /**
  37149. * This represents the default audio engine used in babylon.
  37150. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37152. */
  37153. export class AudioEngine implements IAudioEngine {
  37154. private _audioContext;
  37155. private _audioContextInitialized;
  37156. private _muteButton;
  37157. private _hostElement;
  37158. /**
  37159. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37160. */
  37161. canUseWebAudio: boolean;
  37162. /**
  37163. * The master gain node defines the global audio volume of your audio engine.
  37164. */
  37165. masterGain: GainNode;
  37166. /**
  37167. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37168. * @ignoreNaming
  37169. */
  37170. WarnedWebAudioUnsupported: boolean;
  37171. /**
  37172. * Gets whether or not mp3 are supported by your browser.
  37173. */
  37174. isMP3supported: boolean;
  37175. /**
  37176. * Gets whether or not ogg are supported by your browser.
  37177. */
  37178. isOGGsupported: boolean;
  37179. /**
  37180. * Gets whether audio has been unlocked on the device.
  37181. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37182. * a user interaction has happened.
  37183. */
  37184. unlocked: boolean;
  37185. /**
  37186. * Defines if the audio engine relies on a custom unlocked button.
  37187. * In this case, the embedded button will not be displayed.
  37188. */
  37189. useCustomUnlockedButton: boolean;
  37190. /**
  37191. * Event raised when audio has been unlocked on the browser.
  37192. */
  37193. onAudioUnlockedObservable: Observable<AudioEngine>;
  37194. /**
  37195. * Event raised when audio has been locked on the browser.
  37196. */
  37197. onAudioLockedObservable: Observable<AudioEngine>;
  37198. /**
  37199. * Gets the current AudioContext if available.
  37200. */
  37201. get audioContext(): Nullable<AudioContext>;
  37202. private _connectedAnalyser;
  37203. /**
  37204. * Instantiates a new audio engine.
  37205. *
  37206. * There should be only one per page as some browsers restrict the number
  37207. * of audio contexts you can create.
  37208. * @param hostElement defines the host element where to display the mute icon if necessary
  37209. */
  37210. constructor(hostElement?: Nullable<HTMLElement>);
  37211. /**
  37212. * Flags the audio engine in Locked state.
  37213. * This happens due to new browser policies preventing audio to autoplay.
  37214. */
  37215. lock(): void;
  37216. /**
  37217. * Unlocks the audio engine once a user action has been done on the dom.
  37218. * This is helpful to resume play once browser policies have been satisfied.
  37219. */
  37220. unlock(): void;
  37221. private _resumeAudioContext;
  37222. private _initializeAudioContext;
  37223. private _tryToRun;
  37224. private _triggerRunningState;
  37225. private _triggerSuspendedState;
  37226. private _displayMuteButton;
  37227. private _moveButtonToTopLeft;
  37228. private _onResize;
  37229. private _hideMuteButton;
  37230. /**
  37231. * Destroy and release the resources associated with the audio ccontext.
  37232. */
  37233. dispose(): void;
  37234. /**
  37235. * Gets the global volume sets on the master gain.
  37236. * @returns the global volume if set or -1 otherwise
  37237. */
  37238. getGlobalVolume(): number;
  37239. /**
  37240. * Sets the global volume of your experience (sets on the master gain).
  37241. * @param newVolume Defines the new global volume of the application
  37242. */
  37243. setGlobalVolume(newVolume: number): void;
  37244. /**
  37245. * Connect the audio engine to an audio analyser allowing some amazing
  37246. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37248. * @param analyser The analyser to connect to the engine
  37249. */
  37250. connectToAnalyser(analyser: Analyser): void;
  37251. }
  37252. }
  37253. declare module "babylonjs/Loading/loadingScreen" {
  37254. /**
  37255. * Interface used to present a loading screen while loading a scene
  37256. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37257. */
  37258. export interface ILoadingScreen {
  37259. /**
  37260. * Function called to display the loading screen
  37261. */
  37262. displayLoadingUI: () => void;
  37263. /**
  37264. * Function called to hide the loading screen
  37265. */
  37266. hideLoadingUI: () => void;
  37267. /**
  37268. * Gets or sets the color to use for the background
  37269. */
  37270. loadingUIBackgroundColor: string;
  37271. /**
  37272. * Gets or sets the text to display while loading
  37273. */
  37274. loadingUIText: string;
  37275. }
  37276. /**
  37277. * Class used for the default loading screen
  37278. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37279. */
  37280. export class DefaultLoadingScreen implements ILoadingScreen {
  37281. private _renderingCanvas;
  37282. private _loadingText;
  37283. private _loadingDivBackgroundColor;
  37284. private _loadingDiv;
  37285. private _loadingTextDiv;
  37286. /** Gets or sets the logo url to use for the default loading screen */
  37287. static DefaultLogoUrl: string;
  37288. /** Gets or sets the spinner url to use for the default loading screen */
  37289. static DefaultSpinnerUrl: string;
  37290. /**
  37291. * Creates a new default loading screen
  37292. * @param _renderingCanvas defines the canvas used to render the scene
  37293. * @param _loadingText defines the default text to display
  37294. * @param _loadingDivBackgroundColor defines the default background color
  37295. */
  37296. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37297. /**
  37298. * Function called to display the loading screen
  37299. */
  37300. displayLoadingUI(): void;
  37301. /**
  37302. * Function called to hide the loading screen
  37303. */
  37304. hideLoadingUI(): void;
  37305. /**
  37306. * Gets or sets the text to display while loading
  37307. */
  37308. set loadingUIText(text: string);
  37309. get loadingUIText(): string;
  37310. /**
  37311. * Gets or sets the color to use for the background
  37312. */
  37313. get loadingUIBackgroundColor(): string;
  37314. set loadingUIBackgroundColor(color: string);
  37315. private _resizeLoadingUI;
  37316. }
  37317. }
  37318. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37319. /**
  37320. * Interface for any object that can request an animation frame
  37321. */
  37322. export interface ICustomAnimationFrameRequester {
  37323. /**
  37324. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37325. */
  37326. renderFunction?: Function;
  37327. /**
  37328. * Called to request the next frame to render to
  37329. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37330. */
  37331. requestAnimationFrame: Function;
  37332. /**
  37333. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37334. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37335. */
  37336. requestID?: number;
  37337. }
  37338. }
  37339. declare module "babylonjs/Misc/performanceMonitor" {
  37340. /**
  37341. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37342. */
  37343. export class PerformanceMonitor {
  37344. private _enabled;
  37345. private _rollingFrameTime;
  37346. private _lastFrameTimeMs;
  37347. /**
  37348. * constructor
  37349. * @param frameSampleSize The number of samples required to saturate the sliding window
  37350. */
  37351. constructor(frameSampleSize?: number);
  37352. /**
  37353. * Samples current frame
  37354. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37355. */
  37356. sampleFrame(timeMs?: number): void;
  37357. /**
  37358. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37359. */
  37360. get averageFrameTime(): number;
  37361. /**
  37362. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37363. */
  37364. get averageFrameTimeVariance(): number;
  37365. /**
  37366. * Returns the frame time of the most recent frame
  37367. */
  37368. get instantaneousFrameTime(): number;
  37369. /**
  37370. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37371. */
  37372. get averageFPS(): number;
  37373. /**
  37374. * Returns the average framerate in frames per second using the most recent frame time
  37375. */
  37376. get instantaneousFPS(): number;
  37377. /**
  37378. * Returns true if enough samples have been taken to completely fill the sliding window
  37379. */
  37380. get isSaturated(): boolean;
  37381. /**
  37382. * Enables contributions to the sliding window sample set
  37383. */
  37384. enable(): void;
  37385. /**
  37386. * Disables contributions to the sliding window sample set
  37387. * Samples will not be interpolated over the disabled period
  37388. */
  37389. disable(): void;
  37390. /**
  37391. * Returns true if sampling is enabled
  37392. */
  37393. get isEnabled(): boolean;
  37394. /**
  37395. * Resets performance monitor
  37396. */
  37397. reset(): void;
  37398. }
  37399. /**
  37400. * RollingAverage
  37401. *
  37402. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37403. */
  37404. export class RollingAverage {
  37405. /**
  37406. * Current average
  37407. */
  37408. average: number;
  37409. /**
  37410. * Current variance
  37411. */
  37412. variance: number;
  37413. protected _samples: Array<number>;
  37414. protected _sampleCount: number;
  37415. protected _pos: number;
  37416. protected _m2: number;
  37417. /**
  37418. * constructor
  37419. * @param length The number of samples required to saturate the sliding window
  37420. */
  37421. constructor(length: number);
  37422. /**
  37423. * Adds a sample to the sample set
  37424. * @param v The sample value
  37425. */
  37426. add(v: number): void;
  37427. /**
  37428. * Returns previously added values or null if outside of history or outside the sliding window domain
  37429. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37430. * @return Value previously recorded with add() or null if outside of range
  37431. */
  37432. history(i: number): number;
  37433. /**
  37434. * Returns true if enough samples have been taken to completely fill the sliding window
  37435. * @return true if sample-set saturated
  37436. */
  37437. isSaturated(): boolean;
  37438. /**
  37439. * Resets the rolling average (equivalent to 0 samples taken so far)
  37440. */
  37441. reset(): void;
  37442. /**
  37443. * Wraps a value around the sample range boundaries
  37444. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37445. * @return Wrapped position in sample range
  37446. */
  37447. protected _wrapPosition(i: number): number;
  37448. }
  37449. }
  37450. declare module "babylonjs/Misc/perfCounter" {
  37451. /**
  37452. * This class is used to track a performance counter which is number based.
  37453. * The user has access to many properties which give statistics of different nature.
  37454. *
  37455. * The implementer can track two kinds of Performance Counter: time and count.
  37456. * 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.
  37457. * 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.
  37458. */
  37459. export class PerfCounter {
  37460. /**
  37461. * Gets or sets a global boolean to turn on and off all the counters
  37462. */
  37463. static Enabled: boolean;
  37464. /**
  37465. * Returns the smallest value ever
  37466. */
  37467. get min(): number;
  37468. /**
  37469. * Returns the biggest value ever
  37470. */
  37471. get max(): number;
  37472. /**
  37473. * Returns the average value since the performance counter is running
  37474. */
  37475. get average(): number;
  37476. /**
  37477. * Returns the average value of the last second the counter was monitored
  37478. */
  37479. get lastSecAverage(): number;
  37480. /**
  37481. * Returns the current value
  37482. */
  37483. get current(): number;
  37484. /**
  37485. * Gets the accumulated total
  37486. */
  37487. get total(): number;
  37488. /**
  37489. * Gets the total value count
  37490. */
  37491. get count(): number;
  37492. /**
  37493. * Creates a new counter
  37494. */
  37495. constructor();
  37496. /**
  37497. * Call this method to start monitoring a new frame.
  37498. * 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.
  37499. */
  37500. fetchNewFrame(): void;
  37501. /**
  37502. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37503. * @param newCount the count value to add to the monitored count
  37504. * @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.
  37505. */
  37506. addCount(newCount: number, fetchResult: boolean): void;
  37507. /**
  37508. * Start monitoring this performance counter
  37509. */
  37510. beginMonitoring(): void;
  37511. /**
  37512. * Compute the time lapsed since the previous beginMonitoring() call.
  37513. * @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
  37514. */
  37515. endMonitoring(newFrame?: boolean): void;
  37516. private _fetchResult;
  37517. private _startMonitoringTime;
  37518. private _min;
  37519. private _max;
  37520. private _average;
  37521. private _current;
  37522. private _totalValueCount;
  37523. private _totalAccumulated;
  37524. private _lastSecAverage;
  37525. private _lastSecAccumulated;
  37526. private _lastSecTime;
  37527. private _lastSecValueCount;
  37528. }
  37529. }
  37530. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37531. module "babylonjs/Engines/thinEngine" {
  37532. interface ThinEngine {
  37533. /**
  37534. * Sets alpha constants used by some alpha blending modes
  37535. * @param r defines the red component
  37536. * @param g defines the green component
  37537. * @param b defines the blue component
  37538. * @param a defines the alpha component
  37539. */
  37540. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37541. /**
  37542. * Sets the current alpha mode
  37543. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37544. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37545. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37546. */
  37547. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37548. /**
  37549. * Gets the current alpha mode
  37550. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37551. * @returns the current alpha mode
  37552. */
  37553. getAlphaMode(): number;
  37554. /**
  37555. * Sets the current alpha equation
  37556. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37557. */
  37558. setAlphaEquation(equation: number): void;
  37559. /**
  37560. * Gets the current alpha equation.
  37561. * @returns the current alpha equation
  37562. */
  37563. getAlphaEquation(): number;
  37564. }
  37565. }
  37566. }
  37567. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37568. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37569. import { Nullable } from "babylonjs/types";
  37570. module "babylonjs/Engines/thinEngine" {
  37571. interface ThinEngine {
  37572. /** @hidden */
  37573. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37574. }
  37575. }
  37576. }
  37577. declare module "babylonjs/Engines/engine" {
  37578. import { Observable } from "babylonjs/Misc/observable";
  37579. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37580. import { Scene } from "babylonjs/scene";
  37581. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37582. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37583. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37584. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37585. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37586. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37587. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37588. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37589. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37590. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37591. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37592. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37593. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37594. import "babylonjs/Engines/Extensions/engine.alpha";
  37595. import "babylonjs/Engines/Extensions/engine.readTexture";
  37596. import { Material } from "babylonjs/Materials/material";
  37597. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37598. /**
  37599. * Defines the interface used by display changed events
  37600. */
  37601. export interface IDisplayChangedEventArgs {
  37602. /** Gets the vrDisplay object (if any) */
  37603. vrDisplay: Nullable<any>;
  37604. /** Gets a boolean indicating if webVR is supported */
  37605. vrSupported: boolean;
  37606. }
  37607. /**
  37608. * Defines the interface used by objects containing a viewport (like a camera)
  37609. */
  37610. interface IViewportOwnerLike {
  37611. /**
  37612. * Gets or sets the viewport
  37613. */
  37614. viewport: IViewportLike;
  37615. }
  37616. /**
  37617. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37618. */
  37619. export class Engine extends ThinEngine {
  37620. /** Defines that alpha blending is disabled */
  37621. static readonly ALPHA_DISABLE: number;
  37622. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37623. static readonly ALPHA_ADD: number;
  37624. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37625. static readonly ALPHA_COMBINE: number;
  37626. /** Defines that alpha blending to DEST - SRC * DEST */
  37627. static readonly ALPHA_SUBTRACT: number;
  37628. /** Defines that alpha blending to SRC * DEST */
  37629. static readonly ALPHA_MULTIPLY: number;
  37630. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37631. static readonly ALPHA_MAXIMIZED: number;
  37632. /** Defines that alpha blending to SRC + DEST */
  37633. static readonly ALPHA_ONEONE: number;
  37634. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37635. static readonly ALPHA_PREMULTIPLIED: number;
  37636. /**
  37637. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37638. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37639. */
  37640. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37641. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37642. static readonly ALPHA_INTERPOLATE: number;
  37643. /**
  37644. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37645. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37646. */
  37647. static readonly ALPHA_SCREENMODE: number;
  37648. /** Defines that the ressource is not delayed*/
  37649. static readonly DELAYLOADSTATE_NONE: number;
  37650. /** Defines that the ressource was successfully delay loaded */
  37651. static readonly DELAYLOADSTATE_LOADED: number;
  37652. /** Defines that the ressource is currently delay loading */
  37653. static readonly DELAYLOADSTATE_LOADING: number;
  37654. /** Defines that the ressource is delayed and has not started loading */
  37655. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37656. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37657. static readonly NEVER: number;
  37658. /** 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 */
  37659. static readonly ALWAYS: number;
  37660. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37661. static readonly LESS: number;
  37662. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37663. static readonly EQUAL: number;
  37664. /** 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 */
  37665. static readonly LEQUAL: number;
  37666. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37667. static readonly GREATER: number;
  37668. /** 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 */
  37669. static readonly GEQUAL: number;
  37670. /** 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 */
  37671. static readonly NOTEQUAL: number;
  37672. /** Passed to stencilOperation to specify that stencil value must be kept */
  37673. static readonly KEEP: number;
  37674. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37675. static readonly REPLACE: number;
  37676. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37677. static readonly INCR: number;
  37678. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37679. static readonly DECR: number;
  37680. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37681. static readonly INVERT: number;
  37682. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37683. static readonly INCR_WRAP: number;
  37684. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37685. static readonly DECR_WRAP: number;
  37686. /** Texture is not repeating outside of 0..1 UVs */
  37687. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37688. /** Texture is repeating outside of 0..1 UVs */
  37689. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37690. /** Texture is repeating and mirrored */
  37691. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37692. /** ALPHA */
  37693. static readonly TEXTUREFORMAT_ALPHA: number;
  37694. /** LUMINANCE */
  37695. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37696. /** LUMINANCE_ALPHA */
  37697. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37698. /** RGB */
  37699. static readonly TEXTUREFORMAT_RGB: number;
  37700. /** RGBA */
  37701. static readonly TEXTUREFORMAT_RGBA: number;
  37702. /** RED */
  37703. static readonly TEXTUREFORMAT_RED: number;
  37704. /** RED (2nd reference) */
  37705. static readonly TEXTUREFORMAT_R: number;
  37706. /** RG */
  37707. static readonly TEXTUREFORMAT_RG: number;
  37708. /** RED_INTEGER */
  37709. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37710. /** RED_INTEGER (2nd reference) */
  37711. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37712. /** RG_INTEGER */
  37713. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37714. /** RGB_INTEGER */
  37715. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37716. /** RGBA_INTEGER */
  37717. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37718. /** UNSIGNED_BYTE */
  37719. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37720. /** UNSIGNED_BYTE (2nd reference) */
  37721. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37722. /** FLOAT */
  37723. static readonly TEXTURETYPE_FLOAT: number;
  37724. /** HALF_FLOAT */
  37725. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37726. /** BYTE */
  37727. static readonly TEXTURETYPE_BYTE: number;
  37728. /** SHORT */
  37729. static readonly TEXTURETYPE_SHORT: number;
  37730. /** UNSIGNED_SHORT */
  37731. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37732. /** INT */
  37733. static readonly TEXTURETYPE_INT: number;
  37734. /** UNSIGNED_INT */
  37735. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37736. /** UNSIGNED_SHORT_4_4_4_4 */
  37737. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37738. /** UNSIGNED_SHORT_5_5_5_1 */
  37739. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37740. /** UNSIGNED_SHORT_5_6_5 */
  37741. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37742. /** UNSIGNED_INT_2_10_10_10_REV */
  37743. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37744. /** UNSIGNED_INT_24_8 */
  37745. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37746. /** UNSIGNED_INT_10F_11F_11F_REV */
  37747. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37748. /** UNSIGNED_INT_5_9_9_9_REV */
  37749. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37750. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37751. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37752. /** nearest is mag = nearest and min = nearest and mip = linear */
  37753. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37754. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37755. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37756. /** Trilinear is mag = linear and min = linear and mip = linear */
  37757. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37758. /** nearest is mag = nearest and min = nearest and mip = linear */
  37759. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37760. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37761. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37762. /** Trilinear is mag = linear and min = linear and mip = linear */
  37763. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37764. /** mag = nearest and min = nearest and mip = nearest */
  37765. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37766. /** mag = nearest and min = linear and mip = nearest */
  37767. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37768. /** mag = nearest and min = linear and mip = linear */
  37769. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37770. /** mag = nearest and min = linear and mip = none */
  37771. static readonly TEXTURE_NEAREST_LINEAR: number;
  37772. /** mag = nearest and min = nearest and mip = none */
  37773. static readonly TEXTURE_NEAREST_NEAREST: number;
  37774. /** mag = linear and min = nearest and mip = nearest */
  37775. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37776. /** mag = linear and min = nearest and mip = linear */
  37777. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37778. /** mag = linear and min = linear and mip = none */
  37779. static readonly TEXTURE_LINEAR_LINEAR: number;
  37780. /** mag = linear and min = nearest and mip = none */
  37781. static readonly TEXTURE_LINEAR_NEAREST: number;
  37782. /** Explicit coordinates mode */
  37783. static readonly TEXTURE_EXPLICIT_MODE: number;
  37784. /** Spherical coordinates mode */
  37785. static readonly TEXTURE_SPHERICAL_MODE: number;
  37786. /** Planar coordinates mode */
  37787. static readonly TEXTURE_PLANAR_MODE: number;
  37788. /** Cubic coordinates mode */
  37789. static readonly TEXTURE_CUBIC_MODE: number;
  37790. /** Projection coordinates mode */
  37791. static readonly TEXTURE_PROJECTION_MODE: number;
  37792. /** Skybox coordinates mode */
  37793. static readonly TEXTURE_SKYBOX_MODE: number;
  37794. /** Inverse Cubic coordinates mode */
  37795. static readonly TEXTURE_INVCUBIC_MODE: number;
  37796. /** Equirectangular coordinates mode */
  37797. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37798. /** Equirectangular Fixed coordinates mode */
  37799. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37800. /** Equirectangular Fixed Mirrored coordinates mode */
  37801. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37802. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37803. static readonly SCALEMODE_FLOOR: number;
  37804. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37805. static readonly SCALEMODE_NEAREST: number;
  37806. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37807. static readonly SCALEMODE_CEILING: number;
  37808. /**
  37809. * Returns the current npm package of the sdk
  37810. */
  37811. static get NpmPackage(): string;
  37812. /**
  37813. * Returns the current version of the framework
  37814. */
  37815. static get Version(): string;
  37816. /** Gets the list of created engines */
  37817. static get Instances(): Engine[];
  37818. /**
  37819. * Gets the latest created engine
  37820. */
  37821. static get LastCreatedEngine(): Nullable<Engine>;
  37822. /**
  37823. * Gets the latest created scene
  37824. */
  37825. static get LastCreatedScene(): Nullable<Scene>;
  37826. /**
  37827. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37828. * @param flag defines which part of the materials must be marked as dirty
  37829. * @param predicate defines a predicate used to filter which materials should be affected
  37830. */
  37831. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37832. /**
  37833. * Method called to create the default loading screen.
  37834. * This can be overriden in your own app.
  37835. * @param canvas The rendering canvas element
  37836. * @returns The loading screen
  37837. */
  37838. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37839. /**
  37840. * Method called to create the default rescale post process on each engine.
  37841. */
  37842. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37843. /**
  37844. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37845. **/
  37846. enableOfflineSupport: boolean;
  37847. /**
  37848. * 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)
  37849. **/
  37850. disableManifestCheck: boolean;
  37851. /**
  37852. * Gets the list of created scenes
  37853. */
  37854. scenes: Scene[];
  37855. /**
  37856. * Event raised when a new scene is created
  37857. */
  37858. onNewSceneAddedObservable: Observable<Scene>;
  37859. /**
  37860. * Gets the list of created postprocesses
  37861. */
  37862. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37863. /**
  37864. * Gets a boolean indicating if the pointer is currently locked
  37865. */
  37866. isPointerLock: boolean;
  37867. /**
  37868. * Observable event triggered each time the rendering canvas is resized
  37869. */
  37870. onResizeObservable: Observable<Engine>;
  37871. /**
  37872. * Observable event triggered each time the canvas loses focus
  37873. */
  37874. onCanvasBlurObservable: Observable<Engine>;
  37875. /**
  37876. * Observable event triggered each time the canvas gains focus
  37877. */
  37878. onCanvasFocusObservable: Observable<Engine>;
  37879. /**
  37880. * Observable event triggered each time the canvas receives pointerout event
  37881. */
  37882. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37883. /**
  37884. * Observable raised when the engine begins a new frame
  37885. */
  37886. onBeginFrameObservable: Observable<Engine>;
  37887. /**
  37888. * If set, will be used to request the next animation frame for the render loop
  37889. */
  37890. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37891. /**
  37892. * Observable raised when the engine ends the current frame
  37893. */
  37894. onEndFrameObservable: Observable<Engine>;
  37895. /**
  37896. * Observable raised when the engine is about to compile a shader
  37897. */
  37898. onBeforeShaderCompilationObservable: Observable<Engine>;
  37899. /**
  37900. * Observable raised when the engine has jsut compiled a shader
  37901. */
  37902. onAfterShaderCompilationObservable: Observable<Engine>;
  37903. /**
  37904. * Gets the audio engine
  37905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37906. * @ignorenaming
  37907. */
  37908. static audioEngine: IAudioEngine;
  37909. /**
  37910. * Default AudioEngine factory responsible of creating the Audio Engine.
  37911. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37912. */
  37913. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37914. /**
  37915. * Default offline support factory responsible of creating a tool used to store data locally.
  37916. * By default, this will create a Database object if the workload has been embedded.
  37917. */
  37918. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37919. private _loadingScreen;
  37920. private _pointerLockRequested;
  37921. private _rescalePostProcess;
  37922. private _deterministicLockstep;
  37923. private _lockstepMaxSteps;
  37924. private _timeStep;
  37925. protected get _supportsHardwareTextureRescaling(): boolean;
  37926. private _fps;
  37927. private _deltaTime;
  37928. /** @hidden */
  37929. _drawCalls: PerfCounter;
  37930. /** 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 */
  37931. canvasTabIndex: number;
  37932. /**
  37933. * Turn this value on if you want to pause FPS computation when in background
  37934. */
  37935. disablePerformanceMonitorInBackground: boolean;
  37936. private _performanceMonitor;
  37937. /**
  37938. * Gets the performance monitor attached to this engine
  37939. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37940. */
  37941. get performanceMonitor(): PerformanceMonitor;
  37942. private _onFocus;
  37943. private _onBlur;
  37944. private _onCanvasPointerOut;
  37945. private _onCanvasBlur;
  37946. private _onCanvasFocus;
  37947. private _onFullscreenChange;
  37948. private _onPointerLockChange;
  37949. /**
  37950. * Gets the HTML element used to attach event listeners
  37951. * @returns a HTML element
  37952. */
  37953. getInputElement(): Nullable<HTMLElement>;
  37954. /**
  37955. * Creates a new engine
  37956. * @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
  37957. * @param antialias defines enable antialiasing (default: false)
  37958. * @param options defines further options to be sent to the getContext() function
  37959. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37960. */
  37961. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37962. /**
  37963. * Gets current aspect ratio
  37964. * @param viewportOwner defines the camera to use to get the aspect ratio
  37965. * @param useScreen defines if screen size must be used (or the current render target if any)
  37966. * @returns a number defining the aspect ratio
  37967. */
  37968. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37969. /**
  37970. * Gets current screen aspect ratio
  37971. * @returns a number defining the aspect ratio
  37972. */
  37973. getScreenAspectRatio(): number;
  37974. /**
  37975. * Gets the client rect of the HTML canvas attached with the current webGL context
  37976. * @returns a client rectanglee
  37977. */
  37978. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37979. /**
  37980. * Gets the client rect of the HTML element used for events
  37981. * @returns a client rectanglee
  37982. */
  37983. getInputElementClientRect(): Nullable<ClientRect>;
  37984. /**
  37985. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37986. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37987. * @returns true if engine is in deterministic lock step mode
  37988. */
  37989. isDeterministicLockStep(): boolean;
  37990. /**
  37991. * Gets the max steps when engine is running in deterministic lock step
  37992. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37993. * @returns the max steps
  37994. */
  37995. getLockstepMaxSteps(): number;
  37996. /**
  37997. * Returns the time in ms between steps when using deterministic lock step.
  37998. * @returns time step in (ms)
  37999. */
  38000. getTimeStep(): number;
  38001. /**
  38002. * Force the mipmap generation for the given render target texture
  38003. * @param texture defines the render target texture to use
  38004. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38005. */
  38006. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38007. /** States */
  38008. /**
  38009. * Set various states to the webGL context
  38010. * @param culling defines backface culling state
  38011. * @param zOffset defines the value to apply to zOffset (0 by default)
  38012. * @param force defines if states must be applied even if cache is up to date
  38013. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38014. */
  38015. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38016. /**
  38017. * Set the z offset to apply to current rendering
  38018. * @param value defines the offset to apply
  38019. */
  38020. setZOffset(value: number): void;
  38021. /**
  38022. * Gets the current value of the zOffset
  38023. * @returns the current zOffset state
  38024. */
  38025. getZOffset(): number;
  38026. /**
  38027. * Enable or disable depth buffering
  38028. * @param enable defines the state to set
  38029. */
  38030. setDepthBuffer(enable: boolean): void;
  38031. /**
  38032. * Gets a boolean indicating if depth writing is enabled
  38033. * @returns the current depth writing state
  38034. */
  38035. getDepthWrite(): boolean;
  38036. /**
  38037. * Enable or disable depth writing
  38038. * @param enable defines the state to set
  38039. */
  38040. setDepthWrite(enable: boolean): void;
  38041. /**
  38042. * Gets a boolean indicating if stencil buffer is enabled
  38043. * @returns the current stencil buffer state
  38044. */
  38045. getStencilBuffer(): boolean;
  38046. /**
  38047. * Enable or disable the stencil buffer
  38048. * @param enable defines if the stencil buffer must be enabled or disabled
  38049. */
  38050. setStencilBuffer(enable: boolean): void;
  38051. /**
  38052. * Gets the current stencil mask
  38053. * @returns a number defining the new stencil mask to use
  38054. */
  38055. getStencilMask(): number;
  38056. /**
  38057. * Sets the current stencil mask
  38058. * @param mask defines the new stencil mask to use
  38059. */
  38060. setStencilMask(mask: number): void;
  38061. /**
  38062. * Gets the current stencil function
  38063. * @returns a number defining the stencil function to use
  38064. */
  38065. getStencilFunction(): number;
  38066. /**
  38067. * Gets the current stencil reference value
  38068. * @returns a number defining the stencil reference value to use
  38069. */
  38070. getStencilFunctionReference(): number;
  38071. /**
  38072. * Gets the current stencil mask
  38073. * @returns a number defining the stencil mask to use
  38074. */
  38075. getStencilFunctionMask(): number;
  38076. /**
  38077. * Sets the current stencil function
  38078. * @param stencilFunc defines the new stencil function to use
  38079. */
  38080. setStencilFunction(stencilFunc: number): void;
  38081. /**
  38082. * Sets the current stencil reference
  38083. * @param reference defines the new stencil reference to use
  38084. */
  38085. setStencilFunctionReference(reference: number): void;
  38086. /**
  38087. * Sets the current stencil mask
  38088. * @param mask defines the new stencil mask to use
  38089. */
  38090. setStencilFunctionMask(mask: number): void;
  38091. /**
  38092. * Gets the current stencil operation when stencil fails
  38093. * @returns a number defining stencil operation to use when stencil fails
  38094. */
  38095. getStencilOperationFail(): number;
  38096. /**
  38097. * Gets the current stencil operation when depth fails
  38098. * @returns a number defining stencil operation to use when depth fails
  38099. */
  38100. getStencilOperationDepthFail(): number;
  38101. /**
  38102. * Gets the current stencil operation when stencil passes
  38103. * @returns a number defining stencil operation to use when stencil passes
  38104. */
  38105. getStencilOperationPass(): number;
  38106. /**
  38107. * Sets the stencil operation to use when stencil fails
  38108. * @param operation defines the stencil operation to use when stencil fails
  38109. */
  38110. setStencilOperationFail(operation: number): void;
  38111. /**
  38112. * Sets the stencil operation to use when depth fails
  38113. * @param operation defines the stencil operation to use when depth fails
  38114. */
  38115. setStencilOperationDepthFail(operation: number): void;
  38116. /**
  38117. * Sets the stencil operation to use when stencil passes
  38118. * @param operation defines the stencil operation to use when stencil passes
  38119. */
  38120. setStencilOperationPass(operation: number): void;
  38121. /**
  38122. * Sets a boolean indicating if the dithering state is enabled or disabled
  38123. * @param value defines the dithering state
  38124. */
  38125. setDitheringState(value: boolean): void;
  38126. /**
  38127. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38128. * @param value defines the rasterizer state
  38129. */
  38130. setRasterizerState(value: boolean): void;
  38131. /**
  38132. * Gets the current depth function
  38133. * @returns a number defining the depth function
  38134. */
  38135. getDepthFunction(): Nullable<number>;
  38136. /**
  38137. * Sets the current depth function
  38138. * @param depthFunc defines the function to use
  38139. */
  38140. setDepthFunction(depthFunc: number): void;
  38141. /**
  38142. * Sets the current depth function to GREATER
  38143. */
  38144. setDepthFunctionToGreater(): void;
  38145. /**
  38146. * Sets the current depth function to GEQUAL
  38147. */
  38148. setDepthFunctionToGreaterOrEqual(): void;
  38149. /**
  38150. * Sets the current depth function to LESS
  38151. */
  38152. setDepthFunctionToLess(): void;
  38153. /**
  38154. * Sets the current depth function to LEQUAL
  38155. */
  38156. setDepthFunctionToLessOrEqual(): void;
  38157. private _cachedStencilBuffer;
  38158. private _cachedStencilFunction;
  38159. private _cachedStencilMask;
  38160. private _cachedStencilOperationPass;
  38161. private _cachedStencilOperationFail;
  38162. private _cachedStencilOperationDepthFail;
  38163. private _cachedStencilReference;
  38164. /**
  38165. * Caches the the state of the stencil buffer
  38166. */
  38167. cacheStencilState(): void;
  38168. /**
  38169. * Restores the state of the stencil buffer
  38170. */
  38171. restoreStencilState(): void;
  38172. /**
  38173. * Directly set the WebGL Viewport
  38174. * @param x defines the x coordinate of the viewport (in screen space)
  38175. * @param y defines the y coordinate of the viewport (in screen space)
  38176. * @param width defines the width of the viewport (in screen space)
  38177. * @param height defines the height of the viewport (in screen space)
  38178. * @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
  38179. */
  38180. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38181. /**
  38182. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38183. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38184. * @param y defines the y-coordinate of the corner of the clear rectangle
  38185. * @param width defines the width of the clear rectangle
  38186. * @param height defines the height of the clear rectangle
  38187. * @param clearColor defines the clear color
  38188. */
  38189. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38190. /**
  38191. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38192. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38193. * @param y defines the y-coordinate of the corner of the clear rectangle
  38194. * @param width defines the width of the clear rectangle
  38195. * @param height defines the height of the clear rectangle
  38196. */
  38197. enableScissor(x: number, y: number, width: number, height: number): void;
  38198. /**
  38199. * Disable previously set scissor test rectangle
  38200. */
  38201. disableScissor(): void;
  38202. protected _reportDrawCall(): void;
  38203. /**
  38204. * Initializes a webVR display and starts listening to display change events
  38205. * The onVRDisplayChangedObservable will be notified upon these changes
  38206. * @returns The onVRDisplayChangedObservable
  38207. */
  38208. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38209. /** @hidden */
  38210. _prepareVRComponent(): void;
  38211. /** @hidden */
  38212. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38213. /** @hidden */
  38214. _submitVRFrame(): void;
  38215. /**
  38216. * Call this function to leave webVR mode
  38217. * Will do nothing if webVR is not supported or if there is no webVR device
  38218. * @see http://doc.babylonjs.com/how_to/webvr_camera
  38219. */
  38220. disableVR(): void;
  38221. /**
  38222. * Gets a boolean indicating that the system is in VR mode and is presenting
  38223. * @returns true if VR mode is engaged
  38224. */
  38225. isVRPresenting(): boolean;
  38226. /** @hidden */
  38227. _requestVRFrame(): void;
  38228. /** @hidden */
  38229. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38230. /**
  38231. * Gets the source code of the vertex shader associated with a specific webGL program
  38232. * @param program defines the program to use
  38233. * @returns a string containing the source code of the vertex shader associated with the program
  38234. */
  38235. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38236. /**
  38237. * Gets the source code of the fragment shader associated with a specific webGL program
  38238. * @param program defines the program to use
  38239. * @returns a string containing the source code of the fragment shader associated with the program
  38240. */
  38241. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38242. /**
  38243. * Sets a depth stencil texture from a render target to the according uniform.
  38244. * @param channel The texture channel
  38245. * @param uniform The uniform to set
  38246. * @param texture The render target texture containing the depth stencil texture to apply
  38247. */
  38248. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38249. /**
  38250. * Sets a texture to the webGL context from a postprocess
  38251. * @param channel defines the channel to use
  38252. * @param postProcess defines the source postprocess
  38253. */
  38254. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38255. /**
  38256. * Binds the output of the passed in post process to the texture channel specified
  38257. * @param channel The channel the texture should be bound to
  38258. * @param postProcess The post process which's output should be bound
  38259. */
  38260. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38261. protected _rebuildBuffers(): void;
  38262. /** @hidden */
  38263. _renderFrame(): void;
  38264. _renderLoop(): void;
  38265. /** @hidden */
  38266. _renderViews(): boolean;
  38267. /**
  38268. * Toggle full screen mode
  38269. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38270. */
  38271. switchFullscreen(requestPointerLock: boolean): void;
  38272. /**
  38273. * Enters full screen mode
  38274. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38275. */
  38276. enterFullscreen(requestPointerLock: boolean): void;
  38277. /**
  38278. * Exits full screen mode
  38279. */
  38280. exitFullscreen(): void;
  38281. /**
  38282. * Enters Pointerlock mode
  38283. */
  38284. enterPointerlock(): void;
  38285. /**
  38286. * Exits Pointerlock mode
  38287. */
  38288. exitPointerlock(): void;
  38289. /**
  38290. * Begin a new frame
  38291. */
  38292. beginFrame(): void;
  38293. /**
  38294. * Enf the current frame
  38295. */
  38296. endFrame(): void;
  38297. resize(): void;
  38298. /**
  38299. * Force a specific size of the canvas
  38300. * @param width defines the new canvas' width
  38301. * @param height defines the new canvas' height
  38302. */
  38303. setSize(width: number, height: number): void;
  38304. /**
  38305. * Updates a dynamic vertex buffer.
  38306. * @param vertexBuffer the vertex buffer to update
  38307. * @param data the data used to update the vertex buffer
  38308. * @param byteOffset the byte offset of the data
  38309. * @param byteLength the byte length of the data
  38310. */
  38311. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38312. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38313. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38314. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38315. _releaseTexture(texture: InternalTexture): void;
  38316. /**
  38317. * @hidden
  38318. * Rescales a texture
  38319. * @param source input texutre
  38320. * @param destination destination texture
  38321. * @param scene scene to use to render the resize
  38322. * @param internalFormat format to use when resizing
  38323. * @param onComplete callback to be called when resize has completed
  38324. */
  38325. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38326. /**
  38327. * Gets the current framerate
  38328. * @returns a number representing the framerate
  38329. */
  38330. getFps(): number;
  38331. /**
  38332. * Gets the time spent between current and previous frame
  38333. * @returns a number representing the delta time in ms
  38334. */
  38335. getDeltaTime(): number;
  38336. private _measureFps;
  38337. /** @hidden */
  38338. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38339. /**
  38340. * Update a dynamic index buffer
  38341. * @param indexBuffer defines the target index buffer
  38342. * @param indices defines the data to update
  38343. * @param offset defines the offset in the target index buffer where update should start
  38344. */
  38345. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38346. /**
  38347. * Updates the sample count of a render target texture
  38348. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38349. * @param texture defines the texture to update
  38350. * @param samples defines the sample count to set
  38351. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38352. */
  38353. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38354. /**
  38355. * Updates a depth texture Comparison Mode and Function.
  38356. * If the comparison Function is equal to 0, the mode will be set to none.
  38357. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38358. * @param texture The texture to set the comparison function for
  38359. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38360. */
  38361. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38362. /**
  38363. * Creates a webGL buffer to use with instanciation
  38364. * @param capacity defines the size of the buffer
  38365. * @returns the webGL buffer
  38366. */
  38367. createInstancesBuffer(capacity: number): DataBuffer;
  38368. /**
  38369. * Delete a webGL buffer used with instanciation
  38370. * @param buffer defines the webGL buffer to delete
  38371. */
  38372. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38373. private _clientWaitAsync;
  38374. /** @hidden */
  38375. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38376. dispose(): void;
  38377. private _disableTouchAction;
  38378. /**
  38379. * Display the loading screen
  38380. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38381. */
  38382. displayLoadingUI(): void;
  38383. /**
  38384. * Hide the loading screen
  38385. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38386. */
  38387. hideLoadingUI(): void;
  38388. /**
  38389. * Gets the current loading screen object
  38390. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38391. */
  38392. get loadingScreen(): ILoadingScreen;
  38393. /**
  38394. * Sets the current loading screen object
  38395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38396. */
  38397. set loadingScreen(loadingScreen: ILoadingScreen);
  38398. /**
  38399. * Sets the current loading screen text
  38400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38401. */
  38402. set loadingUIText(text: string);
  38403. /**
  38404. * Sets the current loading screen background color
  38405. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38406. */
  38407. set loadingUIBackgroundColor(color: string);
  38408. /** Pointerlock and fullscreen */
  38409. /**
  38410. * Ask the browser to promote the current element to pointerlock mode
  38411. * @param element defines the DOM element to promote
  38412. */
  38413. static _RequestPointerlock(element: HTMLElement): void;
  38414. /**
  38415. * Asks the browser to exit pointerlock mode
  38416. */
  38417. static _ExitPointerlock(): void;
  38418. /**
  38419. * Ask the browser to promote the current element to fullscreen rendering mode
  38420. * @param element defines the DOM element to promote
  38421. */
  38422. static _RequestFullscreen(element: HTMLElement): void;
  38423. /**
  38424. * Asks the browser to exit fullscreen mode
  38425. */
  38426. static _ExitFullscreen(): void;
  38427. }
  38428. }
  38429. declare module "babylonjs/Engines/engineStore" {
  38430. import { Nullable } from "babylonjs/types";
  38431. import { Engine } from "babylonjs/Engines/engine";
  38432. import { Scene } from "babylonjs/scene";
  38433. /**
  38434. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38435. * during the life time of the application.
  38436. */
  38437. export class EngineStore {
  38438. /** Gets the list of created engines */
  38439. static Instances: import("babylonjs/Engines/engine").Engine[];
  38440. /** @hidden */
  38441. static _LastCreatedScene: Nullable<Scene>;
  38442. /**
  38443. * Gets the latest created engine
  38444. */
  38445. static get LastCreatedEngine(): Nullable<Engine>;
  38446. /**
  38447. * Gets the latest created scene
  38448. */
  38449. static get LastCreatedScene(): Nullable<Scene>;
  38450. /**
  38451. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38452. * @ignorenaming
  38453. */
  38454. static UseFallbackTexture: boolean;
  38455. /**
  38456. * Texture content used if a texture cannot loaded
  38457. * @ignorenaming
  38458. */
  38459. static FallbackTexture: string;
  38460. }
  38461. }
  38462. declare module "babylonjs/Misc/promise" {
  38463. /**
  38464. * Helper class that provides a small promise polyfill
  38465. */
  38466. export class PromisePolyfill {
  38467. /**
  38468. * Static function used to check if the polyfill is required
  38469. * If this is the case then the function will inject the polyfill to window.Promise
  38470. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38471. */
  38472. static Apply(force?: boolean): void;
  38473. }
  38474. }
  38475. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38476. /**
  38477. * Interface for screenshot methods with describe argument called `size` as object with options
  38478. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38479. */
  38480. export interface IScreenshotSize {
  38481. /**
  38482. * number in pixels for canvas height
  38483. */
  38484. height?: number;
  38485. /**
  38486. * multiplier allowing render at a higher or lower resolution
  38487. * If value is defined then height and width will be ignored and taken from camera
  38488. */
  38489. precision?: number;
  38490. /**
  38491. * number in pixels for canvas width
  38492. */
  38493. width?: number;
  38494. }
  38495. }
  38496. declare module "babylonjs/Misc/tools" {
  38497. import { Nullable, float } from "babylonjs/types";
  38498. import { DomManagement } from "babylonjs/Misc/domManagement";
  38499. import { WebRequest } from "babylonjs/Misc/webRequest";
  38500. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38501. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38502. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38503. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38504. import { Camera } from "babylonjs/Cameras/camera";
  38505. import { Engine } from "babylonjs/Engines/engine";
  38506. interface IColor4Like {
  38507. r: float;
  38508. g: float;
  38509. b: float;
  38510. a: float;
  38511. }
  38512. /**
  38513. * Class containing a set of static utilities functions
  38514. */
  38515. export class Tools {
  38516. /**
  38517. * Gets or sets the base URL to use to load assets
  38518. */
  38519. static get BaseUrl(): string;
  38520. static set BaseUrl(value: string);
  38521. /**
  38522. * Enable/Disable Custom HTTP Request Headers globally.
  38523. * default = false
  38524. * @see CustomRequestHeaders
  38525. */
  38526. static UseCustomRequestHeaders: boolean;
  38527. /**
  38528. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38529. * i.e. when loading files, where the server/service expects an Authorization header
  38530. */
  38531. static CustomRequestHeaders: {
  38532. [key: string]: string;
  38533. };
  38534. /**
  38535. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38536. */
  38537. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38538. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38539. /**
  38540. * Default behaviour for cors in the application.
  38541. * It can be a string if the expected behavior is identical in the entire app.
  38542. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38543. */
  38544. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38545. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38546. /**
  38547. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38548. * @ignorenaming
  38549. */
  38550. static get UseFallbackTexture(): boolean;
  38551. static set UseFallbackTexture(value: boolean);
  38552. /**
  38553. * Use this object to register external classes like custom textures or material
  38554. * to allow the laoders to instantiate them
  38555. */
  38556. static get RegisteredExternalClasses(): {
  38557. [key: string]: Object;
  38558. };
  38559. static set RegisteredExternalClasses(classes: {
  38560. [key: string]: Object;
  38561. });
  38562. /**
  38563. * Texture content used if a texture cannot loaded
  38564. * @ignorenaming
  38565. */
  38566. static get fallbackTexture(): string;
  38567. static set fallbackTexture(value: string);
  38568. /**
  38569. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38570. * @param u defines the coordinate on X axis
  38571. * @param v defines the coordinate on Y axis
  38572. * @param width defines the width of the source data
  38573. * @param height defines the height of the source data
  38574. * @param pixels defines the source byte array
  38575. * @param color defines the output color
  38576. */
  38577. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38578. /**
  38579. * Interpolates between a and b via alpha
  38580. * @param a The lower value (returned when alpha = 0)
  38581. * @param b The upper value (returned when alpha = 1)
  38582. * @param alpha The interpolation-factor
  38583. * @return The mixed value
  38584. */
  38585. static Mix(a: number, b: number, alpha: number): number;
  38586. /**
  38587. * Tries to instantiate a new object from a given class name
  38588. * @param className defines the class name to instantiate
  38589. * @returns the new object or null if the system was not able to do the instantiation
  38590. */
  38591. static Instantiate(className: string): any;
  38592. /**
  38593. * Provides a slice function that will work even on IE
  38594. * @param data defines the array to slice
  38595. * @param start defines the start of the data (optional)
  38596. * @param end defines the end of the data (optional)
  38597. * @returns the new sliced array
  38598. */
  38599. static Slice<T>(data: T, start?: number, end?: number): T;
  38600. /**
  38601. * Polyfill for setImmediate
  38602. * @param action defines the action to execute after the current execution block
  38603. */
  38604. static SetImmediate(action: () => void): void;
  38605. /**
  38606. * Function indicating if a number is an exponent of 2
  38607. * @param value defines the value to test
  38608. * @returns true if the value is an exponent of 2
  38609. */
  38610. static IsExponentOfTwo(value: number): boolean;
  38611. private static _tmpFloatArray;
  38612. /**
  38613. * Returns the nearest 32-bit single precision float representation of a Number
  38614. * @param value A Number. If the parameter is of a different type, it will get converted
  38615. * to a number or to NaN if it cannot be converted
  38616. * @returns number
  38617. */
  38618. static FloatRound(value: number): number;
  38619. /**
  38620. * Extracts the filename from a path
  38621. * @param path defines the path to use
  38622. * @returns the filename
  38623. */
  38624. static GetFilename(path: string): string;
  38625. /**
  38626. * Extracts the "folder" part of a path (everything before the filename).
  38627. * @param uri The URI to extract the info from
  38628. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38629. * @returns The "folder" part of the path
  38630. */
  38631. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38632. /**
  38633. * Extracts text content from a DOM element hierarchy
  38634. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38635. */
  38636. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38637. /**
  38638. * Convert an angle in radians to degrees
  38639. * @param angle defines the angle to convert
  38640. * @returns the angle in degrees
  38641. */
  38642. static ToDegrees(angle: number): number;
  38643. /**
  38644. * Convert an angle in degrees to radians
  38645. * @param angle defines the angle to convert
  38646. * @returns the angle in radians
  38647. */
  38648. static ToRadians(angle: number): number;
  38649. /**
  38650. * Returns an array if obj is not an array
  38651. * @param obj defines the object to evaluate as an array
  38652. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38653. * @returns either obj directly if obj is an array or a new array containing obj
  38654. */
  38655. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38656. /**
  38657. * Gets the pointer prefix to use
  38658. * @param engine defines the engine we are finding the prefix for
  38659. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38660. */
  38661. static GetPointerPrefix(engine: Engine): string;
  38662. /**
  38663. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38664. * @param url define the url we are trying
  38665. * @param element define the dom element where to configure the cors policy
  38666. */
  38667. static SetCorsBehavior(url: string | string[], element: {
  38668. crossOrigin: string | null;
  38669. }): void;
  38670. /**
  38671. * Removes unwanted characters from an url
  38672. * @param url defines the url to clean
  38673. * @returns the cleaned url
  38674. */
  38675. static CleanUrl(url: string): string;
  38676. /**
  38677. * Gets or sets a function used to pre-process url before using them to load assets
  38678. */
  38679. static get PreprocessUrl(): (url: string) => string;
  38680. static set PreprocessUrl(processor: (url: string) => string);
  38681. /**
  38682. * Loads an image as an HTMLImageElement.
  38683. * @param input url string, ArrayBuffer, or Blob to load
  38684. * @param onLoad callback called when the image successfully loads
  38685. * @param onError callback called when the image fails to load
  38686. * @param offlineProvider offline provider for caching
  38687. * @param mimeType optional mime type
  38688. * @returns the HTMLImageElement of the loaded image
  38689. */
  38690. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38691. /**
  38692. * Loads a file from a url
  38693. * @param url url string, ArrayBuffer, or Blob to load
  38694. * @param onSuccess callback called when the file successfully loads
  38695. * @param onProgress callback called while file is loading (if the server supports this mode)
  38696. * @param offlineProvider defines the offline provider for caching
  38697. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38698. * @param onError callback called when the file fails to load
  38699. * @returns a file request object
  38700. */
  38701. 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;
  38702. /**
  38703. * Loads a file from a url
  38704. * @param url the file url to load
  38705. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38706. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38707. */
  38708. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38709. /**
  38710. * Load a script (identified by an url). When the url returns, the
  38711. * content of this file is added into a new script element, attached to the DOM (body element)
  38712. * @param scriptUrl defines the url of the script to laod
  38713. * @param onSuccess defines the callback called when the script is loaded
  38714. * @param onError defines the callback to call if an error occurs
  38715. * @param scriptId defines the id of the script element
  38716. */
  38717. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38718. /**
  38719. * Load an asynchronous script (identified by an url). When the url returns, the
  38720. * content of this file is added into a new script element, attached to the DOM (body element)
  38721. * @param scriptUrl defines the url of the script to laod
  38722. * @param scriptId defines the id of the script element
  38723. * @returns a promise request object
  38724. */
  38725. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38726. /**
  38727. * Loads a file from a blob
  38728. * @param fileToLoad defines the blob to use
  38729. * @param callback defines the callback to call when data is loaded
  38730. * @param progressCallback defines the callback to call during loading process
  38731. * @returns a file request object
  38732. */
  38733. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38734. /**
  38735. * Reads a file from a File object
  38736. * @param file defines the file to load
  38737. * @param onSuccess defines the callback to call when data is loaded
  38738. * @param onProgress defines the callback to call during loading process
  38739. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38740. * @param onError defines the callback to call when an error occurs
  38741. * @returns a file request object
  38742. */
  38743. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38744. /**
  38745. * Creates a data url from a given string content
  38746. * @param content defines the content to convert
  38747. * @returns the new data url link
  38748. */
  38749. static FileAsURL(content: string): string;
  38750. /**
  38751. * Format the given number to a specific decimal format
  38752. * @param value defines the number to format
  38753. * @param decimals defines the number of decimals to use
  38754. * @returns the formatted string
  38755. */
  38756. static Format(value: number, decimals?: number): string;
  38757. /**
  38758. * Tries to copy an object by duplicating every property
  38759. * @param source defines the source object
  38760. * @param destination defines the target object
  38761. * @param doNotCopyList defines a list of properties to avoid
  38762. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38763. */
  38764. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38765. /**
  38766. * Gets a boolean indicating if the given object has no own property
  38767. * @param obj defines the object to test
  38768. * @returns true if object has no own property
  38769. */
  38770. static IsEmpty(obj: any): boolean;
  38771. /**
  38772. * Function used to register events at window level
  38773. * @param windowElement defines the Window object to use
  38774. * @param events defines the events to register
  38775. */
  38776. static RegisterTopRootEvents(windowElement: Window, events: {
  38777. name: string;
  38778. handler: Nullable<(e: FocusEvent) => any>;
  38779. }[]): void;
  38780. /**
  38781. * Function used to unregister events from window level
  38782. * @param windowElement defines the Window object to use
  38783. * @param events defines the events to unregister
  38784. */
  38785. static UnregisterTopRootEvents(windowElement: Window, events: {
  38786. name: string;
  38787. handler: Nullable<(e: FocusEvent) => any>;
  38788. }[]): void;
  38789. /**
  38790. * @ignore
  38791. */
  38792. static _ScreenshotCanvas: HTMLCanvasElement;
  38793. /**
  38794. * Dumps the current bound framebuffer
  38795. * @param width defines the rendering width
  38796. * @param height defines the rendering height
  38797. * @param engine defines the hosting engine
  38798. * @param successCallback defines the callback triggered once the data are available
  38799. * @param mimeType defines the mime type of the result
  38800. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38801. */
  38802. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38803. /**
  38804. * Converts the canvas data to blob.
  38805. * This acts as a polyfill for browsers not supporting the to blob function.
  38806. * @param canvas Defines the canvas to extract the data from
  38807. * @param successCallback Defines the callback triggered once the data are available
  38808. * @param mimeType Defines the mime type of the result
  38809. */
  38810. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38811. /**
  38812. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38813. * @param successCallback defines the callback triggered once the data are available
  38814. * @param mimeType defines the mime type of the result
  38815. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38816. */
  38817. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38818. /**
  38819. * Downloads a blob in the browser
  38820. * @param blob defines the blob to download
  38821. * @param fileName defines the name of the downloaded file
  38822. */
  38823. static Download(blob: Blob, fileName: string): void;
  38824. /**
  38825. * Captures a screenshot of the current rendering
  38826. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38827. * @param engine defines the rendering engine
  38828. * @param camera defines the source camera
  38829. * @param size This parameter can be set to a single number or to an object with the
  38830. * following (optional) properties: precision, width, height. If a single number is passed,
  38831. * it will be used for both width and height. If an object is passed, the screenshot size
  38832. * will be derived from the parameters. The precision property is a multiplier allowing
  38833. * rendering at a higher or lower resolution
  38834. * @param successCallback defines the callback receives a single parameter which contains the
  38835. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38836. * src parameter of an <img> to display it
  38837. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38838. * Check your browser for supported MIME types
  38839. */
  38840. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38841. /**
  38842. * Captures a screenshot of the current rendering
  38843. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38844. * @param engine defines the rendering engine
  38845. * @param camera defines the source camera
  38846. * @param size This parameter can be set to a single number or to an object with the
  38847. * following (optional) properties: precision, width, height. If a single number is passed,
  38848. * it will be used for both width and height. If an object is passed, the screenshot size
  38849. * will be derived from the parameters. The precision property is a multiplier allowing
  38850. * rendering at a higher or lower resolution
  38851. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38852. * Check your browser for supported MIME types
  38853. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38854. * to the src parameter of an <img> to display it
  38855. */
  38856. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38857. /**
  38858. * Generates an image screenshot from the specified camera.
  38859. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38860. * @param engine The engine to use for rendering
  38861. * @param camera The camera to use for rendering
  38862. * @param size This parameter can be set to a single number or to an object with the
  38863. * following (optional) properties: precision, width, height. If a single number is passed,
  38864. * it will be used for both width and height. If an object is passed, the screenshot size
  38865. * will be derived from the parameters. The precision property is a multiplier allowing
  38866. * rendering at a higher or lower resolution
  38867. * @param successCallback The callback receives a single parameter which contains the
  38868. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38869. * src parameter of an <img> to display it
  38870. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38871. * Check your browser for supported MIME types
  38872. * @param samples Texture samples (default: 1)
  38873. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38874. * @param fileName A name for for the downloaded file.
  38875. */
  38876. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38877. /**
  38878. * Generates an image screenshot from the specified camera.
  38879. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38880. * @param engine The engine to use for rendering
  38881. * @param camera The camera to use for rendering
  38882. * @param size This parameter can be set to a single number or to an object with the
  38883. * following (optional) properties: precision, width, height. If a single number is passed,
  38884. * it will be used for both width and height. If an object is passed, the screenshot size
  38885. * will be derived from the parameters. The precision property is a multiplier allowing
  38886. * rendering at a higher or lower resolution
  38887. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38888. * Check your browser for supported MIME types
  38889. * @param samples Texture samples (default: 1)
  38890. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38891. * @param fileName A name for for the downloaded file.
  38892. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38893. * to the src parameter of an <img> to display it
  38894. */
  38895. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38896. /**
  38897. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38898. * Be aware Math.random() could cause collisions, but:
  38899. * "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"
  38900. * @returns a pseudo random id
  38901. */
  38902. static RandomId(): string;
  38903. /**
  38904. * Test if the given uri is a base64 string
  38905. * @param uri The uri to test
  38906. * @return True if the uri is a base64 string or false otherwise
  38907. */
  38908. static IsBase64(uri: string): boolean;
  38909. /**
  38910. * Decode the given base64 uri.
  38911. * @param uri The uri to decode
  38912. * @return The decoded base64 data.
  38913. */
  38914. static DecodeBase64(uri: string): ArrayBuffer;
  38915. /**
  38916. * Gets the absolute url.
  38917. * @param url the input url
  38918. * @return the absolute url
  38919. */
  38920. static GetAbsoluteUrl(url: string): string;
  38921. /**
  38922. * No log
  38923. */
  38924. static readonly NoneLogLevel: number;
  38925. /**
  38926. * Only message logs
  38927. */
  38928. static readonly MessageLogLevel: number;
  38929. /**
  38930. * Only warning logs
  38931. */
  38932. static readonly WarningLogLevel: number;
  38933. /**
  38934. * Only error logs
  38935. */
  38936. static readonly ErrorLogLevel: number;
  38937. /**
  38938. * All logs
  38939. */
  38940. static readonly AllLogLevel: number;
  38941. /**
  38942. * Gets a value indicating the number of loading errors
  38943. * @ignorenaming
  38944. */
  38945. static get errorsCount(): number;
  38946. /**
  38947. * Callback called when a new log is added
  38948. */
  38949. static OnNewCacheEntry: (entry: string) => void;
  38950. /**
  38951. * Log a message to the console
  38952. * @param message defines the message to log
  38953. */
  38954. static Log(message: string): void;
  38955. /**
  38956. * Write a warning message to the console
  38957. * @param message defines the message to log
  38958. */
  38959. static Warn(message: string): void;
  38960. /**
  38961. * Write an error message to the console
  38962. * @param message defines the message to log
  38963. */
  38964. static Error(message: string): void;
  38965. /**
  38966. * Gets current log cache (list of logs)
  38967. */
  38968. static get LogCache(): string;
  38969. /**
  38970. * Clears the log cache
  38971. */
  38972. static ClearLogCache(): void;
  38973. /**
  38974. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38975. */
  38976. static set LogLevels(level: number);
  38977. /**
  38978. * Checks if the window object exists
  38979. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38980. */
  38981. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38982. /**
  38983. * No performance log
  38984. */
  38985. static readonly PerformanceNoneLogLevel: number;
  38986. /**
  38987. * Use user marks to log performance
  38988. */
  38989. static readonly PerformanceUserMarkLogLevel: number;
  38990. /**
  38991. * Log performance to the console
  38992. */
  38993. static readonly PerformanceConsoleLogLevel: number;
  38994. private static _performance;
  38995. /**
  38996. * Sets the current performance log level
  38997. */
  38998. static set PerformanceLogLevel(level: number);
  38999. private static _StartPerformanceCounterDisabled;
  39000. private static _EndPerformanceCounterDisabled;
  39001. private static _StartUserMark;
  39002. private static _EndUserMark;
  39003. private static _StartPerformanceConsole;
  39004. private static _EndPerformanceConsole;
  39005. /**
  39006. * Starts a performance counter
  39007. */
  39008. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39009. /**
  39010. * Ends a specific performance coutner
  39011. */
  39012. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39013. /**
  39014. * Gets either window.performance.now() if supported or Date.now() else
  39015. */
  39016. static get Now(): number;
  39017. /**
  39018. * This method will return the name of the class used to create the instance of the given object.
  39019. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39020. * @param object the object to get the class name from
  39021. * @param isType defines if the object is actually a type
  39022. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39023. */
  39024. static GetClassName(object: any, isType?: boolean): string;
  39025. /**
  39026. * Gets the first element of an array satisfying a given predicate
  39027. * @param array defines the array to browse
  39028. * @param predicate defines the predicate to use
  39029. * @returns null if not found or the element
  39030. */
  39031. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39032. /**
  39033. * This method will return the name of the full name of the class, including its owning module (if any).
  39034. * 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).
  39035. * @param object the object to get the class name from
  39036. * @param isType defines if the object is actually a type
  39037. * @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.
  39038. * @ignorenaming
  39039. */
  39040. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39041. /**
  39042. * Returns a promise that resolves after the given amount of time.
  39043. * @param delay Number of milliseconds to delay
  39044. * @returns Promise that resolves after the given amount of time
  39045. */
  39046. static DelayAsync(delay: number): Promise<void>;
  39047. /**
  39048. * Utility function to detect if the current user agent is Safari
  39049. * @returns whether or not the current user agent is safari
  39050. */
  39051. static IsSafari(): boolean;
  39052. }
  39053. /**
  39054. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39055. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39056. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39057. * @param name The name of the class, case should be preserved
  39058. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39059. */
  39060. export function className(name: string, module?: string): (target: Object) => void;
  39061. /**
  39062. * An implementation of a loop for asynchronous functions.
  39063. */
  39064. export class AsyncLoop {
  39065. /**
  39066. * Defines the number of iterations for the loop
  39067. */
  39068. iterations: number;
  39069. /**
  39070. * Defines the current index of the loop.
  39071. */
  39072. index: number;
  39073. private _done;
  39074. private _fn;
  39075. private _successCallback;
  39076. /**
  39077. * Constructor.
  39078. * @param iterations the number of iterations.
  39079. * @param func the function to run each iteration
  39080. * @param successCallback the callback that will be called upon succesful execution
  39081. * @param offset starting offset.
  39082. */
  39083. constructor(
  39084. /**
  39085. * Defines the number of iterations for the loop
  39086. */
  39087. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39088. /**
  39089. * Execute the next iteration. Must be called after the last iteration was finished.
  39090. */
  39091. executeNext(): void;
  39092. /**
  39093. * Break the loop and run the success callback.
  39094. */
  39095. breakLoop(): void;
  39096. /**
  39097. * Create and run an async loop.
  39098. * @param iterations the number of iterations.
  39099. * @param fn the function to run each iteration
  39100. * @param successCallback the callback that will be called upon succesful execution
  39101. * @param offset starting offset.
  39102. * @returns the created async loop object
  39103. */
  39104. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39105. /**
  39106. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39107. * @param iterations total number of iterations
  39108. * @param syncedIterations number of synchronous iterations in each async iteration.
  39109. * @param fn the function to call each iteration.
  39110. * @param callback a success call back that will be called when iterating stops.
  39111. * @param breakFunction a break condition (optional)
  39112. * @param timeout timeout settings for the setTimeout function. default - 0.
  39113. * @returns the created async loop object
  39114. */
  39115. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39116. }
  39117. }
  39118. declare module "babylonjs/Misc/stringDictionary" {
  39119. import { Nullable } from "babylonjs/types";
  39120. /**
  39121. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39122. * The underlying implementation relies on an associative array to ensure the best performances.
  39123. * The value can be anything including 'null' but except 'undefined'
  39124. */
  39125. export class StringDictionary<T> {
  39126. /**
  39127. * This will clear this dictionary and copy the content from the 'source' one.
  39128. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39129. * @param source the dictionary to take the content from and copy to this dictionary
  39130. */
  39131. copyFrom(source: StringDictionary<T>): void;
  39132. /**
  39133. * Get a value based from its key
  39134. * @param key the given key to get the matching value from
  39135. * @return the value if found, otherwise undefined is returned
  39136. */
  39137. get(key: string): T | undefined;
  39138. /**
  39139. * Get a value from its key or add it if it doesn't exist.
  39140. * This method will ensure you that a given key/data will be present in the dictionary.
  39141. * @param key the given key to get the matching value from
  39142. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39143. * The factory will only be invoked if there's no data for the given key.
  39144. * @return the value corresponding to the key.
  39145. */
  39146. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39147. /**
  39148. * Get a value from its key if present in the dictionary otherwise add it
  39149. * @param key the key to get the value from
  39150. * @param val if there's no such key/value pair in the dictionary add it with this value
  39151. * @return the value corresponding to the key
  39152. */
  39153. getOrAdd(key: string, val: T): T;
  39154. /**
  39155. * Check if there's a given key in the dictionary
  39156. * @param key the key to check for
  39157. * @return true if the key is present, false otherwise
  39158. */
  39159. contains(key: string): boolean;
  39160. /**
  39161. * Add a new key and its corresponding value
  39162. * @param key the key to add
  39163. * @param value the value corresponding to the key
  39164. * @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
  39165. */
  39166. add(key: string, value: T): boolean;
  39167. /**
  39168. * Update a specific value associated to a key
  39169. * @param key defines the key to use
  39170. * @param value defines the value to store
  39171. * @returns true if the value was updated (or false if the key was not found)
  39172. */
  39173. set(key: string, value: T): boolean;
  39174. /**
  39175. * Get the element of the given key and remove it from the dictionary
  39176. * @param key defines the key to search
  39177. * @returns the value associated with the key or null if not found
  39178. */
  39179. getAndRemove(key: string): Nullable<T>;
  39180. /**
  39181. * Remove a key/value from the dictionary.
  39182. * @param key the key to remove
  39183. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39184. */
  39185. remove(key: string): boolean;
  39186. /**
  39187. * Clear the whole content of the dictionary
  39188. */
  39189. clear(): void;
  39190. /**
  39191. * Gets the current count
  39192. */
  39193. get count(): number;
  39194. /**
  39195. * Execute a callback on each key/val of the dictionary.
  39196. * Note that you can remove any element in this dictionary in the callback implementation
  39197. * @param callback the callback to execute on a given key/value pair
  39198. */
  39199. forEach(callback: (key: string, val: T) => void): void;
  39200. /**
  39201. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39202. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39203. * Note that you can remove any element in this dictionary in the callback implementation
  39204. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39205. * @returns the first item
  39206. */
  39207. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39208. private _count;
  39209. private _data;
  39210. }
  39211. }
  39212. declare module "babylonjs/Collisions/collisionCoordinator" {
  39213. import { Nullable } from "babylonjs/types";
  39214. import { Scene } from "babylonjs/scene";
  39215. import { Vector3 } from "babylonjs/Maths/math.vector";
  39216. import { Collider } from "babylonjs/Collisions/collider";
  39217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39218. /** @hidden */
  39219. export interface ICollisionCoordinator {
  39220. createCollider(): Collider;
  39221. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39222. init(scene: Scene): void;
  39223. }
  39224. /** @hidden */
  39225. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39226. private _scene;
  39227. private _scaledPosition;
  39228. private _scaledVelocity;
  39229. private _finalPosition;
  39230. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39231. createCollider(): Collider;
  39232. init(scene: Scene): void;
  39233. private _collideWithWorld;
  39234. }
  39235. }
  39236. declare module "babylonjs/Inputs/scene.inputManager" {
  39237. import { Nullable } from "babylonjs/types";
  39238. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39239. import { Vector2 } from "babylonjs/Maths/math.vector";
  39240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39241. import { Scene } from "babylonjs/scene";
  39242. /**
  39243. * Class used to manage all inputs for the scene.
  39244. */
  39245. export class InputManager {
  39246. /** The distance in pixel that you have to move to prevent some events */
  39247. static DragMovementThreshold: number;
  39248. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39249. static LongPressDelay: number;
  39250. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39251. static DoubleClickDelay: number;
  39252. /** If you need to check double click without raising a single click at first click, enable this flag */
  39253. static ExclusiveDoubleClickMode: boolean;
  39254. private _wheelEventName;
  39255. private _onPointerMove;
  39256. private _onPointerDown;
  39257. private _onPointerUp;
  39258. private _initClickEvent;
  39259. private _initActionManager;
  39260. private _delayedSimpleClick;
  39261. private _delayedSimpleClickTimeout;
  39262. private _previousDelayedSimpleClickTimeout;
  39263. private _meshPickProceed;
  39264. private _previousButtonPressed;
  39265. private _currentPickResult;
  39266. private _previousPickResult;
  39267. private _totalPointersPressed;
  39268. private _doubleClickOccured;
  39269. private _pointerOverMesh;
  39270. private _pickedDownMesh;
  39271. private _pickedUpMesh;
  39272. private _pointerX;
  39273. private _pointerY;
  39274. private _unTranslatedPointerX;
  39275. private _unTranslatedPointerY;
  39276. private _startingPointerPosition;
  39277. private _previousStartingPointerPosition;
  39278. private _startingPointerTime;
  39279. private _previousStartingPointerTime;
  39280. private _pointerCaptures;
  39281. private _onKeyDown;
  39282. private _onKeyUp;
  39283. private _onCanvasFocusObserver;
  39284. private _onCanvasBlurObserver;
  39285. private _scene;
  39286. /**
  39287. * Creates a new InputManager
  39288. * @param scene defines the hosting scene
  39289. */
  39290. constructor(scene: Scene);
  39291. /**
  39292. * Gets the mesh that is currently under the pointer
  39293. */
  39294. get meshUnderPointer(): Nullable<AbstractMesh>;
  39295. /**
  39296. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39297. */
  39298. get unTranslatedPointer(): Vector2;
  39299. /**
  39300. * Gets or sets the current on-screen X position of the pointer
  39301. */
  39302. get pointerX(): number;
  39303. set pointerX(value: number);
  39304. /**
  39305. * Gets or sets the current on-screen Y position of the pointer
  39306. */
  39307. get pointerY(): number;
  39308. set pointerY(value: number);
  39309. private _updatePointerPosition;
  39310. private _processPointerMove;
  39311. private _setRayOnPointerInfo;
  39312. private _checkPrePointerObservable;
  39313. /**
  39314. * Use this method to simulate a pointer move on a mesh
  39315. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39316. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39317. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39318. */
  39319. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39320. /**
  39321. * Use this method to simulate a pointer down on a mesh
  39322. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39323. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39324. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39325. */
  39326. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39327. private _processPointerDown;
  39328. /** @hidden */
  39329. _isPointerSwiping(): boolean;
  39330. /**
  39331. * Use this method to simulate a pointer up on a mesh
  39332. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39333. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39334. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39335. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39336. */
  39337. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39338. private _processPointerUp;
  39339. /**
  39340. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39341. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39342. * @returns true if the pointer was captured
  39343. */
  39344. isPointerCaptured(pointerId?: number): boolean;
  39345. /**
  39346. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39347. * @param attachUp defines if you want to attach events to pointerup
  39348. * @param attachDown defines if you want to attach events to pointerdown
  39349. * @param attachMove defines if you want to attach events to pointermove
  39350. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39351. */
  39352. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39353. /**
  39354. * Detaches all event handlers
  39355. */
  39356. detachControl(): void;
  39357. /**
  39358. * Force the value of meshUnderPointer
  39359. * @param mesh defines the mesh to use
  39360. */
  39361. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39362. /**
  39363. * Gets the mesh under the pointer
  39364. * @returns a Mesh or null if no mesh is under the pointer
  39365. */
  39366. getPointerOverMesh(): Nullable<AbstractMesh>;
  39367. }
  39368. }
  39369. declare module "babylonjs/Animations/animationGroup" {
  39370. import { Animatable } from "babylonjs/Animations/animatable";
  39371. import { Animation } from "babylonjs/Animations/animation";
  39372. import { Scene, IDisposable } from "babylonjs/scene";
  39373. import { Observable } from "babylonjs/Misc/observable";
  39374. import { Nullable } from "babylonjs/types";
  39375. import "babylonjs/Animations/animatable";
  39376. /**
  39377. * This class defines the direct association between an animation and a target
  39378. */
  39379. export class TargetedAnimation {
  39380. /**
  39381. * Animation to perform
  39382. */
  39383. animation: Animation;
  39384. /**
  39385. * Target to animate
  39386. */
  39387. target: any;
  39388. /**
  39389. * Returns the string "TargetedAnimation"
  39390. * @returns "TargetedAnimation"
  39391. */
  39392. getClassName(): string;
  39393. /**
  39394. * Serialize the object
  39395. * @returns the JSON object representing the current entity
  39396. */
  39397. serialize(): any;
  39398. }
  39399. /**
  39400. * Use this class to create coordinated animations on multiple targets
  39401. */
  39402. export class AnimationGroup implements IDisposable {
  39403. /** The name of the animation group */
  39404. name: string;
  39405. private _scene;
  39406. private _targetedAnimations;
  39407. private _animatables;
  39408. private _from;
  39409. private _to;
  39410. private _isStarted;
  39411. private _isPaused;
  39412. private _speedRatio;
  39413. private _loopAnimation;
  39414. private _isAdditive;
  39415. /**
  39416. * Gets or sets the unique id of the node
  39417. */
  39418. uniqueId: number;
  39419. /**
  39420. * This observable will notify when one animation have ended
  39421. */
  39422. onAnimationEndObservable: Observable<TargetedAnimation>;
  39423. /**
  39424. * Observer raised when one animation loops
  39425. */
  39426. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39427. /**
  39428. * Observer raised when all animations have looped
  39429. */
  39430. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39431. /**
  39432. * This observable will notify when all animations have ended.
  39433. */
  39434. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39435. /**
  39436. * This observable will notify when all animations have paused.
  39437. */
  39438. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39439. /**
  39440. * This observable will notify when all animations are playing.
  39441. */
  39442. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39443. /**
  39444. * Gets the first frame
  39445. */
  39446. get from(): number;
  39447. /**
  39448. * Gets the last frame
  39449. */
  39450. get to(): number;
  39451. /**
  39452. * Define if the animations are started
  39453. */
  39454. get isStarted(): boolean;
  39455. /**
  39456. * Gets a value indicating that the current group is playing
  39457. */
  39458. get isPlaying(): boolean;
  39459. /**
  39460. * Gets or sets the speed ratio to use for all animations
  39461. */
  39462. get speedRatio(): number;
  39463. /**
  39464. * Gets or sets the speed ratio to use for all animations
  39465. */
  39466. set speedRatio(value: number);
  39467. /**
  39468. * Gets or sets if all animations should loop or not
  39469. */
  39470. get loopAnimation(): boolean;
  39471. set loopAnimation(value: boolean);
  39472. /**
  39473. * Gets or sets if all animations should be evaluated additively
  39474. */
  39475. get isAdditive(): boolean;
  39476. set isAdditive(value: boolean);
  39477. /**
  39478. * Gets the targeted animations for this animation group
  39479. */
  39480. get targetedAnimations(): Array<TargetedAnimation>;
  39481. /**
  39482. * returning the list of animatables controlled by this animation group.
  39483. */
  39484. get animatables(): Array<Animatable>;
  39485. /**
  39486. * Gets the list of target animations
  39487. */
  39488. get children(): TargetedAnimation[];
  39489. /**
  39490. * Instantiates a new Animation Group.
  39491. * This helps managing several animations at once.
  39492. * @see http://doc.babylonjs.com/how_to/group
  39493. * @param name Defines the name of the group
  39494. * @param scene Defines the scene the group belongs to
  39495. */
  39496. constructor(
  39497. /** The name of the animation group */
  39498. name: string, scene?: Nullable<Scene>);
  39499. /**
  39500. * Add an animation (with its target) in the group
  39501. * @param animation defines the animation we want to add
  39502. * @param target defines the target of the animation
  39503. * @returns the TargetedAnimation object
  39504. */
  39505. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39506. /**
  39507. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39508. * It can add constant keys at begin or end
  39509. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39510. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39511. * @returns the animation group
  39512. */
  39513. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39514. private _animationLoopCount;
  39515. private _animationLoopFlags;
  39516. private _processLoop;
  39517. /**
  39518. * Start all animations on given targets
  39519. * @param loop defines if animations must loop
  39520. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39521. * @param from defines the from key (optional)
  39522. * @param to defines the to key (optional)
  39523. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39524. * @returns the current animation group
  39525. */
  39526. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39527. /**
  39528. * Pause all animations
  39529. * @returns the animation group
  39530. */
  39531. pause(): AnimationGroup;
  39532. /**
  39533. * Play all animations to initial state
  39534. * This function will start() the animations if they were not started or will restart() them if they were paused
  39535. * @param loop defines if animations must loop
  39536. * @returns the animation group
  39537. */
  39538. play(loop?: boolean): AnimationGroup;
  39539. /**
  39540. * Reset all animations to initial state
  39541. * @returns the animation group
  39542. */
  39543. reset(): AnimationGroup;
  39544. /**
  39545. * Restart animations from key 0
  39546. * @returns the animation group
  39547. */
  39548. restart(): AnimationGroup;
  39549. /**
  39550. * Stop all animations
  39551. * @returns the animation group
  39552. */
  39553. stop(): AnimationGroup;
  39554. /**
  39555. * Set animation weight for all animatables
  39556. * @param weight defines the weight to use
  39557. * @return the animationGroup
  39558. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39559. */
  39560. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39561. /**
  39562. * Synchronize and normalize all animatables with a source animatable
  39563. * @param root defines the root animatable to synchronize with
  39564. * @return the animationGroup
  39565. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39566. */
  39567. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39568. /**
  39569. * Goes to a specific frame in this animation group
  39570. * @param frame the frame number to go to
  39571. * @return the animationGroup
  39572. */
  39573. goToFrame(frame: number): AnimationGroup;
  39574. /**
  39575. * Dispose all associated resources
  39576. */
  39577. dispose(): void;
  39578. private _checkAnimationGroupEnded;
  39579. /**
  39580. * Clone the current animation group and returns a copy
  39581. * @param newName defines the name of the new group
  39582. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39583. * @returns the new aniamtion group
  39584. */
  39585. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39586. /**
  39587. * Serializes the animationGroup to an object
  39588. * @returns Serialized object
  39589. */
  39590. serialize(): any;
  39591. /**
  39592. * Returns a new AnimationGroup object parsed from the source provided.
  39593. * @param parsedAnimationGroup defines the source
  39594. * @param scene defines the scene that will receive the animationGroup
  39595. * @returns a new AnimationGroup
  39596. */
  39597. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39598. /**
  39599. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39600. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39601. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39602. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39603. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39604. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39605. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39606. */
  39607. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39608. /**
  39609. * Returns the string "AnimationGroup"
  39610. * @returns "AnimationGroup"
  39611. */
  39612. getClassName(): string;
  39613. /**
  39614. * Creates a detailled string about the object
  39615. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39616. * @returns a string representing the object
  39617. */
  39618. toString(fullDetails?: boolean): string;
  39619. }
  39620. }
  39621. declare module "babylonjs/scene" {
  39622. import { Nullable } from "babylonjs/types";
  39623. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39624. import { Observable } from "babylonjs/Misc/observable";
  39625. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39626. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39627. import { Geometry } from "babylonjs/Meshes/geometry";
  39628. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39629. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39631. import { Mesh } from "babylonjs/Meshes/mesh";
  39632. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39633. import { Bone } from "babylonjs/Bones/bone";
  39634. import { Skeleton } from "babylonjs/Bones/skeleton";
  39635. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39636. import { Camera } from "babylonjs/Cameras/camera";
  39637. import { AbstractScene } from "babylonjs/abstractScene";
  39638. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39639. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39640. import { Material } from "babylonjs/Materials/material";
  39641. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39642. import { Effect } from "babylonjs/Materials/effect";
  39643. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39644. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39645. import { Light } from "babylonjs/Lights/light";
  39646. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39647. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39648. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39649. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39650. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39651. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39652. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39653. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39654. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39655. import { Engine } from "babylonjs/Engines/engine";
  39656. import { Node } from "babylonjs/node";
  39657. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39658. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39659. import { WebRequest } from "babylonjs/Misc/webRequest";
  39660. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39661. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39662. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39663. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39664. import { Plane } from "babylonjs/Maths/math.plane";
  39665. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39666. import { Ray } from "babylonjs/Culling/ray";
  39667. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39668. import { Animation } from "babylonjs/Animations/animation";
  39669. import { Animatable } from "babylonjs/Animations/animatable";
  39670. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39671. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39672. import { Collider } from "babylonjs/Collisions/collider";
  39673. /**
  39674. * Define an interface for all classes that will hold resources
  39675. */
  39676. export interface IDisposable {
  39677. /**
  39678. * Releases all held resources
  39679. */
  39680. dispose(): void;
  39681. }
  39682. /** Interface defining initialization parameters for Scene class */
  39683. export interface SceneOptions {
  39684. /**
  39685. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39686. * It will improve performance when the number of geometries becomes important.
  39687. */
  39688. useGeometryUniqueIdsMap?: boolean;
  39689. /**
  39690. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39691. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39692. */
  39693. useMaterialMeshMap?: boolean;
  39694. /**
  39695. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39696. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39697. */
  39698. useClonedMeshMap?: boolean;
  39699. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39700. virtual?: boolean;
  39701. }
  39702. /**
  39703. * Represents a scene to be rendered by the engine.
  39704. * @see http://doc.babylonjs.com/features/scene
  39705. */
  39706. export class Scene extends AbstractScene implements IAnimatable {
  39707. /** The fog is deactivated */
  39708. static readonly FOGMODE_NONE: number;
  39709. /** The fog density is following an exponential function */
  39710. static readonly FOGMODE_EXP: number;
  39711. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39712. static readonly FOGMODE_EXP2: number;
  39713. /** The fog density is following a linear function. */
  39714. static readonly FOGMODE_LINEAR: number;
  39715. /**
  39716. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39717. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39718. */
  39719. static MinDeltaTime: number;
  39720. /**
  39721. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39722. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39723. */
  39724. static MaxDeltaTime: number;
  39725. /**
  39726. * Factory used to create the default material.
  39727. * @param name The name of the material to create
  39728. * @param scene The scene to create the material for
  39729. * @returns The default material
  39730. */
  39731. static DefaultMaterialFactory(scene: Scene): Material;
  39732. /**
  39733. * Factory used to create the a collision coordinator.
  39734. * @returns The collision coordinator
  39735. */
  39736. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39737. /** @hidden */
  39738. _inputManager: InputManager;
  39739. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39740. cameraToUseForPointers: Nullable<Camera>;
  39741. /** @hidden */
  39742. readonly _isScene: boolean;
  39743. /** @hidden */
  39744. _blockEntityCollection: boolean;
  39745. /**
  39746. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39747. */
  39748. autoClear: boolean;
  39749. /**
  39750. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39751. */
  39752. autoClearDepthAndStencil: boolean;
  39753. /**
  39754. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39755. */
  39756. clearColor: Color4;
  39757. /**
  39758. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39759. */
  39760. ambientColor: Color3;
  39761. /**
  39762. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39763. * It should only be one of the following (if not the default embedded one):
  39764. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39765. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39766. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39767. * The material properties need to be setup according to the type of texture in use.
  39768. */
  39769. environmentBRDFTexture: BaseTexture;
  39770. /** @hidden */
  39771. protected _environmentTexture: Nullable<BaseTexture>;
  39772. /**
  39773. * Texture used in all pbr material as the reflection texture.
  39774. * As in the majority of the scene they are the same (exception for multi room and so on),
  39775. * this is easier to reference from here than from all the materials.
  39776. */
  39777. get environmentTexture(): Nullable<BaseTexture>;
  39778. /**
  39779. * Texture used in all pbr material as the reflection texture.
  39780. * As in the majority of the scene they are the same (exception for multi room and so on),
  39781. * this is easier to set here than in all the materials.
  39782. */
  39783. set environmentTexture(value: Nullable<BaseTexture>);
  39784. /** @hidden */
  39785. protected _environmentIntensity: number;
  39786. /**
  39787. * Intensity of the environment in all pbr material.
  39788. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39789. * As in the majority of the scene they are the same (exception for multi room and so on),
  39790. * this is easier to reference from here than from all the materials.
  39791. */
  39792. get environmentIntensity(): number;
  39793. /**
  39794. * Intensity of the environment in all pbr material.
  39795. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39796. * As in the majority of the scene they are the same (exception for multi room and so on),
  39797. * this is easier to set here than in all the materials.
  39798. */
  39799. set environmentIntensity(value: number);
  39800. /** @hidden */
  39801. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39802. /**
  39803. * Default image processing configuration used either in the rendering
  39804. * Forward main pass or through the imageProcessingPostProcess if present.
  39805. * As in the majority of the scene they are the same (exception for multi camera),
  39806. * this is easier to reference from here than from all the materials and post process.
  39807. *
  39808. * No setter as we it is a shared configuration, you can set the values instead.
  39809. */
  39810. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39811. private _forceWireframe;
  39812. /**
  39813. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39814. */
  39815. set forceWireframe(value: boolean);
  39816. get forceWireframe(): boolean;
  39817. private _skipFrustumClipping;
  39818. /**
  39819. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39820. */
  39821. set skipFrustumClipping(value: boolean);
  39822. get skipFrustumClipping(): boolean;
  39823. private _forcePointsCloud;
  39824. /**
  39825. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39826. */
  39827. set forcePointsCloud(value: boolean);
  39828. get forcePointsCloud(): boolean;
  39829. /**
  39830. * Gets or sets the active clipplane 1
  39831. */
  39832. clipPlane: Nullable<Plane>;
  39833. /**
  39834. * Gets or sets the active clipplane 2
  39835. */
  39836. clipPlane2: Nullable<Plane>;
  39837. /**
  39838. * Gets or sets the active clipplane 3
  39839. */
  39840. clipPlane3: Nullable<Plane>;
  39841. /**
  39842. * Gets or sets the active clipplane 4
  39843. */
  39844. clipPlane4: Nullable<Plane>;
  39845. /**
  39846. * Gets or sets the active clipplane 5
  39847. */
  39848. clipPlane5: Nullable<Plane>;
  39849. /**
  39850. * Gets or sets the active clipplane 6
  39851. */
  39852. clipPlane6: Nullable<Plane>;
  39853. /**
  39854. * Gets or sets a boolean indicating if animations are enabled
  39855. */
  39856. animationsEnabled: boolean;
  39857. private _animationPropertiesOverride;
  39858. /**
  39859. * Gets or sets the animation properties override
  39860. */
  39861. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39862. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39863. /**
  39864. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39865. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39866. */
  39867. useConstantAnimationDeltaTime: boolean;
  39868. /**
  39869. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39870. * Please note that it requires to run a ray cast through the scene on every frame
  39871. */
  39872. constantlyUpdateMeshUnderPointer: boolean;
  39873. /**
  39874. * Defines the HTML cursor to use when hovering over interactive elements
  39875. */
  39876. hoverCursor: string;
  39877. /**
  39878. * Defines the HTML default cursor to use (empty by default)
  39879. */
  39880. defaultCursor: string;
  39881. /**
  39882. * Defines whether cursors are handled by the scene.
  39883. */
  39884. doNotHandleCursors: boolean;
  39885. /**
  39886. * This is used to call preventDefault() on pointer down
  39887. * in order to block unwanted artifacts like system double clicks
  39888. */
  39889. preventDefaultOnPointerDown: boolean;
  39890. /**
  39891. * This is used to call preventDefault() on pointer up
  39892. * in order to block unwanted artifacts like system double clicks
  39893. */
  39894. preventDefaultOnPointerUp: boolean;
  39895. /**
  39896. * Gets or sets user defined metadata
  39897. */
  39898. metadata: any;
  39899. /**
  39900. * For internal use only. Please do not use.
  39901. */
  39902. reservedDataStore: any;
  39903. /**
  39904. * Gets the name of the plugin used to load this scene (null by default)
  39905. */
  39906. loadingPluginName: string;
  39907. /**
  39908. * Use this array to add regular expressions used to disable offline support for specific urls
  39909. */
  39910. disableOfflineSupportExceptionRules: RegExp[];
  39911. /**
  39912. * An event triggered when the scene is disposed.
  39913. */
  39914. onDisposeObservable: Observable<Scene>;
  39915. private _onDisposeObserver;
  39916. /** Sets a function to be executed when this scene is disposed. */
  39917. set onDispose(callback: () => void);
  39918. /**
  39919. * An event triggered before rendering the scene (right after animations and physics)
  39920. */
  39921. onBeforeRenderObservable: Observable<Scene>;
  39922. private _onBeforeRenderObserver;
  39923. /** Sets a function to be executed before rendering this scene */
  39924. set beforeRender(callback: Nullable<() => void>);
  39925. /**
  39926. * An event triggered after rendering the scene
  39927. */
  39928. onAfterRenderObservable: Observable<Scene>;
  39929. /**
  39930. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39931. */
  39932. onAfterRenderCameraObservable: Observable<Camera>;
  39933. private _onAfterRenderObserver;
  39934. /** Sets a function to be executed after rendering this scene */
  39935. set afterRender(callback: Nullable<() => void>);
  39936. /**
  39937. * An event triggered before animating the scene
  39938. */
  39939. onBeforeAnimationsObservable: Observable<Scene>;
  39940. /**
  39941. * An event triggered after animations processing
  39942. */
  39943. onAfterAnimationsObservable: Observable<Scene>;
  39944. /**
  39945. * An event triggered before draw calls are ready to be sent
  39946. */
  39947. onBeforeDrawPhaseObservable: Observable<Scene>;
  39948. /**
  39949. * An event triggered after draw calls have been sent
  39950. */
  39951. onAfterDrawPhaseObservable: Observable<Scene>;
  39952. /**
  39953. * An event triggered when the scene is ready
  39954. */
  39955. onReadyObservable: Observable<Scene>;
  39956. /**
  39957. * An event triggered before rendering a camera
  39958. */
  39959. onBeforeCameraRenderObservable: Observable<Camera>;
  39960. private _onBeforeCameraRenderObserver;
  39961. /** Sets a function to be executed before rendering a camera*/
  39962. set beforeCameraRender(callback: () => void);
  39963. /**
  39964. * An event triggered after rendering a camera
  39965. */
  39966. onAfterCameraRenderObservable: Observable<Camera>;
  39967. private _onAfterCameraRenderObserver;
  39968. /** Sets a function to be executed after rendering a camera*/
  39969. set afterCameraRender(callback: () => void);
  39970. /**
  39971. * An event triggered when active meshes evaluation is about to start
  39972. */
  39973. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39974. /**
  39975. * An event triggered when active meshes evaluation is done
  39976. */
  39977. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39978. /**
  39979. * An event triggered when particles rendering is about to start
  39980. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39981. */
  39982. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39983. /**
  39984. * An event triggered when particles rendering is done
  39985. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39986. */
  39987. onAfterParticlesRenderingObservable: Observable<Scene>;
  39988. /**
  39989. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39990. */
  39991. onDataLoadedObservable: Observable<Scene>;
  39992. /**
  39993. * An event triggered when a camera is created
  39994. */
  39995. onNewCameraAddedObservable: Observable<Camera>;
  39996. /**
  39997. * An event triggered when a camera is removed
  39998. */
  39999. onCameraRemovedObservable: Observable<Camera>;
  40000. /**
  40001. * An event triggered when a light is created
  40002. */
  40003. onNewLightAddedObservable: Observable<Light>;
  40004. /**
  40005. * An event triggered when a light is removed
  40006. */
  40007. onLightRemovedObservable: Observable<Light>;
  40008. /**
  40009. * An event triggered when a geometry is created
  40010. */
  40011. onNewGeometryAddedObservable: Observable<Geometry>;
  40012. /**
  40013. * An event triggered when a geometry is removed
  40014. */
  40015. onGeometryRemovedObservable: Observable<Geometry>;
  40016. /**
  40017. * An event triggered when a transform node is created
  40018. */
  40019. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40020. /**
  40021. * An event triggered when a transform node is removed
  40022. */
  40023. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40024. /**
  40025. * An event triggered when a mesh is created
  40026. */
  40027. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40028. /**
  40029. * An event triggered when a mesh is removed
  40030. */
  40031. onMeshRemovedObservable: Observable<AbstractMesh>;
  40032. /**
  40033. * An event triggered when a skeleton is created
  40034. */
  40035. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40036. /**
  40037. * An event triggered when a skeleton is removed
  40038. */
  40039. onSkeletonRemovedObservable: Observable<Skeleton>;
  40040. /**
  40041. * An event triggered when a material is created
  40042. */
  40043. onNewMaterialAddedObservable: Observable<Material>;
  40044. /**
  40045. * An event triggered when a material is removed
  40046. */
  40047. onMaterialRemovedObservable: Observable<Material>;
  40048. /**
  40049. * An event triggered when a texture is created
  40050. */
  40051. onNewTextureAddedObservable: Observable<BaseTexture>;
  40052. /**
  40053. * An event triggered when a texture is removed
  40054. */
  40055. onTextureRemovedObservable: Observable<BaseTexture>;
  40056. /**
  40057. * An event triggered when render targets are about to be rendered
  40058. * Can happen multiple times per frame.
  40059. */
  40060. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40061. /**
  40062. * An event triggered when render targets were rendered.
  40063. * Can happen multiple times per frame.
  40064. */
  40065. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40066. /**
  40067. * An event triggered before calculating deterministic simulation step
  40068. */
  40069. onBeforeStepObservable: Observable<Scene>;
  40070. /**
  40071. * An event triggered after calculating deterministic simulation step
  40072. */
  40073. onAfterStepObservable: Observable<Scene>;
  40074. /**
  40075. * An event triggered when the activeCamera property is updated
  40076. */
  40077. onActiveCameraChanged: Observable<Scene>;
  40078. /**
  40079. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40080. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40081. * 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)
  40082. */
  40083. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40084. /**
  40085. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40086. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40087. * 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)
  40088. */
  40089. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40090. /**
  40091. * This Observable will when a mesh has been imported into the scene.
  40092. */
  40093. onMeshImportedObservable: Observable<AbstractMesh>;
  40094. /**
  40095. * This Observable will when an animation file has been imported into the scene.
  40096. */
  40097. onAnimationFileImportedObservable: Observable<Scene>;
  40098. /**
  40099. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40100. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40101. */
  40102. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40103. /** @hidden */
  40104. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40105. /**
  40106. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40107. */
  40108. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40109. /**
  40110. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40111. */
  40112. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40113. /**
  40114. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40115. */
  40116. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40117. /** Callback called when a pointer move is detected */
  40118. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40119. /** Callback called when a pointer down is detected */
  40120. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40121. /** Callback called when a pointer up is detected */
  40122. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40123. /** Callback called when a pointer pick is detected */
  40124. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40125. /**
  40126. * 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).
  40127. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40128. */
  40129. onPrePointerObservable: Observable<PointerInfoPre>;
  40130. /**
  40131. * Observable event triggered each time an input event is received from the rendering canvas
  40132. */
  40133. onPointerObservable: Observable<PointerInfo>;
  40134. /**
  40135. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40136. */
  40137. get unTranslatedPointer(): Vector2;
  40138. /**
  40139. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40140. */
  40141. static get DragMovementThreshold(): number;
  40142. static set DragMovementThreshold(value: number);
  40143. /**
  40144. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40145. */
  40146. static get LongPressDelay(): number;
  40147. static set LongPressDelay(value: number);
  40148. /**
  40149. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40150. */
  40151. static get DoubleClickDelay(): number;
  40152. static set DoubleClickDelay(value: number);
  40153. /** If you need to check double click without raising a single click at first click, enable this flag */
  40154. static get ExclusiveDoubleClickMode(): boolean;
  40155. static set ExclusiveDoubleClickMode(value: boolean);
  40156. /** @hidden */
  40157. _mirroredCameraPosition: Nullable<Vector3>;
  40158. /**
  40159. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40160. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40161. */
  40162. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40163. /**
  40164. * Observable event triggered each time an keyboard event is received from the hosting window
  40165. */
  40166. onKeyboardObservable: Observable<KeyboardInfo>;
  40167. private _useRightHandedSystem;
  40168. /**
  40169. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40170. */
  40171. set useRightHandedSystem(value: boolean);
  40172. get useRightHandedSystem(): boolean;
  40173. private _timeAccumulator;
  40174. private _currentStepId;
  40175. private _currentInternalStep;
  40176. /**
  40177. * Sets the step Id used by deterministic lock step
  40178. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40179. * @param newStepId defines the step Id
  40180. */
  40181. setStepId(newStepId: number): void;
  40182. /**
  40183. * Gets the step Id used by deterministic lock step
  40184. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40185. * @returns the step Id
  40186. */
  40187. getStepId(): number;
  40188. /**
  40189. * Gets the internal step used by deterministic lock step
  40190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40191. * @returns the internal step
  40192. */
  40193. getInternalStep(): number;
  40194. private _fogEnabled;
  40195. /**
  40196. * Gets or sets a boolean indicating if fog is enabled on this scene
  40197. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40198. * (Default is true)
  40199. */
  40200. set fogEnabled(value: boolean);
  40201. get fogEnabled(): boolean;
  40202. private _fogMode;
  40203. /**
  40204. * Gets or sets the fog mode to use
  40205. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40206. * | mode | value |
  40207. * | --- | --- |
  40208. * | FOGMODE_NONE | 0 |
  40209. * | FOGMODE_EXP | 1 |
  40210. * | FOGMODE_EXP2 | 2 |
  40211. * | FOGMODE_LINEAR | 3 |
  40212. */
  40213. set fogMode(value: number);
  40214. get fogMode(): number;
  40215. /**
  40216. * Gets or sets the fog color to use
  40217. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40218. * (Default is Color3(0.2, 0.2, 0.3))
  40219. */
  40220. fogColor: Color3;
  40221. /**
  40222. * Gets or sets the fog density to use
  40223. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40224. * (Default is 0.1)
  40225. */
  40226. fogDensity: number;
  40227. /**
  40228. * Gets or sets the fog start distance to use
  40229. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40230. * (Default is 0)
  40231. */
  40232. fogStart: number;
  40233. /**
  40234. * Gets or sets the fog end distance to use
  40235. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40236. * (Default is 1000)
  40237. */
  40238. fogEnd: number;
  40239. private _shadowsEnabled;
  40240. /**
  40241. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40242. */
  40243. set shadowsEnabled(value: boolean);
  40244. get shadowsEnabled(): boolean;
  40245. private _lightsEnabled;
  40246. /**
  40247. * Gets or sets a boolean indicating if lights are enabled on this scene
  40248. */
  40249. set lightsEnabled(value: boolean);
  40250. get lightsEnabled(): boolean;
  40251. /** All of the active cameras added to this scene. */
  40252. activeCameras: Camera[];
  40253. /** @hidden */
  40254. _activeCamera: Nullable<Camera>;
  40255. /** Gets or sets the current active camera */
  40256. get activeCamera(): Nullable<Camera>;
  40257. set activeCamera(value: Nullable<Camera>);
  40258. private _defaultMaterial;
  40259. /** The default material used on meshes when no material is affected */
  40260. get defaultMaterial(): Material;
  40261. /** The default material used on meshes when no material is affected */
  40262. set defaultMaterial(value: Material);
  40263. private _texturesEnabled;
  40264. /**
  40265. * Gets or sets a boolean indicating if textures are enabled on this scene
  40266. */
  40267. set texturesEnabled(value: boolean);
  40268. get texturesEnabled(): boolean;
  40269. /**
  40270. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40271. */
  40272. physicsEnabled: boolean;
  40273. /**
  40274. * Gets or sets a boolean indicating if particles are enabled on this scene
  40275. */
  40276. particlesEnabled: boolean;
  40277. /**
  40278. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40279. */
  40280. spritesEnabled: boolean;
  40281. private _skeletonsEnabled;
  40282. /**
  40283. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40284. */
  40285. set skeletonsEnabled(value: boolean);
  40286. get skeletonsEnabled(): boolean;
  40287. /**
  40288. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40289. */
  40290. lensFlaresEnabled: boolean;
  40291. /**
  40292. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40294. */
  40295. collisionsEnabled: boolean;
  40296. private _collisionCoordinator;
  40297. /** @hidden */
  40298. get collisionCoordinator(): ICollisionCoordinator;
  40299. /**
  40300. * Defines the gravity applied to this scene (used only for collisions)
  40301. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40302. */
  40303. gravity: Vector3;
  40304. /**
  40305. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40306. */
  40307. postProcessesEnabled: boolean;
  40308. /**
  40309. * The list of postprocesses added to the scene
  40310. */
  40311. postProcesses: PostProcess[];
  40312. /**
  40313. * Gets the current postprocess manager
  40314. */
  40315. postProcessManager: PostProcessManager;
  40316. /**
  40317. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40318. */
  40319. renderTargetsEnabled: boolean;
  40320. /**
  40321. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40322. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40323. */
  40324. dumpNextRenderTargets: boolean;
  40325. /**
  40326. * The list of user defined render targets added to the scene
  40327. */
  40328. customRenderTargets: RenderTargetTexture[];
  40329. /**
  40330. * Defines if texture loading must be delayed
  40331. * If true, textures will only be loaded when they need to be rendered
  40332. */
  40333. useDelayedTextureLoading: boolean;
  40334. /**
  40335. * Gets the list of meshes imported to the scene through SceneLoader
  40336. */
  40337. importedMeshesFiles: String[];
  40338. /**
  40339. * Gets or sets a boolean indicating if probes are enabled on this scene
  40340. */
  40341. probesEnabled: boolean;
  40342. /**
  40343. * Gets or sets the current offline provider to use to store scene data
  40344. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40345. */
  40346. offlineProvider: IOfflineProvider;
  40347. /**
  40348. * Gets or sets the action manager associated with the scene
  40349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40350. */
  40351. actionManager: AbstractActionManager;
  40352. private _meshesForIntersections;
  40353. /**
  40354. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40355. */
  40356. proceduralTexturesEnabled: boolean;
  40357. private _engine;
  40358. private _totalVertices;
  40359. /** @hidden */
  40360. _activeIndices: PerfCounter;
  40361. /** @hidden */
  40362. _activeParticles: PerfCounter;
  40363. /** @hidden */
  40364. _activeBones: PerfCounter;
  40365. private _animationRatio;
  40366. /** @hidden */
  40367. _animationTimeLast: number;
  40368. /** @hidden */
  40369. _animationTime: number;
  40370. /**
  40371. * Gets or sets a general scale for animation speed
  40372. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40373. */
  40374. animationTimeScale: number;
  40375. /** @hidden */
  40376. _cachedMaterial: Nullable<Material>;
  40377. /** @hidden */
  40378. _cachedEffect: Nullable<Effect>;
  40379. /** @hidden */
  40380. _cachedVisibility: Nullable<number>;
  40381. private _renderId;
  40382. private _frameId;
  40383. private _executeWhenReadyTimeoutId;
  40384. private _intermediateRendering;
  40385. private _viewUpdateFlag;
  40386. private _projectionUpdateFlag;
  40387. /** @hidden */
  40388. _toBeDisposed: Nullable<IDisposable>[];
  40389. private _activeRequests;
  40390. /** @hidden */
  40391. _pendingData: any[];
  40392. private _isDisposed;
  40393. /**
  40394. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40395. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40396. */
  40397. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40398. private _activeMeshes;
  40399. private _processedMaterials;
  40400. private _renderTargets;
  40401. /** @hidden */
  40402. _activeParticleSystems: SmartArray<IParticleSystem>;
  40403. private _activeSkeletons;
  40404. private _softwareSkinnedMeshes;
  40405. private _renderingManager;
  40406. /** @hidden */
  40407. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40408. private _transformMatrix;
  40409. private _sceneUbo;
  40410. /** @hidden */
  40411. _viewMatrix: Matrix;
  40412. private _projectionMatrix;
  40413. /** @hidden */
  40414. _forcedViewPosition: Nullable<Vector3>;
  40415. /** @hidden */
  40416. _frustumPlanes: Plane[];
  40417. /**
  40418. * Gets the list of frustum planes (built from the active camera)
  40419. */
  40420. get frustumPlanes(): Plane[];
  40421. /**
  40422. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40423. * This is useful if there are more lights that the maximum simulteanous authorized
  40424. */
  40425. requireLightSorting: boolean;
  40426. /** @hidden */
  40427. readonly useMaterialMeshMap: boolean;
  40428. /** @hidden */
  40429. readonly useClonedMeshMap: boolean;
  40430. private _externalData;
  40431. private _uid;
  40432. /**
  40433. * @hidden
  40434. * Backing store of defined scene components.
  40435. */
  40436. _components: ISceneComponent[];
  40437. /**
  40438. * @hidden
  40439. * Backing store of defined scene components.
  40440. */
  40441. _serializableComponents: ISceneSerializableComponent[];
  40442. /**
  40443. * List of components to register on the next registration step.
  40444. */
  40445. private _transientComponents;
  40446. /**
  40447. * Registers the transient components if needed.
  40448. */
  40449. private _registerTransientComponents;
  40450. /**
  40451. * @hidden
  40452. * Add a component to the scene.
  40453. * Note that the ccomponent could be registered on th next frame if this is called after
  40454. * the register component stage.
  40455. * @param component Defines the component to add to the scene
  40456. */
  40457. _addComponent(component: ISceneComponent): void;
  40458. /**
  40459. * @hidden
  40460. * Gets a component from the scene.
  40461. * @param name defines the name of the component to retrieve
  40462. * @returns the component or null if not present
  40463. */
  40464. _getComponent(name: string): Nullable<ISceneComponent>;
  40465. /**
  40466. * @hidden
  40467. * Defines the actions happening before camera updates.
  40468. */
  40469. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40470. /**
  40471. * @hidden
  40472. * Defines the actions happening before clear the canvas.
  40473. */
  40474. _beforeClearStage: Stage<SimpleStageAction>;
  40475. /**
  40476. * @hidden
  40477. * Defines the actions when collecting render targets for the frame.
  40478. */
  40479. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40480. /**
  40481. * @hidden
  40482. * Defines the actions happening for one camera in the frame.
  40483. */
  40484. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40485. /**
  40486. * @hidden
  40487. * Defines the actions happening during the per mesh ready checks.
  40488. */
  40489. _isReadyForMeshStage: Stage<MeshStageAction>;
  40490. /**
  40491. * @hidden
  40492. * Defines the actions happening before evaluate active mesh checks.
  40493. */
  40494. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40495. /**
  40496. * @hidden
  40497. * Defines the actions happening during the evaluate sub mesh checks.
  40498. */
  40499. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40500. /**
  40501. * @hidden
  40502. * Defines the actions happening during the active mesh stage.
  40503. */
  40504. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40505. /**
  40506. * @hidden
  40507. * Defines the actions happening during the per camera render target step.
  40508. */
  40509. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40510. /**
  40511. * @hidden
  40512. * Defines the actions happening just before the active camera is drawing.
  40513. */
  40514. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40515. /**
  40516. * @hidden
  40517. * Defines the actions happening just before a render target is drawing.
  40518. */
  40519. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40520. /**
  40521. * @hidden
  40522. * Defines the actions happening just before a rendering group is drawing.
  40523. */
  40524. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40525. /**
  40526. * @hidden
  40527. * Defines the actions happening just before a mesh is drawing.
  40528. */
  40529. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40530. /**
  40531. * @hidden
  40532. * Defines the actions happening just after a mesh has been drawn.
  40533. */
  40534. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40535. /**
  40536. * @hidden
  40537. * Defines the actions happening just after a rendering group has been drawn.
  40538. */
  40539. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40540. /**
  40541. * @hidden
  40542. * Defines the actions happening just after the active camera has been drawn.
  40543. */
  40544. _afterCameraDrawStage: Stage<CameraStageAction>;
  40545. /**
  40546. * @hidden
  40547. * Defines the actions happening just after a render target has been drawn.
  40548. */
  40549. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40550. /**
  40551. * @hidden
  40552. * Defines the actions happening just after rendering all cameras and computing intersections.
  40553. */
  40554. _afterRenderStage: Stage<SimpleStageAction>;
  40555. /**
  40556. * @hidden
  40557. * Defines the actions happening when a pointer move event happens.
  40558. */
  40559. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40560. /**
  40561. * @hidden
  40562. * Defines the actions happening when a pointer down event happens.
  40563. */
  40564. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40565. /**
  40566. * @hidden
  40567. * Defines the actions happening when a pointer up event happens.
  40568. */
  40569. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40570. /**
  40571. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40572. */
  40573. private geometriesByUniqueId;
  40574. /**
  40575. * Creates a new Scene
  40576. * @param engine defines the engine to use to render this scene
  40577. * @param options defines the scene options
  40578. */
  40579. constructor(engine: Engine, options?: SceneOptions);
  40580. /**
  40581. * Gets a string idenfifying the name of the class
  40582. * @returns "Scene" string
  40583. */
  40584. getClassName(): string;
  40585. private _defaultMeshCandidates;
  40586. /**
  40587. * @hidden
  40588. */
  40589. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40590. private _defaultSubMeshCandidates;
  40591. /**
  40592. * @hidden
  40593. */
  40594. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40595. /**
  40596. * Sets the default candidate providers for the scene.
  40597. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40598. * and getCollidingSubMeshCandidates to their default function
  40599. */
  40600. setDefaultCandidateProviders(): void;
  40601. /**
  40602. * Gets the mesh that is currently under the pointer
  40603. */
  40604. get meshUnderPointer(): Nullable<AbstractMesh>;
  40605. /**
  40606. * Gets or sets the current on-screen X position of the pointer
  40607. */
  40608. get pointerX(): number;
  40609. set pointerX(value: number);
  40610. /**
  40611. * Gets or sets the current on-screen Y position of the pointer
  40612. */
  40613. get pointerY(): number;
  40614. set pointerY(value: number);
  40615. /**
  40616. * Gets the cached material (ie. the latest rendered one)
  40617. * @returns the cached material
  40618. */
  40619. getCachedMaterial(): Nullable<Material>;
  40620. /**
  40621. * Gets the cached effect (ie. the latest rendered one)
  40622. * @returns the cached effect
  40623. */
  40624. getCachedEffect(): Nullable<Effect>;
  40625. /**
  40626. * Gets the cached visibility state (ie. the latest rendered one)
  40627. * @returns the cached visibility state
  40628. */
  40629. getCachedVisibility(): Nullable<number>;
  40630. /**
  40631. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40632. * @param material defines the current material
  40633. * @param effect defines the current effect
  40634. * @param visibility defines the current visibility state
  40635. * @returns true if one parameter is not cached
  40636. */
  40637. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40638. /**
  40639. * Gets the engine associated with the scene
  40640. * @returns an Engine
  40641. */
  40642. getEngine(): Engine;
  40643. /**
  40644. * Gets the total number of vertices rendered per frame
  40645. * @returns the total number of vertices rendered per frame
  40646. */
  40647. getTotalVertices(): number;
  40648. /**
  40649. * Gets the performance counter for total vertices
  40650. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40651. */
  40652. get totalVerticesPerfCounter(): PerfCounter;
  40653. /**
  40654. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40655. * @returns the total number of active indices rendered per frame
  40656. */
  40657. getActiveIndices(): number;
  40658. /**
  40659. * Gets the performance counter for active indices
  40660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40661. */
  40662. get totalActiveIndicesPerfCounter(): PerfCounter;
  40663. /**
  40664. * Gets the total number of active particles rendered per frame
  40665. * @returns the total number of active particles rendered per frame
  40666. */
  40667. getActiveParticles(): number;
  40668. /**
  40669. * Gets the performance counter for active particles
  40670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40671. */
  40672. get activeParticlesPerfCounter(): PerfCounter;
  40673. /**
  40674. * Gets the total number of active bones rendered per frame
  40675. * @returns the total number of active bones rendered per frame
  40676. */
  40677. getActiveBones(): number;
  40678. /**
  40679. * Gets the performance counter for active bones
  40680. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40681. */
  40682. get activeBonesPerfCounter(): PerfCounter;
  40683. /**
  40684. * Gets the array of active meshes
  40685. * @returns an array of AbstractMesh
  40686. */
  40687. getActiveMeshes(): SmartArray<AbstractMesh>;
  40688. /**
  40689. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40690. * @returns a number
  40691. */
  40692. getAnimationRatio(): number;
  40693. /**
  40694. * Gets an unique Id for the current render phase
  40695. * @returns a number
  40696. */
  40697. getRenderId(): number;
  40698. /**
  40699. * Gets an unique Id for the current frame
  40700. * @returns a number
  40701. */
  40702. getFrameId(): number;
  40703. /** Call this function if you want to manually increment the render Id*/
  40704. incrementRenderId(): void;
  40705. private _createUbo;
  40706. /**
  40707. * Use this method to simulate a pointer move on a mesh
  40708. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40709. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40710. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40711. * @returns the current scene
  40712. */
  40713. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40714. /**
  40715. * Use this method to simulate a pointer down on a mesh
  40716. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40717. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40718. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40719. * @returns the current scene
  40720. */
  40721. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40722. /**
  40723. * Use this method to simulate a pointer up on a mesh
  40724. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40725. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40726. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40727. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40728. * @returns the current scene
  40729. */
  40730. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40731. /**
  40732. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40733. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40734. * @returns true if the pointer was captured
  40735. */
  40736. isPointerCaptured(pointerId?: number): boolean;
  40737. /**
  40738. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40739. * @param attachUp defines if you want to attach events to pointerup
  40740. * @param attachDown defines if you want to attach events to pointerdown
  40741. * @param attachMove defines if you want to attach events to pointermove
  40742. */
  40743. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40744. /** Detaches all event handlers*/
  40745. detachControl(): void;
  40746. /**
  40747. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40748. * Delay loaded resources are not taking in account
  40749. * @return true if all required resources are ready
  40750. */
  40751. isReady(): boolean;
  40752. /** Resets all cached information relative to material (including effect and visibility) */
  40753. resetCachedMaterial(): void;
  40754. /**
  40755. * Registers a function to be called before every frame render
  40756. * @param func defines the function to register
  40757. */
  40758. registerBeforeRender(func: () => void): void;
  40759. /**
  40760. * Unregisters a function called before every frame render
  40761. * @param func defines the function to unregister
  40762. */
  40763. unregisterBeforeRender(func: () => void): void;
  40764. /**
  40765. * Registers a function to be called after every frame render
  40766. * @param func defines the function to register
  40767. */
  40768. registerAfterRender(func: () => void): void;
  40769. /**
  40770. * Unregisters a function called after every frame render
  40771. * @param func defines the function to unregister
  40772. */
  40773. unregisterAfterRender(func: () => void): void;
  40774. private _executeOnceBeforeRender;
  40775. /**
  40776. * The provided function will run before render once and will be disposed afterwards.
  40777. * A timeout delay can be provided so that the function will be executed in N ms.
  40778. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40779. * @param func The function to be executed.
  40780. * @param timeout optional delay in ms
  40781. */
  40782. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40783. /** @hidden */
  40784. _addPendingData(data: any): void;
  40785. /** @hidden */
  40786. _removePendingData(data: any): void;
  40787. /**
  40788. * Returns the number of items waiting to be loaded
  40789. * @returns the number of items waiting to be loaded
  40790. */
  40791. getWaitingItemsCount(): number;
  40792. /**
  40793. * Returns a boolean indicating if the scene is still loading data
  40794. */
  40795. get isLoading(): boolean;
  40796. /**
  40797. * Registers a function to be executed when the scene is ready
  40798. * @param {Function} func - the function to be executed
  40799. */
  40800. executeWhenReady(func: () => void): void;
  40801. /**
  40802. * Returns a promise that resolves when the scene is ready
  40803. * @returns A promise that resolves when the scene is ready
  40804. */
  40805. whenReadyAsync(): Promise<void>;
  40806. /** @hidden */
  40807. _checkIsReady(): void;
  40808. /**
  40809. * Gets all animatable attached to the scene
  40810. */
  40811. get animatables(): Animatable[];
  40812. /**
  40813. * Resets the last animation time frame.
  40814. * Useful to override when animations start running when loading a scene for the first time.
  40815. */
  40816. resetLastAnimationTimeFrame(): void;
  40817. /**
  40818. * Gets the current view matrix
  40819. * @returns a Matrix
  40820. */
  40821. getViewMatrix(): Matrix;
  40822. /**
  40823. * Gets the current projection matrix
  40824. * @returns a Matrix
  40825. */
  40826. getProjectionMatrix(): Matrix;
  40827. /**
  40828. * Gets the current transform matrix
  40829. * @returns a Matrix made of View * Projection
  40830. */
  40831. getTransformMatrix(): Matrix;
  40832. /**
  40833. * Sets the current transform matrix
  40834. * @param viewL defines the View matrix to use
  40835. * @param projectionL defines the Projection matrix to use
  40836. * @param viewR defines the right View matrix to use (if provided)
  40837. * @param projectionR defines the right Projection matrix to use (if provided)
  40838. */
  40839. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40840. /**
  40841. * Gets the uniform buffer used to store scene data
  40842. * @returns a UniformBuffer
  40843. */
  40844. getSceneUniformBuffer(): UniformBuffer;
  40845. /**
  40846. * Gets an unique (relatively to the current scene) Id
  40847. * @returns an unique number for the scene
  40848. */
  40849. getUniqueId(): number;
  40850. /**
  40851. * Add a mesh to the list of scene's meshes
  40852. * @param newMesh defines the mesh to add
  40853. * @param recursive if all child meshes should also be added to the scene
  40854. */
  40855. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40856. /**
  40857. * Remove a mesh for the list of scene's meshes
  40858. * @param toRemove defines the mesh to remove
  40859. * @param recursive if all child meshes should also be removed from the scene
  40860. * @returns the index where the mesh was in the mesh list
  40861. */
  40862. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40863. /**
  40864. * Add a transform node to the list of scene's transform nodes
  40865. * @param newTransformNode defines the transform node to add
  40866. */
  40867. addTransformNode(newTransformNode: TransformNode): void;
  40868. /**
  40869. * Remove a transform node for the list of scene's transform nodes
  40870. * @param toRemove defines the transform node to remove
  40871. * @returns the index where the transform node was in the transform node list
  40872. */
  40873. removeTransformNode(toRemove: TransformNode): number;
  40874. /**
  40875. * Remove a skeleton for the list of scene's skeletons
  40876. * @param toRemove defines the skeleton to remove
  40877. * @returns the index where the skeleton was in the skeleton list
  40878. */
  40879. removeSkeleton(toRemove: Skeleton): number;
  40880. /**
  40881. * Remove a morph target for the list of scene's morph targets
  40882. * @param toRemove defines the morph target to remove
  40883. * @returns the index where the morph target was in the morph target list
  40884. */
  40885. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40886. /**
  40887. * Remove a light for the list of scene's lights
  40888. * @param toRemove defines the light to remove
  40889. * @returns the index where the light was in the light list
  40890. */
  40891. removeLight(toRemove: Light): number;
  40892. /**
  40893. * Remove a camera for the list of scene's cameras
  40894. * @param toRemove defines the camera to remove
  40895. * @returns the index where the camera was in the camera list
  40896. */
  40897. removeCamera(toRemove: Camera): number;
  40898. /**
  40899. * Remove a particle system for the list of scene's particle systems
  40900. * @param toRemove defines the particle system to remove
  40901. * @returns the index where the particle system was in the particle system list
  40902. */
  40903. removeParticleSystem(toRemove: IParticleSystem): number;
  40904. /**
  40905. * Remove a animation for the list of scene's animations
  40906. * @param toRemove defines the animation to remove
  40907. * @returns the index where the animation was in the animation list
  40908. */
  40909. removeAnimation(toRemove: Animation): number;
  40910. /**
  40911. * Will stop the animation of the given target
  40912. * @param target - the target
  40913. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40914. * @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)
  40915. */
  40916. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40917. /**
  40918. * Removes the given animation group from this scene.
  40919. * @param toRemove The animation group to remove
  40920. * @returns The index of the removed animation group
  40921. */
  40922. removeAnimationGroup(toRemove: AnimationGroup): number;
  40923. /**
  40924. * Removes the given multi-material from this scene.
  40925. * @param toRemove The multi-material to remove
  40926. * @returns The index of the removed multi-material
  40927. */
  40928. removeMultiMaterial(toRemove: MultiMaterial): number;
  40929. /**
  40930. * Removes the given material from this scene.
  40931. * @param toRemove The material to remove
  40932. * @returns The index of the removed material
  40933. */
  40934. removeMaterial(toRemove: Material): number;
  40935. /**
  40936. * Removes the given action manager from this scene.
  40937. * @param toRemove The action manager to remove
  40938. * @returns The index of the removed action manager
  40939. */
  40940. removeActionManager(toRemove: AbstractActionManager): number;
  40941. /**
  40942. * Removes the given texture from this scene.
  40943. * @param toRemove The texture to remove
  40944. * @returns The index of the removed texture
  40945. */
  40946. removeTexture(toRemove: BaseTexture): number;
  40947. /**
  40948. * Adds the given light to this scene
  40949. * @param newLight The light to add
  40950. */
  40951. addLight(newLight: Light): void;
  40952. /**
  40953. * Sorts the list list based on light priorities
  40954. */
  40955. sortLightsByPriority(): void;
  40956. /**
  40957. * Adds the given camera to this scene
  40958. * @param newCamera The camera to add
  40959. */
  40960. addCamera(newCamera: Camera): void;
  40961. /**
  40962. * Adds the given skeleton to this scene
  40963. * @param newSkeleton The skeleton to add
  40964. */
  40965. addSkeleton(newSkeleton: Skeleton): void;
  40966. /**
  40967. * Adds the given particle system to this scene
  40968. * @param newParticleSystem The particle system to add
  40969. */
  40970. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40971. /**
  40972. * Adds the given animation to this scene
  40973. * @param newAnimation The animation to add
  40974. */
  40975. addAnimation(newAnimation: Animation): void;
  40976. /**
  40977. * Adds the given animation group to this scene.
  40978. * @param newAnimationGroup The animation group to add
  40979. */
  40980. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40981. /**
  40982. * Adds the given multi-material to this scene
  40983. * @param newMultiMaterial The multi-material to add
  40984. */
  40985. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40986. /**
  40987. * Adds the given material to this scene
  40988. * @param newMaterial The material to add
  40989. */
  40990. addMaterial(newMaterial: Material): void;
  40991. /**
  40992. * Adds the given morph target to this scene
  40993. * @param newMorphTargetManager The morph target to add
  40994. */
  40995. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40996. /**
  40997. * Adds the given geometry to this scene
  40998. * @param newGeometry The geometry to add
  40999. */
  41000. addGeometry(newGeometry: Geometry): void;
  41001. /**
  41002. * Adds the given action manager to this scene
  41003. * @param newActionManager The action manager to add
  41004. */
  41005. addActionManager(newActionManager: AbstractActionManager): void;
  41006. /**
  41007. * Adds the given texture to this scene.
  41008. * @param newTexture The texture to add
  41009. */
  41010. addTexture(newTexture: BaseTexture): void;
  41011. /**
  41012. * Switch active camera
  41013. * @param newCamera defines the new active camera
  41014. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41015. */
  41016. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41017. /**
  41018. * sets the active camera of the scene using its ID
  41019. * @param id defines the camera's ID
  41020. * @return the new active camera or null if none found.
  41021. */
  41022. setActiveCameraByID(id: string): Nullable<Camera>;
  41023. /**
  41024. * sets the active camera of the scene using its name
  41025. * @param name defines the camera's name
  41026. * @returns the new active camera or null if none found.
  41027. */
  41028. setActiveCameraByName(name: string): Nullable<Camera>;
  41029. /**
  41030. * get an animation group using its name
  41031. * @param name defines the material's name
  41032. * @return the animation group or null if none found.
  41033. */
  41034. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41035. /**
  41036. * Get a material using its unique id
  41037. * @param uniqueId defines the material's unique id
  41038. * @return the material or null if none found.
  41039. */
  41040. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41041. /**
  41042. * get a material using its id
  41043. * @param id defines the material's ID
  41044. * @return the material or null if none found.
  41045. */
  41046. getMaterialByID(id: string): Nullable<Material>;
  41047. /**
  41048. * Gets a the last added material using a given id
  41049. * @param id defines the material's ID
  41050. * @return the last material with the given id or null if none found.
  41051. */
  41052. getLastMaterialByID(id: string): Nullable<Material>;
  41053. /**
  41054. * Gets a material using its name
  41055. * @param name defines the material's name
  41056. * @return the material or null if none found.
  41057. */
  41058. getMaterialByName(name: string): Nullable<Material>;
  41059. /**
  41060. * Get a texture using its unique id
  41061. * @param uniqueId defines the texture's unique id
  41062. * @return the texture or null if none found.
  41063. */
  41064. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41065. /**
  41066. * Gets a camera using its id
  41067. * @param id defines the id to look for
  41068. * @returns the camera or null if not found
  41069. */
  41070. getCameraByID(id: string): Nullable<Camera>;
  41071. /**
  41072. * Gets a camera using its unique id
  41073. * @param uniqueId defines the unique id to look for
  41074. * @returns the camera or null if not found
  41075. */
  41076. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41077. /**
  41078. * Gets a camera using its name
  41079. * @param name defines the camera's name
  41080. * @return the camera or null if none found.
  41081. */
  41082. getCameraByName(name: string): Nullable<Camera>;
  41083. /**
  41084. * Gets a bone using its id
  41085. * @param id defines the bone's id
  41086. * @return the bone or null if not found
  41087. */
  41088. getBoneByID(id: string): Nullable<Bone>;
  41089. /**
  41090. * Gets a bone using its id
  41091. * @param name defines the bone's name
  41092. * @return the bone or null if not found
  41093. */
  41094. getBoneByName(name: string): Nullable<Bone>;
  41095. /**
  41096. * Gets a light node using its name
  41097. * @param name defines the the light's name
  41098. * @return the light or null if none found.
  41099. */
  41100. getLightByName(name: string): Nullable<Light>;
  41101. /**
  41102. * Gets a light node using its id
  41103. * @param id defines the light's id
  41104. * @return the light or null if none found.
  41105. */
  41106. getLightByID(id: string): Nullable<Light>;
  41107. /**
  41108. * Gets a light node using its scene-generated unique ID
  41109. * @param uniqueId defines the light's unique id
  41110. * @return the light or null if none found.
  41111. */
  41112. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41113. /**
  41114. * Gets a particle system by id
  41115. * @param id defines the particle system id
  41116. * @return the corresponding system or null if none found
  41117. */
  41118. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41119. /**
  41120. * Gets a geometry using its ID
  41121. * @param id defines the geometry's id
  41122. * @return the geometry or null if none found.
  41123. */
  41124. getGeometryByID(id: string): Nullable<Geometry>;
  41125. private _getGeometryByUniqueID;
  41126. /**
  41127. * Add a new geometry to this scene
  41128. * @param geometry defines the geometry to be added to the scene.
  41129. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41130. * @return a boolean defining if the geometry was added or not
  41131. */
  41132. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41133. /**
  41134. * Removes an existing geometry
  41135. * @param geometry defines the geometry to be removed from the scene
  41136. * @return a boolean defining if the geometry was removed or not
  41137. */
  41138. removeGeometry(geometry: Geometry): boolean;
  41139. /**
  41140. * Gets the list of geometries attached to the scene
  41141. * @returns an array of Geometry
  41142. */
  41143. getGeometries(): Geometry[];
  41144. /**
  41145. * Gets the first added mesh found of a given ID
  41146. * @param id defines the id to search for
  41147. * @return the mesh found or null if not found at all
  41148. */
  41149. getMeshByID(id: string): Nullable<AbstractMesh>;
  41150. /**
  41151. * Gets a list of meshes using their id
  41152. * @param id defines the id to search for
  41153. * @returns a list of meshes
  41154. */
  41155. getMeshesByID(id: string): Array<AbstractMesh>;
  41156. /**
  41157. * Gets the first added transform node found of a given ID
  41158. * @param id defines the id to search for
  41159. * @return the found transform node or null if not found at all.
  41160. */
  41161. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41162. /**
  41163. * Gets a transform node with its auto-generated unique id
  41164. * @param uniqueId efines the unique id to search for
  41165. * @return the found transform node or null if not found at all.
  41166. */
  41167. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41168. /**
  41169. * Gets a list of transform nodes using their id
  41170. * @param id defines the id to search for
  41171. * @returns a list of transform nodes
  41172. */
  41173. getTransformNodesByID(id: string): Array<TransformNode>;
  41174. /**
  41175. * Gets a mesh with its auto-generated unique id
  41176. * @param uniqueId defines the unique id to search for
  41177. * @return the found mesh or null if not found at all.
  41178. */
  41179. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41180. /**
  41181. * Gets a the last added mesh using a given id
  41182. * @param id defines the id to search for
  41183. * @return the found mesh or null if not found at all.
  41184. */
  41185. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41186. /**
  41187. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41188. * @param id defines the id to search for
  41189. * @return the found node or null if not found at all
  41190. */
  41191. getLastEntryByID(id: string): Nullable<Node>;
  41192. /**
  41193. * Gets a node (Mesh, Camera, Light) using a given id
  41194. * @param id defines the id to search for
  41195. * @return the found node or null if not found at all
  41196. */
  41197. getNodeByID(id: string): Nullable<Node>;
  41198. /**
  41199. * Gets a node (Mesh, Camera, Light) using a given name
  41200. * @param name defines the name to search for
  41201. * @return the found node or null if not found at all.
  41202. */
  41203. getNodeByName(name: string): Nullable<Node>;
  41204. /**
  41205. * Gets a mesh using a given name
  41206. * @param name defines the name to search for
  41207. * @return the found mesh or null if not found at all.
  41208. */
  41209. getMeshByName(name: string): Nullable<AbstractMesh>;
  41210. /**
  41211. * Gets a transform node using a given name
  41212. * @param name defines the name to search for
  41213. * @return the found transform node or null if not found at all.
  41214. */
  41215. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41216. /**
  41217. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41218. * @param id defines the id to search for
  41219. * @return the found skeleton or null if not found at all.
  41220. */
  41221. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41222. /**
  41223. * Gets a skeleton using a given auto generated unique id
  41224. * @param uniqueId defines the unique id to search for
  41225. * @return the found skeleton or null if not found at all.
  41226. */
  41227. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41228. /**
  41229. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41230. * @param id defines the id to search for
  41231. * @return the found skeleton or null if not found at all.
  41232. */
  41233. getSkeletonById(id: string): Nullable<Skeleton>;
  41234. /**
  41235. * Gets a skeleton using a given name
  41236. * @param name defines the name to search for
  41237. * @return the found skeleton or null if not found at all.
  41238. */
  41239. getSkeletonByName(name: string): Nullable<Skeleton>;
  41240. /**
  41241. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41242. * @param id defines the id to search for
  41243. * @return the found morph target manager or null if not found at all.
  41244. */
  41245. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41246. /**
  41247. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41248. * @param id defines the id to search for
  41249. * @return the found morph target or null if not found at all.
  41250. */
  41251. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41252. /**
  41253. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41254. * @param name defines the name to search for
  41255. * @return the found morph target or null if not found at all.
  41256. */
  41257. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41258. /**
  41259. * Gets a boolean indicating if the given mesh is active
  41260. * @param mesh defines the mesh to look for
  41261. * @returns true if the mesh is in the active list
  41262. */
  41263. isActiveMesh(mesh: AbstractMesh): boolean;
  41264. /**
  41265. * Return a unique id as a string which can serve as an identifier for the scene
  41266. */
  41267. get uid(): string;
  41268. /**
  41269. * Add an externaly attached data from its key.
  41270. * This method call will fail and return false, if such key already exists.
  41271. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41272. * @param key the unique key that identifies the data
  41273. * @param data the data object to associate to the key for this Engine instance
  41274. * @return true if no such key were already present and the data was added successfully, false otherwise
  41275. */
  41276. addExternalData<T>(key: string, data: T): boolean;
  41277. /**
  41278. * Get an externaly attached data from its key
  41279. * @param key the unique key that identifies the data
  41280. * @return the associated data, if present (can be null), or undefined if not present
  41281. */
  41282. getExternalData<T>(key: string): Nullable<T>;
  41283. /**
  41284. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41285. * @param key the unique key that identifies the data
  41286. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41287. * @return the associated data, can be null if the factory returned null.
  41288. */
  41289. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41290. /**
  41291. * Remove an externaly attached data from the Engine instance
  41292. * @param key the unique key that identifies the data
  41293. * @return true if the data was successfully removed, false if it doesn't exist
  41294. */
  41295. removeExternalData(key: string): boolean;
  41296. private _evaluateSubMesh;
  41297. /**
  41298. * Clear the processed materials smart array preventing retention point in material dispose.
  41299. */
  41300. freeProcessedMaterials(): void;
  41301. private _preventFreeActiveMeshesAndRenderingGroups;
  41302. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41303. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41304. * when disposing several meshes in a row or a hierarchy of meshes.
  41305. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41306. */
  41307. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41308. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41309. /**
  41310. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41311. */
  41312. freeActiveMeshes(): void;
  41313. /**
  41314. * Clear the info related to rendering groups preventing retention points during dispose.
  41315. */
  41316. freeRenderingGroups(): void;
  41317. /** @hidden */
  41318. _isInIntermediateRendering(): boolean;
  41319. /**
  41320. * Lambda returning the list of potentially active meshes.
  41321. */
  41322. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41323. /**
  41324. * Lambda returning the list of potentially active sub meshes.
  41325. */
  41326. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41327. /**
  41328. * Lambda returning the list of potentially intersecting sub meshes.
  41329. */
  41330. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41331. /**
  41332. * Lambda returning the list of potentially colliding sub meshes.
  41333. */
  41334. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41335. private _activeMeshesFrozen;
  41336. private _skipEvaluateActiveMeshesCompletely;
  41337. /**
  41338. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41339. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41340. * @returns the current scene
  41341. */
  41342. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41343. /**
  41344. * Use this function to restart evaluating active meshes on every frame
  41345. * @returns the current scene
  41346. */
  41347. unfreezeActiveMeshes(): Scene;
  41348. private _evaluateActiveMeshes;
  41349. private _activeMesh;
  41350. /**
  41351. * Update the transform matrix to update from the current active camera
  41352. * @param force defines a boolean used to force the update even if cache is up to date
  41353. */
  41354. updateTransformMatrix(force?: boolean): void;
  41355. private _bindFrameBuffer;
  41356. /** @hidden */
  41357. _allowPostProcessClearColor: boolean;
  41358. /** @hidden */
  41359. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41360. private _processSubCameras;
  41361. private _checkIntersections;
  41362. /** @hidden */
  41363. _advancePhysicsEngineStep(step: number): void;
  41364. /**
  41365. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41366. */
  41367. getDeterministicFrameTime: () => number;
  41368. /** @hidden */
  41369. _animate(): void;
  41370. /** Execute all animations (for a frame) */
  41371. animate(): void;
  41372. /**
  41373. * Render the scene
  41374. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41375. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41376. */
  41377. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41378. /**
  41379. * Freeze all materials
  41380. * A frozen material will not be updatable but should be faster to render
  41381. */
  41382. freezeMaterials(): void;
  41383. /**
  41384. * Unfreeze all materials
  41385. * A frozen material will not be updatable but should be faster to render
  41386. */
  41387. unfreezeMaterials(): void;
  41388. /**
  41389. * Releases all held ressources
  41390. */
  41391. dispose(): void;
  41392. /**
  41393. * Gets if the scene is already disposed
  41394. */
  41395. get isDisposed(): boolean;
  41396. /**
  41397. * Call this function to reduce memory footprint of the scene.
  41398. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41399. */
  41400. clearCachedVertexData(): void;
  41401. /**
  41402. * This function will remove the local cached buffer data from texture.
  41403. * It will save memory but will prevent the texture from being rebuilt
  41404. */
  41405. cleanCachedTextureBuffer(): void;
  41406. /**
  41407. * Get the world extend vectors with an optional filter
  41408. *
  41409. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41410. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41411. */
  41412. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41413. min: Vector3;
  41414. max: Vector3;
  41415. };
  41416. /**
  41417. * Creates a ray that can be used to pick in the scene
  41418. * @param x defines the x coordinate of the origin (on-screen)
  41419. * @param y defines the y coordinate of the origin (on-screen)
  41420. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41421. * @param camera defines the camera to use for the picking
  41422. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41423. * @returns a Ray
  41424. */
  41425. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41426. /**
  41427. * Creates a ray that can be used to pick in the scene
  41428. * @param x defines the x coordinate of the origin (on-screen)
  41429. * @param y defines the y coordinate of the origin (on-screen)
  41430. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41431. * @param result defines the ray where to store the picking ray
  41432. * @param camera defines the camera to use for the picking
  41433. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41434. * @returns the current scene
  41435. */
  41436. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41437. /**
  41438. * Creates a ray that can be used to pick in the scene
  41439. * @param x defines the x coordinate of the origin (on-screen)
  41440. * @param y defines the y coordinate of the origin (on-screen)
  41441. * @param camera defines the camera to use for the picking
  41442. * @returns a Ray
  41443. */
  41444. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41445. /**
  41446. * Creates a ray that can be used to pick in the scene
  41447. * @param x defines the x coordinate of the origin (on-screen)
  41448. * @param y defines the y coordinate of the origin (on-screen)
  41449. * @param result defines the ray where to store the picking ray
  41450. * @param camera defines the camera to use for the picking
  41451. * @returns the current scene
  41452. */
  41453. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41454. /** Launch a ray to try to pick a mesh in the scene
  41455. * @param x position on screen
  41456. * @param y position on screen
  41457. * @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
  41458. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41459. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41461. * @returns a PickingInfo
  41462. */
  41463. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41464. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41465. * @param x position on screen
  41466. * @param y position on screen
  41467. * @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
  41468. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41469. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41470. * @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)
  41471. */
  41472. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41473. /** Use the given ray to pick a mesh in the scene
  41474. * @param ray The ray to use to pick meshes
  41475. * @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
  41476. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41477. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41478. * @returns a PickingInfo
  41479. */
  41480. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41481. /**
  41482. * Launch a ray to try to pick a mesh in the scene
  41483. * @param x X position on screen
  41484. * @param y Y position on screen
  41485. * @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
  41486. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41487. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41488. * @returns an array of PickingInfo
  41489. */
  41490. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41491. /**
  41492. * Launch a ray to try to pick a mesh in the scene
  41493. * @param ray Ray to use
  41494. * @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
  41495. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41496. * @returns an array of PickingInfo
  41497. */
  41498. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41499. /**
  41500. * Force the value of meshUnderPointer
  41501. * @param mesh defines the mesh to use
  41502. */
  41503. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41504. /**
  41505. * Gets the mesh under the pointer
  41506. * @returns a Mesh or null if no mesh is under the pointer
  41507. */
  41508. getPointerOverMesh(): Nullable<AbstractMesh>;
  41509. /** @hidden */
  41510. _rebuildGeometries(): void;
  41511. /** @hidden */
  41512. _rebuildTextures(): void;
  41513. private _getByTags;
  41514. /**
  41515. * Get a list of meshes by tags
  41516. * @param tagsQuery defines the tags query to use
  41517. * @param forEach defines a predicate used to filter results
  41518. * @returns an array of Mesh
  41519. */
  41520. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41521. /**
  41522. * Get a list of cameras by tags
  41523. * @param tagsQuery defines the tags query to use
  41524. * @param forEach defines a predicate used to filter results
  41525. * @returns an array of Camera
  41526. */
  41527. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41528. /**
  41529. * Get a list of lights by tags
  41530. * @param tagsQuery defines the tags query to use
  41531. * @param forEach defines a predicate used to filter results
  41532. * @returns an array of Light
  41533. */
  41534. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41535. /**
  41536. * Get a list of materials by tags
  41537. * @param tagsQuery defines the tags query to use
  41538. * @param forEach defines a predicate used to filter results
  41539. * @returns an array of Material
  41540. */
  41541. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41542. /**
  41543. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41544. * This allowed control for front to back rendering or reversly depending of the special needs.
  41545. *
  41546. * @param renderingGroupId The rendering group id corresponding to its index
  41547. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41548. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41549. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41550. */
  41551. 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;
  41552. /**
  41553. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41554. *
  41555. * @param renderingGroupId The rendering group id corresponding to its index
  41556. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41557. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41558. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41559. */
  41560. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41561. /**
  41562. * Gets the current auto clear configuration for one rendering group of the rendering
  41563. * manager.
  41564. * @param index the rendering group index to get the information for
  41565. * @returns The auto clear setup for the requested rendering group
  41566. */
  41567. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41568. private _blockMaterialDirtyMechanism;
  41569. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41570. get blockMaterialDirtyMechanism(): boolean;
  41571. set blockMaterialDirtyMechanism(value: boolean);
  41572. /**
  41573. * Will flag all materials as dirty to trigger new shader compilation
  41574. * @param flag defines the flag used to specify which material part must be marked as dirty
  41575. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41576. */
  41577. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41578. /** @hidden */
  41579. _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;
  41580. /** @hidden */
  41581. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41582. /** @hidden */
  41583. _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;
  41584. /** @hidden */
  41585. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41586. /** @hidden */
  41587. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41588. /** @hidden */
  41589. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41590. }
  41591. }
  41592. declare module "babylonjs/assetContainer" {
  41593. import { AbstractScene } from "babylonjs/abstractScene";
  41594. import { Scene } from "babylonjs/scene";
  41595. import { Mesh } from "babylonjs/Meshes/mesh";
  41596. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41597. import { Skeleton } from "babylonjs/Bones/skeleton";
  41598. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41599. import { Animatable } from "babylonjs/Animations/animatable";
  41600. import { Nullable } from "babylonjs/types";
  41601. import { Node } from "babylonjs/node";
  41602. /**
  41603. * Set of assets to keep when moving a scene into an asset container.
  41604. */
  41605. export class KeepAssets extends AbstractScene {
  41606. }
  41607. /**
  41608. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41609. */
  41610. export class InstantiatedEntries {
  41611. /**
  41612. * List of new root nodes (eg. nodes with no parent)
  41613. */
  41614. rootNodes: TransformNode[];
  41615. /**
  41616. * List of new skeletons
  41617. */
  41618. skeletons: Skeleton[];
  41619. /**
  41620. * List of new animation groups
  41621. */
  41622. animationGroups: AnimationGroup[];
  41623. }
  41624. /**
  41625. * Container with a set of assets that can be added or removed from a scene.
  41626. */
  41627. export class AssetContainer extends AbstractScene {
  41628. private _wasAddedToScene;
  41629. /**
  41630. * The scene the AssetContainer belongs to.
  41631. */
  41632. scene: Scene;
  41633. /**
  41634. * Instantiates an AssetContainer.
  41635. * @param scene The scene the AssetContainer belongs to.
  41636. */
  41637. constructor(scene: Scene);
  41638. /**
  41639. * Instantiate or clone all meshes and add the new ones to the scene.
  41640. * Skeletons and animation groups will all be cloned
  41641. * @param nameFunction defines an optional function used to get new names for clones
  41642. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41643. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41644. */
  41645. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41646. /**
  41647. * Adds all the assets from the container to the scene.
  41648. */
  41649. addAllToScene(): void;
  41650. /**
  41651. * Removes all the assets in the container from the scene
  41652. */
  41653. removeAllFromScene(): void;
  41654. /**
  41655. * Disposes all the assets in the container
  41656. */
  41657. dispose(): void;
  41658. private _moveAssets;
  41659. /**
  41660. * Removes all the assets contained in the scene and adds them to the container.
  41661. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41662. */
  41663. moveAllFromScene(keepAssets?: KeepAssets): void;
  41664. /**
  41665. * 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.
  41666. * @returns the root mesh
  41667. */
  41668. createRootMesh(): Mesh;
  41669. /**
  41670. * Merge animations (direct and animation groups) from this asset container into a scene
  41671. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41672. * @param animatables set of animatables to retarget to a node from the scene
  41673. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41674. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41675. */
  41676. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41677. }
  41678. }
  41679. declare module "babylonjs/abstractScene" {
  41680. import { Scene } from "babylonjs/scene";
  41681. import { Nullable } from "babylonjs/types";
  41682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41683. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41684. import { Geometry } from "babylonjs/Meshes/geometry";
  41685. import { Skeleton } from "babylonjs/Bones/skeleton";
  41686. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41687. import { AssetContainer } from "babylonjs/assetContainer";
  41688. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41689. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41690. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41691. import { Material } from "babylonjs/Materials/material";
  41692. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41693. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41694. import { Camera } from "babylonjs/Cameras/camera";
  41695. import { Light } from "babylonjs/Lights/light";
  41696. import { Node } from "babylonjs/node";
  41697. import { Animation } from "babylonjs/Animations/animation";
  41698. /**
  41699. * Defines how the parser contract is defined.
  41700. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41701. */
  41702. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41703. /**
  41704. * Defines how the individual parser contract is defined.
  41705. * These parser can parse an individual asset
  41706. */
  41707. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41708. /**
  41709. * Base class of the scene acting as a container for the different elements composing a scene.
  41710. * This class is dynamically extended by the different components of the scene increasing
  41711. * flexibility and reducing coupling
  41712. */
  41713. export abstract class AbstractScene {
  41714. /**
  41715. * Stores the list of available parsers in the application.
  41716. */
  41717. private static _BabylonFileParsers;
  41718. /**
  41719. * Stores the list of available individual parsers in the application.
  41720. */
  41721. private static _IndividualBabylonFileParsers;
  41722. /**
  41723. * Adds a parser in the list of available ones
  41724. * @param name Defines the name of the parser
  41725. * @param parser Defines the parser to add
  41726. */
  41727. static AddParser(name: string, parser: BabylonFileParser): void;
  41728. /**
  41729. * Gets a general parser from the list of avaialble ones
  41730. * @param name Defines the name of the parser
  41731. * @returns the requested parser or null
  41732. */
  41733. static GetParser(name: string): Nullable<BabylonFileParser>;
  41734. /**
  41735. * Adds n individual parser in the list of available ones
  41736. * @param name Defines the name of the parser
  41737. * @param parser Defines the parser to add
  41738. */
  41739. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41740. /**
  41741. * Gets an individual parser from the list of avaialble ones
  41742. * @param name Defines the name of the parser
  41743. * @returns the requested parser or null
  41744. */
  41745. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41746. /**
  41747. * Parser json data and populate both a scene and its associated container object
  41748. * @param jsonData Defines the data to parse
  41749. * @param scene Defines the scene to parse the data for
  41750. * @param container Defines the container attached to the parsing sequence
  41751. * @param rootUrl Defines the root url of the data
  41752. */
  41753. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41754. /**
  41755. * Gets the list of root nodes (ie. nodes with no parent)
  41756. */
  41757. rootNodes: Node[];
  41758. /** All of the cameras added to this scene
  41759. * @see http://doc.babylonjs.com/babylon101/cameras
  41760. */
  41761. cameras: Camera[];
  41762. /**
  41763. * All of the lights added to this scene
  41764. * @see http://doc.babylonjs.com/babylon101/lights
  41765. */
  41766. lights: Light[];
  41767. /**
  41768. * All of the (abstract) meshes added to this scene
  41769. */
  41770. meshes: AbstractMesh[];
  41771. /**
  41772. * The list of skeletons added to the scene
  41773. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41774. */
  41775. skeletons: Skeleton[];
  41776. /**
  41777. * All of the particle systems added to this scene
  41778. * @see http://doc.babylonjs.com/babylon101/particles
  41779. */
  41780. particleSystems: IParticleSystem[];
  41781. /**
  41782. * Gets a list of Animations associated with the scene
  41783. */
  41784. animations: Animation[];
  41785. /**
  41786. * All of the animation groups added to this scene
  41787. * @see http://doc.babylonjs.com/how_to/group
  41788. */
  41789. animationGroups: AnimationGroup[];
  41790. /**
  41791. * All of the multi-materials added to this scene
  41792. * @see http://doc.babylonjs.com/how_to/multi_materials
  41793. */
  41794. multiMaterials: MultiMaterial[];
  41795. /**
  41796. * All of the materials added to this scene
  41797. * In the context of a Scene, it is not supposed to be modified manually.
  41798. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41799. * Note also that the order of the Material within the array is not significant and might change.
  41800. * @see http://doc.babylonjs.com/babylon101/materials
  41801. */
  41802. materials: Material[];
  41803. /**
  41804. * The list of morph target managers added to the scene
  41805. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41806. */
  41807. morphTargetManagers: MorphTargetManager[];
  41808. /**
  41809. * The list of geometries used in the scene.
  41810. */
  41811. geometries: Geometry[];
  41812. /**
  41813. * All of the tranform nodes added to this scene
  41814. * In the context of a Scene, it is not supposed to be modified manually.
  41815. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41816. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41817. * @see http://doc.babylonjs.com/how_to/transformnode
  41818. */
  41819. transformNodes: TransformNode[];
  41820. /**
  41821. * ActionManagers available on the scene.
  41822. */
  41823. actionManagers: AbstractActionManager[];
  41824. /**
  41825. * Textures to keep.
  41826. */
  41827. textures: BaseTexture[];
  41828. /**
  41829. * Environment texture for the scene
  41830. */
  41831. environmentTexture: Nullable<BaseTexture>;
  41832. /**
  41833. * @returns all meshes, lights, cameras, transformNodes and bones
  41834. */
  41835. getNodes(): Array<Node>;
  41836. }
  41837. }
  41838. declare module "babylonjs/Audio/sound" {
  41839. import { Observable } from "babylonjs/Misc/observable";
  41840. import { Vector3 } from "babylonjs/Maths/math.vector";
  41841. import { Nullable } from "babylonjs/types";
  41842. import { Scene } from "babylonjs/scene";
  41843. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41844. /**
  41845. * Interface used to define options for Sound class
  41846. */
  41847. export interface ISoundOptions {
  41848. /**
  41849. * Does the sound autoplay once loaded.
  41850. */
  41851. autoplay?: boolean;
  41852. /**
  41853. * Does the sound loop after it finishes playing once.
  41854. */
  41855. loop?: boolean;
  41856. /**
  41857. * Sound's volume
  41858. */
  41859. volume?: number;
  41860. /**
  41861. * Is it a spatial sound?
  41862. */
  41863. spatialSound?: boolean;
  41864. /**
  41865. * Maximum distance to hear that sound
  41866. */
  41867. maxDistance?: number;
  41868. /**
  41869. * Uses user defined attenuation function
  41870. */
  41871. useCustomAttenuation?: boolean;
  41872. /**
  41873. * Define the roll off factor of spatial sounds.
  41874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41875. */
  41876. rolloffFactor?: number;
  41877. /**
  41878. * Define the reference distance the sound should be heard perfectly.
  41879. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41880. */
  41881. refDistance?: number;
  41882. /**
  41883. * Define the distance attenuation model the sound will follow.
  41884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41885. */
  41886. distanceModel?: string;
  41887. /**
  41888. * Defines the playback speed (1 by default)
  41889. */
  41890. playbackRate?: number;
  41891. /**
  41892. * Defines if the sound is from a streaming source
  41893. */
  41894. streaming?: boolean;
  41895. /**
  41896. * Defines an optional length (in seconds) inside the sound file
  41897. */
  41898. length?: number;
  41899. /**
  41900. * Defines an optional offset (in seconds) inside the sound file
  41901. */
  41902. offset?: number;
  41903. /**
  41904. * If true, URLs will not be required to state the audio file codec to use.
  41905. */
  41906. skipCodecCheck?: boolean;
  41907. }
  41908. /**
  41909. * Defines a sound that can be played in the application.
  41910. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41912. */
  41913. export class Sound {
  41914. /**
  41915. * The name of the sound in the scene.
  41916. */
  41917. name: string;
  41918. /**
  41919. * Does the sound autoplay once loaded.
  41920. */
  41921. autoplay: boolean;
  41922. /**
  41923. * Does the sound loop after it finishes playing once.
  41924. */
  41925. loop: boolean;
  41926. /**
  41927. * Does the sound use a custom attenuation curve to simulate the falloff
  41928. * happening when the source gets further away from the camera.
  41929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41930. */
  41931. useCustomAttenuation: boolean;
  41932. /**
  41933. * The sound track id this sound belongs to.
  41934. */
  41935. soundTrackId: number;
  41936. /**
  41937. * Is this sound currently played.
  41938. */
  41939. isPlaying: boolean;
  41940. /**
  41941. * Is this sound currently paused.
  41942. */
  41943. isPaused: boolean;
  41944. /**
  41945. * Does this sound enables spatial sound.
  41946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41947. */
  41948. spatialSound: boolean;
  41949. /**
  41950. * Define the reference distance the sound should be heard perfectly.
  41951. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41952. */
  41953. refDistance: number;
  41954. /**
  41955. * Define the roll off factor of spatial sounds.
  41956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41957. */
  41958. rolloffFactor: number;
  41959. /**
  41960. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41962. */
  41963. maxDistance: number;
  41964. /**
  41965. * Define the distance attenuation model the sound will follow.
  41966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41967. */
  41968. distanceModel: string;
  41969. /**
  41970. * @hidden
  41971. * Back Compat
  41972. **/
  41973. onended: () => any;
  41974. /**
  41975. * Gets or sets an object used to store user defined information for the sound.
  41976. */
  41977. metadata: any;
  41978. /**
  41979. * Observable event when the current playing sound finishes.
  41980. */
  41981. onEndedObservable: Observable<Sound>;
  41982. private _panningModel;
  41983. private _playbackRate;
  41984. private _streaming;
  41985. private _startTime;
  41986. private _startOffset;
  41987. private _position;
  41988. /** @hidden */
  41989. _positionInEmitterSpace: boolean;
  41990. private _localDirection;
  41991. private _volume;
  41992. private _isReadyToPlay;
  41993. private _isDirectional;
  41994. private _readyToPlayCallback;
  41995. private _audioBuffer;
  41996. private _soundSource;
  41997. private _streamingSource;
  41998. private _soundPanner;
  41999. private _soundGain;
  42000. private _inputAudioNode;
  42001. private _outputAudioNode;
  42002. private _coneInnerAngle;
  42003. private _coneOuterAngle;
  42004. private _coneOuterGain;
  42005. private _scene;
  42006. private _connectedTransformNode;
  42007. private _customAttenuationFunction;
  42008. private _registerFunc;
  42009. private _isOutputConnected;
  42010. private _htmlAudioElement;
  42011. private _urlType;
  42012. private _length?;
  42013. private _offset?;
  42014. /** @hidden */
  42015. static _SceneComponentInitialization: (scene: Scene) => void;
  42016. /**
  42017. * Create a sound and attach it to a scene
  42018. * @param name Name of your sound
  42019. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42020. * @param scene defines the scene the sound belongs to
  42021. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42022. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42023. */
  42024. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42025. /**
  42026. * Release the sound and its associated resources
  42027. */
  42028. dispose(): void;
  42029. /**
  42030. * Gets if the sounds is ready to be played or not.
  42031. * @returns true if ready, otherwise false
  42032. */
  42033. isReady(): boolean;
  42034. private _soundLoaded;
  42035. /**
  42036. * Sets the data of the sound from an audiobuffer
  42037. * @param audioBuffer The audioBuffer containing the data
  42038. */
  42039. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42040. /**
  42041. * Updates the current sounds options such as maxdistance, loop...
  42042. * @param options A JSON object containing values named as the object properties
  42043. */
  42044. updateOptions(options: ISoundOptions): void;
  42045. private _createSpatialParameters;
  42046. private _updateSpatialParameters;
  42047. /**
  42048. * Switch the panning model to HRTF:
  42049. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42051. */
  42052. switchPanningModelToHRTF(): void;
  42053. /**
  42054. * Switch the panning model to Equal Power:
  42055. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42057. */
  42058. switchPanningModelToEqualPower(): void;
  42059. private _switchPanningModel;
  42060. /**
  42061. * Connect this sound to a sound track audio node like gain...
  42062. * @param soundTrackAudioNode the sound track audio node to connect to
  42063. */
  42064. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42065. /**
  42066. * Transform this sound into a directional source
  42067. * @param coneInnerAngle Size of the inner cone in degree
  42068. * @param coneOuterAngle Size of the outer cone in degree
  42069. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42070. */
  42071. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42072. /**
  42073. * Gets or sets the inner angle for the directional cone.
  42074. */
  42075. get directionalConeInnerAngle(): number;
  42076. /**
  42077. * Gets or sets the inner angle for the directional cone.
  42078. */
  42079. set directionalConeInnerAngle(value: number);
  42080. /**
  42081. * Gets or sets the outer angle for the directional cone.
  42082. */
  42083. get directionalConeOuterAngle(): number;
  42084. /**
  42085. * Gets or sets the outer angle for the directional cone.
  42086. */
  42087. set directionalConeOuterAngle(value: number);
  42088. /**
  42089. * Sets the position of the emitter if spatial sound is enabled
  42090. * @param newPosition Defines the new posisiton
  42091. */
  42092. setPosition(newPosition: Vector3): void;
  42093. /**
  42094. * Sets the local direction of the emitter if spatial sound is enabled
  42095. * @param newLocalDirection Defines the new local direction
  42096. */
  42097. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42098. private _updateDirection;
  42099. /** @hidden */
  42100. updateDistanceFromListener(): void;
  42101. /**
  42102. * Sets a new custom attenuation function for the sound.
  42103. * @param callback Defines the function used for the attenuation
  42104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42105. */
  42106. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42107. /**
  42108. * Play the sound
  42109. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42110. * @param offset (optional) Start the sound at a specific time in seconds
  42111. * @param length (optional) Sound duration (in seconds)
  42112. */
  42113. play(time?: number, offset?: number, length?: number): void;
  42114. private _onended;
  42115. /**
  42116. * Stop the sound
  42117. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42118. */
  42119. stop(time?: number): void;
  42120. /**
  42121. * Put the sound in pause
  42122. */
  42123. pause(): void;
  42124. /**
  42125. * Sets a dedicated volume for this sounds
  42126. * @param newVolume Define the new volume of the sound
  42127. * @param time Define time for gradual change to new volume
  42128. */
  42129. setVolume(newVolume: number, time?: number): void;
  42130. /**
  42131. * Set the sound play back rate
  42132. * @param newPlaybackRate Define the playback rate the sound should be played at
  42133. */
  42134. setPlaybackRate(newPlaybackRate: number): void;
  42135. /**
  42136. * Gets the volume of the sound.
  42137. * @returns the volume of the sound
  42138. */
  42139. getVolume(): number;
  42140. /**
  42141. * Attach the sound to a dedicated mesh
  42142. * @param transformNode The transform node to connect the sound with
  42143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42144. */
  42145. attachToMesh(transformNode: TransformNode): void;
  42146. /**
  42147. * Detach the sound from the previously attached mesh
  42148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42149. */
  42150. detachFromMesh(): void;
  42151. private _onRegisterAfterWorldMatrixUpdate;
  42152. /**
  42153. * Clone the current sound in the scene.
  42154. * @returns the new sound clone
  42155. */
  42156. clone(): Nullable<Sound>;
  42157. /**
  42158. * Gets the current underlying audio buffer containing the data
  42159. * @returns the audio buffer
  42160. */
  42161. getAudioBuffer(): Nullable<AudioBuffer>;
  42162. /**
  42163. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42164. * @returns the source node
  42165. */
  42166. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42167. /**
  42168. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42169. * @returns the gain node
  42170. */
  42171. getSoundGain(): Nullable<GainNode>;
  42172. /**
  42173. * Serializes the Sound in a JSON representation
  42174. * @returns the JSON representation of the sound
  42175. */
  42176. serialize(): any;
  42177. /**
  42178. * Parse a JSON representation of a sound to innstantiate in a given scene
  42179. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42180. * @param scene Define the scene the new parsed sound should be created in
  42181. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42182. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42183. * @returns the newly parsed sound
  42184. */
  42185. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42186. }
  42187. }
  42188. declare module "babylonjs/Actions/directAudioActions" {
  42189. import { Action } from "babylonjs/Actions/action";
  42190. import { Condition } from "babylonjs/Actions/condition";
  42191. import { Sound } from "babylonjs/Audio/sound";
  42192. /**
  42193. * This defines an action helpful to play a defined sound on a triggered action.
  42194. */
  42195. export class PlaySoundAction extends Action {
  42196. private _sound;
  42197. /**
  42198. * Instantiate the action
  42199. * @param triggerOptions defines the trigger options
  42200. * @param sound defines the sound to play
  42201. * @param condition defines the trigger related conditions
  42202. */
  42203. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42204. /** @hidden */
  42205. _prepare(): void;
  42206. /**
  42207. * Execute the action and play the sound.
  42208. */
  42209. execute(): void;
  42210. /**
  42211. * Serializes the actions and its related information.
  42212. * @param parent defines the object to serialize in
  42213. * @returns the serialized object
  42214. */
  42215. serialize(parent: any): any;
  42216. }
  42217. /**
  42218. * This defines an action helpful to stop a defined sound on a triggered action.
  42219. */
  42220. export class StopSoundAction extends Action {
  42221. private _sound;
  42222. /**
  42223. * Instantiate the action
  42224. * @param triggerOptions defines the trigger options
  42225. * @param sound defines the sound to stop
  42226. * @param condition defines the trigger related conditions
  42227. */
  42228. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42229. /** @hidden */
  42230. _prepare(): void;
  42231. /**
  42232. * Execute the action and stop the sound.
  42233. */
  42234. execute(): void;
  42235. /**
  42236. * Serializes the actions and its related information.
  42237. * @param parent defines the object to serialize in
  42238. * @returns the serialized object
  42239. */
  42240. serialize(parent: any): any;
  42241. }
  42242. }
  42243. declare module "babylonjs/Actions/interpolateValueAction" {
  42244. import { Action } from "babylonjs/Actions/action";
  42245. import { Condition } from "babylonjs/Actions/condition";
  42246. import { Observable } from "babylonjs/Misc/observable";
  42247. /**
  42248. * This defines an action responsible to change the value of a property
  42249. * by interpolating between its current value and the newly set one once triggered.
  42250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  42251. */
  42252. export class InterpolateValueAction extends Action {
  42253. /**
  42254. * Defines the path of the property where the value should be interpolated
  42255. */
  42256. propertyPath: string;
  42257. /**
  42258. * Defines the target value at the end of the interpolation.
  42259. */
  42260. value: any;
  42261. /**
  42262. * Defines the time it will take for the property to interpolate to the value.
  42263. */
  42264. duration: number;
  42265. /**
  42266. * Defines if the other scene animations should be stopped when the action has been triggered
  42267. */
  42268. stopOtherAnimations?: boolean;
  42269. /**
  42270. * Defines a callback raised once the interpolation animation has been done.
  42271. */
  42272. onInterpolationDone?: () => void;
  42273. /**
  42274. * Observable triggered once the interpolation animation has been done.
  42275. */
  42276. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42277. private _target;
  42278. private _effectiveTarget;
  42279. private _property;
  42280. /**
  42281. * Instantiate the action
  42282. * @param triggerOptions defines the trigger options
  42283. * @param target defines the object containing the value to interpolate
  42284. * @param propertyPath defines the path to the property in the target object
  42285. * @param value defines the target value at the end of the interpolation
  42286. * @param duration deines the time it will take for the property to interpolate to the value.
  42287. * @param condition defines the trigger related conditions
  42288. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42289. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42290. */
  42291. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42292. /** @hidden */
  42293. _prepare(): void;
  42294. /**
  42295. * Execute the action starts the value interpolation.
  42296. */
  42297. execute(): void;
  42298. /**
  42299. * Serializes the actions and its related information.
  42300. * @param parent defines the object to serialize in
  42301. * @returns the serialized object
  42302. */
  42303. serialize(parent: any): any;
  42304. }
  42305. }
  42306. declare module "babylonjs/Actions/index" {
  42307. export * from "babylonjs/Actions/abstractActionManager";
  42308. export * from "babylonjs/Actions/action";
  42309. export * from "babylonjs/Actions/actionEvent";
  42310. export * from "babylonjs/Actions/actionManager";
  42311. export * from "babylonjs/Actions/condition";
  42312. export * from "babylonjs/Actions/directActions";
  42313. export * from "babylonjs/Actions/directAudioActions";
  42314. export * from "babylonjs/Actions/interpolateValueAction";
  42315. }
  42316. declare module "babylonjs/Animations/index" {
  42317. export * from "babylonjs/Animations/animatable";
  42318. export * from "babylonjs/Animations/animation";
  42319. export * from "babylonjs/Animations/animationGroup";
  42320. export * from "babylonjs/Animations/animationPropertiesOverride";
  42321. export * from "babylonjs/Animations/easing";
  42322. export * from "babylonjs/Animations/runtimeAnimation";
  42323. export * from "babylonjs/Animations/animationEvent";
  42324. export * from "babylonjs/Animations/animationGroup";
  42325. export * from "babylonjs/Animations/animationKey";
  42326. export * from "babylonjs/Animations/animationRange";
  42327. export * from "babylonjs/Animations/animatable.interface";
  42328. }
  42329. declare module "babylonjs/Audio/soundTrack" {
  42330. import { Sound } from "babylonjs/Audio/sound";
  42331. import { Analyser } from "babylonjs/Audio/analyser";
  42332. import { Scene } from "babylonjs/scene";
  42333. /**
  42334. * Options allowed during the creation of a sound track.
  42335. */
  42336. export interface ISoundTrackOptions {
  42337. /**
  42338. * The volume the sound track should take during creation
  42339. */
  42340. volume?: number;
  42341. /**
  42342. * Define if the sound track is the main sound track of the scene
  42343. */
  42344. mainTrack?: boolean;
  42345. }
  42346. /**
  42347. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42348. * It will be also used in a future release to apply effects on a specific track.
  42349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42350. */
  42351. export class SoundTrack {
  42352. /**
  42353. * The unique identifier of the sound track in the scene.
  42354. */
  42355. id: number;
  42356. /**
  42357. * The list of sounds included in the sound track.
  42358. */
  42359. soundCollection: Array<Sound>;
  42360. private _outputAudioNode;
  42361. private _scene;
  42362. private _connectedAnalyser;
  42363. private _options;
  42364. private _isInitialized;
  42365. /**
  42366. * Creates a new sound track.
  42367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42368. * @param scene Define the scene the sound track belongs to
  42369. * @param options
  42370. */
  42371. constructor(scene: Scene, options?: ISoundTrackOptions);
  42372. private _initializeSoundTrackAudioGraph;
  42373. /**
  42374. * Release the sound track and its associated resources
  42375. */
  42376. dispose(): void;
  42377. /**
  42378. * Adds a sound to this sound track
  42379. * @param sound define the cound to add
  42380. * @ignoreNaming
  42381. */
  42382. AddSound(sound: Sound): void;
  42383. /**
  42384. * Removes a sound to this sound track
  42385. * @param sound define the cound to remove
  42386. * @ignoreNaming
  42387. */
  42388. RemoveSound(sound: Sound): void;
  42389. /**
  42390. * Set a global volume for the full sound track.
  42391. * @param newVolume Define the new volume of the sound track
  42392. */
  42393. setVolume(newVolume: number): void;
  42394. /**
  42395. * Switch the panning model to HRTF:
  42396. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42398. */
  42399. switchPanningModelToHRTF(): void;
  42400. /**
  42401. * Switch the panning model to Equal Power:
  42402. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42404. */
  42405. switchPanningModelToEqualPower(): void;
  42406. /**
  42407. * Connect the sound track to an audio analyser allowing some amazing
  42408. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42409. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42410. * @param analyser The analyser to connect to the engine
  42411. */
  42412. connectToAnalyser(analyser: Analyser): void;
  42413. }
  42414. }
  42415. declare module "babylonjs/Audio/audioSceneComponent" {
  42416. import { Sound } from "babylonjs/Audio/sound";
  42417. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42418. import { Nullable } from "babylonjs/types";
  42419. import { Vector3 } from "babylonjs/Maths/math.vector";
  42420. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42421. import { Scene } from "babylonjs/scene";
  42422. import { AbstractScene } from "babylonjs/abstractScene";
  42423. import "babylonjs/Audio/audioEngine";
  42424. module "babylonjs/abstractScene" {
  42425. interface AbstractScene {
  42426. /**
  42427. * The list of sounds used in the scene.
  42428. */
  42429. sounds: Nullable<Array<Sound>>;
  42430. }
  42431. }
  42432. module "babylonjs/scene" {
  42433. interface Scene {
  42434. /**
  42435. * @hidden
  42436. * Backing field
  42437. */
  42438. _mainSoundTrack: SoundTrack;
  42439. /**
  42440. * The main sound track played by the scene.
  42441. * It cotains your primary collection of sounds.
  42442. */
  42443. mainSoundTrack: SoundTrack;
  42444. /**
  42445. * The list of sound tracks added to the scene
  42446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42447. */
  42448. soundTracks: Nullable<Array<SoundTrack>>;
  42449. /**
  42450. * Gets a sound using a given name
  42451. * @param name defines the name to search for
  42452. * @return the found sound or null if not found at all.
  42453. */
  42454. getSoundByName(name: string): Nullable<Sound>;
  42455. /**
  42456. * Gets or sets if audio support is enabled
  42457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42458. */
  42459. audioEnabled: boolean;
  42460. /**
  42461. * Gets or sets if audio will be output to headphones
  42462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42463. */
  42464. headphone: boolean;
  42465. /**
  42466. * Gets or sets custom audio listener position provider
  42467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42468. */
  42469. audioListenerPositionProvider: Nullable<() => Vector3>;
  42470. /**
  42471. * Gets or sets a refresh rate when using 3D audio positioning
  42472. */
  42473. audioPositioningRefreshRate: number;
  42474. }
  42475. }
  42476. /**
  42477. * Defines the sound scene component responsible to manage any sounds
  42478. * in a given scene.
  42479. */
  42480. export class AudioSceneComponent implements ISceneSerializableComponent {
  42481. /**
  42482. * The component name helpfull to identify the component in the list of scene components.
  42483. */
  42484. readonly name: string;
  42485. /**
  42486. * The scene the component belongs to.
  42487. */
  42488. scene: Scene;
  42489. private _audioEnabled;
  42490. /**
  42491. * Gets whether audio is enabled or not.
  42492. * Please use related enable/disable method to switch state.
  42493. */
  42494. get audioEnabled(): boolean;
  42495. private _headphone;
  42496. /**
  42497. * Gets whether audio is outputing to headphone or not.
  42498. * Please use the according Switch methods to change output.
  42499. */
  42500. get headphone(): boolean;
  42501. /**
  42502. * Gets or sets a refresh rate when using 3D audio positioning
  42503. */
  42504. audioPositioningRefreshRate: number;
  42505. private _audioListenerPositionProvider;
  42506. /**
  42507. * Gets the current audio listener position provider
  42508. */
  42509. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42510. /**
  42511. * Sets a custom listener position for all sounds in the scene
  42512. * By default, this is the position of the first active camera
  42513. */
  42514. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42515. /**
  42516. * Creates a new instance of the component for the given scene
  42517. * @param scene Defines the scene to register the component in
  42518. */
  42519. constructor(scene: Scene);
  42520. /**
  42521. * Registers the component in a given scene
  42522. */
  42523. register(): void;
  42524. /**
  42525. * Rebuilds the elements related to this component in case of
  42526. * context lost for instance.
  42527. */
  42528. rebuild(): void;
  42529. /**
  42530. * Serializes the component data to the specified json object
  42531. * @param serializationObject The object to serialize to
  42532. */
  42533. serialize(serializationObject: any): void;
  42534. /**
  42535. * Adds all the elements from the container to the scene
  42536. * @param container the container holding the elements
  42537. */
  42538. addFromContainer(container: AbstractScene): void;
  42539. /**
  42540. * Removes all the elements in the container from the scene
  42541. * @param container contains the elements to remove
  42542. * @param dispose if the removed element should be disposed (default: false)
  42543. */
  42544. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42545. /**
  42546. * Disposes the component and the associated ressources.
  42547. */
  42548. dispose(): void;
  42549. /**
  42550. * Disables audio in the associated scene.
  42551. */
  42552. disableAudio(): void;
  42553. /**
  42554. * Enables audio in the associated scene.
  42555. */
  42556. enableAudio(): void;
  42557. /**
  42558. * Switch audio to headphone output.
  42559. */
  42560. switchAudioModeForHeadphones(): void;
  42561. /**
  42562. * Switch audio to normal speakers.
  42563. */
  42564. switchAudioModeForNormalSpeakers(): void;
  42565. private _cachedCameraDirection;
  42566. private _cachedCameraPosition;
  42567. private _lastCheck;
  42568. private _afterRender;
  42569. }
  42570. }
  42571. declare module "babylonjs/Audio/weightedsound" {
  42572. import { Sound } from "babylonjs/Audio/sound";
  42573. /**
  42574. * Wraps one or more Sound objects and selects one with random weight for playback.
  42575. */
  42576. export class WeightedSound {
  42577. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42578. loop: boolean;
  42579. private _coneInnerAngle;
  42580. private _coneOuterAngle;
  42581. private _volume;
  42582. /** A Sound is currently playing. */
  42583. isPlaying: boolean;
  42584. /** A Sound is currently paused. */
  42585. isPaused: boolean;
  42586. private _sounds;
  42587. private _weights;
  42588. private _currentIndex?;
  42589. /**
  42590. * Creates a new WeightedSound from the list of sounds given.
  42591. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42592. * @param sounds Array of Sounds that will be selected from.
  42593. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42594. */
  42595. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42596. /**
  42597. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42598. */
  42599. get directionalConeInnerAngle(): number;
  42600. /**
  42601. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42602. */
  42603. set directionalConeInnerAngle(value: number);
  42604. /**
  42605. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42606. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42607. */
  42608. get directionalConeOuterAngle(): number;
  42609. /**
  42610. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42611. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42612. */
  42613. set directionalConeOuterAngle(value: number);
  42614. /**
  42615. * Playback volume.
  42616. */
  42617. get volume(): number;
  42618. /**
  42619. * Playback volume.
  42620. */
  42621. set volume(value: number);
  42622. private _onended;
  42623. /**
  42624. * Suspend playback
  42625. */
  42626. pause(): void;
  42627. /**
  42628. * Stop playback
  42629. */
  42630. stop(): void;
  42631. /**
  42632. * Start playback.
  42633. * @param startOffset Position the clip head at a specific time in seconds.
  42634. */
  42635. play(startOffset?: number): void;
  42636. }
  42637. }
  42638. declare module "babylonjs/Audio/index" {
  42639. export * from "babylonjs/Audio/analyser";
  42640. export * from "babylonjs/Audio/audioEngine";
  42641. export * from "babylonjs/Audio/audioSceneComponent";
  42642. export * from "babylonjs/Audio/sound";
  42643. export * from "babylonjs/Audio/soundTrack";
  42644. export * from "babylonjs/Audio/weightedsound";
  42645. }
  42646. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42647. import { Behavior } from "babylonjs/Behaviors/behavior";
  42648. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42649. import { BackEase } from "babylonjs/Animations/easing";
  42650. /**
  42651. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42652. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42653. */
  42654. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42655. /**
  42656. * Gets the name of the behavior.
  42657. */
  42658. get name(): string;
  42659. /**
  42660. * The easing function used by animations
  42661. */
  42662. static EasingFunction: BackEase;
  42663. /**
  42664. * The easing mode used by animations
  42665. */
  42666. static EasingMode: number;
  42667. /**
  42668. * The duration of the animation, in milliseconds
  42669. */
  42670. transitionDuration: number;
  42671. /**
  42672. * Length of the distance animated by the transition when lower radius is reached
  42673. */
  42674. lowerRadiusTransitionRange: number;
  42675. /**
  42676. * Length of the distance animated by the transition when upper radius is reached
  42677. */
  42678. upperRadiusTransitionRange: number;
  42679. private _autoTransitionRange;
  42680. /**
  42681. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42682. */
  42683. get autoTransitionRange(): boolean;
  42684. /**
  42685. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42686. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42687. */
  42688. set autoTransitionRange(value: boolean);
  42689. private _attachedCamera;
  42690. private _onAfterCheckInputsObserver;
  42691. private _onMeshTargetChangedObserver;
  42692. /**
  42693. * Initializes the behavior.
  42694. */
  42695. init(): void;
  42696. /**
  42697. * Attaches the behavior to its arc rotate camera.
  42698. * @param camera Defines the camera to attach the behavior to
  42699. */
  42700. attach(camera: ArcRotateCamera): void;
  42701. /**
  42702. * Detaches the behavior from its current arc rotate camera.
  42703. */
  42704. detach(): void;
  42705. private _radiusIsAnimating;
  42706. private _radiusBounceTransition;
  42707. private _animatables;
  42708. private _cachedWheelPrecision;
  42709. /**
  42710. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42711. * @param radiusLimit The limit to check against.
  42712. * @return Bool to indicate if at limit.
  42713. */
  42714. private _isRadiusAtLimit;
  42715. /**
  42716. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42717. * @param radiusDelta The delta by which to animate to. Can be negative.
  42718. */
  42719. private _applyBoundRadiusAnimation;
  42720. /**
  42721. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42722. */
  42723. protected _clearAnimationLocks(): void;
  42724. /**
  42725. * Stops and removes all animations that have been applied to the camera
  42726. */
  42727. stopAllAnimations(): void;
  42728. }
  42729. }
  42730. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42731. import { Behavior } from "babylonjs/Behaviors/behavior";
  42732. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42733. import { ExponentialEase } from "babylonjs/Animations/easing";
  42734. import { Nullable } from "babylonjs/types";
  42735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42736. import { Vector3 } from "babylonjs/Maths/math.vector";
  42737. /**
  42738. * 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.
  42739. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42740. */
  42741. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42742. /**
  42743. * Gets the name of the behavior.
  42744. */
  42745. get name(): string;
  42746. private _mode;
  42747. private _radiusScale;
  42748. private _positionScale;
  42749. private _defaultElevation;
  42750. private _elevationReturnTime;
  42751. private _elevationReturnWaitTime;
  42752. private _zoomStopsAnimation;
  42753. private _framingTime;
  42754. /**
  42755. * The easing function used by animations
  42756. */
  42757. static EasingFunction: ExponentialEase;
  42758. /**
  42759. * The easing mode used by animations
  42760. */
  42761. static EasingMode: number;
  42762. /**
  42763. * Sets the current mode used by the behavior
  42764. */
  42765. set mode(mode: number);
  42766. /**
  42767. * Gets current mode used by the behavior.
  42768. */
  42769. get mode(): number;
  42770. /**
  42771. * Sets the scale applied to the radius (1 by default)
  42772. */
  42773. set radiusScale(radius: number);
  42774. /**
  42775. * Gets the scale applied to the radius
  42776. */
  42777. get radiusScale(): number;
  42778. /**
  42779. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42780. */
  42781. set positionScale(scale: number);
  42782. /**
  42783. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42784. */
  42785. get positionScale(): number;
  42786. /**
  42787. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42788. * behaviour is triggered, in radians.
  42789. */
  42790. set defaultElevation(elevation: number);
  42791. /**
  42792. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42793. * behaviour is triggered, in radians.
  42794. */
  42795. get defaultElevation(): number;
  42796. /**
  42797. * Sets the time (in milliseconds) taken to return to the default beta position.
  42798. * Negative value indicates camera should not return to default.
  42799. */
  42800. set elevationReturnTime(speed: number);
  42801. /**
  42802. * Gets the time (in milliseconds) taken to return to the default beta position.
  42803. * Negative value indicates camera should not return to default.
  42804. */
  42805. get elevationReturnTime(): number;
  42806. /**
  42807. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42808. */
  42809. set elevationReturnWaitTime(time: number);
  42810. /**
  42811. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42812. */
  42813. get elevationReturnWaitTime(): number;
  42814. /**
  42815. * Sets the flag that indicates if user zooming should stop animation.
  42816. */
  42817. set zoomStopsAnimation(flag: boolean);
  42818. /**
  42819. * Gets the flag that indicates if user zooming should stop animation.
  42820. */
  42821. get zoomStopsAnimation(): boolean;
  42822. /**
  42823. * Sets the transition time when framing the mesh, in milliseconds
  42824. */
  42825. set framingTime(time: number);
  42826. /**
  42827. * Gets the transition time when framing the mesh, in milliseconds
  42828. */
  42829. get framingTime(): number;
  42830. /**
  42831. * Define if the behavior should automatically change the configured
  42832. * camera limits and sensibilities.
  42833. */
  42834. autoCorrectCameraLimitsAndSensibility: boolean;
  42835. private _onPrePointerObservableObserver;
  42836. private _onAfterCheckInputsObserver;
  42837. private _onMeshTargetChangedObserver;
  42838. private _attachedCamera;
  42839. private _isPointerDown;
  42840. private _lastInteractionTime;
  42841. /**
  42842. * Initializes the behavior.
  42843. */
  42844. init(): void;
  42845. /**
  42846. * Attaches the behavior to its arc rotate camera.
  42847. * @param camera Defines the camera to attach the behavior to
  42848. */
  42849. attach(camera: ArcRotateCamera): void;
  42850. /**
  42851. * Detaches the behavior from its current arc rotate camera.
  42852. */
  42853. detach(): void;
  42854. private _animatables;
  42855. private _betaIsAnimating;
  42856. private _betaTransition;
  42857. private _radiusTransition;
  42858. private _vectorTransition;
  42859. /**
  42860. * Targets the given mesh and updates zoom level accordingly.
  42861. * @param mesh The mesh to target.
  42862. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42863. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42864. */
  42865. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42866. /**
  42867. * Targets the given mesh with its children and updates zoom level accordingly.
  42868. * @param mesh The mesh to target.
  42869. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42870. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42871. */
  42872. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42873. /**
  42874. * Targets the given meshes with their children and updates zoom level accordingly.
  42875. * @param meshes The mesh to target.
  42876. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42877. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42878. */
  42879. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42880. /**
  42881. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42882. * @param minimumWorld Determines the smaller position of the bounding box extend
  42883. * @param maximumWorld Determines the bigger position of the bounding box extend
  42884. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42885. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42886. */
  42887. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42888. /**
  42889. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42890. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42891. * frustum width.
  42892. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42893. * to fully enclose the mesh in the viewing frustum.
  42894. */
  42895. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42896. /**
  42897. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42898. * is automatically returned to its default position (expected to be above ground plane).
  42899. */
  42900. private _maintainCameraAboveGround;
  42901. /**
  42902. * Returns the frustum slope based on the canvas ratio and camera FOV
  42903. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42904. */
  42905. private _getFrustumSlope;
  42906. /**
  42907. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42908. */
  42909. private _clearAnimationLocks;
  42910. /**
  42911. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42912. */
  42913. private _applyUserInteraction;
  42914. /**
  42915. * Stops and removes all animations that have been applied to the camera
  42916. */
  42917. stopAllAnimations(): void;
  42918. /**
  42919. * Gets a value indicating if the user is moving the camera
  42920. */
  42921. get isUserIsMoving(): boolean;
  42922. /**
  42923. * The camera can move all the way towards the mesh.
  42924. */
  42925. static IgnoreBoundsSizeMode: number;
  42926. /**
  42927. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42928. */
  42929. static FitFrustumSidesMode: number;
  42930. }
  42931. }
  42932. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42933. import { Nullable } from "babylonjs/types";
  42934. import { Camera } from "babylonjs/Cameras/camera";
  42935. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42936. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42937. /**
  42938. * Base class for Camera Pointer Inputs.
  42939. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42940. * for example usage.
  42941. */
  42942. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42943. /**
  42944. * Defines the camera the input is attached to.
  42945. */
  42946. abstract camera: Camera;
  42947. /**
  42948. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42949. */
  42950. protected _altKey: boolean;
  42951. protected _ctrlKey: boolean;
  42952. protected _metaKey: boolean;
  42953. protected _shiftKey: boolean;
  42954. /**
  42955. * Which mouse buttons were pressed at time of last mouse event.
  42956. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42957. */
  42958. protected _buttonsPressed: number;
  42959. /**
  42960. * Defines the buttons associated with the input to handle camera move.
  42961. */
  42962. buttons: number[];
  42963. /**
  42964. * Attach the input controls to a specific dom element to get the input from.
  42965. * @param element Defines the element the controls should be listened from
  42966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42967. */
  42968. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42969. /**
  42970. * Detach the current controls from the specified dom element.
  42971. * @param element Defines the element to stop listening the inputs from
  42972. */
  42973. detachControl(element: Nullable<HTMLElement>): void;
  42974. /**
  42975. * Gets the class name of the current input.
  42976. * @returns the class name
  42977. */
  42978. getClassName(): string;
  42979. /**
  42980. * Get the friendly name associated with the input class.
  42981. * @returns the input friendly name
  42982. */
  42983. getSimpleName(): string;
  42984. /**
  42985. * Called on pointer POINTERDOUBLETAP event.
  42986. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42987. */
  42988. protected onDoubleTap(type: string): void;
  42989. /**
  42990. * Called on pointer POINTERMOVE event if only a single touch is active.
  42991. * Override this method to provide functionality.
  42992. */
  42993. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42994. /**
  42995. * Called on pointer POINTERMOVE event if multiple touches are active.
  42996. * Override this method to provide functionality.
  42997. */
  42998. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42999. /**
  43000. * Called on JS contextmenu event.
  43001. * Override this method to provide functionality.
  43002. */
  43003. protected onContextMenu(evt: PointerEvent): void;
  43004. /**
  43005. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43006. * press.
  43007. * Override this method to provide functionality.
  43008. */
  43009. protected onButtonDown(evt: PointerEvent): void;
  43010. /**
  43011. * Called each time a new POINTERUP event occurs. Ie, for each button
  43012. * release.
  43013. * Override this method to provide functionality.
  43014. */
  43015. protected onButtonUp(evt: PointerEvent): void;
  43016. /**
  43017. * Called when window becomes inactive.
  43018. * Override this method to provide functionality.
  43019. */
  43020. protected onLostFocus(): void;
  43021. private _pointerInput;
  43022. private _observer;
  43023. private _onLostFocus;
  43024. private pointA;
  43025. private pointB;
  43026. }
  43027. }
  43028. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43029. import { Nullable } from "babylonjs/types";
  43030. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43031. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43032. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43033. /**
  43034. * Manage the pointers inputs to control an arc rotate camera.
  43035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43036. */
  43037. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43038. /**
  43039. * Defines the camera the input is attached to.
  43040. */
  43041. camera: ArcRotateCamera;
  43042. /**
  43043. * Gets the class name of the current input.
  43044. * @returns the class name
  43045. */
  43046. getClassName(): string;
  43047. /**
  43048. * Defines the buttons associated with the input to handle camera move.
  43049. */
  43050. buttons: number[];
  43051. /**
  43052. * Defines the pointer angular sensibility along the X axis or how fast is
  43053. * the camera rotating.
  43054. */
  43055. angularSensibilityX: number;
  43056. /**
  43057. * Defines the pointer angular sensibility along the Y axis or how fast is
  43058. * the camera rotating.
  43059. */
  43060. angularSensibilityY: number;
  43061. /**
  43062. * Defines the pointer pinch precision or how fast is the camera zooming.
  43063. */
  43064. pinchPrecision: number;
  43065. /**
  43066. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43067. * from 0.
  43068. * It defines the percentage of current camera.radius to use as delta when
  43069. * pinch zoom is used.
  43070. */
  43071. pinchDeltaPercentage: number;
  43072. /**
  43073. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43074. * that any object in the plane at the camera's target point will scale
  43075. * perfectly with finger motion.
  43076. * Overrides pinchDeltaPercentage and pinchPrecision.
  43077. */
  43078. useNaturalPinchZoom: boolean;
  43079. /**
  43080. * Defines the pointer panning sensibility or how fast is the camera moving.
  43081. */
  43082. panningSensibility: number;
  43083. /**
  43084. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43085. */
  43086. multiTouchPanning: boolean;
  43087. /**
  43088. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43089. * zoom (pinch) through multitouch.
  43090. */
  43091. multiTouchPanAndZoom: boolean;
  43092. /**
  43093. * Revers pinch action direction.
  43094. */
  43095. pinchInwards: boolean;
  43096. private _isPanClick;
  43097. private _twoFingerActivityCount;
  43098. private _isPinching;
  43099. /**
  43100. * Called on pointer POINTERMOVE event if only a single touch is active.
  43101. */
  43102. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43103. /**
  43104. * Called on pointer POINTERDOUBLETAP event.
  43105. */
  43106. protected onDoubleTap(type: string): void;
  43107. /**
  43108. * Called on pointer POINTERMOVE event if multiple touches are active.
  43109. */
  43110. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43111. /**
  43112. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43113. * press.
  43114. */
  43115. protected onButtonDown(evt: PointerEvent): void;
  43116. /**
  43117. * Called each time a new POINTERUP event occurs. Ie, for each button
  43118. * release.
  43119. */
  43120. protected onButtonUp(evt: PointerEvent): void;
  43121. /**
  43122. * Called when window becomes inactive.
  43123. */
  43124. protected onLostFocus(): void;
  43125. }
  43126. }
  43127. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43128. import { Nullable } from "babylonjs/types";
  43129. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43130. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43131. /**
  43132. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43134. */
  43135. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43136. /**
  43137. * Defines the camera the input is attached to.
  43138. */
  43139. camera: ArcRotateCamera;
  43140. /**
  43141. * Defines the list of key codes associated with the up action (increase alpha)
  43142. */
  43143. keysUp: number[];
  43144. /**
  43145. * Defines the list of key codes associated with the down action (decrease alpha)
  43146. */
  43147. keysDown: number[];
  43148. /**
  43149. * Defines the list of key codes associated with the left action (increase beta)
  43150. */
  43151. keysLeft: number[];
  43152. /**
  43153. * Defines the list of key codes associated with the right action (decrease beta)
  43154. */
  43155. keysRight: number[];
  43156. /**
  43157. * Defines the list of key codes associated with the reset action.
  43158. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43159. */
  43160. keysReset: number[];
  43161. /**
  43162. * Defines the panning sensibility of the inputs.
  43163. * (How fast is the camera panning)
  43164. */
  43165. panningSensibility: number;
  43166. /**
  43167. * Defines the zooming sensibility of the inputs.
  43168. * (How fast is the camera zooming)
  43169. */
  43170. zoomingSensibility: number;
  43171. /**
  43172. * Defines whether maintaining the alt key down switch the movement mode from
  43173. * orientation to zoom.
  43174. */
  43175. useAltToZoom: boolean;
  43176. /**
  43177. * Rotation speed of the camera
  43178. */
  43179. angularSpeed: number;
  43180. private _keys;
  43181. private _ctrlPressed;
  43182. private _altPressed;
  43183. private _onCanvasBlurObserver;
  43184. private _onKeyboardObserver;
  43185. private _engine;
  43186. private _scene;
  43187. /**
  43188. * Attach the input controls to a specific dom element to get the input from.
  43189. * @param element Defines the element the controls should be listened from
  43190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43191. */
  43192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43193. /**
  43194. * Detach the current controls from the specified dom element.
  43195. * @param element Defines the element to stop listening the inputs from
  43196. */
  43197. detachControl(element: Nullable<HTMLElement>): void;
  43198. /**
  43199. * Update the current camera state depending on the inputs that have been used this frame.
  43200. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43201. */
  43202. checkInputs(): void;
  43203. /**
  43204. * Gets the class name of the current intput.
  43205. * @returns the class name
  43206. */
  43207. getClassName(): string;
  43208. /**
  43209. * Get the friendly name associated with the input class.
  43210. * @returns the input friendly name
  43211. */
  43212. getSimpleName(): string;
  43213. }
  43214. }
  43215. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43216. import { Nullable } from "babylonjs/types";
  43217. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43218. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43219. /**
  43220. * Manage the mouse wheel inputs to control an arc rotate camera.
  43221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43222. */
  43223. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43224. /**
  43225. * Defines the camera the input is attached to.
  43226. */
  43227. camera: ArcRotateCamera;
  43228. /**
  43229. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43230. */
  43231. wheelPrecision: number;
  43232. /**
  43233. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43234. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43235. */
  43236. wheelDeltaPercentage: number;
  43237. private _wheel;
  43238. private _observer;
  43239. private computeDeltaFromMouseWheelLegacyEvent;
  43240. /**
  43241. * Attach the input controls to a specific dom element to get the input from.
  43242. * @param element Defines the element the controls should be listened from
  43243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43244. */
  43245. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43246. /**
  43247. * Detach the current controls from the specified dom element.
  43248. * @param element Defines the element to stop listening the inputs from
  43249. */
  43250. detachControl(element: Nullable<HTMLElement>): void;
  43251. /**
  43252. * Gets the class name of the current intput.
  43253. * @returns the class name
  43254. */
  43255. getClassName(): string;
  43256. /**
  43257. * Get the friendly name associated with the input class.
  43258. * @returns the input friendly name
  43259. */
  43260. getSimpleName(): string;
  43261. }
  43262. }
  43263. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43264. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43265. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43266. /**
  43267. * Default Inputs manager for the ArcRotateCamera.
  43268. * It groups all the default supported inputs for ease of use.
  43269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43270. */
  43271. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43272. /**
  43273. * Instantiates a new ArcRotateCameraInputsManager.
  43274. * @param camera Defines the camera the inputs belong to
  43275. */
  43276. constructor(camera: ArcRotateCamera);
  43277. /**
  43278. * Add mouse wheel input support to the input manager.
  43279. * @returns the current input manager
  43280. */
  43281. addMouseWheel(): ArcRotateCameraInputsManager;
  43282. /**
  43283. * Add pointers input support to the input manager.
  43284. * @returns the current input manager
  43285. */
  43286. addPointers(): ArcRotateCameraInputsManager;
  43287. /**
  43288. * Add keyboard input support to the input manager.
  43289. * @returns the current input manager
  43290. */
  43291. addKeyboard(): ArcRotateCameraInputsManager;
  43292. }
  43293. }
  43294. declare module "babylonjs/Cameras/arcRotateCamera" {
  43295. import { Observable } from "babylonjs/Misc/observable";
  43296. import { Nullable } from "babylonjs/types";
  43297. import { Scene } from "babylonjs/scene";
  43298. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43300. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43301. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43302. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43303. import { Camera } from "babylonjs/Cameras/camera";
  43304. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43305. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43306. import { Collider } from "babylonjs/Collisions/collider";
  43307. /**
  43308. * This represents an orbital type of camera.
  43309. *
  43310. * 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.
  43311. * 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.
  43312. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43313. */
  43314. export class ArcRotateCamera extends TargetCamera {
  43315. /**
  43316. * Defines the rotation angle of the camera along the longitudinal axis.
  43317. */
  43318. alpha: number;
  43319. /**
  43320. * Defines the rotation angle of the camera along the latitudinal axis.
  43321. */
  43322. beta: number;
  43323. /**
  43324. * Defines the radius of the camera from it s target point.
  43325. */
  43326. radius: number;
  43327. protected _target: Vector3;
  43328. protected _targetHost: Nullable<AbstractMesh>;
  43329. /**
  43330. * Defines the target point of the camera.
  43331. * The camera looks towards it form the radius distance.
  43332. */
  43333. get target(): Vector3;
  43334. set target(value: Vector3);
  43335. /**
  43336. * Define the current local position of the camera in the scene
  43337. */
  43338. get position(): Vector3;
  43339. set position(newPosition: Vector3);
  43340. protected _upVector: Vector3;
  43341. protected _upToYMatrix: Matrix;
  43342. protected _YToUpMatrix: Matrix;
  43343. /**
  43344. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43345. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43346. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43347. */
  43348. set upVector(vec: Vector3);
  43349. get upVector(): Vector3;
  43350. /**
  43351. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43352. */
  43353. setMatUp(): void;
  43354. /**
  43355. * Current inertia value on the longitudinal axis.
  43356. * The bigger this number the longer it will take for the camera to stop.
  43357. */
  43358. inertialAlphaOffset: number;
  43359. /**
  43360. * Current inertia value on the latitudinal axis.
  43361. * The bigger this number the longer it will take for the camera to stop.
  43362. */
  43363. inertialBetaOffset: number;
  43364. /**
  43365. * Current inertia value on the radius axis.
  43366. * The bigger this number the longer it will take for the camera to stop.
  43367. */
  43368. inertialRadiusOffset: number;
  43369. /**
  43370. * Minimum allowed angle on the longitudinal axis.
  43371. * This can help limiting how the Camera is able to move in the scene.
  43372. */
  43373. lowerAlphaLimit: Nullable<number>;
  43374. /**
  43375. * Maximum allowed angle on the longitudinal axis.
  43376. * This can help limiting how the Camera is able to move in the scene.
  43377. */
  43378. upperAlphaLimit: Nullable<number>;
  43379. /**
  43380. * Minimum allowed angle on the latitudinal axis.
  43381. * This can help limiting how the Camera is able to move in the scene.
  43382. */
  43383. lowerBetaLimit: number;
  43384. /**
  43385. * Maximum allowed angle on the latitudinal axis.
  43386. * This can help limiting how the Camera is able to move in the scene.
  43387. */
  43388. upperBetaLimit: number;
  43389. /**
  43390. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43391. * This can help limiting how the Camera is able to move in the scene.
  43392. */
  43393. lowerRadiusLimit: Nullable<number>;
  43394. /**
  43395. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43396. * This can help limiting how the Camera is able to move in the scene.
  43397. */
  43398. upperRadiusLimit: Nullable<number>;
  43399. /**
  43400. * Defines the current inertia value used during panning of the camera along the X axis.
  43401. */
  43402. inertialPanningX: number;
  43403. /**
  43404. * Defines the current inertia value used during panning of the camera along the Y axis.
  43405. */
  43406. inertialPanningY: number;
  43407. /**
  43408. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43409. * Basically if your fingers moves away from more than this distance you will be considered
  43410. * in pinch mode.
  43411. */
  43412. pinchToPanMaxDistance: number;
  43413. /**
  43414. * Defines the maximum distance the camera can pan.
  43415. * This could help keeping the cammera always in your scene.
  43416. */
  43417. panningDistanceLimit: Nullable<number>;
  43418. /**
  43419. * Defines the target of the camera before paning.
  43420. */
  43421. panningOriginTarget: Vector3;
  43422. /**
  43423. * Defines the value of the inertia used during panning.
  43424. * 0 would mean stop inertia and one would mean no decelleration at all.
  43425. */
  43426. panningInertia: number;
  43427. /**
  43428. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43429. */
  43430. get angularSensibilityX(): number;
  43431. set angularSensibilityX(value: number);
  43432. /**
  43433. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43434. */
  43435. get angularSensibilityY(): number;
  43436. set angularSensibilityY(value: number);
  43437. /**
  43438. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43439. */
  43440. get pinchPrecision(): number;
  43441. set pinchPrecision(value: number);
  43442. /**
  43443. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43444. * It will be used instead of pinchDeltaPrecision if different from 0.
  43445. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43446. */
  43447. get pinchDeltaPercentage(): number;
  43448. set pinchDeltaPercentage(value: number);
  43449. /**
  43450. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43451. * and pinch delta percentage.
  43452. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43453. * that any object in the plane at the camera's target point will scale
  43454. * perfectly with finger motion.
  43455. */
  43456. get useNaturalPinchZoom(): boolean;
  43457. set useNaturalPinchZoom(value: boolean);
  43458. /**
  43459. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43460. */
  43461. get panningSensibility(): number;
  43462. set panningSensibility(value: number);
  43463. /**
  43464. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43465. */
  43466. get keysUp(): number[];
  43467. set keysUp(value: number[]);
  43468. /**
  43469. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43470. */
  43471. get keysDown(): number[];
  43472. set keysDown(value: number[]);
  43473. /**
  43474. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43475. */
  43476. get keysLeft(): number[];
  43477. set keysLeft(value: number[]);
  43478. /**
  43479. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43480. */
  43481. get keysRight(): number[];
  43482. set keysRight(value: number[]);
  43483. /**
  43484. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43485. */
  43486. get wheelPrecision(): number;
  43487. set wheelPrecision(value: number);
  43488. /**
  43489. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43490. * It will be used instead of pinchDeltaPrecision if different from 0.
  43491. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43492. */
  43493. get wheelDeltaPercentage(): number;
  43494. set wheelDeltaPercentage(value: number);
  43495. /**
  43496. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43497. */
  43498. zoomOnFactor: number;
  43499. /**
  43500. * Defines a screen offset for the camera position.
  43501. */
  43502. targetScreenOffset: Vector2;
  43503. /**
  43504. * Allows the camera to be completely reversed.
  43505. * If false the camera can not arrive upside down.
  43506. */
  43507. allowUpsideDown: boolean;
  43508. /**
  43509. * Define if double tap/click is used to restore the previously saved state of the camera.
  43510. */
  43511. useInputToRestoreState: boolean;
  43512. /** @hidden */
  43513. _viewMatrix: Matrix;
  43514. /** @hidden */
  43515. _useCtrlForPanning: boolean;
  43516. /** @hidden */
  43517. _panningMouseButton: number;
  43518. /**
  43519. * Defines the input associated to the camera.
  43520. */
  43521. inputs: ArcRotateCameraInputsManager;
  43522. /** @hidden */
  43523. _reset: () => void;
  43524. /**
  43525. * Defines the allowed panning axis.
  43526. */
  43527. panningAxis: Vector3;
  43528. protected _localDirection: Vector3;
  43529. protected _transformedDirection: Vector3;
  43530. private _bouncingBehavior;
  43531. /**
  43532. * Gets the bouncing behavior of the camera if it has been enabled.
  43533. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43534. */
  43535. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43536. /**
  43537. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43538. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43539. */
  43540. get useBouncingBehavior(): boolean;
  43541. set useBouncingBehavior(value: boolean);
  43542. private _framingBehavior;
  43543. /**
  43544. * Gets the framing behavior of the camera if it has been enabled.
  43545. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43546. */
  43547. get framingBehavior(): Nullable<FramingBehavior>;
  43548. /**
  43549. * Defines if the framing behavior of the camera is enabled on the camera.
  43550. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43551. */
  43552. get useFramingBehavior(): boolean;
  43553. set useFramingBehavior(value: boolean);
  43554. private _autoRotationBehavior;
  43555. /**
  43556. * Gets the auto rotation behavior of the camera if it has been enabled.
  43557. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43558. */
  43559. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43560. /**
  43561. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43562. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43563. */
  43564. get useAutoRotationBehavior(): boolean;
  43565. set useAutoRotationBehavior(value: boolean);
  43566. /**
  43567. * Observable triggered when the mesh target has been changed on the camera.
  43568. */
  43569. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43570. /**
  43571. * Event raised when the camera is colliding with a mesh.
  43572. */
  43573. onCollide: (collidedMesh: AbstractMesh) => void;
  43574. /**
  43575. * Defines whether the camera should check collision with the objects oh the scene.
  43576. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43577. */
  43578. checkCollisions: boolean;
  43579. /**
  43580. * Defines the collision radius of the camera.
  43581. * This simulates a sphere around the camera.
  43582. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43583. */
  43584. collisionRadius: Vector3;
  43585. protected _collider: Collider;
  43586. protected _previousPosition: Vector3;
  43587. protected _collisionVelocity: Vector3;
  43588. protected _newPosition: Vector3;
  43589. protected _previousAlpha: number;
  43590. protected _previousBeta: number;
  43591. protected _previousRadius: number;
  43592. protected _collisionTriggered: boolean;
  43593. protected _targetBoundingCenter: Nullable<Vector3>;
  43594. private _computationVector;
  43595. /**
  43596. * Instantiates a new ArcRotateCamera in a given scene
  43597. * @param name Defines the name of the camera
  43598. * @param alpha Defines the camera rotation along the logitudinal axis
  43599. * @param beta Defines the camera rotation along the latitudinal axis
  43600. * @param radius Defines the camera distance from its target
  43601. * @param target Defines the camera target
  43602. * @param scene Defines the scene the camera belongs to
  43603. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43604. */
  43605. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43606. /** @hidden */
  43607. _initCache(): void;
  43608. /** @hidden */
  43609. _updateCache(ignoreParentClass?: boolean): void;
  43610. protected _getTargetPosition(): Vector3;
  43611. private _storedAlpha;
  43612. private _storedBeta;
  43613. private _storedRadius;
  43614. private _storedTarget;
  43615. private _storedTargetScreenOffset;
  43616. /**
  43617. * Stores the current state of the camera (alpha, beta, radius and target)
  43618. * @returns the camera itself
  43619. */
  43620. storeState(): Camera;
  43621. /**
  43622. * @hidden
  43623. * Restored camera state. You must call storeState() first
  43624. */
  43625. _restoreStateValues(): boolean;
  43626. /** @hidden */
  43627. _isSynchronizedViewMatrix(): boolean;
  43628. /**
  43629. * Attached controls to the current camera.
  43630. * @param element Defines the element the controls should be listened from
  43631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43632. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43633. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43634. */
  43635. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43636. /**
  43637. * Detach the current controls from the camera.
  43638. * The camera will stop reacting to inputs.
  43639. * @param element Defines the element to stop listening the inputs from
  43640. */
  43641. detachControl(element: HTMLElement): void;
  43642. /** @hidden */
  43643. _checkInputs(): void;
  43644. protected _checkLimits(): void;
  43645. /**
  43646. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43647. */
  43648. rebuildAnglesAndRadius(): void;
  43649. /**
  43650. * Use a position to define the current camera related information like alpha, beta and radius
  43651. * @param position Defines the position to set the camera at
  43652. */
  43653. setPosition(position: Vector3): void;
  43654. /**
  43655. * Defines the target the camera should look at.
  43656. * This will automatically adapt alpha beta and radius to fit within the new target.
  43657. * @param target Defines the new target as a Vector or a mesh
  43658. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43659. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43660. */
  43661. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43662. /** @hidden */
  43663. _getViewMatrix(): Matrix;
  43664. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43665. /**
  43666. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43667. * @param meshes Defines the mesh to zoom on
  43668. * @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)
  43669. */
  43670. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43671. /**
  43672. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43673. * The target will be changed but the radius
  43674. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43675. * @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)
  43676. */
  43677. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43678. min: Vector3;
  43679. max: Vector3;
  43680. distance: number;
  43681. }, doNotUpdateMaxZ?: boolean): void;
  43682. /**
  43683. * @override
  43684. * Override Camera.createRigCamera
  43685. */
  43686. createRigCamera(name: string, cameraIndex: number): Camera;
  43687. /**
  43688. * @hidden
  43689. * @override
  43690. * Override Camera._updateRigCameras
  43691. */
  43692. _updateRigCameras(): void;
  43693. /**
  43694. * Destroy the camera and release the current resources hold by it.
  43695. */
  43696. dispose(): void;
  43697. /**
  43698. * Gets the current object class name.
  43699. * @return the class name
  43700. */
  43701. getClassName(): string;
  43702. }
  43703. }
  43704. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43705. import { Behavior } from "babylonjs/Behaviors/behavior";
  43706. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43707. /**
  43708. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43709. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43710. */
  43711. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43712. /**
  43713. * Gets the name of the behavior.
  43714. */
  43715. get name(): string;
  43716. private _zoomStopsAnimation;
  43717. private _idleRotationSpeed;
  43718. private _idleRotationWaitTime;
  43719. private _idleRotationSpinupTime;
  43720. /**
  43721. * Sets the flag that indicates if user zooming should stop animation.
  43722. */
  43723. set zoomStopsAnimation(flag: boolean);
  43724. /**
  43725. * Gets the flag that indicates if user zooming should stop animation.
  43726. */
  43727. get zoomStopsAnimation(): boolean;
  43728. /**
  43729. * Sets the default speed at which the camera rotates around the model.
  43730. */
  43731. set idleRotationSpeed(speed: number);
  43732. /**
  43733. * Gets the default speed at which the camera rotates around the model.
  43734. */
  43735. get idleRotationSpeed(): number;
  43736. /**
  43737. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43738. */
  43739. set idleRotationWaitTime(time: number);
  43740. /**
  43741. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43742. */
  43743. get idleRotationWaitTime(): number;
  43744. /**
  43745. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43746. */
  43747. set idleRotationSpinupTime(time: number);
  43748. /**
  43749. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43750. */
  43751. get idleRotationSpinupTime(): number;
  43752. /**
  43753. * Gets a value indicating if the camera is currently rotating because of this behavior
  43754. */
  43755. get rotationInProgress(): boolean;
  43756. private _onPrePointerObservableObserver;
  43757. private _onAfterCheckInputsObserver;
  43758. private _attachedCamera;
  43759. private _isPointerDown;
  43760. private _lastFrameTime;
  43761. private _lastInteractionTime;
  43762. private _cameraRotationSpeed;
  43763. /**
  43764. * Initializes the behavior.
  43765. */
  43766. init(): void;
  43767. /**
  43768. * Attaches the behavior to its arc rotate camera.
  43769. * @param camera Defines the camera to attach the behavior to
  43770. */
  43771. attach(camera: ArcRotateCamera): void;
  43772. /**
  43773. * Detaches the behavior from its current arc rotate camera.
  43774. */
  43775. detach(): void;
  43776. /**
  43777. * Returns true if user is scrolling.
  43778. * @return true if user is scrolling.
  43779. */
  43780. private _userIsZooming;
  43781. private _lastFrameRadius;
  43782. private _shouldAnimationStopForInteraction;
  43783. /**
  43784. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43785. */
  43786. private _applyUserInteraction;
  43787. private _userIsMoving;
  43788. }
  43789. }
  43790. declare module "babylonjs/Behaviors/Cameras/index" {
  43791. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43792. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43793. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43794. }
  43795. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43796. import { Mesh } from "babylonjs/Meshes/mesh";
  43797. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43798. import { Behavior } from "babylonjs/Behaviors/behavior";
  43799. /**
  43800. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43801. */
  43802. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43803. private ui;
  43804. /**
  43805. * The name of the behavior
  43806. */
  43807. name: string;
  43808. /**
  43809. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43810. */
  43811. distanceAwayFromFace: number;
  43812. /**
  43813. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43814. */
  43815. distanceAwayFromBottomOfFace: number;
  43816. private _faceVectors;
  43817. private _target;
  43818. private _scene;
  43819. private _onRenderObserver;
  43820. private _tmpMatrix;
  43821. private _tmpVector;
  43822. /**
  43823. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43824. * @param ui The transform node that should be attched to the mesh
  43825. */
  43826. constructor(ui: TransformNode);
  43827. /**
  43828. * Initializes the behavior
  43829. */
  43830. init(): void;
  43831. private _closestFace;
  43832. private _zeroVector;
  43833. private _lookAtTmpMatrix;
  43834. private _lookAtToRef;
  43835. /**
  43836. * Attaches the AttachToBoxBehavior to the passed in mesh
  43837. * @param target The mesh that the specified node will be attached to
  43838. */
  43839. attach(target: Mesh): void;
  43840. /**
  43841. * Detaches the behavior from the mesh
  43842. */
  43843. detach(): void;
  43844. }
  43845. }
  43846. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43847. import { Behavior } from "babylonjs/Behaviors/behavior";
  43848. import { Mesh } from "babylonjs/Meshes/mesh";
  43849. /**
  43850. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43851. */
  43852. export class FadeInOutBehavior implements Behavior<Mesh> {
  43853. /**
  43854. * Time in milliseconds to delay before fading in (Default: 0)
  43855. */
  43856. delay: number;
  43857. /**
  43858. * Time in milliseconds for the mesh to fade in (Default: 300)
  43859. */
  43860. fadeInTime: number;
  43861. private _millisecondsPerFrame;
  43862. private _hovered;
  43863. private _hoverValue;
  43864. private _ownerNode;
  43865. /**
  43866. * Instatiates the FadeInOutBehavior
  43867. */
  43868. constructor();
  43869. /**
  43870. * The name of the behavior
  43871. */
  43872. get name(): string;
  43873. /**
  43874. * Initializes the behavior
  43875. */
  43876. init(): void;
  43877. /**
  43878. * Attaches the fade behavior on the passed in mesh
  43879. * @param ownerNode The mesh that will be faded in/out once attached
  43880. */
  43881. attach(ownerNode: Mesh): void;
  43882. /**
  43883. * Detaches the behavior from the mesh
  43884. */
  43885. detach(): void;
  43886. /**
  43887. * Triggers the mesh to begin fading in or out
  43888. * @param value if the object should fade in or out (true to fade in)
  43889. */
  43890. fadeIn(value: boolean): void;
  43891. private _update;
  43892. private _setAllVisibility;
  43893. }
  43894. }
  43895. declare module "babylonjs/Misc/pivotTools" {
  43896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43897. /**
  43898. * Class containing a set of static utilities functions for managing Pivots
  43899. * @hidden
  43900. */
  43901. export class PivotTools {
  43902. private static _PivotCached;
  43903. private static _OldPivotPoint;
  43904. private static _PivotTranslation;
  43905. private static _PivotTmpVector;
  43906. /** @hidden */
  43907. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43908. /** @hidden */
  43909. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43910. }
  43911. }
  43912. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43913. import { Scene } from "babylonjs/scene";
  43914. import { Vector4 } from "babylonjs/Maths/math.vector";
  43915. import { Mesh } from "babylonjs/Meshes/mesh";
  43916. import { Nullable } from "babylonjs/types";
  43917. import { Plane } from "babylonjs/Maths/math.plane";
  43918. /**
  43919. * Class containing static functions to help procedurally build meshes
  43920. */
  43921. export class PlaneBuilder {
  43922. /**
  43923. * Creates a plane mesh
  43924. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43925. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43926. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43930. * @param name defines the name of the mesh
  43931. * @param options defines the options used to create the mesh
  43932. * @param scene defines the hosting scene
  43933. * @returns the plane mesh
  43934. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43935. */
  43936. static CreatePlane(name: string, options: {
  43937. size?: number;
  43938. width?: number;
  43939. height?: number;
  43940. sideOrientation?: number;
  43941. frontUVs?: Vector4;
  43942. backUVs?: Vector4;
  43943. updatable?: boolean;
  43944. sourcePlane?: Plane;
  43945. }, scene?: Nullable<Scene>): Mesh;
  43946. }
  43947. }
  43948. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43949. import { Behavior } from "babylonjs/Behaviors/behavior";
  43950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43951. import { Observable } from "babylonjs/Misc/observable";
  43952. import { Vector3 } from "babylonjs/Maths/math.vector";
  43953. import { Ray } from "babylonjs/Culling/ray";
  43954. import "babylonjs/Meshes/Builders/planeBuilder";
  43955. /**
  43956. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43957. */
  43958. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43959. private static _AnyMouseID;
  43960. /**
  43961. * Abstract mesh the behavior is set on
  43962. */
  43963. attachedNode: AbstractMesh;
  43964. private _dragPlane;
  43965. private _scene;
  43966. private _pointerObserver;
  43967. private _beforeRenderObserver;
  43968. private static _planeScene;
  43969. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43970. /**
  43971. * 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)
  43972. */
  43973. maxDragAngle: number;
  43974. /**
  43975. * @hidden
  43976. */
  43977. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43978. /**
  43979. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43980. */
  43981. currentDraggingPointerID: number;
  43982. /**
  43983. * The last position where the pointer hit the drag plane in world space
  43984. */
  43985. lastDragPosition: Vector3;
  43986. /**
  43987. * If the behavior is currently in a dragging state
  43988. */
  43989. dragging: boolean;
  43990. /**
  43991. * 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)
  43992. */
  43993. dragDeltaRatio: number;
  43994. /**
  43995. * If the drag plane orientation should be updated during the dragging (Default: true)
  43996. */
  43997. updateDragPlane: boolean;
  43998. private _debugMode;
  43999. private _moving;
  44000. /**
  44001. * Fires each time the attached mesh is dragged with the pointer
  44002. * * delta between last drag position and current drag position in world space
  44003. * * dragDistance along the drag axis
  44004. * * dragPlaneNormal normal of the current drag plane used during the drag
  44005. * * dragPlanePoint in world space where the drag intersects the drag plane
  44006. */
  44007. onDragObservable: Observable<{
  44008. delta: Vector3;
  44009. dragPlanePoint: Vector3;
  44010. dragPlaneNormal: Vector3;
  44011. dragDistance: number;
  44012. pointerId: number;
  44013. }>;
  44014. /**
  44015. * Fires each time a drag begins (eg. mouse down on mesh)
  44016. */
  44017. onDragStartObservable: Observable<{
  44018. dragPlanePoint: Vector3;
  44019. pointerId: number;
  44020. }>;
  44021. /**
  44022. * Fires each time a drag ends (eg. mouse release after drag)
  44023. */
  44024. onDragEndObservable: Observable<{
  44025. dragPlanePoint: Vector3;
  44026. pointerId: number;
  44027. }>;
  44028. /**
  44029. * If the attached mesh should be moved when dragged
  44030. */
  44031. moveAttached: boolean;
  44032. /**
  44033. * If the drag behavior will react to drag events (Default: true)
  44034. */
  44035. enabled: boolean;
  44036. /**
  44037. * If pointer events should start and release the drag (Default: true)
  44038. */
  44039. startAndReleaseDragOnPointerEvents: boolean;
  44040. /**
  44041. * If camera controls should be detached during the drag
  44042. */
  44043. detachCameraControls: boolean;
  44044. /**
  44045. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44046. */
  44047. useObjectOrientationForDragging: boolean;
  44048. private _options;
  44049. /**
  44050. * Gets the options used by the behavior
  44051. */
  44052. get options(): {
  44053. dragAxis?: Vector3;
  44054. dragPlaneNormal?: Vector3;
  44055. };
  44056. /**
  44057. * Sets the options used by the behavior
  44058. */
  44059. set options(options: {
  44060. dragAxis?: Vector3;
  44061. dragPlaneNormal?: Vector3;
  44062. });
  44063. /**
  44064. * Creates a pointer drag behavior that can be attached to a mesh
  44065. * @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)
  44066. */
  44067. constructor(options?: {
  44068. dragAxis?: Vector3;
  44069. dragPlaneNormal?: Vector3;
  44070. });
  44071. /**
  44072. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44073. */
  44074. validateDrag: (targetPosition: Vector3) => boolean;
  44075. /**
  44076. * The name of the behavior
  44077. */
  44078. get name(): string;
  44079. /**
  44080. * Initializes the behavior
  44081. */
  44082. init(): void;
  44083. private _tmpVector;
  44084. private _alternatePickedPoint;
  44085. private _worldDragAxis;
  44086. private _targetPosition;
  44087. private _attachedElement;
  44088. /**
  44089. * Attaches the drag behavior the passed in mesh
  44090. * @param ownerNode The mesh that will be dragged around once attached
  44091. * @param predicate Predicate to use for pick filtering
  44092. */
  44093. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44094. /**
  44095. * Force relase the drag action by code.
  44096. */
  44097. releaseDrag(): void;
  44098. private _startDragRay;
  44099. private _lastPointerRay;
  44100. /**
  44101. * Simulates the start of a pointer drag event on the behavior
  44102. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44103. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44104. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44105. */
  44106. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44107. private _startDrag;
  44108. private _dragDelta;
  44109. private _moveDrag;
  44110. private _pickWithRayOnDragPlane;
  44111. private _pointA;
  44112. private _pointB;
  44113. private _pointC;
  44114. private _lineA;
  44115. private _lineB;
  44116. private _localAxis;
  44117. private _lookAt;
  44118. private _updateDragPlanePosition;
  44119. /**
  44120. * Detaches the behavior from the mesh
  44121. */
  44122. detach(): void;
  44123. }
  44124. }
  44125. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44126. import { Mesh } from "babylonjs/Meshes/mesh";
  44127. import { Behavior } from "babylonjs/Behaviors/behavior";
  44128. /**
  44129. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44130. */
  44131. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44132. private _dragBehaviorA;
  44133. private _dragBehaviorB;
  44134. private _startDistance;
  44135. private _initialScale;
  44136. private _targetScale;
  44137. private _ownerNode;
  44138. private _sceneRenderObserver;
  44139. /**
  44140. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44141. */
  44142. constructor();
  44143. /**
  44144. * The name of the behavior
  44145. */
  44146. get name(): string;
  44147. /**
  44148. * Initializes the behavior
  44149. */
  44150. init(): void;
  44151. private _getCurrentDistance;
  44152. /**
  44153. * Attaches the scale behavior the passed in mesh
  44154. * @param ownerNode The mesh that will be scaled around once attached
  44155. */
  44156. attach(ownerNode: Mesh): void;
  44157. /**
  44158. * Detaches the behavior from the mesh
  44159. */
  44160. detach(): void;
  44161. }
  44162. }
  44163. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44164. import { Behavior } from "babylonjs/Behaviors/behavior";
  44165. import { Mesh } from "babylonjs/Meshes/mesh";
  44166. import { Observable } from "babylonjs/Misc/observable";
  44167. /**
  44168. * 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
  44169. */
  44170. export class SixDofDragBehavior implements Behavior<Mesh> {
  44171. private static _virtualScene;
  44172. private _ownerNode;
  44173. private _sceneRenderObserver;
  44174. private _scene;
  44175. private _targetPosition;
  44176. private _virtualOriginMesh;
  44177. private _virtualDragMesh;
  44178. private _pointerObserver;
  44179. private _moving;
  44180. private _startingOrientation;
  44181. private _attachedElement;
  44182. /**
  44183. * 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)
  44184. */
  44185. private zDragFactor;
  44186. /**
  44187. * If the object should rotate to face the drag origin
  44188. */
  44189. rotateDraggedObject: boolean;
  44190. /**
  44191. * If the behavior is currently in a dragging state
  44192. */
  44193. dragging: boolean;
  44194. /**
  44195. * 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)
  44196. */
  44197. dragDeltaRatio: number;
  44198. /**
  44199. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44200. */
  44201. currentDraggingPointerID: number;
  44202. /**
  44203. * If camera controls should be detached during the drag
  44204. */
  44205. detachCameraControls: boolean;
  44206. /**
  44207. * Fires each time a drag starts
  44208. */
  44209. onDragStartObservable: Observable<{}>;
  44210. /**
  44211. * Fires each time a drag ends (eg. mouse release after drag)
  44212. */
  44213. onDragEndObservable: Observable<{}>;
  44214. /**
  44215. * 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
  44216. */
  44217. constructor();
  44218. /**
  44219. * The name of the behavior
  44220. */
  44221. get name(): string;
  44222. /**
  44223. * Initializes the behavior
  44224. */
  44225. init(): void;
  44226. /**
  44227. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44228. */
  44229. private get _pointerCamera();
  44230. /**
  44231. * Attaches the scale behavior the passed in mesh
  44232. * @param ownerNode The mesh that will be scaled around once attached
  44233. */
  44234. attach(ownerNode: Mesh): void;
  44235. /**
  44236. * Detaches the behavior from the mesh
  44237. */
  44238. detach(): void;
  44239. }
  44240. }
  44241. declare module "babylonjs/Behaviors/Meshes/index" {
  44242. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44243. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44244. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44245. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44246. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44247. }
  44248. declare module "babylonjs/Behaviors/index" {
  44249. export * from "babylonjs/Behaviors/behavior";
  44250. export * from "babylonjs/Behaviors/Cameras/index";
  44251. export * from "babylonjs/Behaviors/Meshes/index";
  44252. }
  44253. declare module "babylonjs/Bones/boneIKController" {
  44254. import { Bone } from "babylonjs/Bones/bone";
  44255. import { Vector3 } from "babylonjs/Maths/math.vector";
  44256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44257. import { Nullable } from "babylonjs/types";
  44258. /**
  44259. * Class used to apply inverse kinematics to bones
  44260. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44261. */
  44262. export class BoneIKController {
  44263. private static _tmpVecs;
  44264. private static _tmpQuat;
  44265. private static _tmpMats;
  44266. /**
  44267. * Gets or sets the target mesh
  44268. */
  44269. targetMesh: AbstractMesh;
  44270. /** Gets or sets the mesh used as pole */
  44271. poleTargetMesh: AbstractMesh;
  44272. /**
  44273. * Gets or sets the bone used as pole
  44274. */
  44275. poleTargetBone: Nullable<Bone>;
  44276. /**
  44277. * Gets or sets the target position
  44278. */
  44279. targetPosition: Vector3;
  44280. /**
  44281. * Gets or sets the pole target position
  44282. */
  44283. poleTargetPosition: Vector3;
  44284. /**
  44285. * Gets or sets the pole target local offset
  44286. */
  44287. poleTargetLocalOffset: Vector3;
  44288. /**
  44289. * Gets or sets the pole angle
  44290. */
  44291. poleAngle: number;
  44292. /**
  44293. * Gets or sets the mesh associated with the controller
  44294. */
  44295. mesh: AbstractMesh;
  44296. /**
  44297. * 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)
  44298. */
  44299. slerpAmount: number;
  44300. private _bone1Quat;
  44301. private _bone1Mat;
  44302. private _bone2Ang;
  44303. private _bone1;
  44304. private _bone2;
  44305. private _bone1Length;
  44306. private _bone2Length;
  44307. private _maxAngle;
  44308. private _maxReach;
  44309. private _rightHandedSystem;
  44310. private _bendAxis;
  44311. private _slerping;
  44312. private _adjustRoll;
  44313. /**
  44314. * Gets or sets maximum allowed angle
  44315. */
  44316. get maxAngle(): number;
  44317. set maxAngle(value: number);
  44318. /**
  44319. * Creates a new BoneIKController
  44320. * @param mesh defines the mesh to control
  44321. * @param bone defines the bone to control
  44322. * @param options defines options to set up the controller
  44323. */
  44324. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44325. targetMesh?: AbstractMesh;
  44326. poleTargetMesh?: AbstractMesh;
  44327. poleTargetBone?: Bone;
  44328. poleTargetLocalOffset?: Vector3;
  44329. poleAngle?: number;
  44330. bendAxis?: Vector3;
  44331. maxAngle?: number;
  44332. slerpAmount?: number;
  44333. });
  44334. private _setMaxAngle;
  44335. /**
  44336. * Force the controller to update the bones
  44337. */
  44338. update(): void;
  44339. }
  44340. }
  44341. declare module "babylonjs/Bones/boneLookController" {
  44342. import { Vector3 } from "babylonjs/Maths/math.vector";
  44343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44344. import { Bone } from "babylonjs/Bones/bone";
  44345. import { Space } from "babylonjs/Maths/math.axis";
  44346. /**
  44347. * Class used to make a bone look toward a point in space
  44348. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44349. */
  44350. export class BoneLookController {
  44351. private static _tmpVecs;
  44352. private static _tmpQuat;
  44353. private static _tmpMats;
  44354. /**
  44355. * The target Vector3 that the bone will look at
  44356. */
  44357. target: Vector3;
  44358. /**
  44359. * The mesh that the bone is attached to
  44360. */
  44361. mesh: AbstractMesh;
  44362. /**
  44363. * The bone that will be looking to the target
  44364. */
  44365. bone: Bone;
  44366. /**
  44367. * The up axis of the coordinate system that is used when the bone is rotated
  44368. */
  44369. upAxis: Vector3;
  44370. /**
  44371. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44372. */
  44373. upAxisSpace: Space;
  44374. /**
  44375. * Used to make an adjustment to the yaw of the bone
  44376. */
  44377. adjustYaw: number;
  44378. /**
  44379. * Used to make an adjustment to the pitch of the bone
  44380. */
  44381. adjustPitch: number;
  44382. /**
  44383. * Used to make an adjustment to the roll of the bone
  44384. */
  44385. adjustRoll: number;
  44386. /**
  44387. * 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)
  44388. */
  44389. slerpAmount: number;
  44390. private _minYaw;
  44391. private _maxYaw;
  44392. private _minPitch;
  44393. private _maxPitch;
  44394. private _minYawSin;
  44395. private _minYawCos;
  44396. private _maxYawSin;
  44397. private _maxYawCos;
  44398. private _midYawConstraint;
  44399. private _minPitchTan;
  44400. private _maxPitchTan;
  44401. private _boneQuat;
  44402. private _slerping;
  44403. private _transformYawPitch;
  44404. private _transformYawPitchInv;
  44405. private _firstFrameSkipped;
  44406. private _yawRange;
  44407. private _fowardAxis;
  44408. /**
  44409. * Gets or sets the minimum yaw angle that the bone can look to
  44410. */
  44411. get minYaw(): number;
  44412. set minYaw(value: number);
  44413. /**
  44414. * Gets or sets the maximum yaw angle that the bone can look to
  44415. */
  44416. get maxYaw(): number;
  44417. set maxYaw(value: number);
  44418. /**
  44419. * Gets or sets the minimum pitch angle that the bone can look to
  44420. */
  44421. get minPitch(): number;
  44422. set minPitch(value: number);
  44423. /**
  44424. * Gets or sets the maximum pitch angle that the bone can look to
  44425. */
  44426. get maxPitch(): number;
  44427. set maxPitch(value: number);
  44428. /**
  44429. * Create a BoneLookController
  44430. * @param mesh the mesh that the bone belongs to
  44431. * @param bone the bone that will be looking to the target
  44432. * @param target the target Vector3 to look at
  44433. * @param options optional settings:
  44434. * * maxYaw: the maximum angle the bone will yaw to
  44435. * * minYaw: the minimum angle the bone will yaw to
  44436. * * maxPitch: the maximum angle the bone will pitch to
  44437. * * minPitch: the minimum angle the bone will yaw to
  44438. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44439. * * upAxis: the up axis of the coordinate system
  44440. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44441. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44442. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44443. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44444. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44445. * * adjustRoll: used to make an adjustment to the roll of the bone
  44446. **/
  44447. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44448. maxYaw?: number;
  44449. minYaw?: number;
  44450. maxPitch?: number;
  44451. minPitch?: number;
  44452. slerpAmount?: number;
  44453. upAxis?: Vector3;
  44454. upAxisSpace?: Space;
  44455. yawAxis?: Vector3;
  44456. pitchAxis?: Vector3;
  44457. adjustYaw?: number;
  44458. adjustPitch?: number;
  44459. adjustRoll?: number;
  44460. });
  44461. /**
  44462. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44463. */
  44464. update(): void;
  44465. private _getAngleDiff;
  44466. private _getAngleBetween;
  44467. private _isAngleBetween;
  44468. }
  44469. }
  44470. declare module "babylonjs/Bones/index" {
  44471. export * from "babylonjs/Bones/bone";
  44472. export * from "babylonjs/Bones/boneIKController";
  44473. export * from "babylonjs/Bones/boneLookController";
  44474. export * from "babylonjs/Bones/skeleton";
  44475. }
  44476. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44477. import { Nullable } from "babylonjs/types";
  44478. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44479. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44480. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44481. /**
  44482. * Manage the gamepad inputs to control an arc rotate camera.
  44483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44484. */
  44485. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44486. /**
  44487. * Defines the camera the input is attached to.
  44488. */
  44489. camera: ArcRotateCamera;
  44490. /**
  44491. * Defines the gamepad the input is gathering event from.
  44492. */
  44493. gamepad: Nullable<Gamepad>;
  44494. /**
  44495. * Defines the gamepad rotation sensiblity.
  44496. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44497. */
  44498. gamepadRotationSensibility: number;
  44499. /**
  44500. * Defines the gamepad move sensiblity.
  44501. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44502. */
  44503. gamepadMoveSensibility: number;
  44504. private _yAxisScale;
  44505. /**
  44506. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44507. */
  44508. get invertYAxis(): boolean;
  44509. set invertYAxis(value: boolean);
  44510. private _onGamepadConnectedObserver;
  44511. private _onGamepadDisconnectedObserver;
  44512. /**
  44513. * Attach the input controls to a specific dom element to get the input from.
  44514. * @param element Defines the element the controls should be listened from
  44515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44516. */
  44517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44518. /**
  44519. * Detach the current controls from the specified dom element.
  44520. * @param element Defines the element to stop listening the inputs from
  44521. */
  44522. detachControl(element: Nullable<HTMLElement>): void;
  44523. /**
  44524. * Update the current camera state depending on the inputs that have been used this frame.
  44525. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44526. */
  44527. checkInputs(): void;
  44528. /**
  44529. * Gets the class name of the current intput.
  44530. * @returns the class name
  44531. */
  44532. getClassName(): string;
  44533. /**
  44534. * Get the friendly name associated with the input class.
  44535. * @returns the input friendly name
  44536. */
  44537. getSimpleName(): string;
  44538. }
  44539. }
  44540. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44541. import { Nullable } from "babylonjs/types";
  44542. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44543. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44544. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44545. interface ArcRotateCameraInputsManager {
  44546. /**
  44547. * Add orientation input support to the input manager.
  44548. * @returns the current input manager
  44549. */
  44550. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44551. }
  44552. }
  44553. /**
  44554. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44556. */
  44557. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44558. /**
  44559. * Defines the camera the input is attached to.
  44560. */
  44561. camera: ArcRotateCamera;
  44562. /**
  44563. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44564. */
  44565. alphaCorrection: number;
  44566. /**
  44567. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44568. */
  44569. gammaCorrection: number;
  44570. private _alpha;
  44571. private _gamma;
  44572. private _dirty;
  44573. private _deviceOrientationHandler;
  44574. /**
  44575. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44576. */
  44577. constructor();
  44578. /**
  44579. * Attach the input controls to a specific dom element to get the input from.
  44580. * @param element Defines the element the controls should be listened from
  44581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44582. */
  44583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44584. /** @hidden */
  44585. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44586. /**
  44587. * Update the current camera state depending on the inputs that have been used this frame.
  44588. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44589. */
  44590. checkInputs(): void;
  44591. /**
  44592. * Detach the current controls from the specified dom element.
  44593. * @param element Defines the element to stop listening the inputs from
  44594. */
  44595. detachControl(element: Nullable<HTMLElement>): void;
  44596. /**
  44597. * Gets the class name of the current intput.
  44598. * @returns the class name
  44599. */
  44600. getClassName(): string;
  44601. /**
  44602. * Get the friendly name associated with the input class.
  44603. * @returns the input friendly name
  44604. */
  44605. getSimpleName(): string;
  44606. }
  44607. }
  44608. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44609. import { Nullable } from "babylonjs/types";
  44610. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44611. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44612. /**
  44613. * Listen to mouse events to control the camera.
  44614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44615. */
  44616. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44617. /**
  44618. * Defines the camera the input is attached to.
  44619. */
  44620. camera: FlyCamera;
  44621. /**
  44622. * Defines if touch is enabled. (Default is true.)
  44623. */
  44624. touchEnabled: boolean;
  44625. /**
  44626. * Defines the buttons associated with the input to handle camera rotation.
  44627. */
  44628. buttons: number[];
  44629. /**
  44630. * Assign buttons for Yaw control.
  44631. */
  44632. buttonsYaw: number[];
  44633. /**
  44634. * Assign buttons for Pitch control.
  44635. */
  44636. buttonsPitch: number[];
  44637. /**
  44638. * Assign buttons for Roll control.
  44639. */
  44640. buttonsRoll: number[];
  44641. /**
  44642. * Detect if any button is being pressed while mouse is moved.
  44643. * -1 = Mouse locked.
  44644. * 0 = Left button.
  44645. * 1 = Middle Button.
  44646. * 2 = Right Button.
  44647. */
  44648. activeButton: number;
  44649. /**
  44650. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44651. * Higher values reduce its sensitivity.
  44652. */
  44653. angularSensibility: number;
  44654. private _mousemoveCallback;
  44655. private _observer;
  44656. private _rollObserver;
  44657. private previousPosition;
  44658. private noPreventDefault;
  44659. private element;
  44660. /**
  44661. * Listen to mouse events to control the camera.
  44662. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44664. */
  44665. constructor(touchEnabled?: boolean);
  44666. /**
  44667. * Attach the mouse control to the HTML DOM element.
  44668. * @param element Defines the element that listens to the input events.
  44669. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44670. */
  44671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44672. /**
  44673. * Detach the current controls from the specified dom element.
  44674. * @param element Defines the element to stop listening the inputs from
  44675. */
  44676. detachControl(element: Nullable<HTMLElement>): void;
  44677. /**
  44678. * Gets the class name of the current input.
  44679. * @returns the class name.
  44680. */
  44681. getClassName(): string;
  44682. /**
  44683. * Get the friendly name associated with the input class.
  44684. * @returns the input's friendly name.
  44685. */
  44686. getSimpleName(): string;
  44687. private _pointerInput;
  44688. private _onMouseMove;
  44689. /**
  44690. * Rotate camera by mouse offset.
  44691. */
  44692. private rotateCamera;
  44693. }
  44694. }
  44695. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44696. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44697. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44698. /**
  44699. * Default Inputs manager for the FlyCamera.
  44700. * It groups all the default supported inputs for ease of use.
  44701. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44702. */
  44703. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44704. /**
  44705. * Instantiates a new FlyCameraInputsManager.
  44706. * @param camera Defines the camera the inputs belong to.
  44707. */
  44708. constructor(camera: FlyCamera);
  44709. /**
  44710. * Add keyboard input support to the input manager.
  44711. * @returns the new FlyCameraKeyboardMoveInput().
  44712. */
  44713. addKeyboard(): FlyCameraInputsManager;
  44714. /**
  44715. * Add mouse input support to the input manager.
  44716. * @param touchEnabled Enable touch screen support.
  44717. * @returns the new FlyCameraMouseInput().
  44718. */
  44719. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44720. }
  44721. }
  44722. declare module "babylonjs/Cameras/flyCamera" {
  44723. import { Scene } from "babylonjs/scene";
  44724. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44726. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44727. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44728. /**
  44729. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44730. * such as in a 3D Space Shooter or a Flight Simulator.
  44731. */
  44732. export class FlyCamera extends TargetCamera {
  44733. /**
  44734. * Define the collision ellipsoid of the camera.
  44735. * This is helpful for simulating a camera body, like a player's body.
  44736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44737. */
  44738. ellipsoid: Vector3;
  44739. /**
  44740. * Define an offset for the position of the ellipsoid around the camera.
  44741. * This can be helpful if the camera is attached away from the player's body center,
  44742. * such as at its head.
  44743. */
  44744. ellipsoidOffset: Vector3;
  44745. /**
  44746. * Enable or disable collisions of the camera with the rest of the scene objects.
  44747. */
  44748. checkCollisions: boolean;
  44749. /**
  44750. * Enable or disable gravity on the camera.
  44751. */
  44752. applyGravity: boolean;
  44753. /**
  44754. * Define the current direction the camera is moving to.
  44755. */
  44756. cameraDirection: Vector3;
  44757. /**
  44758. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44759. * This overrides and empties cameraRotation.
  44760. */
  44761. rotationQuaternion: Quaternion;
  44762. /**
  44763. * Track Roll to maintain the wanted Rolling when looking around.
  44764. */
  44765. _trackRoll: number;
  44766. /**
  44767. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44768. */
  44769. rollCorrect: number;
  44770. /**
  44771. * Mimic a banked turn, Rolling the camera when Yawing.
  44772. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44773. */
  44774. bankedTurn: boolean;
  44775. /**
  44776. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44777. */
  44778. bankedTurnLimit: number;
  44779. /**
  44780. * Value of 0 disables the banked Roll.
  44781. * Value of 1 is equal to the Yaw angle in radians.
  44782. */
  44783. bankedTurnMultiplier: number;
  44784. /**
  44785. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44786. */
  44787. inputs: FlyCameraInputsManager;
  44788. /**
  44789. * Gets the input sensibility for mouse input.
  44790. * Higher values reduce sensitivity.
  44791. */
  44792. get angularSensibility(): number;
  44793. /**
  44794. * Sets the input sensibility for a mouse input.
  44795. * Higher values reduce sensitivity.
  44796. */
  44797. set angularSensibility(value: number);
  44798. /**
  44799. * Get the keys for camera movement forward.
  44800. */
  44801. get keysForward(): number[];
  44802. /**
  44803. * Set the keys for camera movement forward.
  44804. */
  44805. set keysForward(value: number[]);
  44806. /**
  44807. * Get the keys for camera movement backward.
  44808. */
  44809. get keysBackward(): number[];
  44810. set keysBackward(value: number[]);
  44811. /**
  44812. * Get the keys for camera movement up.
  44813. */
  44814. get keysUp(): number[];
  44815. /**
  44816. * Set the keys for camera movement up.
  44817. */
  44818. set keysUp(value: number[]);
  44819. /**
  44820. * Get the keys for camera movement down.
  44821. */
  44822. get keysDown(): number[];
  44823. /**
  44824. * Set the keys for camera movement down.
  44825. */
  44826. set keysDown(value: number[]);
  44827. /**
  44828. * Get the keys for camera movement left.
  44829. */
  44830. get keysLeft(): number[];
  44831. /**
  44832. * Set the keys for camera movement left.
  44833. */
  44834. set keysLeft(value: number[]);
  44835. /**
  44836. * Set the keys for camera movement right.
  44837. */
  44838. get keysRight(): number[];
  44839. /**
  44840. * Set the keys for camera movement right.
  44841. */
  44842. set keysRight(value: number[]);
  44843. /**
  44844. * Event raised when the camera collides with a mesh in the scene.
  44845. */
  44846. onCollide: (collidedMesh: AbstractMesh) => void;
  44847. private _collider;
  44848. private _needMoveForGravity;
  44849. private _oldPosition;
  44850. private _diffPosition;
  44851. private _newPosition;
  44852. /** @hidden */
  44853. _localDirection: Vector3;
  44854. /** @hidden */
  44855. _transformedDirection: Vector3;
  44856. /**
  44857. * Instantiates a FlyCamera.
  44858. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44859. * such as in a 3D Space Shooter or a Flight Simulator.
  44860. * @param name Define the name of the camera in the scene.
  44861. * @param position Define the starting position of the camera in the scene.
  44862. * @param scene Define the scene the camera belongs to.
  44863. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44864. */
  44865. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44866. /**
  44867. * Attach a control to the HTML DOM element.
  44868. * @param element Defines the element that listens to the input events.
  44869. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44870. */
  44871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44872. /**
  44873. * Detach a control from the HTML DOM element.
  44874. * The camera will stop reacting to that input.
  44875. * @param element Defines the element that listens to the input events.
  44876. */
  44877. detachControl(element: HTMLElement): void;
  44878. private _collisionMask;
  44879. /**
  44880. * Get the mask that the camera ignores in collision events.
  44881. */
  44882. get collisionMask(): number;
  44883. /**
  44884. * Set the mask that the camera ignores in collision events.
  44885. */
  44886. set collisionMask(mask: number);
  44887. /** @hidden */
  44888. _collideWithWorld(displacement: Vector3): void;
  44889. /** @hidden */
  44890. private _onCollisionPositionChange;
  44891. /** @hidden */
  44892. _checkInputs(): void;
  44893. /** @hidden */
  44894. _decideIfNeedsToMove(): boolean;
  44895. /** @hidden */
  44896. _updatePosition(): void;
  44897. /**
  44898. * Restore the Roll to its target value at the rate specified.
  44899. * @param rate - Higher means slower restoring.
  44900. * @hidden
  44901. */
  44902. restoreRoll(rate: number): void;
  44903. /**
  44904. * Destroy the camera and release the current resources held by it.
  44905. */
  44906. dispose(): void;
  44907. /**
  44908. * Get the current object class name.
  44909. * @returns the class name.
  44910. */
  44911. getClassName(): string;
  44912. }
  44913. }
  44914. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44915. import { Nullable } from "babylonjs/types";
  44916. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44917. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44918. /**
  44919. * Listen to keyboard events to control the camera.
  44920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44921. */
  44922. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44923. /**
  44924. * Defines the camera the input is attached to.
  44925. */
  44926. camera: FlyCamera;
  44927. /**
  44928. * The list of keyboard keys used to control the forward move of the camera.
  44929. */
  44930. keysForward: number[];
  44931. /**
  44932. * The list of keyboard keys used to control the backward move of the camera.
  44933. */
  44934. keysBackward: number[];
  44935. /**
  44936. * The list of keyboard keys used to control the forward move of the camera.
  44937. */
  44938. keysUp: number[];
  44939. /**
  44940. * The list of keyboard keys used to control the backward move of the camera.
  44941. */
  44942. keysDown: number[];
  44943. /**
  44944. * The list of keyboard keys used to control the right strafe move of the camera.
  44945. */
  44946. keysRight: number[];
  44947. /**
  44948. * The list of keyboard keys used to control the left strafe move of the camera.
  44949. */
  44950. keysLeft: number[];
  44951. private _keys;
  44952. private _onCanvasBlurObserver;
  44953. private _onKeyboardObserver;
  44954. private _engine;
  44955. private _scene;
  44956. /**
  44957. * Attach the input controls to a specific dom element to get the input from.
  44958. * @param element Defines the element the controls should be listened from
  44959. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44960. */
  44961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44962. /**
  44963. * Detach the current controls from the specified dom element.
  44964. * @param element Defines the element to stop listening the inputs from
  44965. */
  44966. detachControl(element: Nullable<HTMLElement>): void;
  44967. /**
  44968. * Gets the class name of the current intput.
  44969. * @returns the class name
  44970. */
  44971. getClassName(): string;
  44972. /** @hidden */
  44973. _onLostFocus(e: FocusEvent): void;
  44974. /**
  44975. * Get the friendly name associated with the input class.
  44976. * @returns the input friendly name
  44977. */
  44978. getSimpleName(): string;
  44979. /**
  44980. * Update the current camera state depending on the inputs that have been used this frame.
  44981. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44982. */
  44983. checkInputs(): void;
  44984. }
  44985. }
  44986. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44987. import { Nullable } from "babylonjs/types";
  44988. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44989. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44990. /**
  44991. * Manage the mouse wheel inputs to control a follow camera.
  44992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44993. */
  44994. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44995. /**
  44996. * Defines the camera the input is attached to.
  44997. */
  44998. camera: FollowCamera;
  44999. /**
  45000. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45001. */
  45002. axisControlRadius: boolean;
  45003. /**
  45004. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45005. */
  45006. axisControlHeight: boolean;
  45007. /**
  45008. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45009. */
  45010. axisControlRotation: boolean;
  45011. /**
  45012. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45013. * relation to mouseWheel events.
  45014. */
  45015. wheelPrecision: number;
  45016. /**
  45017. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45018. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45019. */
  45020. wheelDeltaPercentage: number;
  45021. private _wheel;
  45022. private _observer;
  45023. /**
  45024. * Attach the input controls to a specific dom element to get the input from.
  45025. * @param element Defines the element the controls should be listened from
  45026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45027. */
  45028. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45029. /**
  45030. * Detach the current controls from the specified dom element.
  45031. * @param element Defines the element to stop listening the inputs from
  45032. */
  45033. detachControl(element: Nullable<HTMLElement>): void;
  45034. /**
  45035. * Gets the class name of the current intput.
  45036. * @returns the class name
  45037. */
  45038. getClassName(): string;
  45039. /**
  45040. * Get the friendly name associated with the input class.
  45041. * @returns the input friendly name
  45042. */
  45043. getSimpleName(): string;
  45044. }
  45045. }
  45046. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45047. import { Nullable } from "babylonjs/types";
  45048. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45049. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45050. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45051. /**
  45052. * Manage the pointers inputs to control an follow camera.
  45053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45054. */
  45055. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45056. /**
  45057. * Defines the camera the input is attached to.
  45058. */
  45059. camera: FollowCamera;
  45060. /**
  45061. * Gets the class name of the current input.
  45062. * @returns the class name
  45063. */
  45064. getClassName(): string;
  45065. /**
  45066. * Defines the pointer angular sensibility along the X axis or how fast is
  45067. * the camera rotating.
  45068. * A negative number will reverse the axis direction.
  45069. */
  45070. angularSensibilityX: number;
  45071. /**
  45072. * Defines the pointer angular sensibility along the Y axis or how fast is
  45073. * the camera rotating.
  45074. * A negative number will reverse the axis direction.
  45075. */
  45076. angularSensibilityY: number;
  45077. /**
  45078. * Defines the pointer pinch precision or how fast is the camera zooming.
  45079. * A negative number will reverse the axis direction.
  45080. */
  45081. pinchPrecision: number;
  45082. /**
  45083. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45084. * from 0.
  45085. * It defines the percentage of current camera.radius to use as delta when
  45086. * pinch zoom is used.
  45087. */
  45088. pinchDeltaPercentage: number;
  45089. /**
  45090. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45091. */
  45092. axisXControlRadius: boolean;
  45093. /**
  45094. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45095. */
  45096. axisXControlHeight: boolean;
  45097. /**
  45098. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45099. */
  45100. axisXControlRotation: boolean;
  45101. /**
  45102. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45103. */
  45104. axisYControlRadius: boolean;
  45105. /**
  45106. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45107. */
  45108. axisYControlHeight: boolean;
  45109. /**
  45110. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45111. */
  45112. axisYControlRotation: boolean;
  45113. /**
  45114. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45115. */
  45116. axisPinchControlRadius: boolean;
  45117. /**
  45118. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45119. */
  45120. axisPinchControlHeight: boolean;
  45121. /**
  45122. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45123. */
  45124. axisPinchControlRotation: boolean;
  45125. /**
  45126. * Log error messages if basic misconfiguration has occurred.
  45127. */
  45128. warningEnable: boolean;
  45129. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45130. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45131. private _warningCounter;
  45132. private _warning;
  45133. }
  45134. }
  45135. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45136. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45137. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45138. /**
  45139. * Default Inputs manager for the FollowCamera.
  45140. * It groups all the default supported inputs for ease of use.
  45141. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45142. */
  45143. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45144. /**
  45145. * Instantiates a new FollowCameraInputsManager.
  45146. * @param camera Defines the camera the inputs belong to
  45147. */
  45148. constructor(camera: FollowCamera);
  45149. /**
  45150. * Add keyboard input support to the input manager.
  45151. * @returns the current input manager
  45152. */
  45153. addKeyboard(): FollowCameraInputsManager;
  45154. /**
  45155. * Add mouse wheel input support to the input manager.
  45156. * @returns the current input manager
  45157. */
  45158. addMouseWheel(): FollowCameraInputsManager;
  45159. /**
  45160. * Add pointers input support to the input manager.
  45161. * @returns the current input manager
  45162. */
  45163. addPointers(): FollowCameraInputsManager;
  45164. /**
  45165. * Add orientation input support to the input manager.
  45166. * @returns the current input manager
  45167. */
  45168. addVRDeviceOrientation(): FollowCameraInputsManager;
  45169. }
  45170. }
  45171. declare module "babylonjs/Cameras/followCamera" {
  45172. import { Nullable } from "babylonjs/types";
  45173. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45174. import { Scene } from "babylonjs/scene";
  45175. import { Vector3 } from "babylonjs/Maths/math.vector";
  45176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45177. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45178. /**
  45179. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45180. * an arc rotate version arcFollowCamera are available.
  45181. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45182. */
  45183. export class FollowCamera extends TargetCamera {
  45184. /**
  45185. * Distance the follow camera should follow an object at
  45186. */
  45187. radius: number;
  45188. /**
  45189. * Minimum allowed distance of the camera to the axis of rotation
  45190. * (The camera can not get closer).
  45191. * This can help limiting how the Camera is able to move in the scene.
  45192. */
  45193. lowerRadiusLimit: Nullable<number>;
  45194. /**
  45195. * Maximum allowed distance of the camera to the axis of rotation
  45196. * (The camera can not get further).
  45197. * This can help limiting how the Camera is able to move in the scene.
  45198. */
  45199. upperRadiusLimit: Nullable<number>;
  45200. /**
  45201. * Define a rotation offset between the camera and the object it follows
  45202. */
  45203. rotationOffset: number;
  45204. /**
  45205. * Minimum allowed angle to camera position relative to target object.
  45206. * This can help limiting how the Camera is able to move in the scene.
  45207. */
  45208. lowerRotationOffsetLimit: Nullable<number>;
  45209. /**
  45210. * Maximum allowed angle to camera position relative to target object.
  45211. * This can help limiting how the Camera is able to move in the scene.
  45212. */
  45213. upperRotationOffsetLimit: Nullable<number>;
  45214. /**
  45215. * Define a height offset between the camera and the object it follows.
  45216. * It can help following an object from the top (like a car chaing a plane)
  45217. */
  45218. heightOffset: number;
  45219. /**
  45220. * Minimum allowed height of camera position relative to target object.
  45221. * This can help limiting how the Camera is able to move in the scene.
  45222. */
  45223. lowerHeightOffsetLimit: Nullable<number>;
  45224. /**
  45225. * Maximum allowed height of camera position relative to target object.
  45226. * This can help limiting how the Camera is able to move in the scene.
  45227. */
  45228. upperHeightOffsetLimit: Nullable<number>;
  45229. /**
  45230. * Define how fast the camera can accelerate to follow it s target.
  45231. */
  45232. cameraAcceleration: number;
  45233. /**
  45234. * Define the speed limit of the camera following an object.
  45235. */
  45236. maxCameraSpeed: number;
  45237. /**
  45238. * Define the target of the camera.
  45239. */
  45240. lockedTarget: Nullable<AbstractMesh>;
  45241. /**
  45242. * Defines the input associated with the camera.
  45243. */
  45244. inputs: FollowCameraInputsManager;
  45245. /**
  45246. * Instantiates the follow camera.
  45247. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45248. * @param name Define the name of the camera in the scene
  45249. * @param position Define the position of the camera
  45250. * @param scene Define the scene the camera belong to
  45251. * @param lockedTarget Define the target of the camera
  45252. */
  45253. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45254. private _follow;
  45255. /**
  45256. * Attached controls to the current camera.
  45257. * @param element Defines the element the controls should be listened from
  45258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45259. */
  45260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45261. /**
  45262. * Detach the current controls from the camera.
  45263. * The camera will stop reacting to inputs.
  45264. * @param element Defines the element to stop listening the inputs from
  45265. */
  45266. detachControl(element: HTMLElement): void;
  45267. /** @hidden */
  45268. _checkInputs(): void;
  45269. private _checkLimits;
  45270. /**
  45271. * Gets the camera class name.
  45272. * @returns the class name
  45273. */
  45274. getClassName(): string;
  45275. }
  45276. /**
  45277. * Arc Rotate version of the follow camera.
  45278. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45279. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45280. */
  45281. export class ArcFollowCamera extends TargetCamera {
  45282. /** The longitudinal angle of the camera */
  45283. alpha: number;
  45284. /** The latitudinal angle of the camera */
  45285. beta: number;
  45286. /** The radius of the camera from its target */
  45287. radius: number;
  45288. /** Define the camera target (the mesh it should follow) */
  45289. target: Nullable<AbstractMesh>;
  45290. private _cartesianCoordinates;
  45291. /**
  45292. * Instantiates a new ArcFollowCamera
  45293. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45294. * @param name Define the name of the camera
  45295. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45296. * @param beta Define the rotation angle of the camera around the elevation axis
  45297. * @param radius Define the radius of the camera from its target point
  45298. * @param target Define the target of the camera
  45299. * @param scene Define the scene the camera belongs to
  45300. */
  45301. constructor(name: string,
  45302. /** The longitudinal angle of the camera */
  45303. alpha: number,
  45304. /** The latitudinal angle of the camera */
  45305. beta: number,
  45306. /** The radius of the camera from its target */
  45307. radius: number,
  45308. /** Define the camera target (the mesh it should follow) */
  45309. target: Nullable<AbstractMesh>, scene: Scene);
  45310. private _follow;
  45311. /** @hidden */
  45312. _checkInputs(): void;
  45313. /**
  45314. * Returns the class name of the object.
  45315. * It is mostly used internally for serialization purposes.
  45316. */
  45317. getClassName(): string;
  45318. }
  45319. }
  45320. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45321. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45322. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45323. import { Nullable } from "babylonjs/types";
  45324. /**
  45325. * Manage the keyboard inputs to control the movement of a follow camera.
  45326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45327. */
  45328. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45329. /**
  45330. * Defines the camera the input is attached to.
  45331. */
  45332. camera: FollowCamera;
  45333. /**
  45334. * Defines the list of key codes associated with the up action (increase heightOffset)
  45335. */
  45336. keysHeightOffsetIncr: number[];
  45337. /**
  45338. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45339. */
  45340. keysHeightOffsetDecr: number[];
  45341. /**
  45342. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45343. */
  45344. keysHeightOffsetModifierAlt: boolean;
  45345. /**
  45346. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45347. */
  45348. keysHeightOffsetModifierCtrl: boolean;
  45349. /**
  45350. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45351. */
  45352. keysHeightOffsetModifierShift: boolean;
  45353. /**
  45354. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45355. */
  45356. keysRotationOffsetIncr: number[];
  45357. /**
  45358. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45359. */
  45360. keysRotationOffsetDecr: number[];
  45361. /**
  45362. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45363. */
  45364. keysRotationOffsetModifierAlt: boolean;
  45365. /**
  45366. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45367. */
  45368. keysRotationOffsetModifierCtrl: boolean;
  45369. /**
  45370. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45371. */
  45372. keysRotationOffsetModifierShift: boolean;
  45373. /**
  45374. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45375. */
  45376. keysRadiusIncr: number[];
  45377. /**
  45378. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45379. */
  45380. keysRadiusDecr: number[];
  45381. /**
  45382. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45383. */
  45384. keysRadiusModifierAlt: boolean;
  45385. /**
  45386. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45387. */
  45388. keysRadiusModifierCtrl: boolean;
  45389. /**
  45390. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45391. */
  45392. keysRadiusModifierShift: boolean;
  45393. /**
  45394. * Defines the rate of change of heightOffset.
  45395. */
  45396. heightSensibility: number;
  45397. /**
  45398. * Defines the rate of change of rotationOffset.
  45399. */
  45400. rotationSensibility: number;
  45401. /**
  45402. * Defines the rate of change of radius.
  45403. */
  45404. radiusSensibility: number;
  45405. private _keys;
  45406. private _ctrlPressed;
  45407. private _altPressed;
  45408. private _shiftPressed;
  45409. private _onCanvasBlurObserver;
  45410. private _onKeyboardObserver;
  45411. private _engine;
  45412. private _scene;
  45413. /**
  45414. * Attach the input controls to a specific dom element to get the input from.
  45415. * @param element Defines the element the controls should be listened from
  45416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45417. */
  45418. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45419. /**
  45420. * Detach the current controls from the specified dom element.
  45421. * @param element Defines the element to stop listening the inputs from
  45422. */
  45423. detachControl(element: Nullable<HTMLElement>): void;
  45424. /**
  45425. * Update the current camera state depending on the inputs that have been used this frame.
  45426. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45427. */
  45428. checkInputs(): void;
  45429. /**
  45430. * Gets the class name of the current input.
  45431. * @returns the class name
  45432. */
  45433. getClassName(): string;
  45434. /**
  45435. * Get the friendly name associated with the input class.
  45436. * @returns the input friendly name
  45437. */
  45438. getSimpleName(): string;
  45439. /**
  45440. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45441. * allow modification of the heightOffset value.
  45442. */
  45443. private _modifierHeightOffset;
  45444. /**
  45445. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45446. * allow modification of the rotationOffset value.
  45447. */
  45448. private _modifierRotationOffset;
  45449. /**
  45450. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45451. * allow modification of the radius value.
  45452. */
  45453. private _modifierRadius;
  45454. }
  45455. }
  45456. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45457. import { Nullable } from "babylonjs/types";
  45458. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45459. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45460. import { Observable } from "babylonjs/Misc/observable";
  45461. module "babylonjs/Cameras/freeCameraInputsManager" {
  45462. interface FreeCameraInputsManager {
  45463. /**
  45464. * @hidden
  45465. */
  45466. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45467. /**
  45468. * Add orientation input support to the input manager.
  45469. * @returns the current input manager
  45470. */
  45471. addDeviceOrientation(): FreeCameraInputsManager;
  45472. }
  45473. }
  45474. /**
  45475. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45476. * Screen rotation is taken into account.
  45477. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45478. */
  45479. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45480. private _camera;
  45481. private _screenOrientationAngle;
  45482. private _constantTranform;
  45483. private _screenQuaternion;
  45484. private _alpha;
  45485. private _beta;
  45486. private _gamma;
  45487. /**
  45488. * Can be used to detect if a device orientation sensor is available on a device
  45489. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45490. * @returns a promise that will resolve on orientation change
  45491. */
  45492. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45493. /**
  45494. * @hidden
  45495. */
  45496. _onDeviceOrientationChangedObservable: Observable<void>;
  45497. /**
  45498. * Instantiates a new input
  45499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45500. */
  45501. constructor();
  45502. /**
  45503. * Define the camera controlled by the input.
  45504. */
  45505. get camera(): FreeCamera;
  45506. set camera(camera: FreeCamera);
  45507. /**
  45508. * Attach the input controls to a specific dom element to get the input from.
  45509. * @param element Defines the element the controls should be listened from
  45510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45511. */
  45512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45513. private _orientationChanged;
  45514. private _deviceOrientation;
  45515. /**
  45516. * Detach the current controls from the specified dom element.
  45517. * @param element Defines the element to stop listening the inputs from
  45518. */
  45519. detachControl(element: Nullable<HTMLElement>): void;
  45520. /**
  45521. * Update the current camera state depending on the inputs that have been used this frame.
  45522. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45523. */
  45524. checkInputs(): void;
  45525. /**
  45526. * Gets the class name of the current intput.
  45527. * @returns the class name
  45528. */
  45529. getClassName(): string;
  45530. /**
  45531. * Get the friendly name associated with the input class.
  45532. * @returns the input friendly name
  45533. */
  45534. getSimpleName(): string;
  45535. }
  45536. }
  45537. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45538. import { Nullable } from "babylonjs/types";
  45539. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45540. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45541. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45542. /**
  45543. * Manage the gamepad inputs to control a free camera.
  45544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45545. */
  45546. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45547. /**
  45548. * Define the camera the input is attached to.
  45549. */
  45550. camera: FreeCamera;
  45551. /**
  45552. * Define the Gamepad controlling the input
  45553. */
  45554. gamepad: Nullable<Gamepad>;
  45555. /**
  45556. * Defines the gamepad rotation sensiblity.
  45557. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45558. */
  45559. gamepadAngularSensibility: number;
  45560. /**
  45561. * Defines the gamepad move sensiblity.
  45562. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45563. */
  45564. gamepadMoveSensibility: number;
  45565. private _yAxisScale;
  45566. /**
  45567. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45568. */
  45569. get invertYAxis(): boolean;
  45570. set invertYAxis(value: boolean);
  45571. private _onGamepadConnectedObserver;
  45572. private _onGamepadDisconnectedObserver;
  45573. private _cameraTransform;
  45574. private _deltaTransform;
  45575. private _vector3;
  45576. private _vector2;
  45577. /**
  45578. * Attach the input controls to a specific dom element to get the input from.
  45579. * @param element Defines the element the controls should be listened from
  45580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45581. */
  45582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45583. /**
  45584. * Detach the current controls from the specified dom element.
  45585. * @param element Defines the element to stop listening the inputs from
  45586. */
  45587. detachControl(element: Nullable<HTMLElement>): void;
  45588. /**
  45589. * Update the current camera state depending on the inputs that have been used this frame.
  45590. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45591. */
  45592. checkInputs(): void;
  45593. /**
  45594. * Gets the class name of the current intput.
  45595. * @returns the class name
  45596. */
  45597. getClassName(): string;
  45598. /**
  45599. * Get the friendly name associated with the input class.
  45600. * @returns the input friendly name
  45601. */
  45602. getSimpleName(): string;
  45603. }
  45604. }
  45605. declare module "babylonjs/Misc/virtualJoystick" {
  45606. import { Nullable } from "babylonjs/types";
  45607. import { Vector3 } from "babylonjs/Maths/math.vector";
  45608. /**
  45609. * Defines the potential axis of a Joystick
  45610. */
  45611. export enum JoystickAxis {
  45612. /** X axis */
  45613. X = 0,
  45614. /** Y axis */
  45615. Y = 1,
  45616. /** Z axis */
  45617. Z = 2
  45618. }
  45619. /**
  45620. * Class used to define virtual joystick (used in touch mode)
  45621. */
  45622. export class VirtualJoystick {
  45623. /**
  45624. * Gets or sets a boolean indicating that left and right values must be inverted
  45625. */
  45626. reverseLeftRight: boolean;
  45627. /**
  45628. * Gets or sets a boolean indicating that up and down values must be inverted
  45629. */
  45630. reverseUpDown: boolean;
  45631. /**
  45632. * Gets the offset value for the position (ie. the change of the position value)
  45633. */
  45634. deltaPosition: Vector3;
  45635. /**
  45636. * Gets a boolean indicating if the virtual joystick was pressed
  45637. */
  45638. pressed: boolean;
  45639. /**
  45640. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45641. */
  45642. static Canvas: Nullable<HTMLCanvasElement>;
  45643. private static _globalJoystickIndex;
  45644. private static vjCanvasContext;
  45645. private static vjCanvasWidth;
  45646. private static vjCanvasHeight;
  45647. private static halfWidth;
  45648. private _action;
  45649. private _axisTargetedByLeftAndRight;
  45650. private _axisTargetedByUpAndDown;
  45651. private _joystickSensibility;
  45652. private _inversedSensibility;
  45653. private _joystickPointerID;
  45654. private _joystickColor;
  45655. private _joystickPointerPos;
  45656. private _joystickPreviousPointerPos;
  45657. private _joystickPointerStartPos;
  45658. private _deltaJoystickVector;
  45659. private _leftJoystick;
  45660. private _touches;
  45661. private _onPointerDownHandlerRef;
  45662. private _onPointerMoveHandlerRef;
  45663. private _onPointerUpHandlerRef;
  45664. private _onResize;
  45665. /**
  45666. * Creates a new virtual joystick
  45667. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45668. */
  45669. constructor(leftJoystick?: boolean);
  45670. /**
  45671. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45672. * @param newJoystickSensibility defines the new sensibility
  45673. */
  45674. setJoystickSensibility(newJoystickSensibility: number): void;
  45675. private _onPointerDown;
  45676. private _onPointerMove;
  45677. private _onPointerUp;
  45678. /**
  45679. * Change the color of the virtual joystick
  45680. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45681. */
  45682. setJoystickColor(newColor: string): void;
  45683. /**
  45684. * Defines a callback to call when the joystick is touched
  45685. * @param action defines the callback
  45686. */
  45687. setActionOnTouch(action: () => any): void;
  45688. /**
  45689. * Defines which axis you'd like to control for left & right
  45690. * @param axis defines the axis to use
  45691. */
  45692. setAxisForLeftRight(axis: JoystickAxis): void;
  45693. /**
  45694. * Defines which axis you'd like to control for up & down
  45695. * @param axis defines the axis to use
  45696. */
  45697. setAxisForUpDown(axis: JoystickAxis): void;
  45698. private _drawVirtualJoystick;
  45699. /**
  45700. * Release internal HTML canvas
  45701. */
  45702. releaseCanvas(): void;
  45703. }
  45704. }
  45705. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45706. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45707. import { Nullable } from "babylonjs/types";
  45708. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45709. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45710. module "babylonjs/Cameras/freeCameraInputsManager" {
  45711. interface FreeCameraInputsManager {
  45712. /**
  45713. * Add virtual joystick input support to the input manager.
  45714. * @returns the current input manager
  45715. */
  45716. addVirtualJoystick(): FreeCameraInputsManager;
  45717. }
  45718. }
  45719. /**
  45720. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45721. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45722. */
  45723. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45724. /**
  45725. * Defines the camera the input is attached to.
  45726. */
  45727. camera: FreeCamera;
  45728. private _leftjoystick;
  45729. private _rightjoystick;
  45730. /**
  45731. * Gets the left stick of the virtual joystick.
  45732. * @returns The virtual Joystick
  45733. */
  45734. getLeftJoystick(): VirtualJoystick;
  45735. /**
  45736. * Gets the right stick of the virtual joystick.
  45737. * @returns The virtual Joystick
  45738. */
  45739. getRightJoystick(): VirtualJoystick;
  45740. /**
  45741. * Update the current camera state depending on the inputs that have been used this frame.
  45742. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45743. */
  45744. checkInputs(): void;
  45745. /**
  45746. * Attach the input controls to a specific dom element to get the input from.
  45747. * @param element Defines the element the controls should be listened from
  45748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45749. */
  45750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45751. /**
  45752. * Detach the current controls from the specified dom element.
  45753. * @param element Defines the element to stop listening the inputs from
  45754. */
  45755. detachControl(element: Nullable<HTMLElement>): void;
  45756. /**
  45757. * Gets the class name of the current intput.
  45758. * @returns the class name
  45759. */
  45760. getClassName(): string;
  45761. /**
  45762. * Get the friendly name associated with the input class.
  45763. * @returns the input friendly name
  45764. */
  45765. getSimpleName(): string;
  45766. }
  45767. }
  45768. declare module "babylonjs/Cameras/Inputs/index" {
  45769. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45770. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45771. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45772. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45773. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45774. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45775. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45776. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45777. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45778. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45779. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45780. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45781. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45782. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45783. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45784. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45785. }
  45786. declare module "babylonjs/Cameras/touchCamera" {
  45787. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45788. import { Scene } from "babylonjs/scene";
  45789. import { Vector3 } from "babylonjs/Maths/math.vector";
  45790. /**
  45791. * This represents a FPS type of camera controlled by touch.
  45792. * This is like a universal camera minus the Gamepad controls.
  45793. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45794. */
  45795. export class TouchCamera extends FreeCamera {
  45796. /**
  45797. * Defines the touch sensibility for rotation.
  45798. * The higher the faster.
  45799. */
  45800. get touchAngularSensibility(): number;
  45801. set touchAngularSensibility(value: number);
  45802. /**
  45803. * Defines the touch sensibility for move.
  45804. * The higher the faster.
  45805. */
  45806. get touchMoveSensibility(): number;
  45807. set touchMoveSensibility(value: number);
  45808. /**
  45809. * Instantiates a new touch camera.
  45810. * This represents a FPS type of camera controlled by touch.
  45811. * This is like a universal camera minus the Gamepad controls.
  45812. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45813. * @param name Define the name of the camera in the scene
  45814. * @param position Define the start position of the camera in the scene
  45815. * @param scene Define the scene the camera belongs to
  45816. */
  45817. constructor(name: string, position: Vector3, scene: Scene);
  45818. /**
  45819. * Gets the current object class name.
  45820. * @return the class name
  45821. */
  45822. getClassName(): string;
  45823. /** @hidden */
  45824. _setupInputs(): void;
  45825. }
  45826. }
  45827. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45828. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45829. import { Scene } from "babylonjs/scene";
  45830. import { Vector3 } from "babylonjs/Maths/math.vector";
  45831. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45832. import { Axis } from "babylonjs/Maths/math.axis";
  45833. /**
  45834. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45835. * being tilted forward or back and left or right.
  45836. */
  45837. export class DeviceOrientationCamera extends FreeCamera {
  45838. private _initialQuaternion;
  45839. private _quaternionCache;
  45840. private _tmpDragQuaternion;
  45841. private _disablePointerInputWhenUsingDeviceOrientation;
  45842. /**
  45843. * Creates a new device orientation camera
  45844. * @param name The name of the camera
  45845. * @param position The start position camera
  45846. * @param scene The scene the camera belongs to
  45847. */
  45848. constructor(name: string, position: Vector3, scene: Scene);
  45849. /**
  45850. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45851. */
  45852. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45853. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45854. private _dragFactor;
  45855. /**
  45856. * Enabled turning on the y axis when the orientation sensor is active
  45857. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45858. */
  45859. enableHorizontalDragging(dragFactor?: number): void;
  45860. /**
  45861. * Gets the current instance class name ("DeviceOrientationCamera").
  45862. * This helps avoiding instanceof at run time.
  45863. * @returns the class name
  45864. */
  45865. getClassName(): string;
  45866. /**
  45867. * @hidden
  45868. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45869. */
  45870. _checkInputs(): void;
  45871. /**
  45872. * Reset the camera to its default orientation on the specified axis only.
  45873. * @param axis The axis to reset
  45874. */
  45875. resetToCurrentRotation(axis?: Axis): void;
  45876. }
  45877. }
  45878. declare module "babylonjs/Gamepads/xboxGamepad" {
  45879. import { Observable } from "babylonjs/Misc/observable";
  45880. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45881. /**
  45882. * Defines supported buttons for XBox360 compatible gamepads
  45883. */
  45884. export enum Xbox360Button {
  45885. /** A */
  45886. A = 0,
  45887. /** B */
  45888. B = 1,
  45889. /** X */
  45890. X = 2,
  45891. /** Y */
  45892. Y = 3,
  45893. /** Left button */
  45894. LB = 4,
  45895. /** Right button */
  45896. RB = 5,
  45897. /** Back */
  45898. Back = 8,
  45899. /** Start */
  45900. Start = 9,
  45901. /** Left stick */
  45902. LeftStick = 10,
  45903. /** Right stick */
  45904. RightStick = 11
  45905. }
  45906. /** Defines values for XBox360 DPad */
  45907. export enum Xbox360Dpad {
  45908. /** Up */
  45909. Up = 12,
  45910. /** Down */
  45911. Down = 13,
  45912. /** Left */
  45913. Left = 14,
  45914. /** Right */
  45915. Right = 15
  45916. }
  45917. /**
  45918. * Defines a XBox360 gamepad
  45919. */
  45920. export class Xbox360Pad extends Gamepad {
  45921. private _leftTrigger;
  45922. private _rightTrigger;
  45923. private _onlefttriggerchanged;
  45924. private _onrighttriggerchanged;
  45925. private _onbuttondown;
  45926. private _onbuttonup;
  45927. private _ondpaddown;
  45928. private _ondpadup;
  45929. /** Observable raised when a button is pressed */
  45930. onButtonDownObservable: Observable<Xbox360Button>;
  45931. /** Observable raised when a button is released */
  45932. onButtonUpObservable: Observable<Xbox360Button>;
  45933. /** Observable raised when a pad is pressed */
  45934. onPadDownObservable: Observable<Xbox360Dpad>;
  45935. /** Observable raised when a pad is released */
  45936. onPadUpObservable: Observable<Xbox360Dpad>;
  45937. private _buttonA;
  45938. private _buttonB;
  45939. private _buttonX;
  45940. private _buttonY;
  45941. private _buttonBack;
  45942. private _buttonStart;
  45943. private _buttonLB;
  45944. private _buttonRB;
  45945. private _buttonLeftStick;
  45946. private _buttonRightStick;
  45947. private _dPadUp;
  45948. private _dPadDown;
  45949. private _dPadLeft;
  45950. private _dPadRight;
  45951. private _isXboxOnePad;
  45952. /**
  45953. * Creates a new XBox360 gamepad object
  45954. * @param id defines the id of this gamepad
  45955. * @param index defines its index
  45956. * @param gamepad defines the internal HTML gamepad object
  45957. * @param xboxOne defines if it is a XBox One gamepad
  45958. */
  45959. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45960. /**
  45961. * Defines the callback to call when left trigger is pressed
  45962. * @param callback defines the callback to use
  45963. */
  45964. onlefttriggerchanged(callback: (value: number) => void): void;
  45965. /**
  45966. * Defines the callback to call when right trigger is pressed
  45967. * @param callback defines the callback to use
  45968. */
  45969. onrighttriggerchanged(callback: (value: number) => void): void;
  45970. /**
  45971. * Gets the left trigger value
  45972. */
  45973. get leftTrigger(): number;
  45974. /**
  45975. * Sets the left trigger value
  45976. */
  45977. set leftTrigger(newValue: number);
  45978. /**
  45979. * Gets the right trigger value
  45980. */
  45981. get rightTrigger(): number;
  45982. /**
  45983. * Sets the right trigger value
  45984. */
  45985. set rightTrigger(newValue: number);
  45986. /**
  45987. * Defines the callback to call when a button is pressed
  45988. * @param callback defines the callback to use
  45989. */
  45990. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45991. /**
  45992. * Defines the callback to call when a button is released
  45993. * @param callback defines the callback to use
  45994. */
  45995. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45996. /**
  45997. * Defines the callback to call when a pad is pressed
  45998. * @param callback defines the callback to use
  45999. */
  46000. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46001. /**
  46002. * Defines the callback to call when a pad is released
  46003. * @param callback defines the callback to use
  46004. */
  46005. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46006. private _setButtonValue;
  46007. private _setDPadValue;
  46008. /**
  46009. * Gets the value of the `A` button
  46010. */
  46011. get buttonA(): number;
  46012. /**
  46013. * Sets the value of the `A` button
  46014. */
  46015. set buttonA(value: number);
  46016. /**
  46017. * Gets the value of the `B` button
  46018. */
  46019. get buttonB(): number;
  46020. /**
  46021. * Sets the value of the `B` button
  46022. */
  46023. set buttonB(value: number);
  46024. /**
  46025. * Gets the value of the `X` button
  46026. */
  46027. get buttonX(): number;
  46028. /**
  46029. * Sets the value of the `X` button
  46030. */
  46031. set buttonX(value: number);
  46032. /**
  46033. * Gets the value of the `Y` button
  46034. */
  46035. get buttonY(): number;
  46036. /**
  46037. * Sets the value of the `Y` button
  46038. */
  46039. set buttonY(value: number);
  46040. /**
  46041. * Gets the value of the `Start` button
  46042. */
  46043. get buttonStart(): number;
  46044. /**
  46045. * Sets the value of the `Start` button
  46046. */
  46047. set buttonStart(value: number);
  46048. /**
  46049. * Gets the value of the `Back` button
  46050. */
  46051. get buttonBack(): number;
  46052. /**
  46053. * Sets the value of the `Back` button
  46054. */
  46055. set buttonBack(value: number);
  46056. /**
  46057. * Gets the value of the `Left` button
  46058. */
  46059. get buttonLB(): number;
  46060. /**
  46061. * Sets the value of the `Left` button
  46062. */
  46063. set buttonLB(value: number);
  46064. /**
  46065. * Gets the value of the `Right` button
  46066. */
  46067. get buttonRB(): number;
  46068. /**
  46069. * Sets the value of the `Right` button
  46070. */
  46071. set buttonRB(value: number);
  46072. /**
  46073. * Gets the value of the Left joystick
  46074. */
  46075. get buttonLeftStick(): number;
  46076. /**
  46077. * Sets the value of the Left joystick
  46078. */
  46079. set buttonLeftStick(value: number);
  46080. /**
  46081. * Gets the value of the Right joystick
  46082. */
  46083. get buttonRightStick(): number;
  46084. /**
  46085. * Sets the value of the Right joystick
  46086. */
  46087. set buttonRightStick(value: number);
  46088. /**
  46089. * Gets the value of D-pad up
  46090. */
  46091. get dPadUp(): number;
  46092. /**
  46093. * Sets the value of D-pad up
  46094. */
  46095. set dPadUp(value: number);
  46096. /**
  46097. * Gets the value of D-pad down
  46098. */
  46099. get dPadDown(): number;
  46100. /**
  46101. * Sets the value of D-pad down
  46102. */
  46103. set dPadDown(value: number);
  46104. /**
  46105. * Gets the value of D-pad left
  46106. */
  46107. get dPadLeft(): number;
  46108. /**
  46109. * Sets the value of D-pad left
  46110. */
  46111. set dPadLeft(value: number);
  46112. /**
  46113. * Gets the value of D-pad right
  46114. */
  46115. get dPadRight(): number;
  46116. /**
  46117. * Sets the value of D-pad right
  46118. */
  46119. set dPadRight(value: number);
  46120. /**
  46121. * Force the gamepad to synchronize with device values
  46122. */
  46123. update(): void;
  46124. /**
  46125. * Disposes the gamepad
  46126. */
  46127. dispose(): void;
  46128. }
  46129. }
  46130. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46131. import { Observable } from "babylonjs/Misc/observable";
  46132. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46133. /**
  46134. * Defines supported buttons for DualShock compatible gamepads
  46135. */
  46136. export enum DualShockButton {
  46137. /** Cross */
  46138. Cross = 0,
  46139. /** Circle */
  46140. Circle = 1,
  46141. /** Square */
  46142. Square = 2,
  46143. /** Triangle */
  46144. Triangle = 3,
  46145. /** L1 */
  46146. L1 = 4,
  46147. /** R1 */
  46148. R1 = 5,
  46149. /** Share */
  46150. Share = 8,
  46151. /** Options */
  46152. Options = 9,
  46153. /** Left stick */
  46154. LeftStick = 10,
  46155. /** Right stick */
  46156. RightStick = 11
  46157. }
  46158. /** Defines values for DualShock DPad */
  46159. export enum DualShockDpad {
  46160. /** Up */
  46161. Up = 12,
  46162. /** Down */
  46163. Down = 13,
  46164. /** Left */
  46165. Left = 14,
  46166. /** Right */
  46167. Right = 15
  46168. }
  46169. /**
  46170. * Defines a DualShock gamepad
  46171. */
  46172. export class DualShockPad extends Gamepad {
  46173. private _leftTrigger;
  46174. private _rightTrigger;
  46175. private _onlefttriggerchanged;
  46176. private _onrighttriggerchanged;
  46177. private _onbuttondown;
  46178. private _onbuttonup;
  46179. private _ondpaddown;
  46180. private _ondpadup;
  46181. /** Observable raised when a button is pressed */
  46182. onButtonDownObservable: Observable<DualShockButton>;
  46183. /** Observable raised when a button is released */
  46184. onButtonUpObservable: Observable<DualShockButton>;
  46185. /** Observable raised when a pad is pressed */
  46186. onPadDownObservable: Observable<DualShockDpad>;
  46187. /** Observable raised when a pad is released */
  46188. onPadUpObservable: Observable<DualShockDpad>;
  46189. private _buttonCross;
  46190. private _buttonCircle;
  46191. private _buttonSquare;
  46192. private _buttonTriangle;
  46193. private _buttonShare;
  46194. private _buttonOptions;
  46195. private _buttonL1;
  46196. private _buttonR1;
  46197. private _buttonLeftStick;
  46198. private _buttonRightStick;
  46199. private _dPadUp;
  46200. private _dPadDown;
  46201. private _dPadLeft;
  46202. private _dPadRight;
  46203. /**
  46204. * Creates a new DualShock gamepad object
  46205. * @param id defines the id of this gamepad
  46206. * @param index defines its index
  46207. * @param gamepad defines the internal HTML gamepad object
  46208. */
  46209. constructor(id: string, index: number, gamepad: any);
  46210. /**
  46211. * Defines the callback to call when left trigger is pressed
  46212. * @param callback defines the callback to use
  46213. */
  46214. onlefttriggerchanged(callback: (value: number) => void): void;
  46215. /**
  46216. * Defines the callback to call when right trigger is pressed
  46217. * @param callback defines the callback to use
  46218. */
  46219. onrighttriggerchanged(callback: (value: number) => void): void;
  46220. /**
  46221. * Gets the left trigger value
  46222. */
  46223. get leftTrigger(): number;
  46224. /**
  46225. * Sets the left trigger value
  46226. */
  46227. set leftTrigger(newValue: number);
  46228. /**
  46229. * Gets the right trigger value
  46230. */
  46231. get rightTrigger(): number;
  46232. /**
  46233. * Sets the right trigger value
  46234. */
  46235. set rightTrigger(newValue: number);
  46236. /**
  46237. * Defines the callback to call when a button is pressed
  46238. * @param callback defines the callback to use
  46239. */
  46240. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46241. /**
  46242. * Defines the callback to call when a button is released
  46243. * @param callback defines the callback to use
  46244. */
  46245. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46246. /**
  46247. * Defines the callback to call when a pad is pressed
  46248. * @param callback defines the callback to use
  46249. */
  46250. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46251. /**
  46252. * Defines the callback to call when a pad is released
  46253. * @param callback defines the callback to use
  46254. */
  46255. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46256. private _setButtonValue;
  46257. private _setDPadValue;
  46258. /**
  46259. * Gets the value of the `Cross` button
  46260. */
  46261. get buttonCross(): number;
  46262. /**
  46263. * Sets the value of the `Cross` button
  46264. */
  46265. set buttonCross(value: number);
  46266. /**
  46267. * Gets the value of the `Circle` button
  46268. */
  46269. get buttonCircle(): number;
  46270. /**
  46271. * Sets the value of the `Circle` button
  46272. */
  46273. set buttonCircle(value: number);
  46274. /**
  46275. * Gets the value of the `Square` button
  46276. */
  46277. get buttonSquare(): number;
  46278. /**
  46279. * Sets the value of the `Square` button
  46280. */
  46281. set buttonSquare(value: number);
  46282. /**
  46283. * Gets the value of the `Triangle` button
  46284. */
  46285. get buttonTriangle(): number;
  46286. /**
  46287. * Sets the value of the `Triangle` button
  46288. */
  46289. set buttonTriangle(value: number);
  46290. /**
  46291. * Gets the value of the `Options` button
  46292. */
  46293. get buttonOptions(): number;
  46294. /**
  46295. * Sets the value of the `Options` button
  46296. */
  46297. set buttonOptions(value: number);
  46298. /**
  46299. * Gets the value of the `Share` button
  46300. */
  46301. get buttonShare(): number;
  46302. /**
  46303. * Sets the value of the `Share` button
  46304. */
  46305. set buttonShare(value: number);
  46306. /**
  46307. * Gets the value of the `L1` button
  46308. */
  46309. get buttonL1(): number;
  46310. /**
  46311. * Sets the value of the `L1` button
  46312. */
  46313. set buttonL1(value: number);
  46314. /**
  46315. * Gets the value of the `R1` button
  46316. */
  46317. get buttonR1(): number;
  46318. /**
  46319. * Sets the value of the `R1` button
  46320. */
  46321. set buttonR1(value: number);
  46322. /**
  46323. * Gets the value of the Left joystick
  46324. */
  46325. get buttonLeftStick(): number;
  46326. /**
  46327. * Sets the value of the Left joystick
  46328. */
  46329. set buttonLeftStick(value: number);
  46330. /**
  46331. * Gets the value of the Right joystick
  46332. */
  46333. get buttonRightStick(): number;
  46334. /**
  46335. * Sets the value of the Right joystick
  46336. */
  46337. set buttonRightStick(value: number);
  46338. /**
  46339. * Gets the value of D-pad up
  46340. */
  46341. get dPadUp(): number;
  46342. /**
  46343. * Sets the value of D-pad up
  46344. */
  46345. set dPadUp(value: number);
  46346. /**
  46347. * Gets the value of D-pad down
  46348. */
  46349. get dPadDown(): number;
  46350. /**
  46351. * Sets the value of D-pad down
  46352. */
  46353. set dPadDown(value: number);
  46354. /**
  46355. * Gets the value of D-pad left
  46356. */
  46357. get dPadLeft(): number;
  46358. /**
  46359. * Sets the value of D-pad left
  46360. */
  46361. set dPadLeft(value: number);
  46362. /**
  46363. * Gets the value of D-pad right
  46364. */
  46365. get dPadRight(): number;
  46366. /**
  46367. * Sets the value of D-pad right
  46368. */
  46369. set dPadRight(value: number);
  46370. /**
  46371. * Force the gamepad to synchronize with device values
  46372. */
  46373. update(): void;
  46374. /**
  46375. * Disposes the gamepad
  46376. */
  46377. dispose(): void;
  46378. }
  46379. }
  46380. declare module "babylonjs/Gamepads/gamepadManager" {
  46381. import { Observable } from "babylonjs/Misc/observable";
  46382. import { Nullable } from "babylonjs/types";
  46383. import { Scene } from "babylonjs/scene";
  46384. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46385. /**
  46386. * Manager for handling gamepads
  46387. */
  46388. export class GamepadManager {
  46389. private _scene?;
  46390. private _babylonGamepads;
  46391. private _oneGamepadConnected;
  46392. /** @hidden */
  46393. _isMonitoring: boolean;
  46394. private _gamepadEventSupported;
  46395. private _gamepadSupport?;
  46396. /**
  46397. * observable to be triggered when the gamepad controller has been connected
  46398. */
  46399. onGamepadConnectedObservable: Observable<Gamepad>;
  46400. /**
  46401. * observable to be triggered when the gamepad controller has been disconnected
  46402. */
  46403. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46404. private _onGamepadConnectedEvent;
  46405. private _onGamepadDisconnectedEvent;
  46406. /**
  46407. * Initializes the gamepad manager
  46408. * @param _scene BabylonJS scene
  46409. */
  46410. constructor(_scene?: Scene | undefined);
  46411. /**
  46412. * The gamepads in the game pad manager
  46413. */
  46414. get gamepads(): Gamepad[];
  46415. /**
  46416. * Get the gamepad controllers based on type
  46417. * @param type The type of gamepad controller
  46418. * @returns Nullable gamepad
  46419. */
  46420. getGamepadByType(type?: number): Nullable<Gamepad>;
  46421. /**
  46422. * Disposes the gamepad manager
  46423. */
  46424. dispose(): void;
  46425. private _addNewGamepad;
  46426. private _startMonitoringGamepads;
  46427. private _stopMonitoringGamepads;
  46428. /** @hidden */
  46429. _checkGamepadsStatus(): void;
  46430. private _updateGamepadObjects;
  46431. }
  46432. }
  46433. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46434. import { Nullable } from "babylonjs/types";
  46435. import { Scene } from "babylonjs/scene";
  46436. import { ISceneComponent } from "babylonjs/sceneComponent";
  46437. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46438. module "babylonjs/scene" {
  46439. interface Scene {
  46440. /** @hidden */
  46441. _gamepadManager: Nullable<GamepadManager>;
  46442. /**
  46443. * Gets the gamepad manager associated with the scene
  46444. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46445. */
  46446. gamepadManager: GamepadManager;
  46447. }
  46448. }
  46449. module "babylonjs/Cameras/freeCameraInputsManager" {
  46450. /**
  46451. * Interface representing a free camera inputs manager
  46452. */
  46453. interface FreeCameraInputsManager {
  46454. /**
  46455. * Adds gamepad input support to the FreeCameraInputsManager.
  46456. * @returns the FreeCameraInputsManager
  46457. */
  46458. addGamepad(): FreeCameraInputsManager;
  46459. }
  46460. }
  46461. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46462. /**
  46463. * Interface representing an arc rotate camera inputs manager
  46464. */
  46465. interface ArcRotateCameraInputsManager {
  46466. /**
  46467. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46468. * @returns the camera inputs manager
  46469. */
  46470. addGamepad(): ArcRotateCameraInputsManager;
  46471. }
  46472. }
  46473. /**
  46474. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46475. */
  46476. export class GamepadSystemSceneComponent implements ISceneComponent {
  46477. /**
  46478. * The component name helpfull to identify the component in the list of scene components.
  46479. */
  46480. readonly name: string;
  46481. /**
  46482. * The scene the component belongs to.
  46483. */
  46484. scene: Scene;
  46485. /**
  46486. * Creates a new instance of the component for the given scene
  46487. * @param scene Defines the scene to register the component in
  46488. */
  46489. constructor(scene: Scene);
  46490. /**
  46491. * Registers the component in a given scene
  46492. */
  46493. register(): void;
  46494. /**
  46495. * Rebuilds the elements related to this component in case of
  46496. * context lost for instance.
  46497. */
  46498. rebuild(): void;
  46499. /**
  46500. * Disposes the component and the associated ressources
  46501. */
  46502. dispose(): void;
  46503. private _beforeCameraUpdate;
  46504. }
  46505. }
  46506. declare module "babylonjs/Cameras/universalCamera" {
  46507. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46508. import { Scene } from "babylonjs/scene";
  46509. import { Vector3 } from "babylonjs/Maths/math.vector";
  46510. import "babylonjs/Gamepads/gamepadSceneComponent";
  46511. /**
  46512. * 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,
  46513. * which still works and will still be found in many Playgrounds.
  46514. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46515. */
  46516. export class UniversalCamera extends TouchCamera {
  46517. /**
  46518. * Defines the gamepad rotation sensiblity.
  46519. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46520. */
  46521. get gamepadAngularSensibility(): number;
  46522. set gamepadAngularSensibility(value: number);
  46523. /**
  46524. * Defines the gamepad move sensiblity.
  46525. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46526. */
  46527. get gamepadMoveSensibility(): number;
  46528. set gamepadMoveSensibility(value: number);
  46529. /**
  46530. * 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,
  46531. * which still works and will still be found in many Playgrounds.
  46532. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46533. * @param name Define the name of the camera in the scene
  46534. * @param position Define the start position of the camera in the scene
  46535. * @param scene Define the scene the camera belongs to
  46536. */
  46537. constructor(name: string, position: Vector3, scene: Scene);
  46538. /**
  46539. * Gets the current object class name.
  46540. * @return the class name
  46541. */
  46542. getClassName(): string;
  46543. }
  46544. }
  46545. declare module "babylonjs/Cameras/gamepadCamera" {
  46546. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46547. import { Scene } from "babylonjs/scene";
  46548. import { Vector3 } from "babylonjs/Maths/math.vector";
  46549. /**
  46550. * This represents a FPS type of camera. This is only here for back compat purpose.
  46551. * Please use the UniversalCamera instead as both are identical.
  46552. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46553. */
  46554. export class GamepadCamera extends UniversalCamera {
  46555. /**
  46556. * Instantiates a new Gamepad Camera
  46557. * This represents a FPS type of camera. This is only here for back compat purpose.
  46558. * Please use the UniversalCamera instead as both are identical.
  46559. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46560. * @param name Define the name of the camera in the scene
  46561. * @param position Define the start position of the camera in the scene
  46562. * @param scene Define the scene the camera belongs to
  46563. */
  46564. constructor(name: string, position: Vector3, scene: Scene);
  46565. /**
  46566. * Gets the current object class name.
  46567. * @return the class name
  46568. */
  46569. getClassName(): string;
  46570. }
  46571. }
  46572. declare module "babylonjs/Shaders/pass.fragment" {
  46573. /** @hidden */
  46574. export var passPixelShader: {
  46575. name: string;
  46576. shader: string;
  46577. };
  46578. }
  46579. declare module "babylonjs/Shaders/passCube.fragment" {
  46580. /** @hidden */
  46581. export var passCubePixelShader: {
  46582. name: string;
  46583. shader: string;
  46584. };
  46585. }
  46586. declare module "babylonjs/PostProcesses/passPostProcess" {
  46587. import { Nullable } from "babylonjs/types";
  46588. import { Camera } from "babylonjs/Cameras/camera";
  46589. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46590. import { Engine } from "babylonjs/Engines/engine";
  46591. import "babylonjs/Shaders/pass.fragment";
  46592. import "babylonjs/Shaders/passCube.fragment";
  46593. /**
  46594. * PassPostProcess which produces an output the same as it's input
  46595. */
  46596. export class PassPostProcess extends PostProcess {
  46597. /**
  46598. * Creates the PassPostProcess
  46599. * @param name The name of the effect.
  46600. * @param options The required width/height ratio to downsize to before computing the render pass.
  46601. * @param camera The camera to apply the render pass to.
  46602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46603. * @param engine The engine which the post process will be applied. (default: current engine)
  46604. * @param reusable If the post process can be reused on the same frame. (default: false)
  46605. * @param textureType The type of texture to be used when performing the post processing.
  46606. * @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)
  46607. */
  46608. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46609. }
  46610. /**
  46611. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46612. */
  46613. export class PassCubePostProcess extends PostProcess {
  46614. private _face;
  46615. /**
  46616. * Gets or sets the cube face to display.
  46617. * * 0 is +X
  46618. * * 1 is -X
  46619. * * 2 is +Y
  46620. * * 3 is -Y
  46621. * * 4 is +Z
  46622. * * 5 is -Z
  46623. */
  46624. get face(): number;
  46625. set face(value: number);
  46626. /**
  46627. * Creates the PassCubePostProcess
  46628. * @param name The name of the effect.
  46629. * @param options The required width/height ratio to downsize to before computing the render pass.
  46630. * @param camera The camera to apply the render pass to.
  46631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46632. * @param engine The engine which the post process will be applied. (default: current engine)
  46633. * @param reusable If the post process can be reused on the same frame. (default: false)
  46634. * @param textureType The type of texture to be used when performing the post processing.
  46635. * @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)
  46636. */
  46637. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46638. }
  46639. }
  46640. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46641. /** @hidden */
  46642. export var anaglyphPixelShader: {
  46643. name: string;
  46644. shader: string;
  46645. };
  46646. }
  46647. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46648. import { Engine } from "babylonjs/Engines/engine";
  46649. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46650. import { Camera } from "babylonjs/Cameras/camera";
  46651. import "babylonjs/Shaders/anaglyph.fragment";
  46652. /**
  46653. * Postprocess used to generate anaglyphic rendering
  46654. */
  46655. export class AnaglyphPostProcess extends PostProcess {
  46656. private _passedProcess;
  46657. /**
  46658. * Creates a new AnaglyphPostProcess
  46659. * @param name defines postprocess name
  46660. * @param options defines creation options or target ratio scale
  46661. * @param rigCameras defines cameras using this postprocess
  46662. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46663. * @param engine defines hosting engine
  46664. * @param reusable defines if the postprocess will be reused multiple times per frame
  46665. */
  46666. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46667. }
  46668. }
  46669. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46670. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46671. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46672. import { Scene } from "babylonjs/scene";
  46673. import { Vector3 } from "babylonjs/Maths/math.vector";
  46674. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46675. /**
  46676. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46677. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46678. */
  46679. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46680. /**
  46681. * Creates a new AnaglyphArcRotateCamera
  46682. * @param name defines camera name
  46683. * @param alpha defines alpha angle (in radians)
  46684. * @param beta defines beta angle (in radians)
  46685. * @param radius defines radius
  46686. * @param target defines camera target
  46687. * @param interaxialDistance defines distance between each color axis
  46688. * @param scene defines the hosting scene
  46689. */
  46690. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46691. /**
  46692. * Gets camera class name
  46693. * @returns AnaglyphArcRotateCamera
  46694. */
  46695. getClassName(): string;
  46696. }
  46697. }
  46698. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46699. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46700. import { Scene } from "babylonjs/scene";
  46701. import { Vector3 } from "babylonjs/Maths/math.vector";
  46702. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46703. /**
  46704. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46705. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46706. */
  46707. export class AnaglyphFreeCamera extends FreeCamera {
  46708. /**
  46709. * Creates a new AnaglyphFreeCamera
  46710. * @param name defines camera name
  46711. * @param position defines initial position
  46712. * @param interaxialDistance defines distance between each color axis
  46713. * @param scene defines the hosting scene
  46714. */
  46715. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46716. /**
  46717. * Gets camera class name
  46718. * @returns AnaglyphFreeCamera
  46719. */
  46720. getClassName(): string;
  46721. }
  46722. }
  46723. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46724. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46725. import { Scene } from "babylonjs/scene";
  46726. import { Vector3 } from "babylonjs/Maths/math.vector";
  46727. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46728. /**
  46729. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46730. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46731. */
  46732. export class AnaglyphGamepadCamera extends GamepadCamera {
  46733. /**
  46734. * Creates a new AnaglyphGamepadCamera
  46735. * @param name defines camera name
  46736. * @param position defines initial position
  46737. * @param interaxialDistance defines distance between each color axis
  46738. * @param scene defines the hosting scene
  46739. */
  46740. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46741. /**
  46742. * Gets camera class name
  46743. * @returns AnaglyphGamepadCamera
  46744. */
  46745. getClassName(): string;
  46746. }
  46747. }
  46748. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46749. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46750. import { Scene } from "babylonjs/scene";
  46751. import { Vector3 } from "babylonjs/Maths/math.vector";
  46752. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46753. /**
  46754. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46755. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46756. */
  46757. export class AnaglyphUniversalCamera extends UniversalCamera {
  46758. /**
  46759. * Creates a new AnaglyphUniversalCamera
  46760. * @param name defines camera name
  46761. * @param position defines initial position
  46762. * @param interaxialDistance defines distance between each color axis
  46763. * @param scene defines the hosting scene
  46764. */
  46765. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46766. /**
  46767. * Gets camera class name
  46768. * @returns AnaglyphUniversalCamera
  46769. */
  46770. getClassName(): string;
  46771. }
  46772. }
  46773. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46774. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46775. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46776. import { Scene } from "babylonjs/scene";
  46777. import { Vector3 } from "babylonjs/Maths/math.vector";
  46778. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46779. /**
  46780. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46781. * @see http://doc.babylonjs.com/features/cameras
  46782. */
  46783. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46784. /**
  46785. * Creates a new StereoscopicArcRotateCamera
  46786. * @param name defines camera name
  46787. * @param alpha defines alpha angle (in radians)
  46788. * @param beta defines beta angle (in radians)
  46789. * @param radius defines radius
  46790. * @param target defines camera target
  46791. * @param interaxialDistance defines distance between each color axis
  46792. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46793. * @param scene defines the hosting scene
  46794. */
  46795. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46796. /**
  46797. * Gets camera class name
  46798. * @returns StereoscopicArcRotateCamera
  46799. */
  46800. getClassName(): string;
  46801. }
  46802. }
  46803. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46804. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46805. import { Scene } from "babylonjs/scene";
  46806. import { Vector3 } from "babylonjs/Maths/math.vector";
  46807. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46808. /**
  46809. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46810. * @see http://doc.babylonjs.com/features/cameras
  46811. */
  46812. export class StereoscopicFreeCamera extends FreeCamera {
  46813. /**
  46814. * Creates a new StereoscopicFreeCamera
  46815. * @param name defines camera name
  46816. * @param position defines initial position
  46817. * @param interaxialDistance defines distance between each color axis
  46818. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46819. * @param scene defines the hosting scene
  46820. */
  46821. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46822. /**
  46823. * Gets camera class name
  46824. * @returns StereoscopicFreeCamera
  46825. */
  46826. getClassName(): string;
  46827. }
  46828. }
  46829. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46830. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46831. import { Scene } from "babylonjs/scene";
  46832. import { Vector3 } from "babylonjs/Maths/math.vector";
  46833. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46834. /**
  46835. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46836. * @see http://doc.babylonjs.com/features/cameras
  46837. */
  46838. export class StereoscopicGamepadCamera extends GamepadCamera {
  46839. /**
  46840. * Creates a new StereoscopicGamepadCamera
  46841. * @param name defines camera name
  46842. * @param position defines initial position
  46843. * @param interaxialDistance defines distance between each color axis
  46844. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46845. * @param scene defines the hosting scene
  46846. */
  46847. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46848. /**
  46849. * Gets camera class name
  46850. * @returns StereoscopicGamepadCamera
  46851. */
  46852. getClassName(): string;
  46853. }
  46854. }
  46855. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46856. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46857. import { Scene } from "babylonjs/scene";
  46858. import { Vector3 } from "babylonjs/Maths/math.vector";
  46859. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46860. /**
  46861. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46862. * @see http://doc.babylonjs.com/features/cameras
  46863. */
  46864. export class StereoscopicUniversalCamera extends UniversalCamera {
  46865. /**
  46866. * Creates a new StereoscopicUniversalCamera
  46867. * @param name defines camera name
  46868. * @param position defines initial position
  46869. * @param interaxialDistance defines distance between each color axis
  46870. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46871. * @param scene defines the hosting scene
  46872. */
  46873. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46874. /**
  46875. * Gets camera class name
  46876. * @returns StereoscopicUniversalCamera
  46877. */
  46878. getClassName(): string;
  46879. }
  46880. }
  46881. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46882. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46883. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46884. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46885. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46886. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46887. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46888. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46889. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46890. }
  46891. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46892. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46893. import { Scene } from "babylonjs/scene";
  46894. import { Vector3 } from "babylonjs/Maths/math.vector";
  46895. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46896. /**
  46897. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46898. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46899. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46900. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46901. */
  46902. export class VirtualJoysticksCamera extends FreeCamera {
  46903. /**
  46904. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46905. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46906. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46907. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46908. * @param name Define the name of the camera in the scene
  46909. * @param position Define the start position of the camera in the scene
  46910. * @param scene Define the scene the camera belongs to
  46911. */
  46912. constructor(name: string, position: Vector3, scene: Scene);
  46913. /**
  46914. * Gets the current object class name.
  46915. * @return the class name
  46916. */
  46917. getClassName(): string;
  46918. }
  46919. }
  46920. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46921. import { Matrix } from "babylonjs/Maths/math.vector";
  46922. /**
  46923. * This represents all the required metrics to create a VR camera.
  46924. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46925. */
  46926. export class VRCameraMetrics {
  46927. /**
  46928. * Define the horizontal resolution off the screen.
  46929. */
  46930. hResolution: number;
  46931. /**
  46932. * Define the vertical resolution off the screen.
  46933. */
  46934. vResolution: number;
  46935. /**
  46936. * Define the horizontal screen size.
  46937. */
  46938. hScreenSize: number;
  46939. /**
  46940. * Define the vertical screen size.
  46941. */
  46942. vScreenSize: number;
  46943. /**
  46944. * Define the vertical screen center position.
  46945. */
  46946. vScreenCenter: number;
  46947. /**
  46948. * Define the distance of the eyes to the screen.
  46949. */
  46950. eyeToScreenDistance: number;
  46951. /**
  46952. * Define the distance between both lenses
  46953. */
  46954. lensSeparationDistance: number;
  46955. /**
  46956. * Define the distance between both viewer's eyes.
  46957. */
  46958. interpupillaryDistance: number;
  46959. /**
  46960. * Define the distortion factor of the VR postprocess.
  46961. * Please, touch with care.
  46962. */
  46963. distortionK: number[];
  46964. /**
  46965. * Define the chromatic aberration correction factors for the VR post process.
  46966. */
  46967. chromaAbCorrection: number[];
  46968. /**
  46969. * Define the scale factor of the post process.
  46970. * The smaller the better but the slower.
  46971. */
  46972. postProcessScaleFactor: number;
  46973. /**
  46974. * Define an offset for the lens center.
  46975. */
  46976. lensCenterOffset: number;
  46977. /**
  46978. * Define if the current vr camera should compensate the distortion of the lense or not.
  46979. */
  46980. compensateDistortion: boolean;
  46981. /**
  46982. * Defines if multiview should be enabled when rendering (Default: false)
  46983. */
  46984. multiviewEnabled: boolean;
  46985. /**
  46986. * Gets the rendering aspect ratio based on the provided resolutions.
  46987. */
  46988. get aspectRatio(): number;
  46989. /**
  46990. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46991. */
  46992. get aspectRatioFov(): number;
  46993. /**
  46994. * @hidden
  46995. */
  46996. get leftHMatrix(): Matrix;
  46997. /**
  46998. * @hidden
  46999. */
  47000. get rightHMatrix(): Matrix;
  47001. /**
  47002. * @hidden
  47003. */
  47004. get leftPreViewMatrix(): Matrix;
  47005. /**
  47006. * @hidden
  47007. */
  47008. get rightPreViewMatrix(): Matrix;
  47009. /**
  47010. * Get the default VRMetrics based on the most generic setup.
  47011. * @returns the default vr metrics
  47012. */
  47013. static GetDefault(): VRCameraMetrics;
  47014. }
  47015. }
  47016. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47017. /** @hidden */
  47018. export var vrDistortionCorrectionPixelShader: {
  47019. name: string;
  47020. shader: string;
  47021. };
  47022. }
  47023. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47024. import { Camera } from "babylonjs/Cameras/camera";
  47025. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47026. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47027. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47028. /**
  47029. * VRDistortionCorrectionPostProcess used for mobile VR
  47030. */
  47031. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47032. private _isRightEye;
  47033. private _distortionFactors;
  47034. private _postProcessScaleFactor;
  47035. private _lensCenterOffset;
  47036. private _scaleIn;
  47037. private _scaleFactor;
  47038. private _lensCenter;
  47039. /**
  47040. * Initializes the VRDistortionCorrectionPostProcess
  47041. * @param name The name of the effect.
  47042. * @param camera The camera to apply the render pass to.
  47043. * @param isRightEye If this is for the right eye distortion
  47044. * @param vrMetrics All the required metrics for the VR camera
  47045. */
  47046. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47047. }
  47048. }
  47049. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47050. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47051. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47052. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47053. import { Scene } from "babylonjs/scene";
  47054. import { Vector3 } from "babylonjs/Maths/math.vector";
  47055. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47056. import "babylonjs/Cameras/RigModes/vrRigMode";
  47057. /**
  47058. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47059. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47060. */
  47061. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47062. /**
  47063. * Creates a new VRDeviceOrientationArcRotateCamera
  47064. * @param name defines camera name
  47065. * @param alpha defines the camera rotation along the logitudinal axis
  47066. * @param beta defines the camera rotation along the latitudinal axis
  47067. * @param radius defines the camera distance from its target
  47068. * @param target defines the camera target
  47069. * @param scene defines the scene the camera belongs to
  47070. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47071. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47072. */
  47073. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47074. /**
  47075. * Gets camera class name
  47076. * @returns VRDeviceOrientationArcRotateCamera
  47077. */
  47078. getClassName(): string;
  47079. }
  47080. }
  47081. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47082. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47083. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47084. import { Scene } from "babylonjs/scene";
  47085. import { Vector3 } from "babylonjs/Maths/math.vector";
  47086. import "babylonjs/Cameras/RigModes/vrRigMode";
  47087. /**
  47088. * Camera used to simulate VR rendering (based on FreeCamera)
  47089. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47090. */
  47091. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47092. /**
  47093. * Creates a new VRDeviceOrientationFreeCamera
  47094. * @param name defines camera name
  47095. * @param position defines the start position of the camera
  47096. * @param scene defines the scene the camera belongs to
  47097. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47098. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47099. */
  47100. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47101. /**
  47102. * Gets camera class name
  47103. * @returns VRDeviceOrientationFreeCamera
  47104. */
  47105. getClassName(): string;
  47106. }
  47107. }
  47108. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47109. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47110. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47111. import { Scene } from "babylonjs/scene";
  47112. import { Vector3 } from "babylonjs/Maths/math.vector";
  47113. import "babylonjs/Gamepads/gamepadSceneComponent";
  47114. /**
  47115. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47116. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47117. */
  47118. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47119. /**
  47120. * Creates a new VRDeviceOrientationGamepadCamera
  47121. * @param name defines camera name
  47122. * @param position defines the start position of the camera
  47123. * @param scene defines the scene the camera belongs to
  47124. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47125. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47126. */
  47127. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47128. /**
  47129. * Gets camera class name
  47130. * @returns VRDeviceOrientationGamepadCamera
  47131. */
  47132. getClassName(): string;
  47133. }
  47134. }
  47135. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  47136. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47137. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47138. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47139. /** @hidden */
  47140. export var imageProcessingPixelShader: {
  47141. name: string;
  47142. shader: string;
  47143. };
  47144. }
  47145. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  47146. import { Nullable } from "babylonjs/types";
  47147. import { Color4 } from "babylonjs/Maths/math.color";
  47148. import { Camera } from "babylonjs/Cameras/camera";
  47149. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47150. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47151. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47152. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47153. import { Engine } from "babylonjs/Engines/engine";
  47154. import "babylonjs/Shaders/imageProcessing.fragment";
  47155. import "babylonjs/Shaders/postprocess.vertex";
  47156. /**
  47157. * ImageProcessingPostProcess
  47158. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  47159. */
  47160. export class ImageProcessingPostProcess extends PostProcess {
  47161. /**
  47162. * Default configuration related to image processing available in the PBR Material.
  47163. */
  47164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47165. /**
  47166. * Gets the image processing configuration used either in this material.
  47167. */
  47168. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47169. /**
  47170. * Sets the Default image processing configuration used either in the this material.
  47171. *
  47172. * If sets to null, the scene one is in use.
  47173. */
  47174. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  47175. /**
  47176. * Keep track of the image processing observer to allow dispose and replace.
  47177. */
  47178. private _imageProcessingObserver;
  47179. /**
  47180. * Attaches a new image processing configuration to the PBR Material.
  47181. * @param configuration
  47182. */
  47183. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47184. /**
  47185. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47186. */
  47187. get colorCurves(): Nullable<ColorCurves>;
  47188. /**
  47189. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47190. */
  47191. set colorCurves(value: Nullable<ColorCurves>);
  47192. /**
  47193. * Gets wether the color curves effect is enabled.
  47194. */
  47195. get colorCurvesEnabled(): boolean;
  47196. /**
  47197. * Sets wether the color curves effect is enabled.
  47198. */
  47199. set colorCurvesEnabled(value: boolean);
  47200. /**
  47201. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47202. */
  47203. get colorGradingTexture(): Nullable<BaseTexture>;
  47204. /**
  47205. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47206. */
  47207. set colorGradingTexture(value: Nullable<BaseTexture>);
  47208. /**
  47209. * Gets wether the color grading effect is enabled.
  47210. */
  47211. get colorGradingEnabled(): boolean;
  47212. /**
  47213. * Gets wether the color grading effect is enabled.
  47214. */
  47215. set colorGradingEnabled(value: boolean);
  47216. /**
  47217. * Gets exposure used in the effect.
  47218. */
  47219. get exposure(): number;
  47220. /**
  47221. * Sets exposure used in the effect.
  47222. */
  47223. set exposure(value: number);
  47224. /**
  47225. * Gets wether tonemapping is enabled or not.
  47226. */
  47227. get toneMappingEnabled(): boolean;
  47228. /**
  47229. * Sets wether tonemapping is enabled or not
  47230. */
  47231. set toneMappingEnabled(value: boolean);
  47232. /**
  47233. * Gets the type of tone mapping effect.
  47234. */
  47235. get toneMappingType(): number;
  47236. /**
  47237. * Sets the type of tone mapping effect.
  47238. */
  47239. set toneMappingType(value: number);
  47240. /**
  47241. * Gets contrast used in the effect.
  47242. */
  47243. get contrast(): number;
  47244. /**
  47245. * Sets contrast used in the effect.
  47246. */
  47247. set contrast(value: number);
  47248. /**
  47249. * Gets Vignette stretch size.
  47250. */
  47251. get vignetteStretch(): number;
  47252. /**
  47253. * Sets Vignette stretch size.
  47254. */
  47255. set vignetteStretch(value: number);
  47256. /**
  47257. * Gets Vignette centre X Offset.
  47258. */
  47259. get vignetteCentreX(): number;
  47260. /**
  47261. * Sets Vignette centre X Offset.
  47262. */
  47263. set vignetteCentreX(value: number);
  47264. /**
  47265. * Gets Vignette centre Y Offset.
  47266. */
  47267. get vignetteCentreY(): number;
  47268. /**
  47269. * Sets Vignette centre Y Offset.
  47270. */
  47271. set vignetteCentreY(value: number);
  47272. /**
  47273. * Gets Vignette weight or intensity of the vignette effect.
  47274. */
  47275. get vignetteWeight(): number;
  47276. /**
  47277. * Sets Vignette weight or intensity of the vignette effect.
  47278. */
  47279. set vignetteWeight(value: number);
  47280. /**
  47281. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47282. * if vignetteEnabled is set to true.
  47283. */
  47284. get vignetteColor(): Color4;
  47285. /**
  47286. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47287. * if vignetteEnabled is set to true.
  47288. */
  47289. set vignetteColor(value: Color4);
  47290. /**
  47291. * Gets Camera field of view used by the Vignette effect.
  47292. */
  47293. get vignetteCameraFov(): number;
  47294. /**
  47295. * Sets Camera field of view used by the Vignette effect.
  47296. */
  47297. set vignetteCameraFov(value: number);
  47298. /**
  47299. * Gets the vignette blend mode allowing different kind of effect.
  47300. */
  47301. get vignetteBlendMode(): number;
  47302. /**
  47303. * Sets the vignette blend mode allowing different kind of effect.
  47304. */
  47305. set vignetteBlendMode(value: number);
  47306. /**
  47307. * Gets wether the vignette effect is enabled.
  47308. */
  47309. get vignetteEnabled(): boolean;
  47310. /**
  47311. * Sets wether the vignette effect is enabled.
  47312. */
  47313. set vignetteEnabled(value: boolean);
  47314. private _fromLinearSpace;
  47315. /**
  47316. * Gets wether the input of the processing is in Gamma or Linear Space.
  47317. */
  47318. get fromLinearSpace(): boolean;
  47319. /**
  47320. * Sets wether the input of the processing is in Gamma or Linear Space.
  47321. */
  47322. set fromLinearSpace(value: boolean);
  47323. /**
  47324. * Defines cache preventing GC.
  47325. */
  47326. private _defines;
  47327. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47328. /**
  47329. * "ImageProcessingPostProcess"
  47330. * @returns "ImageProcessingPostProcess"
  47331. */
  47332. getClassName(): string;
  47333. protected _updateParameters(): void;
  47334. dispose(camera?: Camera): void;
  47335. }
  47336. }
  47337. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47338. import { Scene } from "babylonjs/scene";
  47339. import { Color3 } from "babylonjs/Maths/math.color";
  47340. import { Mesh } from "babylonjs/Meshes/mesh";
  47341. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47342. import { Nullable } from "babylonjs/types";
  47343. /**
  47344. * Class containing static functions to help procedurally build meshes
  47345. */
  47346. export class GroundBuilder {
  47347. /**
  47348. * Creates a ground mesh
  47349. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47350. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47352. * @param name defines the name of the mesh
  47353. * @param options defines the options used to create the mesh
  47354. * @param scene defines the hosting scene
  47355. * @returns the ground mesh
  47356. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47357. */
  47358. static CreateGround(name: string, options: {
  47359. width?: number;
  47360. height?: number;
  47361. subdivisions?: number;
  47362. subdivisionsX?: number;
  47363. subdivisionsY?: number;
  47364. updatable?: boolean;
  47365. }, scene: any): Mesh;
  47366. /**
  47367. * Creates a tiled ground mesh
  47368. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47369. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47370. * * 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
  47371. * * 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
  47372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47373. * @param name defines the name of the mesh
  47374. * @param options defines the options used to create the mesh
  47375. * @param scene defines the hosting scene
  47376. * @returns the tiled ground mesh
  47377. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47378. */
  47379. static CreateTiledGround(name: string, options: {
  47380. xmin: number;
  47381. zmin: number;
  47382. xmax: number;
  47383. zmax: number;
  47384. subdivisions?: {
  47385. w: number;
  47386. h: number;
  47387. };
  47388. precision?: {
  47389. w: number;
  47390. h: number;
  47391. };
  47392. updatable?: boolean;
  47393. }, scene?: Nullable<Scene>): Mesh;
  47394. /**
  47395. * Creates a ground mesh from a height map
  47396. * * The parameter `url` sets the URL of the height map image resource.
  47397. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47398. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47399. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47400. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47401. * * 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.
  47402. * * 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).
  47403. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47405. * @param name defines the name of the mesh
  47406. * @param url defines the url to the height map
  47407. * @param options defines the options used to create the mesh
  47408. * @param scene defines the hosting scene
  47409. * @returns the ground mesh
  47410. * @see https://doc.babylonjs.com/babylon101/height_map
  47411. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47412. */
  47413. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47414. width?: number;
  47415. height?: number;
  47416. subdivisions?: number;
  47417. minHeight?: number;
  47418. maxHeight?: number;
  47419. colorFilter?: Color3;
  47420. alphaFilter?: number;
  47421. updatable?: boolean;
  47422. onReady?: (mesh: GroundMesh) => void;
  47423. }, scene?: Nullable<Scene>): GroundMesh;
  47424. }
  47425. }
  47426. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47427. import { Vector4 } from "babylonjs/Maths/math.vector";
  47428. import { Mesh } from "babylonjs/Meshes/mesh";
  47429. /**
  47430. * Class containing static functions to help procedurally build meshes
  47431. */
  47432. export class TorusBuilder {
  47433. /**
  47434. * Creates a torus mesh
  47435. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47436. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47437. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47441. * @param name defines the name of the mesh
  47442. * @param options defines the options used to create the mesh
  47443. * @param scene defines the hosting scene
  47444. * @returns the torus mesh
  47445. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47446. */
  47447. static CreateTorus(name: string, options: {
  47448. diameter?: number;
  47449. thickness?: number;
  47450. tessellation?: number;
  47451. updatable?: boolean;
  47452. sideOrientation?: number;
  47453. frontUVs?: Vector4;
  47454. backUVs?: Vector4;
  47455. }, scene: any): Mesh;
  47456. }
  47457. }
  47458. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47459. import { Vector4 } from "babylonjs/Maths/math.vector";
  47460. import { Color4 } from "babylonjs/Maths/math.color";
  47461. import { Mesh } from "babylonjs/Meshes/mesh";
  47462. /**
  47463. * Class containing static functions to help procedurally build meshes
  47464. */
  47465. export class CylinderBuilder {
  47466. /**
  47467. * Creates a cylinder or a cone mesh
  47468. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47469. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47470. * * 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.
  47471. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47472. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47473. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47474. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47475. * * 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).
  47476. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47477. * * 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).
  47478. * * 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
  47479. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47480. * * 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
  47481. * * 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.
  47482. * * If `enclose` is false, a ring surface is one element.
  47483. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47484. * * 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
  47485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47488. * @param name defines the name of the mesh
  47489. * @param options defines the options used to create the mesh
  47490. * @param scene defines the hosting scene
  47491. * @returns the cylinder mesh
  47492. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47493. */
  47494. static CreateCylinder(name: string, options: {
  47495. height?: number;
  47496. diameterTop?: number;
  47497. diameterBottom?: number;
  47498. diameter?: number;
  47499. tessellation?: number;
  47500. subdivisions?: number;
  47501. arc?: number;
  47502. faceColors?: Color4[];
  47503. faceUV?: Vector4[];
  47504. updatable?: boolean;
  47505. hasRings?: boolean;
  47506. enclose?: boolean;
  47507. cap?: number;
  47508. sideOrientation?: number;
  47509. frontUVs?: Vector4;
  47510. backUVs?: Vector4;
  47511. }, scene: any): Mesh;
  47512. }
  47513. }
  47514. declare module "babylonjs/XR/webXRTypes" {
  47515. import { Nullable } from "babylonjs/types";
  47516. import { IDisposable } from "babylonjs/scene";
  47517. /**
  47518. * States of the webXR experience
  47519. */
  47520. export enum WebXRState {
  47521. /**
  47522. * Transitioning to being in XR mode
  47523. */
  47524. ENTERING_XR = 0,
  47525. /**
  47526. * Transitioning to non XR mode
  47527. */
  47528. EXITING_XR = 1,
  47529. /**
  47530. * In XR mode and presenting
  47531. */
  47532. IN_XR = 2,
  47533. /**
  47534. * Not entered XR mode
  47535. */
  47536. NOT_IN_XR = 3
  47537. }
  47538. /**
  47539. * Abstraction of the XR render target
  47540. */
  47541. export interface WebXRRenderTarget extends IDisposable {
  47542. /**
  47543. * xrpresent context of the canvas which can be used to display/mirror xr content
  47544. */
  47545. canvasContext: WebGLRenderingContext;
  47546. /**
  47547. * xr layer for the canvas
  47548. */
  47549. xrLayer: Nullable<XRWebGLLayer>;
  47550. /**
  47551. * Initializes the xr layer for the session
  47552. * @param xrSession xr session
  47553. * @returns a promise that will resolve once the XR Layer has been created
  47554. */
  47555. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47556. }
  47557. }
  47558. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47559. import { Nullable } from "babylonjs/types";
  47560. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47561. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47562. /**
  47563. * COnfiguration object for WebXR output canvas
  47564. */
  47565. export class WebXRManagedOutputCanvasOptions {
  47566. /**
  47567. * An optional canvas in case you wish to create it yourself and provide it here.
  47568. * If not provided, a new canvas will be created
  47569. */
  47570. canvasElement?: HTMLCanvasElement;
  47571. /**
  47572. * Options for this XR Layer output
  47573. */
  47574. canvasOptions?: XRWebGLLayerOptions;
  47575. /**
  47576. * CSS styling for a newly created canvas (if not provided)
  47577. */
  47578. newCanvasCssStyle?: string;
  47579. /**
  47580. * Get the default values of the configuration object
  47581. * @returns default values of this configuration object
  47582. */
  47583. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47584. }
  47585. /**
  47586. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47587. */
  47588. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47589. private _options;
  47590. private _canvas;
  47591. private _engine;
  47592. /**
  47593. * Rendering context of the canvas which can be used to display/mirror xr content
  47594. */
  47595. canvasContext: WebGLRenderingContext;
  47596. /**
  47597. * xr layer for the canvas
  47598. */
  47599. xrLayer: Nullable<XRWebGLLayer>;
  47600. /**
  47601. * Initializes the canvas to be added/removed upon entering/exiting xr
  47602. * @param _xrSessionManager The XR Session manager
  47603. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47604. */
  47605. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47606. /**
  47607. * Disposes of the object
  47608. */
  47609. dispose(): void;
  47610. /**
  47611. * Initializes the xr layer for the session
  47612. * @param xrSession xr session
  47613. * @returns a promise that will resolve once the XR Layer has been created
  47614. */
  47615. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47616. private _addCanvas;
  47617. private _removeCanvas;
  47618. private _setManagedOutputCanvas;
  47619. }
  47620. }
  47621. declare module "babylonjs/XR/webXRSessionManager" {
  47622. import { Observable } from "babylonjs/Misc/observable";
  47623. import { Nullable } from "babylonjs/types";
  47624. import { IDisposable, Scene } from "babylonjs/scene";
  47625. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47626. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47627. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47628. /**
  47629. * Manages an XRSession to work with Babylon's engine
  47630. * @see https://doc.babylonjs.com/how_to/webxr
  47631. */
  47632. export class WebXRSessionManager implements IDisposable {
  47633. /** The scene which the session should be created for */
  47634. scene: Scene;
  47635. private _referenceSpace;
  47636. private _rttProvider;
  47637. private _sessionEnded;
  47638. private _xrNavigator;
  47639. private baseLayer;
  47640. /**
  47641. * The base reference space from which the session started. good if you want to reset your
  47642. * reference space
  47643. */
  47644. baseReferenceSpace: XRReferenceSpace;
  47645. /**
  47646. * Current XR frame
  47647. */
  47648. currentFrame: Nullable<XRFrame>;
  47649. /** WebXR timestamp updated every frame */
  47650. currentTimestamp: number;
  47651. /**
  47652. * Used just in case of a failure to initialize an immersive session.
  47653. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47654. */
  47655. defaultHeightCompensation: number;
  47656. /**
  47657. * Fires every time a new xrFrame arrives which can be used to update the camera
  47658. */
  47659. onXRFrameObservable: Observable<XRFrame>;
  47660. /**
  47661. * Fires when the reference space changed
  47662. */
  47663. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47664. /**
  47665. * Fires when the xr session is ended either by the device or manually done
  47666. */
  47667. onXRSessionEnded: Observable<any>;
  47668. /**
  47669. * Fires when the xr session is ended either by the device or manually done
  47670. */
  47671. onXRSessionInit: Observable<XRSession>;
  47672. /**
  47673. * Underlying xr session
  47674. */
  47675. session: XRSession;
  47676. /**
  47677. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47678. * or get the offset the player is currently at.
  47679. */
  47680. viewerReferenceSpace: XRReferenceSpace;
  47681. /**
  47682. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47683. * @param scene The scene which the session should be created for
  47684. */
  47685. constructor(
  47686. /** The scene which the session should be created for */
  47687. scene: Scene);
  47688. /**
  47689. * The current reference space used in this session. This reference space can constantly change!
  47690. * It is mainly used to offset the camera's position.
  47691. */
  47692. get referenceSpace(): XRReferenceSpace;
  47693. /**
  47694. * Set a new reference space and triggers the observable
  47695. */
  47696. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47697. /**
  47698. * Disposes of the session manager
  47699. */
  47700. dispose(): void;
  47701. /**
  47702. * Stops the xrSession and restores the render loop
  47703. * @returns Promise which resolves after it exits XR
  47704. */
  47705. exitXRAsync(): Promise<void>;
  47706. /**
  47707. * Gets the correct render target texture to be rendered this frame for this eye
  47708. * @param eye the eye for which to get the render target
  47709. * @returns the render target for the specified eye
  47710. */
  47711. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47712. /**
  47713. * Creates a WebXRRenderTarget object for the XR session
  47714. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47715. * @param options optional options to provide when creating a new render target
  47716. * @returns a WebXR render target to which the session can render
  47717. */
  47718. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47719. /**
  47720. * Initializes the manager
  47721. * After initialization enterXR can be called to start an XR session
  47722. * @returns Promise which resolves after it is initialized
  47723. */
  47724. initializeAsync(): Promise<void>;
  47725. /**
  47726. * Initializes an xr session
  47727. * @param xrSessionMode mode to initialize
  47728. * @param xrSessionInit defines optional and required values to pass to the session builder
  47729. * @returns a promise which will resolve once the session has been initialized
  47730. */
  47731. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47732. /**
  47733. * Checks if a session would be supported for the creation options specified
  47734. * @param sessionMode session mode to check if supported eg. immersive-vr
  47735. * @returns A Promise that resolves to true if supported and false if not
  47736. */
  47737. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47738. /**
  47739. * Resets the reference space to the one started the session
  47740. */
  47741. resetReferenceSpace(): void;
  47742. /**
  47743. * Starts rendering to the xr layer
  47744. */
  47745. runXRRenderLoop(): void;
  47746. /**
  47747. * Sets the reference space on the xr session
  47748. * @param referenceSpaceType space to set
  47749. * @returns a promise that will resolve once the reference space has been set
  47750. */
  47751. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47752. /**
  47753. * Updates the render state of the session
  47754. * @param state state to set
  47755. * @returns a promise that resolves once the render state has been updated
  47756. */
  47757. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47758. /**
  47759. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47760. * @param sessionMode defines the session to test
  47761. * @returns a promise with boolean as final value
  47762. */
  47763. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47764. private _createRenderTargetTexture;
  47765. }
  47766. }
  47767. declare module "babylonjs/XR/webXRCamera" {
  47768. import { Matrix } from "babylonjs/Maths/math.vector";
  47769. import { Scene } from "babylonjs/scene";
  47770. import { Camera } from "babylonjs/Cameras/camera";
  47771. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47772. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47773. /**
  47774. * WebXR Camera which holds the views for the xrSession
  47775. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47776. */
  47777. export class WebXRCamera extends FreeCamera {
  47778. private _xrSessionManager;
  47779. private _firstFrame;
  47780. private _referenceQuaternion;
  47781. private _referencedPosition;
  47782. private _xrInvPositionCache;
  47783. private _xrInvQuaternionCache;
  47784. /**
  47785. * Should position compensation execute on first frame.
  47786. * This is used when copying the position from a native (non XR) camera
  47787. */
  47788. compensateOnFirstFrame: boolean;
  47789. /**
  47790. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47791. * @param name the name of the camera
  47792. * @param scene the scene to add the camera to
  47793. * @param _xrSessionManager a constructed xr session manager
  47794. */
  47795. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47796. /**
  47797. * Return the user's height, unrelated to the current ground.
  47798. * This will be the y position of this camera, when ground level is 0.
  47799. */
  47800. get realWorldHeight(): number;
  47801. /** @hidden */
  47802. _updateForDualEyeDebugging(): void;
  47803. /**
  47804. * Sets this camera's transformation based on a non-vr camera
  47805. * @param otherCamera the non-vr camera to copy the transformation from
  47806. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47807. */
  47808. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47809. /**
  47810. * Gets the current instance class name ("WebXRCamera").
  47811. * @returns the class name
  47812. */
  47813. getClassName(): string;
  47814. /**
  47815. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47816. */
  47817. _getViewMatrix(): Matrix;
  47818. private _updateFromXRSession;
  47819. private _updateNumberOfRigCameras;
  47820. private _updateReferenceSpace;
  47821. private _updateReferenceSpaceOffset;
  47822. }
  47823. }
  47824. declare module "babylonjs/XR/webXRFeaturesManager" {
  47825. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47826. import { IDisposable } from "babylonjs/scene";
  47827. /**
  47828. * Defining the interface required for a (webxr) feature
  47829. */
  47830. export interface IWebXRFeature extends IDisposable {
  47831. /**
  47832. * Is this feature attached
  47833. */
  47834. attached: boolean;
  47835. /**
  47836. * Should auto-attach be disabled?
  47837. */
  47838. disableAutoAttach: boolean;
  47839. /**
  47840. * Attach the feature to the session
  47841. * Will usually be called by the features manager
  47842. *
  47843. * @param force should attachment be forced (even when already attached)
  47844. * @returns true if successful.
  47845. */
  47846. attach(force?: boolean): boolean;
  47847. /**
  47848. * Detach the feature from the session
  47849. * Will usually be called by the features manager
  47850. *
  47851. * @returns true if successful.
  47852. */
  47853. detach(): boolean;
  47854. }
  47855. /**
  47856. * A list of the currently available features without referencing them
  47857. */
  47858. export class WebXRFeatureName {
  47859. /**
  47860. * The name of the anchor system feature
  47861. */
  47862. static ANCHOR_SYSTEM: string;
  47863. /**
  47864. * The name of the background remover feature
  47865. */
  47866. static BACKGROUND_REMOVER: string;
  47867. /**
  47868. * The name of the hit test feature
  47869. */
  47870. static HIT_TEST: string;
  47871. /**
  47872. * physics impostors for xr controllers feature
  47873. */
  47874. static PHYSICS_CONTROLLERS: string;
  47875. /**
  47876. * The name of the plane detection feature
  47877. */
  47878. static PLANE_DETECTION: string;
  47879. /**
  47880. * The name of the pointer selection feature
  47881. */
  47882. static POINTER_SELECTION: string;
  47883. /**
  47884. * The name of the teleportation feature
  47885. */
  47886. static TELEPORTATION: string;
  47887. }
  47888. /**
  47889. * Defining the constructor of a feature. Used to register the modules.
  47890. */
  47891. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  47892. /**
  47893. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47894. * It is mainly used in AR sessions.
  47895. *
  47896. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47897. */
  47898. export class WebXRFeaturesManager implements IDisposable {
  47899. private _xrSessionManager;
  47900. private static readonly _AvailableFeatures;
  47901. private _features;
  47902. /**
  47903. * constructs a new features manages.
  47904. *
  47905. * @param _xrSessionManager an instance of WebXRSessionManager
  47906. */
  47907. constructor(_xrSessionManager: WebXRSessionManager);
  47908. /**
  47909. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47910. * Mainly used internally.
  47911. *
  47912. * @param featureName the name of the feature to register
  47913. * @param constructorFunction the function used to construct the module
  47914. * @param version the (babylon) version of the module
  47915. * @param stable is that a stable version of this module
  47916. */
  47917. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47918. /**
  47919. * Returns a constructor of a specific feature.
  47920. *
  47921. * @param featureName the name of the feature to construct
  47922. * @param version the version of the feature to load
  47923. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47924. * @param options optional options provided to the module.
  47925. * @returns a function that, when called, will return a new instance of this feature
  47926. */
  47927. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  47928. /**
  47929. * Can be used to return the list of features currently registered
  47930. *
  47931. * @returns an Array of available features
  47932. */
  47933. static GetAvailableFeatures(): string[];
  47934. /**
  47935. * Gets the versions available for a specific feature
  47936. * @param featureName the name of the feature
  47937. * @returns an array with the available versions
  47938. */
  47939. static GetAvailableVersions(featureName: string): string[];
  47940. /**
  47941. * Return the latest unstable version of this feature
  47942. * @param featureName the name of the feature to search
  47943. * @returns the version number. if not found will return -1
  47944. */
  47945. static GetLatestVersionOfFeature(featureName: string): number;
  47946. /**
  47947. * Return the latest stable version of this feature
  47948. * @param featureName the name of the feature to search
  47949. * @returns the version number. if not found will return -1
  47950. */
  47951. static GetStableVersionOfFeature(featureName: string): number;
  47952. /**
  47953. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47954. * Can be used during a session to start a feature
  47955. * @param featureName the name of feature to attach
  47956. */
  47957. attachFeature(featureName: string): void;
  47958. /**
  47959. * Can be used inside a session or when the session ends to detach a specific feature
  47960. * @param featureName the name of the feature to detach
  47961. */
  47962. detachFeature(featureName: string): void;
  47963. /**
  47964. * Used to disable an already-enabled feature
  47965. * The feature will be disposed and will be recreated once enabled.
  47966. * @param featureName the feature to disable
  47967. * @returns true if disable was successful
  47968. */
  47969. disableFeature(featureName: string | {
  47970. Name: string;
  47971. }): boolean;
  47972. /**
  47973. * dispose this features manager
  47974. */
  47975. dispose(): void;
  47976. /**
  47977. * 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.
  47978. * 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.
  47979. *
  47980. * @param featureName the name of the feature to load or the class of the feature
  47981. * @param version optional version to load. if not provided the latest version will be enabled
  47982. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47983. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47984. * @returns a new constructed feature or throws an error if feature not found.
  47985. */
  47986. enableFeature(featureName: string | {
  47987. Name: string;
  47988. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  47989. /**
  47990. * get the implementation of an enabled feature.
  47991. * @param featureName the name of the feature to load
  47992. * @returns the feature class, if found
  47993. */
  47994. getEnabledFeature(featureName: string): IWebXRFeature;
  47995. /**
  47996. * Get the list of enabled features
  47997. * @returns an array of enabled features
  47998. */
  47999. getEnabledFeatures(): string[];
  48000. }
  48001. }
  48002. declare module "babylonjs/XR/webXRExperienceHelper" {
  48003. import { Observable } from "babylonjs/Misc/observable";
  48004. import { IDisposable, Scene } from "babylonjs/scene";
  48005. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48006. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48007. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48008. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48009. /**
  48010. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48011. * @see https://doc.babylonjs.com/how_to/webxr
  48012. */
  48013. export class WebXRExperienceHelper implements IDisposable {
  48014. private scene;
  48015. private _nonVRCamera;
  48016. private _originalSceneAutoClear;
  48017. private _supported;
  48018. /**
  48019. * Camera used to render xr content
  48020. */
  48021. camera: WebXRCamera;
  48022. /** A features manager for this xr session */
  48023. featuresManager: WebXRFeaturesManager;
  48024. /**
  48025. * Observers registered here will be triggered after the camera's initial transformation is set
  48026. * This can be used to set a different ground level or an extra rotation.
  48027. *
  48028. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48029. * to the position set after this observable is done executing.
  48030. */
  48031. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48032. /**
  48033. * Fires when the state of the experience helper has changed
  48034. */
  48035. onStateChangedObservable: Observable<WebXRState>;
  48036. /** Session manager used to keep track of xr session */
  48037. sessionManager: WebXRSessionManager;
  48038. /**
  48039. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48040. */
  48041. state: WebXRState;
  48042. /**
  48043. * Creates a WebXRExperienceHelper
  48044. * @param scene The scene the helper should be created in
  48045. */
  48046. private constructor();
  48047. /**
  48048. * Creates the experience helper
  48049. * @param scene the scene to attach the experience helper to
  48050. * @returns a promise for the experience helper
  48051. */
  48052. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48053. /**
  48054. * Disposes of the experience helper
  48055. */
  48056. dispose(): void;
  48057. /**
  48058. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48059. * @param sessionMode options for the XR session
  48060. * @param referenceSpaceType frame of reference of the XR session
  48061. * @param renderTarget the output canvas that will be used to enter XR mode
  48062. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48063. * @returns promise that resolves after xr mode has entered
  48064. */
  48065. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48066. /**
  48067. * Exits XR mode and returns the scene to its original state
  48068. * @returns promise that resolves after xr mode has exited
  48069. */
  48070. exitXRAsync(): Promise<void>;
  48071. private _nonXRToXRCamera;
  48072. private _setState;
  48073. }
  48074. }
  48075. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48076. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48077. import { Observable } from "babylonjs/Misc/observable";
  48078. import { IDisposable } from "babylonjs/scene";
  48079. /**
  48080. * X-Y values for axes in WebXR
  48081. */
  48082. export interface IWebXRMotionControllerAxesValue {
  48083. /**
  48084. * The value of the x axis
  48085. */
  48086. x: number;
  48087. /**
  48088. * The value of the y-axis
  48089. */
  48090. y: number;
  48091. }
  48092. /**
  48093. * changed / previous values for the values of this component
  48094. */
  48095. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48096. /**
  48097. * current (this frame) value
  48098. */
  48099. current: T;
  48100. /**
  48101. * previous (last change) value
  48102. */
  48103. previous: T;
  48104. }
  48105. /**
  48106. * Represents changes in the component between current frame and last values recorded
  48107. */
  48108. export interface IWebXRMotionControllerComponentChanges {
  48109. /**
  48110. * will be populated with previous and current values if axes changed
  48111. */
  48112. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48113. /**
  48114. * will be populated with previous and current values if pressed changed
  48115. */
  48116. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48117. /**
  48118. * will be populated with previous and current values if touched changed
  48119. */
  48120. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48121. /**
  48122. * will be populated with previous and current values if value changed
  48123. */
  48124. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48125. }
  48126. /**
  48127. * This class represents a single component (for example button or thumbstick) of a motion controller
  48128. */
  48129. export class WebXRControllerComponent implements IDisposable {
  48130. /**
  48131. * the id of this component
  48132. */
  48133. id: string;
  48134. /**
  48135. * the type of the component
  48136. */
  48137. type: MotionControllerComponentType;
  48138. private _buttonIndex;
  48139. private _axesIndices;
  48140. private _axes;
  48141. private _changes;
  48142. private _currentValue;
  48143. private _hasChanges;
  48144. private _pressed;
  48145. private _touched;
  48146. /**
  48147. * button component type
  48148. */
  48149. static BUTTON_TYPE: MotionControllerComponentType;
  48150. /**
  48151. * squeeze component type
  48152. */
  48153. static SQUEEZE_TYPE: MotionControllerComponentType;
  48154. /**
  48155. * Thumbstick component type
  48156. */
  48157. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48158. /**
  48159. * Touchpad component type
  48160. */
  48161. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48162. /**
  48163. * trigger component type
  48164. */
  48165. static TRIGGER_TYPE: MotionControllerComponentType;
  48166. /**
  48167. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48168. * the axes data changes
  48169. */
  48170. onAxisValueChangedObservable: Observable<{
  48171. x: number;
  48172. y: number;
  48173. }>;
  48174. /**
  48175. * Observers registered here will be triggered when the state of a button changes
  48176. * State change is either pressed / touched / value
  48177. */
  48178. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48179. /**
  48180. * Creates a new component for a motion controller.
  48181. * It is created by the motion controller itself
  48182. *
  48183. * @param id the id of this component
  48184. * @param type the type of the component
  48185. * @param _buttonIndex index in the buttons array of the gamepad
  48186. * @param _axesIndices indices of the values in the axes array of the gamepad
  48187. */
  48188. constructor(
  48189. /**
  48190. * the id of this component
  48191. */
  48192. id: string,
  48193. /**
  48194. * the type of the component
  48195. */
  48196. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48197. /**
  48198. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48199. */
  48200. get axes(): IWebXRMotionControllerAxesValue;
  48201. /**
  48202. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48203. */
  48204. get changes(): IWebXRMotionControllerComponentChanges;
  48205. /**
  48206. * Return whether or not the component changed the last frame
  48207. */
  48208. get hasChanges(): boolean;
  48209. /**
  48210. * is the button currently pressed
  48211. */
  48212. get pressed(): boolean;
  48213. /**
  48214. * is the button currently touched
  48215. */
  48216. get touched(): boolean;
  48217. /**
  48218. * Get the current value of this component
  48219. */
  48220. get value(): number;
  48221. /**
  48222. * Dispose this component
  48223. */
  48224. dispose(): void;
  48225. /**
  48226. * Are there axes correlating to this component
  48227. * @return true is axes data is available
  48228. */
  48229. isAxes(): boolean;
  48230. /**
  48231. * Is this component a button (hence - pressable)
  48232. * @returns true if can be pressed
  48233. */
  48234. isButton(): boolean;
  48235. /**
  48236. * update this component using the gamepad object it is in. Called on every frame
  48237. * @param nativeController the native gamepad controller object
  48238. */
  48239. update(nativeController: IMinimalMotionControllerObject): void;
  48240. }
  48241. }
  48242. declare module "babylonjs/Loading/sceneLoader" {
  48243. import { Observable } from "babylonjs/Misc/observable";
  48244. import { Nullable } from "babylonjs/types";
  48245. import { Scene } from "babylonjs/scene";
  48246. import { Engine } from "babylonjs/Engines/engine";
  48247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48248. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48249. import { AssetContainer } from "babylonjs/assetContainer";
  48250. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48251. import { Skeleton } from "babylonjs/Bones/skeleton";
  48252. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48253. import { WebRequest } from "babylonjs/Misc/webRequest";
  48254. /**
  48255. * Class used to represent data loading progression
  48256. */
  48257. export class SceneLoaderProgressEvent {
  48258. /** defines if data length to load can be evaluated */
  48259. readonly lengthComputable: boolean;
  48260. /** defines the loaded data length */
  48261. readonly loaded: number;
  48262. /** defines the data length to load */
  48263. readonly total: number;
  48264. /**
  48265. * Create a new progress event
  48266. * @param lengthComputable defines if data length to load can be evaluated
  48267. * @param loaded defines the loaded data length
  48268. * @param total defines the data length to load
  48269. */
  48270. constructor(
  48271. /** defines if data length to load can be evaluated */
  48272. lengthComputable: boolean,
  48273. /** defines the loaded data length */
  48274. loaded: number,
  48275. /** defines the data length to load */
  48276. total: number);
  48277. /**
  48278. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48279. * @param event defines the source event
  48280. * @returns a new SceneLoaderProgressEvent
  48281. */
  48282. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  48283. }
  48284. /**
  48285. * Interface used by SceneLoader plugins to define supported file extensions
  48286. */
  48287. export interface ISceneLoaderPluginExtensions {
  48288. /**
  48289. * Defines the list of supported extensions
  48290. */
  48291. [extension: string]: {
  48292. isBinary: boolean;
  48293. };
  48294. }
  48295. /**
  48296. * Interface used by SceneLoader plugin factory
  48297. */
  48298. export interface ISceneLoaderPluginFactory {
  48299. /**
  48300. * Defines the name of the factory
  48301. */
  48302. name: string;
  48303. /**
  48304. * Function called to create a new plugin
  48305. * @return the new plugin
  48306. */
  48307. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48308. /**
  48309. * The callback that returns true if the data can be directly loaded.
  48310. * @param data string containing the file data
  48311. * @returns if the data can be loaded directly
  48312. */
  48313. canDirectLoad?(data: string): boolean;
  48314. }
  48315. /**
  48316. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48317. */
  48318. export interface ISceneLoaderPluginBase {
  48319. /**
  48320. * The friendly name of this plugin.
  48321. */
  48322. name: string;
  48323. /**
  48324. * The file extensions supported by this plugin.
  48325. */
  48326. extensions: string | ISceneLoaderPluginExtensions;
  48327. /**
  48328. * The callback called when loading from a url.
  48329. * @param scene scene loading this url
  48330. * @param url url to load
  48331. * @param onSuccess callback called when the file successfully loads
  48332. * @param onProgress callback called while file is loading (if the server supports this mode)
  48333. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48334. * @param onError callback called when the file fails to load
  48335. * @returns a file request object
  48336. */
  48337. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48338. /**
  48339. * The callback called when loading from a file object.
  48340. * @param scene scene loading this file
  48341. * @param file defines the file to load
  48342. * @param onSuccess defines the callback to call when data is loaded
  48343. * @param onProgress defines the callback to call during loading process
  48344. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48345. * @param onError defines the callback to call when an error occurs
  48346. * @returns a file request object
  48347. */
  48348. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48349. /**
  48350. * The callback that returns true if the data can be directly loaded.
  48351. * @param data string containing the file data
  48352. * @returns if the data can be loaded directly
  48353. */
  48354. canDirectLoad?(data: string): boolean;
  48355. /**
  48356. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48357. * @param scene scene loading this data
  48358. * @param data string containing the data
  48359. * @returns data to pass to the plugin
  48360. */
  48361. directLoad?(scene: Scene, data: string): any;
  48362. /**
  48363. * The callback that allows custom handling of the root url based on the response url.
  48364. * @param rootUrl the original root url
  48365. * @param responseURL the response url if available
  48366. * @returns the new root url
  48367. */
  48368. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48369. }
  48370. /**
  48371. * Interface used to define a SceneLoader plugin
  48372. */
  48373. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48374. /**
  48375. * Import meshes into a scene.
  48376. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48377. * @param scene The scene to import into
  48378. * @param data The data to import
  48379. * @param rootUrl The root url for scene and resources
  48380. * @param meshes The meshes array to import into
  48381. * @param particleSystems The particle systems array to import into
  48382. * @param skeletons The skeletons array to import into
  48383. * @param onError The callback when import fails
  48384. * @returns True if successful or false otherwise
  48385. */
  48386. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48387. /**
  48388. * Load into a scene.
  48389. * @param scene The scene to load into
  48390. * @param data The data to import
  48391. * @param rootUrl The root url for scene and resources
  48392. * @param onError The callback when import fails
  48393. * @returns True if successful or false otherwise
  48394. */
  48395. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48396. /**
  48397. * Load into an asset container.
  48398. * @param scene The scene to load into
  48399. * @param data The data to import
  48400. * @param rootUrl The root url for scene and resources
  48401. * @param onError The callback when import fails
  48402. * @returns The loaded asset container
  48403. */
  48404. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48405. }
  48406. /**
  48407. * Interface used to define an async SceneLoader plugin
  48408. */
  48409. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48410. /**
  48411. * Import meshes into a scene.
  48412. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48413. * @param scene The scene to import into
  48414. * @param data The data to import
  48415. * @param rootUrl The root url for scene and resources
  48416. * @param onProgress The callback when the load progresses
  48417. * @param fileName Defines the name of the file to load
  48418. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48419. */
  48420. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48421. meshes: AbstractMesh[];
  48422. particleSystems: IParticleSystem[];
  48423. skeletons: Skeleton[];
  48424. animationGroups: AnimationGroup[];
  48425. }>;
  48426. /**
  48427. * Load into a scene.
  48428. * @param scene The scene to load into
  48429. * @param data The data to import
  48430. * @param rootUrl The root url for scene and resources
  48431. * @param onProgress The callback when the load progresses
  48432. * @param fileName Defines the name of the file to load
  48433. * @returns Nothing
  48434. */
  48435. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48436. /**
  48437. * Load into an asset container.
  48438. * @param scene The scene to load into
  48439. * @param data The data to import
  48440. * @param rootUrl The root url for scene and resources
  48441. * @param onProgress The callback when the load progresses
  48442. * @param fileName Defines the name of the file to load
  48443. * @returns The loaded asset container
  48444. */
  48445. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48446. }
  48447. /**
  48448. * Mode that determines how to handle old animation groups before loading new ones.
  48449. */
  48450. export enum SceneLoaderAnimationGroupLoadingMode {
  48451. /**
  48452. * Reset all old animations to initial state then dispose them.
  48453. */
  48454. Clean = 0,
  48455. /**
  48456. * Stop all old animations.
  48457. */
  48458. Stop = 1,
  48459. /**
  48460. * Restart old animations from first frame.
  48461. */
  48462. Sync = 2,
  48463. /**
  48464. * Old animations remains untouched.
  48465. */
  48466. NoSync = 3
  48467. }
  48468. /**
  48469. * Class used to load scene from various file formats using registered plugins
  48470. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48471. */
  48472. export class SceneLoader {
  48473. /**
  48474. * No logging while loading
  48475. */
  48476. static readonly NO_LOGGING: number;
  48477. /**
  48478. * Minimal logging while loading
  48479. */
  48480. static readonly MINIMAL_LOGGING: number;
  48481. /**
  48482. * Summary logging while loading
  48483. */
  48484. static readonly SUMMARY_LOGGING: number;
  48485. /**
  48486. * Detailled logging while loading
  48487. */
  48488. static readonly DETAILED_LOGGING: number;
  48489. /**
  48490. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48491. */
  48492. static get ForceFullSceneLoadingForIncremental(): boolean;
  48493. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48494. /**
  48495. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48496. */
  48497. static get ShowLoadingScreen(): boolean;
  48498. static set ShowLoadingScreen(value: boolean);
  48499. /**
  48500. * Defines the current logging level (while loading the scene)
  48501. * @ignorenaming
  48502. */
  48503. static get loggingLevel(): number;
  48504. static set loggingLevel(value: number);
  48505. /**
  48506. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48507. */
  48508. static get CleanBoneMatrixWeights(): boolean;
  48509. static set CleanBoneMatrixWeights(value: boolean);
  48510. /**
  48511. * Event raised when a plugin is used to load a scene
  48512. */
  48513. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48514. private static _registeredPlugins;
  48515. private static _getDefaultPlugin;
  48516. private static _getPluginForExtension;
  48517. private static _getPluginForDirectLoad;
  48518. private static _getPluginForFilename;
  48519. private static _getDirectLoad;
  48520. private static _loadData;
  48521. private static _getFileInfo;
  48522. /**
  48523. * Gets a plugin that can load the given extension
  48524. * @param extension defines the extension to load
  48525. * @returns a plugin or null if none works
  48526. */
  48527. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48528. /**
  48529. * Gets a boolean indicating that the given extension can be loaded
  48530. * @param extension defines the extension to load
  48531. * @returns true if the extension is supported
  48532. */
  48533. static IsPluginForExtensionAvailable(extension: string): boolean;
  48534. /**
  48535. * Adds a new plugin to the list of registered plugins
  48536. * @param plugin defines the plugin to add
  48537. */
  48538. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48539. /**
  48540. * Import meshes into a scene
  48541. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48542. * @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)
  48543. * @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)
  48544. * @param scene the instance of BABYLON.Scene to append to
  48545. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48546. * @param onProgress a callback with a progress event for each file being loaded
  48547. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48548. * @param pluginExtension the extension used to determine the plugin
  48549. * @returns The loaded plugin
  48550. */
  48551. 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>;
  48552. /**
  48553. * Import meshes into a scene
  48554. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48555. * @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)
  48556. * @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)
  48557. * @param scene the instance of BABYLON.Scene to append to
  48558. * @param onProgress a callback with a progress event for each file being loaded
  48559. * @param pluginExtension the extension used to determine the plugin
  48560. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48561. */
  48562. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48563. meshes: AbstractMesh[];
  48564. particleSystems: IParticleSystem[];
  48565. skeletons: Skeleton[];
  48566. animationGroups: AnimationGroup[];
  48567. }>;
  48568. /**
  48569. * Load a scene
  48570. * @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)
  48571. * @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)
  48572. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48573. * @param onSuccess a callback with the scene when import succeeds
  48574. * @param onProgress a callback with a progress event for each file being loaded
  48575. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48576. * @param pluginExtension the extension used to determine the plugin
  48577. * @returns The loaded plugin
  48578. */
  48579. 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>;
  48580. /**
  48581. * Load a scene
  48582. * @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)
  48583. * @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)
  48584. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48585. * @param onProgress a callback with a progress event for each file being loaded
  48586. * @param pluginExtension the extension used to determine the plugin
  48587. * @returns The loaded scene
  48588. */
  48589. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48590. /**
  48591. * Append a scene
  48592. * @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)
  48593. * @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)
  48594. * @param scene is the instance of BABYLON.Scene to append to
  48595. * @param onSuccess a callback with the scene when import succeeds
  48596. * @param onProgress a callback with a progress event for each file being loaded
  48597. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48598. * @param pluginExtension the extension used to determine the plugin
  48599. * @returns The loaded plugin
  48600. */
  48601. 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>;
  48602. /**
  48603. * Append a scene
  48604. * @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)
  48605. * @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)
  48606. * @param scene is the instance of BABYLON.Scene to append to
  48607. * @param onProgress a callback with a progress event for each file being loaded
  48608. * @param pluginExtension the extension used to determine the plugin
  48609. * @returns The given scene
  48610. */
  48611. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48612. /**
  48613. * Load a scene into an asset container
  48614. * @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)
  48615. * @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)
  48616. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48617. * @param onSuccess a callback with the scene when import succeeds
  48618. * @param onProgress a callback with a progress event for each file being loaded
  48619. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48620. * @param pluginExtension the extension used to determine the plugin
  48621. * @returns The loaded plugin
  48622. */
  48623. 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>;
  48624. /**
  48625. * Load a scene into an asset container
  48626. * @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)
  48627. * @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)
  48628. * @param scene is the instance of Scene to append to
  48629. * @param onProgress a callback with a progress event for each file being loaded
  48630. * @param pluginExtension the extension used to determine the plugin
  48631. * @returns The loaded asset container
  48632. */
  48633. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48634. /**
  48635. * Import animations from a file into a scene
  48636. * @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)
  48637. * @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)
  48638. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48639. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48640. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48641. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48642. * @param onSuccess a callback with the scene when import succeeds
  48643. * @param onProgress a callback with a progress event for each file being loaded
  48644. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48645. */
  48646. 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;
  48647. /**
  48648. * Import animations from a file into a scene
  48649. * @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)
  48650. * @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)
  48651. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48652. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48653. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48654. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48655. * @param onSuccess a callback with the scene when import succeeds
  48656. * @param onProgress a callback with a progress event for each file being loaded
  48657. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48658. * @returns the updated scene with imported animations
  48659. */
  48660. 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>;
  48661. }
  48662. }
  48663. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48664. import { IDisposable, Scene } from "babylonjs/scene";
  48665. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48666. import { Observable } from "babylonjs/Misc/observable";
  48667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48668. import { Nullable } from "babylonjs/types";
  48669. /**
  48670. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48671. */
  48672. export type MotionControllerHandedness = "none" | "left" | "right";
  48673. /**
  48674. * The type of components available in motion controllers.
  48675. * This is not the name of the component.
  48676. */
  48677. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48678. /**
  48679. * The state of a controller component
  48680. */
  48681. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48682. /**
  48683. * The schema of motion controller layout.
  48684. * No object will be initialized using this interface
  48685. * This is used just to define the profile.
  48686. */
  48687. export interface IMotionControllerLayout {
  48688. /**
  48689. * Path to load the assets. Usually relative to the base path
  48690. */
  48691. assetPath: string;
  48692. /**
  48693. * Available components (unsorted)
  48694. */
  48695. components: {
  48696. /**
  48697. * A map of component Ids
  48698. */
  48699. [componentId: string]: {
  48700. /**
  48701. * The type of input the component outputs
  48702. */
  48703. type: MotionControllerComponentType;
  48704. /**
  48705. * The indices of this component in the gamepad object
  48706. */
  48707. gamepadIndices: {
  48708. /**
  48709. * Index of button
  48710. */
  48711. button?: number;
  48712. /**
  48713. * If available, index of x-axis
  48714. */
  48715. xAxis?: number;
  48716. /**
  48717. * If available, index of y-axis
  48718. */
  48719. yAxis?: number;
  48720. };
  48721. /**
  48722. * The mesh's root node name
  48723. */
  48724. rootNodeName: string;
  48725. /**
  48726. * Animation definitions for this model
  48727. */
  48728. visualResponses: {
  48729. [stateKey: string]: {
  48730. /**
  48731. * What property will be animated
  48732. */
  48733. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48734. /**
  48735. * What states influence this visual response
  48736. */
  48737. states: MotionControllerComponentStateType[];
  48738. /**
  48739. * Type of animation - movement or visibility
  48740. */
  48741. valueNodeProperty: "transform" | "visibility";
  48742. /**
  48743. * Base node name to move. Its position will be calculated according to the min and max nodes
  48744. */
  48745. valueNodeName?: string;
  48746. /**
  48747. * Minimum movement node
  48748. */
  48749. minNodeName?: string;
  48750. /**
  48751. * Max movement node
  48752. */
  48753. maxNodeName?: string;
  48754. };
  48755. };
  48756. /**
  48757. * If touch enabled, what is the name of node to display user feedback
  48758. */
  48759. touchPointNodeName?: string;
  48760. };
  48761. };
  48762. /**
  48763. * Is it xr standard mapping or not
  48764. */
  48765. gamepadMapping: "" | "xr-standard";
  48766. /**
  48767. * Base root node of this entire model
  48768. */
  48769. rootNodeName: string;
  48770. /**
  48771. * Defines the main button component id
  48772. */
  48773. selectComponentId: string;
  48774. }
  48775. /**
  48776. * A definition for the layout map in the input profile
  48777. */
  48778. export interface IMotionControllerLayoutMap {
  48779. /**
  48780. * Layouts with handedness type as a key
  48781. */
  48782. [handedness: string]: IMotionControllerLayout;
  48783. }
  48784. /**
  48785. * The XR Input profile schema
  48786. * Profiles can be found here:
  48787. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48788. */
  48789. export interface IMotionControllerProfile {
  48790. /**
  48791. * fallback profiles for this profileId
  48792. */
  48793. fallbackProfileIds: string[];
  48794. /**
  48795. * The layout map, with handedness as key
  48796. */
  48797. layouts: IMotionControllerLayoutMap;
  48798. /**
  48799. * The id of this profile
  48800. * correlates to the profile(s) in the xrInput.profiles array
  48801. */
  48802. profileId: string;
  48803. }
  48804. /**
  48805. * A helper-interface for the 3 meshes needed for controller button animation
  48806. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48807. */
  48808. export interface IMotionControllerButtonMeshMap {
  48809. /**
  48810. * the mesh that defines the pressed value mesh position.
  48811. * This is used to find the max-position of this button
  48812. */
  48813. pressedMesh: AbstractMesh;
  48814. /**
  48815. * the mesh that defines the unpressed value mesh position.
  48816. * This is used to find the min (or initial) position of this button
  48817. */
  48818. unpressedMesh: AbstractMesh;
  48819. /**
  48820. * The mesh that will be changed when value changes
  48821. */
  48822. valueMesh: AbstractMesh;
  48823. }
  48824. /**
  48825. * A helper-interface for the 3 meshes needed for controller axis animation.
  48826. * This will be expanded when touchpad animations are fully supported
  48827. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48828. */
  48829. export interface IMotionControllerMeshMap {
  48830. /**
  48831. * the mesh that defines the maximum value mesh position.
  48832. */
  48833. maxMesh?: AbstractMesh;
  48834. /**
  48835. * the mesh that defines the minimum value mesh position.
  48836. */
  48837. minMesh?: AbstractMesh;
  48838. /**
  48839. * The mesh that will be changed when axis value changes
  48840. */
  48841. valueMesh: AbstractMesh;
  48842. }
  48843. /**
  48844. * The elements needed for change-detection of the gamepad objects in motion controllers
  48845. */
  48846. export interface IMinimalMotionControllerObject {
  48847. /**
  48848. * Available axes of this controller
  48849. */
  48850. axes: number[];
  48851. /**
  48852. * An array of available buttons
  48853. */
  48854. buttons: Array<{
  48855. /**
  48856. * Value of the button/trigger
  48857. */
  48858. value: number;
  48859. /**
  48860. * If the button/trigger is currently touched
  48861. */
  48862. touched: boolean;
  48863. /**
  48864. * If the button/trigger is currently pressed
  48865. */
  48866. pressed: boolean;
  48867. }>;
  48868. /**
  48869. * EXPERIMENTAL haptic support.
  48870. */
  48871. hapticActuators?: Array<{
  48872. pulse: (value: number, duration: number) => Promise<boolean>;
  48873. }>;
  48874. }
  48875. /**
  48876. * An Abstract Motion controller
  48877. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48878. * Each component has an observable to check for changes in value and state
  48879. */
  48880. export abstract class WebXRAbstractMotionController implements IDisposable {
  48881. protected scene: Scene;
  48882. protected layout: IMotionControllerLayout;
  48883. /**
  48884. * The gamepad object correlating to this controller
  48885. */
  48886. gamepadObject: IMinimalMotionControllerObject;
  48887. /**
  48888. * handedness (left/right/none) of this controller
  48889. */
  48890. handedness: MotionControllerHandedness;
  48891. private _initComponent;
  48892. private _modelReady;
  48893. /**
  48894. * A map of components (WebXRControllerComponent) in this motion controller
  48895. * Components have a ComponentType and can also have both button and axis definitions
  48896. */
  48897. readonly components: {
  48898. [id: string]: WebXRControllerComponent;
  48899. };
  48900. /**
  48901. * Disable the model's animation. Can be set at any time.
  48902. */
  48903. disableAnimation: boolean;
  48904. /**
  48905. * Observers registered here will be triggered when the model of this controller is done loading
  48906. */
  48907. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48908. /**
  48909. * The profile id of this motion controller
  48910. */
  48911. abstract profileId: string;
  48912. /**
  48913. * The root mesh of the model. It is null if the model was not yet initialized
  48914. */
  48915. rootMesh: Nullable<AbstractMesh>;
  48916. /**
  48917. * constructs a new abstract motion controller
  48918. * @param scene the scene to which the model of the controller will be added
  48919. * @param layout The profile layout to load
  48920. * @param gamepadObject The gamepad object correlating to this controller
  48921. * @param handedness handedness (left/right/none) of this controller
  48922. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48923. */
  48924. constructor(scene: Scene, layout: IMotionControllerLayout,
  48925. /**
  48926. * The gamepad object correlating to this controller
  48927. */
  48928. gamepadObject: IMinimalMotionControllerObject,
  48929. /**
  48930. * handedness (left/right/none) of this controller
  48931. */
  48932. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48933. /**
  48934. * Dispose this controller, the model mesh and all its components
  48935. */
  48936. dispose(): void;
  48937. /**
  48938. * Returns all components of specific type
  48939. * @param type the type to search for
  48940. * @return an array of components with this type
  48941. */
  48942. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48943. /**
  48944. * get a component based an its component id as defined in layout.components
  48945. * @param id the id of the component
  48946. * @returns the component correlates to the id or undefined if not found
  48947. */
  48948. getComponent(id: string): WebXRControllerComponent;
  48949. /**
  48950. * Get the list of components available in this motion controller
  48951. * @returns an array of strings correlating to available components
  48952. */
  48953. getComponentIds(): string[];
  48954. /**
  48955. * Get the first component of specific type
  48956. * @param type type of component to find
  48957. * @return a controller component or null if not found
  48958. */
  48959. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48960. /**
  48961. * Get the main (Select) component of this controller as defined in the layout
  48962. * @returns the main component of this controller
  48963. */
  48964. getMainComponent(): WebXRControllerComponent;
  48965. /**
  48966. * Loads the model correlating to this controller
  48967. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48968. * @returns A promise fulfilled with the result of the model loading
  48969. */
  48970. loadModel(): Promise<boolean>;
  48971. /**
  48972. * Update this model using the current XRFrame
  48973. * @param xrFrame the current xr frame to use and update the model
  48974. */
  48975. updateFromXRFrame(xrFrame: XRFrame): void;
  48976. /**
  48977. * Backwards compatibility due to a deeply-integrated typo
  48978. */
  48979. get handness(): XREye;
  48980. /**
  48981. * Pulse (vibrate) this controller
  48982. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48983. * Consecutive calls to this function will cancel the last pulse call
  48984. *
  48985. * @param value the strength of the pulse in 0.0...1.0 range
  48986. * @param duration Duration of the pulse in milliseconds
  48987. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48988. * @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
  48989. */
  48990. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48991. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48992. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48993. /**
  48994. * Moves the axis on the controller mesh based on its current state
  48995. * @param axis the index of the axis
  48996. * @param axisValue the value of the axis which determines the meshes new position
  48997. * @hidden
  48998. */
  48999. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49000. /**
  49001. * Update the model itself with the current frame data
  49002. * @param xrFrame the frame to use for updating the model mesh
  49003. */
  49004. protected updateModel(xrFrame: XRFrame): void;
  49005. /**
  49006. * Get the filename and path for this controller's model
  49007. * @returns a map of filename and path
  49008. */
  49009. protected abstract _getFilenameAndPath(): {
  49010. filename: string;
  49011. path: string;
  49012. };
  49013. /**
  49014. * This function is called before the mesh is loaded. It checks for loading constraints.
  49015. * For example, this function can check if the GLB loader is available
  49016. * If this function returns false, the generic controller will be loaded instead
  49017. * @returns Is the client ready to load the mesh
  49018. */
  49019. protected abstract _getModelLoadingConstraints(): boolean;
  49020. /**
  49021. * This function will be called after the model was successfully loaded and can be used
  49022. * for mesh transformations before it is available for the user
  49023. * @param meshes the loaded meshes
  49024. */
  49025. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49026. /**
  49027. * Set the root mesh for this controller. Important for the WebXR controller class
  49028. * @param meshes the loaded meshes
  49029. */
  49030. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49031. /**
  49032. * A function executed each frame that updates the mesh (if needed)
  49033. * @param xrFrame the current xrFrame
  49034. */
  49035. protected abstract _updateModel(xrFrame: XRFrame): void;
  49036. private _getGenericFilenameAndPath;
  49037. private _getGenericParentMesh;
  49038. }
  49039. }
  49040. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49041. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49043. import { Scene } from "babylonjs/scene";
  49044. /**
  49045. * A generic trigger-only motion controller for WebXR
  49046. */
  49047. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49048. /**
  49049. * Static version of the profile id of this controller
  49050. */
  49051. static ProfileId: string;
  49052. profileId: string;
  49053. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49054. protected _getFilenameAndPath(): {
  49055. filename: string;
  49056. path: string;
  49057. };
  49058. protected _getModelLoadingConstraints(): boolean;
  49059. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49060. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49061. protected _updateModel(): void;
  49062. }
  49063. }
  49064. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49065. import { Vector4 } from "babylonjs/Maths/math.vector";
  49066. import { Mesh } from "babylonjs/Meshes/mesh";
  49067. import { Scene } from "babylonjs/scene";
  49068. import { Nullable } from "babylonjs/types";
  49069. /**
  49070. * Class containing static functions to help procedurally build meshes
  49071. */
  49072. export class SphereBuilder {
  49073. /**
  49074. * Creates a sphere mesh
  49075. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49076. * * 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`)
  49077. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49078. * * 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
  49079. * * 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)
  49080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49083. * @param name defines the name of the mesh
  49084. * @param options defines the options used to create the mesh
  49085. * @param scene defines the hosting scene
  49086. * @returns the sphere mesh
  49087. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49088. */
  49089. static CreateSphere(name: string, options: {
  49090. segments?: number;
  49091. diameter?: number;
  49092. diameterX?: number;
  49093. diameterY?: number;
  49094. diameterZ?: number;
  49095. arc?: number;
  49096. slice?: number;
  49097. sideOrientation?: number;
  49098. frontUVs?: Vector4;
  49099. backUVs?: Vector4;
  49100. updatable?: boolean;
  49101. }, scene?: Nullable<Scene>): Mesh;
  49102. }
  49103. }
  49104. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49106. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49107. import { Scene } from "babylonjs/scene";
  49108. /**
  49109. * A profiled motion controller has its profile loaded from an online repository.
  49110. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49111. */
  49112. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49113. private _repositoryUrl;
  49114. private _buttonMeshMapping;
  49115. private _touchDots;
  49116. /**
  49117. * The profile ID of this controller. Will be populated when the controller initializes.
  49118. */
  49119. profileId: string;
  49120. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49121. dispose(): void;
  49122. protected _getFilenameAndPath(): {
  49123. filename: string;
  49124. path: string;
  49125. };
  49126. protected _getModelLoadingConstraints(): boolean;
  49127. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49128. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49129. protected _updateModel(_xrFrame: XRFrame): void;
  49130. }
  49131. }
  49132. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49133. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49134. import { Scene } from "babylonjs/scene";
  49135. /**
  49136. * A construction function type to create a new controller based on an xrInput object
  49137. */
  49138. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49139. /**
  49140. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49141. *
  49142. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49143. * it should be replaced with auto-loaded controllers.
  49144. *
  49145. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49146. */
  49147. export class WebXRMotionControllerManager {
  49148. private static _AvailableControllers;
  49149. private static _Fallbacks;
  49150. private static _ProfileLoadingPromises;
  49151. private static _ProfilesList;
  49152. /**
  49153. * The base URL of the online controller repository. Can be changed at any time.
  49154. */
  49155. static BaseRepositoryUrl: string;
  49156. /**
  49157. * Which repository gets priority - local or online
  49158. */
  49159. static PrioritizeOnlineRepository: boolean;
  49160. /**
  49161. * Use the online repository, or use only locally-defined controllers
  49162. */
  49163. static UseOnlineRepository: boolean;
  49164. /**
  49165. * Clear the cache used for profile loading and reload when requested again
  49166. */
  49167. static ClearProfilesCache(): void;
  49168. /**
  49169. * Register the default fallbacks.
  49170. * This function is called automatically when this file is imported.
  49171. */
  49172. static DefaultFallbacks(): void;
  49173. /**
  49174. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49175. * @param profileId the profile to which a fallback needs to be found
  49176. * @return an array with corresponding fallback profiles
  49177. */
  49178. static FindFallbackWithProfileId(profileId: string): string[];
  49179. /**
  49180. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49181. * The order of search:
  49182. *
  49183. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49184. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49185. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49186. * 4) return the generic trigger controller if none were found
  49187. *
  49188. * @param xrInput the xrInput to which a new controller is initialized
  49189. * @param scene the scene to which the model will be added
  49190. * @param forceProfile force a certain profile for this controller
  49191. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49192. */
  49193. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49194. /**
  49195. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49196. *
  49197. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49198. *
  49199. * @param type the profile type to register
  49200. * @param constructFunction the function to be called when loading this profile
  49201. */
  49202. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49203. /**
  49204. * Register a fallback to a specific profile.
  49205. * @param profileId the profileId that will receive the fallbacks
  49206. * @param fallbacks A list of fallback profiles
  49207. */
  49208. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49209. /**
  49210. * Will update the list of profiles available in the repository
  49211. * @return a promise that resolves to a map of profiles available online
  49212. */
  49213. static UpdateProfilesList(): Promise<{
  49214. [profile: string]: string;
  49215. }>;
  49216. private static _LoadProfileFromRepository;
  49217. private static _LoadProfilesFromAvailableControllers;
  49218. }
  49219. }
  49220. declare module "babylonjs/XR/webXRInputSource" {
  49221. import { Observable } from "babylonjs/Misc/observable";
  49222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49223. import { Ray } from "babylonjs/Culling/ray";
  49224. import { Scene } from "babylonjs/scene";
  49225. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49226. /**
  49227. * Configuration options for the WebXR controller creation
  49228. */
  49229. export interface IWebXRControllerOptions {
  49230. /**
  49231. * Should the controller mesh be animated when a user interacts with it
  49232. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49233. */
  49234. disableMotionControllerAnimation?: boolean;
  49235. /**
  49236. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49237. */
  49238. doNotLoadControllerMesh?: boolean;
  49239. /**
  49240. * Force a specific controller type for this controller.
  49241. * This can be used when creating your own profile or when testing different controllers
  49242. */
  49243. forceControllerProfile?: string;
  49244. /**
  49245. * Defines a rendering group ID for meshes that will be loaded.
  49246. * This is for the default controllers only.
  49247. */
  49248. renderingGroupId?: number;
  49249. }
  49250. /**
  49251. * Represents an XR controller
  49252. */
  49253. export class WebXRInputSource {
  49254. private _scene;
  49255. /** The underlying input source for the controller */
  49256. inputSource: XRInputSource;
  49257. private _options;
  49258. private _tmpVector;
  49259. private _uniqueId;
  49260. /**
  49261. * 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
  49262. */
  49263. grip?: AbstractMesh;
  49264. /**
  49265. * If available, this is the gamepad object related to this controller.
  49266. * Using this object it is possible to get click events and trackpad changes of the
  49267. * webxr controller that is currently being used.
  49268. */
  49269. motionController?: WebXRAbstractMotionController;
  49270. /**
  49271. * Event that fires when the controller is removed/disposed.
  49272. * The object provided as event data is this controller, after associated assets were disposed.
  49273. * uniqueId is still available.
  49274. */
  49275. onDisposeObservable: Observable<WebXRInputSource>;
  49276. /**
  49277. * Will be triggered when the mesh associated with the motion controller is done loading.
  49278. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49279. * A shortened version of controller -> motion controller -> on mesh loaded.
  49280. */
  49281. onMeshLoadedObservable: Observable<AbstractMesh>;
  49282. /**
  49283. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49284. */
  49285. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49286. /**
  49287. * Pointer which can be used to select objects or attach a visible laser to
  49288. */
  49289. pointer: AbstractMesh;
  49290. /**
  49291. * Creates the controller
  49292. * @see https://doc.babylonjs.com/how_to/webxr
  49293. * @param _scene the scene which the controller should be associated to
  49294. * @param inputSource the underlying input source for the controller
  49295. * @param _options options for this controller creation
  49296. */
  49297. constructor(_scene: Scene,
  49298. /** The underlying input source for the controller */
  49299. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49300. /**
  49301. * Get this controllers unique id
  49302. */
  49303. get uniqueId(): string;
  49304. /**
  49305. * Disposes of the object
  49306. */
  49307. dispose(): void;
  49308. /**
  49309. * Gets a world space ray coming from the pointer or grip
  49310. * @param result the resulting ray
  49311. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49312. */
  49313. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49314. /**
  49315. * Updates the controller pose based on the given XRFrame
  49316. * @param xrFrame xr frame to update the pose with
  49317. * @param referenceSpace reference space to use
  49318. */
  49319. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49320. }
  49321. }
  49322. declare module "babylonjs/XR/webXRInput" {
  49323. import { Observable } from "babylonjs/Misc/observable";
  49324. import { IDisposable } from "babylonjs/scene";
  49325. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49326. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49327. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49328. /**
  49329. * The schema for initialization options of the XR Input class
  49330. */
  49331. export interface IWebXRInputOptions {
  49332. /**
  49333. * If set to true no model will be automatically loaded
  49334. */
  49335. doNotLoadControllerMeshes?: boolean;
  49336. /**
  49337. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49338. * If not found, the xr input profile data will be used.
  49339. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49340. */
  49341. forceInputProfile?: string;
  49342. /**
  49343. * Do not send a request to the controller repository to load the profile.
  49344. *
  49345. * Instead, use the controllers available in babylon itself.
  49346. */
  49347. disableOnlineControllerRepository?: boolean;
  49348. /**
  49349. * A custom URL for the controllers repository
  49350. */
  49351. customControllersRepositoryURL?: string;
  49352. /**
  49353. * Should the controller model's components not move according to the user input
  49354. */
  49355. disableControllerAnimation?: boolean;
  49356. /**
  49357. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49358. */
  49359. controllerOptions?: IWebXRControllerOptions;
  49360. }
  49361. /**
  49362. * XR input used to track XR inputs such as controllers/rays
  49363. */
  49364. export class WebXRInput implements IDisposable {
  49365. /**
  49366. * the xr session manager for this session
  49367. */
  49368. xrSessionManager: WebXRSessionManager;
  49369. /**
  49370. * the WebXR camera for this session. Mainly used for teleportation
  49371. */
  49372. xrCamera: WebXRCamera;
  49373. private readonly options;
  49374. /**
  49375. * XR controllers being tracked
  49376. */
  49377. controllers: Array<WebXRInputSource>;
  49378. private _frameObserver;
  49379. private _sessionEndedObserver;
  49380. private _sessionInitObserver;
  49381. /**
  49382. * Event when a controller has been connected/added
  49383. */
  49384. onControllerAddedObservable: Observable<WebXRInputSource>;
  49385. /**
  49386. * Event when a controller has been removed/disconnected
  49387. */
  49388. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49389. /**
  49390. * Initializes the WebXRInput
  49391. * @param xrSessionManager the xr session manager for this session
  49392. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49393. * @param options = initialization options for this xr input
  49394. */
  49395. constructor(
  49396. /**
  49397. * the xr session manager for this session
  49398. */
  49399. xrSessionManager: WebXRSessionManager,
  49400. /**
  49401. * the WebXR camera for this session. Mainly used for teleportation
  49402. */
  49403. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49404. private _onInputSourcesChange;
  49405. private _addAndRemoveControllers;
  49406. /**
  49407. * Disposes of the object
  49408. */
  49409. dispose(): void;
  49410. }
  49411. }
  49412. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49413. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49414. import { Observable, EventState } from "babylonjs/Misc/observable";
  49415. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49416. /**
  49417. * This is the base class for all WebXR features.
  49418. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49419. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49420. */
  49421. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49422. protected _xrSessionManager: WebXRSessionManager;
  49423. private _attached;
  49424. private _removeOnDetach;
  49425. /**
  49426. * Should auto-attach be disabled?
  49427. */
  49428. disableAutoAttach: boolean;
  49429. /**
  49430. * Construct a new (abstract) WebXR feature
  49431. * @param _xrSessionManager the xr session manager for this feature
  49432. */
  49433. constructor(_xrSessionManager: WebXRSessionManager);
  49434. /**
  49435. * Is this feature attached
  49436. */
  49437. get attached(): boolean;
  49438. /**
  49439. * attach this feature
  49440. *
  49441. * @param force should attachment be forced (even when already attached)
  49442. * @returns true if successful, false is failed or already attached
  49443. */
  49444. attach(force?: boolean): boolean;
  49445. /**
  49446. * detach this feature.
  49447. *
  49448. * @returns true if successful, false if failed or already detached
  49449. */
  49450. detach(): boolean;
  49451. /**
  49452. * Dispose this feature and all of the resources attached
  49453. */
  49454. dispose(): void;
  49455. /**
  49456. * This is used to register callbacks that will automatically be removed when detach is called.
  49457. * @param observable the observable to which the observer will be attached
  49458. * @param callback the callback to register
  49459. */
  49460. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49461. /**
  49462. * Code in this function will be executed on each xrFrame received from the browser.
  49463. * This function will not execute after the feature is detached.
  49464. * @param _xrFrame the current frame
  49465. */
  49466. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49467. }
  49468. }
  49469. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49470. import { IDisposable, Scene } from "babylonjs/scene";
  49471. import { Nullable } from "babylonjs/types";
  49472. import { Observable } from "babylonjs/Misc/observable";
  49473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49474. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49475. import { Camera } from "babylonjs/Cameras/camera";
  49476. /**
  49477. * Renders a layer on top of an existing scene
  49478. */
  49479. export class UtilityLayerRenderer implements IDisposable {
  49480. /** the original scene that will be rendered on top of */
  49481. originalScene: Scene;
  49482. private _pointerCaptures;
  49483. private _lastPointerEvents;
  49484. private static _DefaultUtilityLayer;
  49485. private static _DefaultKeepDepthUtilityLayer;
  49486. private _sharedGizmoLight;
  49487. private _renderCamera;
  49488. /**
  49489. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49490. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49491. * @returns the camera that is used when rendering the utility layer
  49492. */
  49493. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49494. /**
  49495. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49496. * @param cam the camera that should be used when rendering the utility layer
  49497. */
  49498. setRenderCamera(cam: Nullable<Camera>): void;
  49499. /**
  49500. * @hidden
  49501. * Light which used by gizmos to get light shading
  49502. */
  49503. _getSharedGizmoLight(): HemisphericLight;
  49504. /**
  49505. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49506. */
  49507. pickUtilitySceneFirst: boolean;
  49508. /**
  49509. * 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)
  49510. */
  49511. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49512. /**
  49513. * 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)
  49514. */
  49515. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49516. /**
  49517. * The scene that is rendered on top of the original scene
  49518. */
  49519. utilityLayerScene: Scene;
  49520. /**
  49521. * If the utility layer should automatically be rendered on top of existing scene
  49522. */
  49523. shouldRender: boolean;
  49524. /**
  49525. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49526. */
  49527. onlyCheckPointerDownEvents: boolean;
  49528. /**
  49529. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49530. */
  49531. processAllEvents: boolean;
  49532. /**
  49533. * Observable raised when the pointer move from the utility layer scene to the main scene
  49534. */
  49535. onPointerOutObservable: Observable<number>;
  49536. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49537. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49538. private _afterRenderObserver;
  49539. private _sceneDisposeObserver;
  49540. private _originalPointerObserver;
  49541. /**
  49542. * Instantiates a UtilityLayerRenderer
  49543. * @param originalScene the original scene that will be rendered on top of
  49544. * @param handleEvents boolean indicating if the utility layer should handle events
  49545. */
  49546. constructor(
  49547. /** the original scene that will be rendered on top of */
  49548. originalScene: Scene, handleEvents?: boolean);
  49549. private _notifyObservers;
  49550. /**
  49551. * Renders the utility layers scene on top of the original scene
  49552. */
  49553. render(): void;
  49554. /**
  49555. * Disposes of the renderer
  49556. */
  49557. dispose(): void;
  49558. private _updateCamera;
  49559. }
  49560. }
  49561. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49562. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49564. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49565. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49566. import { Scene } from "babylonjs/scene";
  49567. import { Nullable } from "babylonjs/types";
  49568. import { Color3 } from "babylonjs/Maths/math.color";
  49569. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49570. /**
  49571. * Options interface for the pointer selection module
  49572. */
  49573. export interface IWebXRControllerPointerSelectionOptions {
  49574. /**
  49575. * if provided, this scene will be used to render meshes.
  49576. */
  49577. customUtilityLayerScene?: Scene;
  49578. /**
  49579. * 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)
  49580. * If not disabled, the last picked point will be used to execute a pointer up event
  49581. * If disabled, pointer up event will be triggered right after the pointer down event.
  49582. * Used in screen and gaze target ray mode only
  49583. */
  49584. disablePointerUpOnTouchOut: boolean;
  49585. /**
  49586. * For gaze mode (time to select instead of press)
  49587. */
  49588. forceGazeMode: boolean;
  49589. /**
  49590. * 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
  49591. * to start a new countdown to the pointer down event.
  49592. * Defaults to 1.
  49593. */
  49594. gazeModePointerMovedFactor?: number;
  49595. /**
  49596. * Different button type to use instead of the main component
  49597. */
  49598. overrideButtonId?: string;
  49599. /**
  49600. * use this rendering group id for the meshes (optional)
  49601. */
  49602. renderingGroupId?: number;
  49603. /**
  49604. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49605. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49606. * 3000 means 3 seconds between pointing at something and selecting it
  49607. */
  49608. timeToSelect?: number;
  49609. /**
  49610. * Should meshes created here be added to a utility layer or the main scene
  49611. */
  49612. useUtilityLayer?: boolean;
  49613. /**
  49614. * the xr input to use with this pointer selection
  49615. */
  49616. xrInput: WebXRInput;
  49617. }
  49618. /**
  49619. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49620. */
  49621. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49622. private readonly _options;
  49623. private static _idCounter;
  49624. private _attachController;
  49625. private _controllers;
  49626. private _scene;
  49627. private _tmpVectorForPickCompare;
  49628. /**
  49629. * The module's name
  49630. */
  49631. static readonly Name: string;
  49632. /**
  49633. * The (Babylon) version of this module.
  49634. * This is an integer representing the implementation version.
  49635. * This number does not correspond to the WebXR specs version
  49636. */
  49637. static readonly Version: number;
  49638. /**
  49639. * Disable lighting on the laser pointer (so it will always be visible)
  49640. */
  49641. disablePointerLighting: boolean;
  49642. /**
  49643. * Disable lighting on the selection mesh (so it will always be visible)
  49644. */
  49645. disableSelectionMeshLighting: boolean;
  49646. /**
  49647. * Should the laser pointer be displayed
  49648. */
  49649. displayLaserPointer: boolean;
  49650. /**
  49651. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49652. */
  49653. displaySelectionMesh: boolean;
  49654. /**
  49655. * This color will be set to the laser pointer when selection is triggered
  49656. */
  49657. laserPointerPickedColor: Color3;
  49658. /**
  49659. * Default color of the laser pointer
  49660. */
  49661. laserPointerDefaultColor: Color3;
  49662. /**
  49663. * default color of the selection ring
  49664. */
  49665. selectionMeshDefaultColor: Color3;
  49666. /**
  49667. * This color will be applied to the selection ring when selection is triggered
  49668. */
  49669. selectionMeshPickedColor: Color3;
  49670. /**
  49671. * Optional filter to be used for ray selection. This predicate shares behavior with
  49672. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49673. */
  49674. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49675. /**
  49676. * constructs a new background remover module
  49677. * @param _xrSessionManager the session manager for this module
  49678. * @param _options read-only options to be used in this module
  49679. */
  49680. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49681. /**
  49682. * attach this feature
  49683. * Will usually be called by the features manager
  49684. *
  49685. * @returns true if successful.
  49686. */
  49687. attach(): boolean;
  49688. /**
  49689. * detach this feature.
  49690. * Will usually be called by the features manager
  49691. *
  49692. * @returns true if successful.
  49693. */
  49694. detach(): boolean;
  49695. /**
  49696. * Will get the mesh under a specific pointer.
  49697. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49698. * @param controllerId the controllerId to check
  49699. * @returns The mesh under pointer or null if no mesh is under the pointer
  49700. */
  49701. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49702. /**
  49703. * Get the xr controller that correlates to the pointer id in the pointer event
  49704. *
  49705. * @param id the pointer id to search for
  49706. * @returns the controller that correlates to this id or null if not found
  49707. */
  49708. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49709. protected _onXRFrame(_xrFrame: XRFrame): void;
  49710. private _attachGazeMode;
  49711. private _attachScreenRayMode;
  49712. private _attachTrackedPointerRayMode;
  49713. private _convertNormalToDirectionOfRay;
  49714. private _detachController;
  49715. private _generateNewMeshPair;
  49716. private _pickingMoved;
  49717. private _updatePointerDistance;
  49718. /** @hidden */
  49719. get lasterPointerDefaultColor(): Color3;
  49720. }
  49721. }
  49722. declare module "babylonjs/XR/webXREnterExitUI" {
  49723. import { Nullable } from "babylonjs/types";
  49724. import { Observable } from "babylonjs/Misc/observable";
  49725. import { IDisposable, Scene } from "babylonjs/scene";
  49726. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49727. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49728. /**
  49729. * Button which can be used to enter a different mode of XR
  49730. */
  49731. export class WebXREnterExitUIButton {
  49732. /** button element */
  49733. element: HTMLElement;
  49734. /** XR initialization options for the button */
  49735. sessionMode: XRSessionMode;
  49736. /** Reference space type */
  49737. referenceSpaceType: XRReferenceSpaceType;
  49738. /**
  49739. * Creates a WebXREnterExitUIButton
  49740. * @param element button element
  49741. * @param sessionMode XR initialization session mode
  49742. * @param referenceSpaceType the type of reference space to be used
  49743. */
  49744. constructor(
  49745. /** button element */
  49746. element: HTMLElement,
  49747. /** XR initialization options for the button */
  49748. sessionMode: XRSessionMode,
  49749. /** Reference space type */
  49750. referenceSpaceType: XRReferenceSpaceType);
  49751. /**
  49752. * Extendable function which can be used to update the button's visuals when the state changes
  49753. * @param activeButton the current active button in the UI
  49754. */
  49755. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49756. }
  49757. /**
  49758. * Options to create the webXR UI
  49759. */
  49760. export class WebXREnterExitUIOptions {
  49761. /**
  49762. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49763. */
  49764. customButtons?: Array<WebXREnterExitUIButton>;
  49765. /**
  49766. * A reference space type to use when creating the default button.
  49767. * Default is local-floor
  49768. */
  49769. referenceSpaceType?: XRReferenceSpaceType;
  49770. /**
  49771. * Context to enter xr with
  49772. */
  49773. renderTarget?: Nullable<WebXRRenderTarget>;
  49774. /**
  49775. * A session mode to use when creating the default button.
  49776. * Default is immersive-vr
  49777. */
  49778. sessionMode?: XRSessionMode;
  49779. /**
  49780. * A list of optional features to init the session with
  49781. */
  49782. optionalFeatures?: string[];
  49783. }
  49784. /**
  49785. * UI to allow the user to enter/exit XR mode
  49786. */
  49787. export class WebXREnterExitUI implements IDisposable {
  49788. private scene;
  49789. /** version of the options passed to this UI */
  49790. options: WebXREnterExitUIOptions;
  49791. private _activeButton;
  49792. private _buttons;
  49793. private _overlay;
  49794. /**
  49795. * Fired every time the active button is changed.
  49796. *
  49797. * When xr is entered via a button that launches xr that button will be the callback parameter
  49798. *
  49799. * When exiting xr the callback parameter will be null)
  49800. */
  49801. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49802. /**
  49803. *
  49804. * @param scene babylon scene object to use
  49805. * @param options (read-only) version of the options passed to this UI
  49806. */
  49807. private constructor();
  49808. /**
  49809. * Creates UI to allow the user to enter/exit XR mode
  49810. * @param scene the scene to add the ui to
  49811. * @param helper the xr experience helper to enter/exit xr with
  49812. * @param options options to configure the UI
  49813. * @returns the created ui
  49814. */
  49815. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49816. /**
  49817. * Disposes of the XR UI component
  49818. */
  49819. dispose(): void;
  49820. private _updateButtons;
  49821. }
  49822. }
  49823. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49824. import { Vector3 } from "babylonjs/Maths/math.vector";
  49825. import { Color4 } from "babylonjs/Maths/math.color";
  49826. import { Nullable } from "babylonjs/types";
  49827. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49828. import { Scene } from "babylonjs/scene";
  49829. /**
  49830. * Class containing static functions to help procedurally build meshes
  49831. */
  49832. export class LinesBuilder {
  49833. /**
  49834. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49835. * * 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
  49836. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49837. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49838. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49839. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49840. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49841. * * 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
  49842. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49844. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49845. * @param name defines the name of the new line system
  49846. * @param options defines the options used to create the line system
  49847. * @param scene defines the hosting scene
  49848. * @returns a new line system mesh
  49849. */
  49850. static CreateLineSystem(name: string, options: {
  49851. lines: Vector3[][];
  49852. updatable?: boolean;
  49853. instance?: Nullable<LinesMesh>;
  49854. colors?: Nullable<Color4[][]>;
  49855. useVertexAlpha?: boolean;
  49856. }, scene: Nullable<Scene>): LinesMesh;
  49857. /**
  49858. * Creates a line mesh
  49859. * 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
  49860. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49861. * * The parameter `points` is an array successive Vector3
  49862. * * 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
  49863. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49864. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49865. * * When updating an instance, remember that only point positions can change, not the number of points
  49866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49868. * @param name defines the name of the new line system
  49869. * @param options defines the options used to create the line system
  49870. * @param scene defines the hosting scene
  49871. * @returns a new line mesh
  49872. */
  49873. static CreateLines(name: string, options: {
  49874. points: Vector3[];
  49875. updatable?: boolean;
  49876. instance?: Nullable<LinesMesh>;
  49877. colors?: Color4[];
  49878. useVertexAlpha?: boolean;
  49879. }, scene?: Nullable<Scene>): LinesMesh;
  49880. /**
  49881. * Creates a dashed line mesh
  49882. * * 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
  49883. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49884. * * The parameter `points` is an array successive Vector3
  49885. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49886. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49887. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49888. * * 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
  49889. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49890. * * When updating an instance, remember that only point positions can change, not the number of points
  49891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49892. * @param name defines the name of the mesh
  49893. * @param options defines the options used to create the mesh
  49894. * @param scene defines the hosting scene
  49895. * @returns the dashed line mesh
  49896. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49897. */
  49898. static CreateDashedLines(name: string, options: {
  49899. points: Vector3[];
  49900. dashSize?: number;
  49901. gapSize?: number;
  49902. dashNb?: number;
  49903. updatable?: boolean;
  49904. instance?: LinesMesh;
  49905. useVertexAlpha?: boolean;
  49906. }, scene?: Nullable<Scene>): LinesMesh;
  49907. }
  49908. }
  49909. declare module "babylonjs/Misc/timer" {
  49910. import { Observable, Observer } from "babylonjs/Misc/observable";
  49911. import { Nullable } from "babylonjs/types";
  49912. import { IDisposable } from "babylonjs/scene";
  49913. /**
  49914. * Construction options for a timer
  49915. */
  49916. export interface ITimerOptions<T> {
  49917. /**
  49918. * Time-to-end
  49919. */
  49920. timeout: number;
  49921. /**
  49922. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49923. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49924. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49925. */
  49926. contextObservable: Observable<T>;
  49927. /**
  49928. * Optional parameters when adding an observer to the observable
  49929. */
  49930. observableParameters?: {
  49931. mask?: number;
  49932. insertFirst?: boolean;
  49933. scope?: any;
  49934. };
  49935. /**
  49936. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49937. */
  49938. breakCondition?: (data?: ITimerData<T>) => boolean;
  49939. /**
  49940. * Will be triggered when the time condition has met
  49941. */
  49942. onEnded?: (data: ITimerData<any>) => void;
  49943. /**
  49944. * Will be triggered when the break condition has met (prematurely ended)
  49945. */
  49946. onAborted?: (data: ITimerData<any>) => void;
  49947. /**
  49948. * Optional function to execute on each tick (or count)
  49949. */
  49950. onTick?: (data: ITimerData<any>) => void;
  49951. }
  49952. /**
  49953. * An interface defining the data sent by the timer
  49954. */
  49955. export interface ITimerData<T> {
  49956. /**
  49957. * When did it start
  49958. */
  49959. startTime: number;
  49960. /**
  49961. * Time now
  49962. */
  49963. currentTime: number;
  49964. /**
  49965. * Time passed since started
  49966. */
  49967. deltaTime: number;
  49968. /**
  49969. * How much is completed, in [0.0...1.0].
  49970. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49971. */
  49972. completeRate: number;
  49973. /**
  49974. * What the registered observable sent in the last count
  49975. */
  49976. payload: T;
  49977. }
  49978. /**
  49979. * The current state of the timer
  49980. */
  49981. export enum TimerState {
  49982. /**
  49983. * Timer initialized, not yet started
  49984. */
  49985. INIT = 0,
  49986. /**
  49987. * Timer started and counting
  49988. */
  49989. STARTED = 1,
  49990. /**
  49991. * Timer ended (whether aborted or time reached)
  49992. */
  49993. ENDED = 2
  49994. }
  49995. /**
  49996. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49997. *
  49998. * @param options options with which to initialize this timer
  49999. */
  50000. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50001. /**
  50002. * An advanced implementation of a timer class
  50003. */
  50004. export class AdvancedTimer<T = any> implements IDisposable {
  50005. /**
  50006. * Will notify each time the timer calculates the remaining time
  50007. */
  50008. onEachCountObservable: Observable<ITimerData<T>>;
  50009. /**
  50010. * Will trigger when the timer was aborted due to the break condition
  50011. */
  50012. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50013. /**
  50014. * Will trigger when the timer ended successfully
  50015. */
  50016. onTimerEndedObservable: Observable<ITimerData<T>>;
  50017. /**
  50018. * Will trigger when the timer state has changed
  50019. */
  50020. onStateChangedObservable: Observable<TimerState>;
  50021. private _observer;
  50022. private _contextObservable;
  50023. private _observableParameters;
  50024. private _startTime;
  50025. private _timer;
  50026. private _state;
  50027. private _breakCondition;
  50028. private _timeToEnd;
  50029. private _breakOnNextTick;
  50030. /**
  50031. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50032. * @param options construction options for this advanced timer
  50033. */
  50034. constructor(options: ITimerOptions<T>);
  50035. /**
  50036. * set a breaking condition for this timer. Default is to never break during count
  50037. * @param predicate the new break condition. Returns true to break, false otherwise
  50038. */
  50039. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50040. /**
  50041. * Reset ALL associated observables in this advanced timer
  50042. */
  50043. clearObservables(): void;
  50044. /**
  50045. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50046. *
  50047. * @param timeToEnd how much time to measure until timer ended
  50048. */
  50049. start(timeToEnd?: number): void;
  50050. /**
  50051. * Will force a stop on the next tick.
  50052. */
  50053. stop(): void;
  50054. /**
  50055. * Dispose this timer, clearing all resources
  50056. */
  50057. dispose(): void;
  50058. private _setState;
  50059. private _tick;
  50060. private _stop;
  50061. }
  50062. }
  50063. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50064. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50065. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50066. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50068. import { Vector3 } from "babylonjs/Maths/math.vector";
  50069. import { Material } from "babylonjs/Materials/material";
  50070. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50071. import { Scene } from "babylonjs/scene";
  50072. /**
  50073. * The options container for the teleportation module
  50074. */
  50075. export interface IWebXRTeleportationOptions {
  50076. /**
  50077. * if provided, this scene will be used to render meshes.
  50078. */
  50079. customUtilityLayerScene?: Scene;
  50080. /**
  50081. * Values to configure the default target mesh
  50082. */
  50083. defaultTargetMeshOptions?: {
  50084. /**
  50085. * Fill color of the teleportation area
  50086. */
  50087. teleportationFillColor?: string;
  50088. /**
  50089. * Border color for the teleportation area
  50090. */
  50091. teleportationBorderColor?: string;
  50092. /**
  50093. * Disable the mesh's animation sequence
  50094. */
  50095. disableAnimation?: boolean;
  50096. /**
  50097. * Disable lighting on the material or the ring and arrow
  50098. */
  50099. disableLighting?: boolean;
  50100. /**
  50101. * Override the default material of the torus and arrow
  50102. */
  50103. torusArrowMaterial?: Material;
  50104. };
  50105. /**
  50106. * A list of meshes to use as floor meshes.
  50107. * Meshes can be added and removed after initializing the feature using the
  50108. * addFloorMesh and removeFloorMesh functions
  50109. * If empty, rotation will still work
  50110. */
  50111. floorMeshes?: AbstractMesh[];
  50112. /**
  50113. * use this rendering group id for the meshes (optional)
  50114. */
  50115. renderingGroupId?: number;
  50116. /**
  50117. * Should teleportation move only to snap points
  50118. */
  50119. snapPointsOnly?: boolean;
  50120. /**
  50121. * An array of points to which the teleportation will snap to.
  50122. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50123. */
  50124. snapPositions?: Vector3[];
  50125. /**
  50126. * How close should the teleportation ray be in order to snap to position.
  50127. * Default to 0.8 units (meters)
  50128. */
  50129. snapToPositionRadius?: number;
  50130. /**
  50131. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50132. * If you want to support rotation, make sure your mesh has a direction indicator.
  50133. *
  50134. * When left untouched, the default mesh will be initialized.
  50135. */
  50136. teleportationTargetMesh?: AbstractMesh;
  50137. /**
  50138. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50139. */
  50140. timeToTeleport?: number;
  50141. /**
  50142. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50143. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50144. */
  50145. useMainComponentOnly?: boolean;
  50146. /**
  50147. * Should meshes created here be added to a utility layer or the main scene
  50148. */
  50149. useUtilityLayer?: boolean;
  50150. /**
  50151. * Babylon XR Input class for controller
  50152. */
  50153. xrInput: WebXRInput;
  50154. }
  50155. /**
  50156. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50157. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50158. * the input of the attached controllers.
  50159. */
  50160. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50161. private _options;
  50162. private _controllers;
  50163. private _currentTeleportationControllerId;
  50164. private _floorMeshes;
  50165. private _quadraticBezierCurve;
  50166. private _selectionFeature;
  50167. private _snapToPositions;
  50168. private _snappedToPoint;
  50169. private _teleportationRingMaterial?;
  50170. private _tmpRay;
  50171. private _tmpVector;
  50172. /**
  50173. * The module's name
  50174. */
  50175. static readonly Name: string;
  50176. /**
  50177. * The (Babylon) version of this module.
  50178. * This is an integer representing the implementation version.
  50179. * This number does not correspond to the webxr specs version
  50180. */
  50181. static readonly Version: number;
  50182. /**
  50183. * Is movement backwards enabled
  50184. */
  50185. backwardsMovementEnabled: boolean;
  50186. /**
  50187. * Distance to travel when moving backwards
  50188. */
  50189. backwardsTeleportationDistance: number;
  50190. /**
  50191. * The distance from the user to the inspection point in the direction of the controller
  50192. * A higher number will allow the user to move further
  50193. * defaults to 5 (meters, in xr units)
  50194. */
  50195. parabolicCheckRadius: number;
  50196. /**
  50197. * Should the module support parabolic ray on top of direct ray
  50198. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50199. * Very helpful when moving between floors / different heights
  50200. */
  50201. parabolicRayEnabled: boolean;
  50202. /**
  50203. * How much rotation should be applied when rotating right and left
  50204. */
  50205. rotationAngle: number;
  50206. /**
  50207. * Is rotation enabled when moving forward?
  50208. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50209. */
  50210. rotationEnabled: boolean;
  50211. /**
  50212. * constructs a new anchor system
  50213. * @param _xrSessionManager an instance of WebXRSessionManager
  50214. * @param _options configuration object for this feature
  50215. */
  50216. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50217. /**
  50218. * Get the snapPointsOnly flag
  50219. */
  50220. get snapPointsOnly(): boolean;
  50221. /**
  50222. * Sets the snapPointsOnly flag
  50223. * @param snapToPoints should teleportation be exclusively to snap points
  50224. */
  50225. set snapPointsOnly(snapToPoints: boolean);
  50226. /**
  50227. * Add a new mesh to the floor meshes array
  50228. * @param mesh the mesh to use as floor mesh
  50229. */
  50230. addFloorMesh(mesh: AbstractMesh): void;
  50231. /**
  50232. * Add a new snap-to point to fix teleportation to this position
  50233. * @param newSnapPoint The new Snap-To point
  50234. */
  50235. addSnapPoint(newSnapPoint: Vector3): void;
  50236. attach(): boolean;
  50237. detach(): boolean;
  50238. dispose(): void;
  50239. /**
  50240. * Remove a mesh from the floor meshes array
  50241. * @param mesh the mesh to remove
  50242. */
  50243. removeFloorMesh(mesh: AbstractMesh): void;
  50244. /**
  50245. * Remove a mesh from the floor meshes array using its name
  50246. * @param name the mesh name to remove
  50247. */
  50248. removeFloorMeshByName(name: string): void;
  50249. /**
  50250. * 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
  50251. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50252. * @returns was the point found and removed or not
  50253. */
  50254. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50255. /**
  50256. * This function sets a selection feature that will be disabled when
  50257. * the forward ray is shown and will be reattached when hidden.
  50258. * This is used to remove the selection rays when moving.
  50259. * @param selectionFeature the feature to disable when forward movement is enabled
  50260. */
  50261. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50262. protected _onXRFrame(_xrFrame: XRFrame): void;
  50263. private _attachController;
  50264. private _createDefaultTargetMesh;
  50265. private _detachController;
  50266. private _findClosestSnapPointWithRadius;
  50267. private _setTargetMeshPosition;
  50268. private _setTargetMeshVisibility;
  50269. private _showParabolicPath;
  50270. private _teleportForward;
  50271. }
  50272. }
  50273. declare module "babylonjs/XR/webXRDefaultExperience" {
  50274. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50275. import { Scene } from "babylonjs/scene";
  50276. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50277. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50278. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50279. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50281. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50282. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50283. /**
  50284. * Options for the default xr helper
  50285. */
  50286. export class WebXRDefaultExperienceOptions {
  50287. /**
  50288. * Enable or disable default UI to enter XR
  50289. */
  50290. disableDefaultUI?: boolean;
  50291. /**
  50292. * Should teleportation not initialize. defaults to false.
  50293. */
  50294. disableTeleportation?: boolean;
  50295. /**
  50296. * Floor meshes that will be used for teleport
  50297. */
  50298. floorMeshes?: Array<AbstractMesh>;
  50299. /**
  50300. * If set to true, the first frame will not be used to reset position
  50301. * The first frame is mainly used when copying transformation from the old camera
  50302. * Mainly used in AR
  50303. */
  50304. ignoreNativeCameraTransformation?: boolean;
  50305. /**
  50306. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50307. */
  50308. inputOptions?: IWebXRInputOptions;
  50309. /**
  50310. * optional configuration for the output canvas
  50311. */
  50312. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50313. /**
  50314. * optional UI options. This can be used among other to change session mode and reference space type
  50315. */
  50316. uiOptions?: WebXREnterExitUIOptions;
  50317. /**
  50318. * When loading teleportation and pointer select, use stable versions instead of latest.
  50319. */
  50320. useStablePlugins?: boolean;
  50321. /**
  50322. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50323. */
  50324. renderingGroupId?: number;
  50325. /**
  50326. * A list of optional features to init the session with
  50327. * If set to true, all features we support will be added
  50328. */
  50329. optionalFeatures?: boolean | string[];
  50330. }
  50331. /**
  50332. * Default experience which provides a similar setup to the previous webVRExperience
  50333. */
  50334. export class WebXRDefaultExperience {
  50335. /**
  50336. * Base experience
  50337. */
  50338. baseExperience: WebXRExperienceHelper;
  50339. /**
  50340. * Enables ui for entering/exiting xr
  50341. */
  50342. enterExitUI: WebXREnterExitUI;
  50343. /**
  50344. * Input experience extension
  50345. */
  50346. input: WebXRInput;
  50347. /**
  50348. * Enables laser pointer and selection
  50349. */
  50350. pointerSelection: WebXRControllerPointerSelection;
  50351. /**
  50352. * Default target xr should render to
  50353. */
  50354. renderTarget: WebXRRenderTarget;
  50355. /**
  50356. * Enables teleportation
  50357. */
  50358. teleportation: WebXRMotionControllerTeleportation;
  50359. private constructor();
  50360. /**
  50361. * Creates the default xr experience
  50362. * @param scene scene
  50363. * @param options options for basic configuration
  50364. * @returns resulting WebXRDefaultExperience
  50365. */
  50366. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50367. /**
  50368. * DIsposes of the experience helper
  50369. */
  50370. dispose(): void;
  50371. }
  50372. }
  50373. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50374. import { Observable } from "babylonjs/Misc/observable";
  50375. import { Nullable } from "babylonjs/types";
  50376. import { Camera } from "babylonjs/Cameras/camera";
  50377. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50378. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50379. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50380. import { Scene } from "babylonjs/scene";
  50381. import { Vector3 } from "babylonjs/Maths/math.vector";
  50382. import { Color3 } from "babylonjs/Maths/math.color";
  50383. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50385. import { Mesh } from "babylonjs/Meshes/mesh";
  50386. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50387. import { EasingFunction } from "babylonjs/Animations/easing";
  50388. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50389. import "babylonjs/Meshes/Builders/groundBuilder";
  50390. import "babylonjs/Meshes/Builders/torusBuilder";
  50391. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50392. import "babylonjs/Gamepads/gamepadSceneComponent";
  50393. import "babylonjs/Animations/animatable";
  50394. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50395. /**
  50396. * Options to modify the vr teleportation behavior.
  50397. */
  50398. export interface VRTeleportationOptions {
  50399. /**
  50400. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50401. */
  50402. floorMeshName?: string;
  50403. /**
  50404. * A list of meshes to be used as the teleportation floor. (default: empty)
  50405. */
  50406. floorMeshes?: Mesh[];
  50407. /**
  50408. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50409. */
  50410. teleportationMode?: number;
  50411. /**
  50412. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50413. */
  50414. teleportationTime?: number;
  50415. /**
  50416. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50417. */
  50418. teleportationSpeed?: number;
  50419. /**
  50420. * The easing function used in the animation or null for Linear. (default CircleEase)
  50421. */
  50422. easingFunction?: EasingFunction;
  50423. }
  50424. /**
  50425. * Options to modify the vr experience helper's behavior.
  50426. */
  50427. export interface VRExperienceHelperOptions extends WebVROptions {
  50428. /**
  50429. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50430. */
  50431. createDeviceOrientationCamera?: boolean;
  50432. /**
  50433. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50434. */
  50435. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50436. /**
  50437. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50438. */
  50439. laserToggle?: boolean;
  50440. /**
  50441. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50442. */
  50443. floorMeshes?: Mesh[];
  50444. /**
  50445. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50446. */
  50447. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50448. /**
  50449. * Defines if WebXR should be used instead of WebVR (if available)
  50450. */
  50451. useXR?: boolean;
  50452. }
  50453. /**
  50454. * Event containing information after VR has been entered
  50455. */
  50456. export class OnAfterEnteringVRObservableEvent {
  50457. /**
  50458. * If entering vr was successful
  50459. */
  50460. success: boolean;
  50461. }
  50462. /**
  50463. * Helps to quickly add VR support to an existing scene.
  50464. * See http://doc.babylonjs.com/how_to/webvr_helper
  50465. */
  50466. export class VRExperienceHelper {
  50467. /** Options to modify the vr experience helper's behavior. */
  50468. webVROptions: VRExperienceHelperOptions;
  50469. private _scene;
  50470. private _position;
  50471. private _btnVR;
  50472. private _btnVRDisplayed;
  50473. private _webVRsupported;
  50474. private _webVRready;
  50475. private _webVRrequesting;
  50476. private _webVRpresenting;
  50477. private _hasEnteredVR;
  50478. private _fullscreenVRpresenting;
  50479. private _inputElement;
  50480. private _webVRCamera;
  50481. private _vrDeviceOrientationCamera;
  50482. private _deviceOrientationCamera;
  50483. private _existingCamera;
  50484. private _onKeyDown;
  50485. private _onVrDisplayPresentChange;
  50486. private _onVRDisplayChanged;
  50487. private _onVRRequestPresentStart;
  50488. private _onVRRequestPresentComplete;
  50489. /**
  50490. * 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)
  50491. */
  50492. enableGazeEvenWhenNoPointerLock: boolean;
  50493. /**
  50494. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50495. */
  50496. exitVROnDoubleTap: boolean;
  50497. /**
  50498. * Observable raised right before entering VR.
  50499. */
  50500. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50501. /**
  50502. * Observable raised when entering VR has completed.
  50503. */
  50504. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50505. /**
  50506. * Observable raised when exiting VR.
  50507. */
  50508. onExitingVRObservable: Observable<VRExperienceHelper>;
  50509. /**
  50510. * Observable raised when controller mesh is loaded.
  50511. */
  50512. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50513. /** Return this.onEnteringVRObservable
  50514. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50515. */
  50516. get onEnteringVR(): Observable<VRExperienceHelper>;
  50517. /** Return this.onExitingVRObservable
  50518. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50519. */
  50520. get onExitingVR(): Observable<VRExperienceHelper>;
  50521. /** Return this.onControllerMeshLoadedObservable
  50522. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50523. */
  50524. get onControllerMeshLoaded(): Observable<WebVRController>;
  50525. private _rayLength;
  50526. private _useCustomVRButton;
  50527. private _teleportationRequested;
  50528. private _teleportActive;
  50529. private _floorMeshName;
  50530. private _floorMeshesCollection;
  50531. private _teleportationMode;
  50532. private _teleportationTime;
  50533. private _teleportationSpeed;
  50534. private _teleportationEasing;
  50535. private _rotationAllowed;
  50536. private _teleportBackwardsVector;
  50537. private _teleportationTarget;
  50538. private _isDefaultTeleportationTarget;
  50539. private _postProcessMove;
  50540. private _teleportationFillColor;
  50541. private _teleportationBorderColor;
  50542. private _rotationAngle;
  50543. private _haloCenter;
  50544. private _cameraGazer;
  50545. private _padSensibilityUp;
  50546. private _padSensibilityDown;
  50547. private _leftController;
  50548. private _rightController;
  50549. private _gazeColor;
  50550. private _laserColor;
  50551. private _pickedLaserColor;
  50552. private _pickedGazeColor;
  50553. /**
  50554. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50555. */
  50556. onNewMeshSelected: Observable<AbstractMesh>;
  50557. /**
  50558. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50559. * This observable will provide the mesh and the controller used to select the mesh
  50560. */
  50561. onMeshSelectedWithController: Observable<{
  50562. mesh: AbstractMesh;
  50563. controller: WebVRController;
  50564. }>;
  50565. /**
  50566. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50567. */
  50568. onNewMeshPicked: Observable<PickingInfo>;
  50569. private _circleEase;
  50570. /**
  50571. * Observable raised before camera teleportation
  50572. */
  50573. onBeforeCameraTeleport: Observable<Vector3>;
  50574. /**
  50575. * Observable raised after camera teleportation
  50576. */
  50577. onAfterCameraTeleport: Observable<Vector3>;
  50578. /**
  50579. * Observable raised when current selected mesh gets unselected
  50580. */
  50581. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50582. private _raySelectionPredicate;
  50583. /**
  50584. * To be optionaly changed by user to define custom ray selection
  50585. */
  50586. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50587. /**
  50588. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50589. */
  50590. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50591. /**
  50592. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50593. */
  50594. teleportationEnabled: boolean;
  50595. private _defaultHeight;
  50596. private _teleportationInitialized;
  50597. private _interactionsEnabled;
  50598. private _interactionsRequested;
  50599. private _displayGaze;
  50600. private _displayLaserPointer;
  50601. /**
  50602. * The mesh used to display where the user is going to teleport.
  50603. */
  50604. get teleportationTarget(): Mesh;
  50605. /**
  50606. * Sets the mesh to be used to display where the user is going to teleport.
  50607. */
  50608. set teleportationTarget(value: Mesh);
  50609. /**
  50610. * 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
  50611. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50612. * See http://doc.babylonjs.com/resources/baking_transformations
  50613. */
  50614. get gazeTrackerMesh(): Mesh;
  50615. set gazeTrackerMesh(value: Mesh);
  50616. /**
  50617. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50618. */
  50619. updateGazeTrackerScale: boolean;
  50620. /**
  50621. * If the gaze trackers color should be updated when selecting meshes
  50622. */
  50623. updateGazeTrackerColor: boolean;
  50624. /**
  50625. * If the controller laser color should be updated when selecting meshes
  50626. */
  50627. updateControllerLaserColor: boolean;
  50628. /**
  50629. * The gaze tracking mesh corresponding to the left controller
  50630. */
  50631. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50632. /**
  50633. * The gaze tracking mesh corresponding to the right controller
  50634. */
  50635. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50636. /**
  50637. * If the ray of the gaze should be displayed.
  50638. */
  50639. get displayGaze(): boolean;
  50640. /**
  50641. * Sets if the ray of the gaze should be displayed.
  50642. */
  50643. set displayGaze(value: boolean);
  50644. /**
  50645. * If the ray of the LaserPointer should be displayed.
  50646. */
  50647. get displayLaserPointer(): boolean;
  50648. /**
  50649. * Sets if the ray of the LaserPointer should be displayed.
  50650. */
  50651. set displayLaserPointer(value: boolean);
  50652. /**
  50653. * The deviceOrientationCamera used as the camera when not in VR.
  50654. */
  50655. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50656. /**
  50657. * Based on the current WebVR support, returns the current VR camera used.
  50658. */
  50659. get currentVRCamera(): Nullable<Camera>;
  50660. /**
  50661. * The webVRCamera which is used when in VR.
  50662. */
  50663. get webVRCamera(): WebVRFreeCamera;
  50664. /**
  50665. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50666. */
  50667. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50668. /**
  50669. * The html button that is used to trigger entering into VR.
  50670. */
  50671. get vrButton(): Nullable<HTMLButtonElement>;
  50672. private get _teleportationRequestInitiated();
  50673. /**
  50674. * Defines whether or not Pointer lock should be requested when switching to
  50675. * full screen.
  50676. */
  50677. requestPointerLockOnFullScreen: boolean;
  50678. /**
  50679. * If asking to force XR, this will be populated with the default xr experience
  50680. */
  50681. xr: WebXRDefaultExperience;
  50682. /**
  50683. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50684. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50685. */
  50686. xrTestDone: boolean;
  50687. /**
  50688. * Instantiates a VRExperienceHelper.
  50689. * Helps to quickly add VR support to an existing scene.
  50690. * @param scene The scene the VRExperienceHelper belongs to.
  50691. * @param webVROptions Options to modify the vr experience helper's behavior.
  50692. */
  50693. constructor(scene: Scene,
  50694. /** Options to modify the vr experience helper's behavior. */
  50695. webVROptions?: VRExperienceHelperOptions);
  50696. private completeVRInit;
  50697. private _onDefaultMeshLoaded;
  50698. private _onResize;
  50699. private _onFullscreenChange;
  50700. /**
  50701. * Gets a value indicating if we are currently in VR mode.
  50702. */
  50703. get isInVRMode(): boolean;
  50704. private onVrDisplayPresentChange;
  50705. private onVRDisplayChanged;
  50706. private moveButtonToBottomRight;
  50707. private displayVRButton;
  50708. private updateButtonVisibility;
  50709. private _cachedAngularSensibility;
  50710. /**
  50711. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50712. * Otherwise, will use the fullscreen API.
  50713. */
  50714. enterVR(): void;
  50715. /**
  50716. * Attempt to exit VR, or fullscreen.
  50717. */
  50718. exitVR(): void;
  50719. /**
  50720. * The position of the vr experience helper.
  50721. */
  50722. get position(): Vector3;
  50723. /**
  50724. * Sets the position of the vr experience helper.
  50725. */
  50726. set position(value: Vector3);
  50727. /**
  50728. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50729. */
  50730. enableInteractions(): void;
  50731. private get _noControllerIsActive();
  50732. private beforeRender;
  50733. private _isTeleportationFloor;
  50734. /**
  50735. * Adds a floor mesh to be used for teleportation.
  50736. * @param floorMesh the mesh to be used for teleportation.
  50737. */
  50738. addFloorMesh(floorMesh: Mesh): void;
  50739. /**
  50740. * Removes a floor mesh from being used for teleportation.
  50741. * @param floorMesh the mesh to be removed.
  50742. */
  50743. removeFloorMesh(floorMesh: Mesh): void;
  50744. /**
  50745. * Enables interactions and teleportation using the VR controllers and gaze.
  50746. * @param vrTeleportationOptions options to modify teleportation behavior.
  50747. */
  50748. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50749. private _onNewGamepadConnected;
  50750. private _tryEnableInteractionOnController;
  50751. private _onNewGamepadDisconnected;
  50752. private _enableInteractionOnController;
  50753. private _checkTeleportWithRay;
  50754. private _checkRotate;
  50755. private _checkTeleportBackwards;
  50756. private _enableTeleportationOnController;
  50757. private _createTeleportationCircles;
  50758. private _displayTeleportationTarget;
  50759. private _hideTeleportationTarget;
  50760. private _rotateCamera;
  50761. private _moveTeleportationSelectorTo;
  50762. private _workingVector;
  50763. private _workingQuaternion;
  50764. private _workingMatrix;
  50765. /**
  50766. * Time Constant Teleportation Mode
  50767. */
  50768. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50769. /**
  50770. * Speed Constant Teleportation Mode
  50771. */
  50772. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50773. /**
  50774. * Teleports the users feet to the desired location
  50775. * @param location The location where the user's feet should be placed
  50776. */
  50777. teleportCamera(location: Vector3): void;
  50778. private _convertNormalToDirectionOfRay;
  50779. private _castRayAndSelectObject;
  50780. private _notifySelectedMeshUnselected;
  50781. /**
  50782. * Permanently set new colors for the laser pointer
  50783. * @param color the new laser color
  50784. * @param pickedColor the new laser color when picked mesh detected
  50785. */
  50786. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50787. /**
  50788. * Set lighting enabled / disabled on the laser pointer of both controllers
  50789. * @param enabled should the lighting be enabled on the laser pointer
  50790. */
  50791. setLaserLightingState(enabled?: boolean): void;
  50792. /**
  50793. * Permanently set new colors for the gaze pointer
  50794. * @param color the new gaze color
  50795. * @param pickedColor the new gaze color when picked mesh detected
  50796. */
  50797. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50798. /**
  50799. * Sets the color of the laser ray from the vr controllers.
  50800. * @param color new color for the ray.
  50801. */
  50802. changeLaserColor(color: Color3): void;
  50803. /**
  50804. * Sets the color of the ray from the vr headsets gaze.
  50805. * @param color new color for the ray.
  50806. */
  50807. changeGazeColor(color: Color3): void;
  50808. /**
  50809. * Exits VR and disposes of the vr experience helper
  50810. */
  50811. dispose(): void;
  50812. /**
  50813. * Gets the name of the VRExperienceHelper class
  50814. * @returns "VRExperienceHelper"
  50815. */
  50816. getClassName(): string;
  50817. }
  50818. }
  50819. declare module "babylonjs/Cameras/VR/index" {
  50820. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50821. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50822. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50823. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50824. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50825. export * from "babylonjs/Cameras/VR/webVRCamera";
  50826. }
  50827. declare module "babylonjs/Cameras/RigModes/index" {
  50828. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50829. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50830. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50831. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50832. }
  50833. declare module "babylonjs/Cameras/index" {
  50834. export * from "babylonjs/Cameras/Inputs/index";
  50835. export * from "babylonjs/Cameras/cameraInputsManager";
  50836. export * from "babylonjs/Cameras/camera";
  50837. export * from "babylonjs/Cameras/targetCamera";
  50838. export * from "babylonjs/Cameras/freeCamera";
  50839. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50840. export * from "babylonjs/Cameras/touchCamera";
  50841. export * from "babylonjs/Cameras/arcRotateCamera";
  50842. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50843. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50844. export * from "babylonjs/Cameras/flyCamera";
  50845. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50846. export * from "babylonjs/Cameras/followCamera";
  50847. export * from "babylonjs/Cameras/followCameraInputsManager";
  50848. export * from "babylonjs/Cameras/gamepadCamera";
  50849. export * from "babylonjs/Cameras/Stereoscopic/index";
  50850. export * from "babylonjs/Cameras/universalCamera";
  50851. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50852. export * from "babylonjs/Cameras/VR/index";
  50853. export * from "babylonjs/Cameras/RigModes/index";
  50854. }
  50855. declare module "babylonjs/Collisions/index" {
  50856. export * from "babylonjs/Collisions/collider";
  50857. export * from "babylonjs/Collisions/collisionCoordinator";
  50858. export * from "babylonjs/Collisions/pickingInfo";
  50859. export * from "babylonjs/Collisions/intersectionInfo";
  50860. export * from "babylonjs/Collisions/meshCollisionData";
  50861. }
  50862. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50863. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50864. import { Vector3 } from "babylonjs/Maths/math.vector";
  50865. import { Ray } from "babylonjs/Culling/ray";
  50866. import { Plane } from "babylonjs/Maths/math.plane";
  50867. /**
  50868. * Contains an array of blocks representing the octree
  50869. */
  50870. export interface IOctreeContainer<T> {
  50871. /**
  50872. * Blocks within the octree
  50873. */
  50874. blocks: Array<OctreeBlock<T>>;
  50875. }
  50876. /**
  50877. * Class used to store a cell in an octree
  50878. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50879. */
  50880. export class OctreeBlock<T> {
  50881. /**
  50882. * Gets the content of the current block
  50883. */
  50884. entries: T[];
  50885. /**
  50886. * Gets the list of block children
  50887. */
  50888. blocks: Array<OctreeBlock<T>>;
  50889. private _depth;
  50890. private _maxDepth;
  50891. private _capacity;
  50892. private _minPoint;
  50893. private _maxPoint;
  50894. private _boundingVectors;
  50895. private _creationFunc;
  50896. /**
  50897. * Creates a new block
  50898. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50899. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50900. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50901. * @param depth defines the current depth of this block in the octree
  50902. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50903. * @param creationFunc defines a callback to call when an element is added to the block
  50904. */
  50905. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50906. /**
  50907. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50908. */
  50909. get capacity(): number;
  50910. /**
  50911. * Gets the minimum vector (in world space) of the block's bounding box
  50912. */
  50913. get minPoint(): Vector3;
  50914. /**
  50915. * Gets the maximum vector (in world space) of the block's bounding box
  50916. */
  50917. get maxPoint(): Vector3;
  50918. /**
  50919. * Add a new element to this block
  50920. * @param entry defines the element to add
  50921. */
  50922. addEntry(entry: T): void;
  50923. /**
  50924. * Remove an element from this block
  50925. * @param entry defines the element to remove
  50926. */
  50927. removeEntry(entry: T): void;
  50928. /**
  50929. * Add an array of elements to this block
  50930. * @param entries defines the array of elements to add
  50931. */
  50932. addEntries(entries: T[]): void;
  50933. /**
  50934. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50935. * @param frustumPlanes defines the frustum planes to test
  50936. * @param selection defines the array to store current content if selection is positive
  50937. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50938. */
  50939. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50940. /**
  50941. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50942. * @param sphereCenter defines the bounding sphere center
  50943. * @param sphereRadius defines the bounding sphere radius
  50944. * @param selection defines the array to store current content if selection is positive
  50945. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50946. */
  50947. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50948. /**
  50949. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50950. * @param ray defines the ray to test with
  50951. * @param selection defines the array to store current content if selection is positive
  50952. */
  50953. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50954. /**
  50955. * Subdivide the content into child blocks (this block will then be empty)
  50956. */
  50957. createInnerBlocks(): void;
  50958. /**
  50959. * @hidden
  50960. */
  50961. 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;
  50962. }
  50963. }
  50964. declare module "babylonjs/Culling/Octrees/octree" {
  50965. import { SmartArray } from "babylonjs/Misc/smartArray";
  50966. import { Vector3 } from "babylonjs/Maths/math.vector";
  50967. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50969. import { Ray } from "babylonjs/Culling/ray";
  50970. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  50971. import { Plane } from "babylonjs/Maths/math.plane";
  50972. /**
  50973. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50974. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50975. */
  50976. export class Octree<T> {
  50977. /** 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.) */
  50978. maxDepth: number;
  50979. /**
  50980. * Blocks within the octree containing objects
  50981. */
  50982. blocks: Array<OctreeBlock<T>>;
  50983. /**
  50984. * Content stored in the octree
  50985. */
  50986. dynamicContent: T[];
  50987. private _maxBlockCapacity;
  50988. private _selectionContent;
  50989. private _creationFunc;
  50990. /**
  50991. * Creates a octree
  50992. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50993. * @param creationFunc function to be used to instatiate the octree
  50994. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50995. * @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.)
  50996. */
  50997. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50998. /** 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.) */
  50999. maxDepth?: number);
  51000. /**
  51001. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51002. * @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);
  51003. * @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);
  51004. * @param entries meshes to be added to the octree blocks
  51005. */
  51006. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51007. /**
  51008. * Adds a mesh to the octree
  51009. * @param entry Mesh to add to the octree
  51010. */
  51011. addMesh(entry: T): void;
  51012. /**
  51013. * Remove an element from the octree
  51014. * @param entry defines the element to remove
  51015. */
  51016. removeMesh(entry: T): void;
  51017. /**
  51018. * Selects an array of meshes within the frustum
  51019. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51020. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51021. * @returns array of meshes within the frustum
  51022. */
  51023. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51024. /**
  51025. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51026. * @param sphereCenter defines the bounding sphere center
  51027. * @param sphereRadius defines the bounding sphere radius
  51028. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51029. * @returns an array of objects that intersect the sphere
  51030. */
  51031. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51032. /**
  51033. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51034. * @param ray defines the ray to test with
  51035. * @returns array of intersected objects
  51036. */
  51037. intersectsRay(ray: Ray): SmartArray<T>;
  51038. /**
  51039. * Adds a mesh into the octree block if it intersects the block
  51040. */
  51041. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51042. /**
  51043. * Adds a submesh into the octree block if it intersects the block
  51044. */
  51045. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51046. }
  51047. }
  51048. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51049. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51050. import { Scene } from "babylonjs/scene";
  51051. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51053. import { Ray } from "babylonjs/Culling/ray";
  51054. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51055. import { Collider } from "babylonjs/Collisions/collider";
  51056. module "babylonjs/scene" {
  51057. interface Scene {
  51058. /**
  51059. * @hidden
  51060. * Backing Filed
  51061. */
  51062. _selectionOctree: Octree<AbstractMesh>;
  51063. /**
  51064. * Gets the octree used to boost mesh selection (picking)
  51065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51066. */
  51067. selectionOctree: Octree<AbstractMesh>;
  51068. /**
  51069. * Creates or updates the octree used to boost selection (picking)
  51070. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51071. * @param maxCapacity defines the maximum capacity per leaf
  51072. * @param maxDepth defines the maximum depth of the octree
  51073. * @returns an octree of AbstractMesh
  51074. */
  51075. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51076. }
  51077. }
  51078. module "babylonjs/Meshes/abstractMesh" {
  51079. interface AbstractMesh {
  51080. /**
  51081. * @hidden
  51082. * Backing Field
  51083. */
  51084. _submeshesOctree: Octree<SubMesh>;
  51085. /**
  51086. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51087. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51088. * @param maxCapacity defines the maximum size of each block (64 by default)
  51089. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51090. * @returns the new octree
  51091. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51092. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51093. */
  51094. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51095. }
  51096. }
  51097. /**
  51098. * Defines the octree scene component responsible to manage any octrees
  51099. * in a given scene.
  51100. */
  51101. export class OctreeSceneComponent {
  51102. /**
  51103. * The component name help to identify the component in the list of scene components.
  51104. */
  51105. readonly name: string;
  51106. /**
  51107. * The scene the component belongs to.
  51108. */
  51109. scene: Scene;
  51110. /**
  51111. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51112. */
  51113. readonly checksIsEnabled: boolean;
  51114. /**
  51115. * Creates a new instance of the component for the given scene
  51116. * @param scene Defines the scene to register the component in
  51117. */
  51118. constructor(scene: Scene);
  51119. /**
  51120. * Registers the component in a given scene
  51121. */
  51122. register(): void;
  51123. /**
  51124. * Return the list of active meshes
  51125. * @returns the list of active meshes
  51126. */
  51127. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51128. /**
  51129. * Return the list of active sub meshes
  51130. * @param mesh The mesh to get the candidates sub meshes from
  51131. * @returns the list of active sub meshes
  51132. */
  51133. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51134. private _tempRay;
  51135. /**
  51136. * Return the list of sub meshes intersecting with a given local ray
  51137. * @param mesh defines the mesh to find the submesh for
  51138. * @param localRay defines the ray in local space
  51139. * @returns the list of intersecting sub meshes
  51140. */
  51141. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51142. /**
  51143. * Return the list of sub meshes colliding with a collider
  51144. * @param mesh defines the mesh to find the submesh for
  51145. * @param collider defines the collider to evaluate the collision against
  51146. * @returns the list of colliding sub meshes
  51147. */
  51148. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51149. /**
  51150. * Rebuilds the elements related to this component in case of
  51151. * context lost for instance.
  51152. */
  51153. rebuild(): void;
  51154. /**
  51155. * Disposes the component and the associated ressources.
  51156. */
  51157. dispose(): void;
  51158. }
  51159. }
  51160. declare module "babylonjs/Culling/Octrees/index" {
  51161. export * from "babylonjs/Culling/Octrees/octree";
  51162. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51163. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51164. }
  51165. declare module "babylonjs/Culling/index" {
  51166. export * from "babylonjs/Culling/boundingBox";
  51167. export * from "babylonjs/Culling/boundingInfo";
  51168. export * from "babylonjs/Culling/boundingSphere";
  51169. export * from "babylonjs/Culling/Octrees/index";
  51170. export * from "babylonjs/Culling/ray";
  51171. }
  51172. declare module "babylonjs/Gizmos/gizmo" {
  51173. import { Nullable } from "babylonjs/types";
  51174. import { IDisposable } from "babylonjs/scene";
  51175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51176. import { Mesh } from "babylonjs/Meshes/mesh";
  51177. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51178. /**
  51179. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51180. */
  51181. export class Gizmo implements IDisposable {
  51182. /** The utility layer the gizmo will be added to */
  51183. gizmoLayer: UtilityLayerRenderer;
  51184. /**
  51185. * The root mesh of the gizmo
  51186. */
  51187. _rootMesh: Mesh;
  51188. private _attachedMesh;
  51189. /**
  51190. * Ratio for the scale of the gizmo (Default: 1)
  51191. */
  51192. scaleRatio: number;
  51193. /**
  51194. * If a custom mesh has been set (Default: false)
  51195. */
  51196. protected _customMeshSet: boolean;
  51197. /**
  51198. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51199. * * When set, interactions will be enabled
  51200. */
  51201. get attachedMesh(): Nullable<AbstractMesh>;
  51202. set attachedMesh(value: Nullable<AbstractMesh>);
  51203. /**
  51204. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51205. * @param mesh The mesh to replace the default mesh of the gizmo
  51206. */
  51207. setCustomMesh(mesh: Mesh): void;
  51208. /**
  51209. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51210. */
  51211. updateGizmoRotationToMatchAttachedMesh: boolean;
  51212. /**
  51213. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51214. */
  51215. updateGizmoPositionToMatchAttachedMesh: boolean;
  51216. /**
  51217. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51218. */
  51219. updateScale: boolean;
  51220. protected _interactionsEnabled: boolean;
  51221. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51222. private _beforeRenderObserver;
  51223. private _tempVector;
  51224. /**
  51225. * Creates a gizmo
  51226. * @param gizmoLayer The utility layer the gizmo will be added to
  51227. */
  51228. constructor(
  51229. /** The utility layer the gizmo will be added to */
  51230. gizmoLayer?: UtilityLayerRenderer);
  51231. /**
  51232. * Updates the gizmo to match the attached mesh's position/rotation
  51233. */
  51234. protected _update(): void;
  51235. /**
  51236. * Disposes of the gizmo
  51237. */
  51238. dispose(): void;
  51239. }
  51240. }
  51241. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51242. import { Observable } from "babylonjs/Misc/observable";
  51243. import { Nullable } from "babylonjs/types";
  51244. import { Vector3 } from "babylonjs/Maths/math.vector";
  51245. import { Color3 } from "babylonjs/Maths/math.color";
  51246. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51248. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51249. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51250. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51251. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51252. import { Scene } from "babylonjs/scene";
  51253. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51254. /**
  51255. * Single plane drag gizmo
  51256. */
  51257. export class PlaneDragGizmo extends Gizmo {
  51258. /**
  51259. * Drag behavior responsible for the gizmos dragging interactions
  51260. */
  51261. dragBehavior: PointerDragBehavior;
  51262. private _pointerObserver;
  51263. /**
  51264. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51265. */
  51266. snapDistance: number;
  51267. /**
  51268. * Event that fires each time the gizmo snaps to a new location.
  51269. * * snapDistance is the the change in distance
  51270. */
  51271. onSnapObservable: Observable<{
  51272. snapDistance: number;
  51273. }>;
  51274. private _plane;
  51275. private _coloredMaterial;
  51276. private _hoverMaterial;
  51277. private _isEnabled;
  51278. private _parent;
  51279. /** @hidden */
  51280. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51281. /** @hidden */
  51282. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51283. /**
  51284. * Creates a PlaneDragGizmo
  51285. * @param gizmoLayer The utility layer the gizmo will be added to
  51286. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51287. * @param color The color of the gizmo
  51288. */
  51289. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51290. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51291. /**
  51292. * If the gizmo is enabled
  51293. */
  51294. set isEnabled(value: boolean);
  51295. get isEnabled(): boolean;
  51296. /**
  51297. * Disposes of the gizmo
  51298. */
  51299. dispose(): void;
  51300. }
  51301. }
  51302. declare module "babylonjs/Gizmos/positionGizmo" {
  51303. import { Observable } from "babylonjs/Misc/observable";
  51304. import { Nullable } from "babylonjs/types";
  51305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51306. import { Mesh } from "babylonjs/Meshes/mesh";
  51307. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51308. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51309. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51310. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51311. /**
  51312. * Gizmo that enables dragging a mesh along 3 axis
  51313. */
  51314. export class PositionGizmo extends Gizmo {
  51315. /**
  51316. * Internal gizmo used for interactions on the x axis
  51317. */
  51318. xGizmo: AxisDragGizmo;
  51319. /**
  51320. * Internal gizmo used for interactions on the y axis
  51321. */
  51322. yGizmo: AxisDragGizmo;
  51323. /**
  51324. * Internal gizmo used for interactions on the z axis
  51325. */
  51326. zGizmo: AxisDragGizmo;
  51327. /**
  51328. * Internal gizmo used for interactions on the yz plane
  51329. */
  51330. xPlaneGizmo: PlaneDragGizmo;
  51331. /**
  51332. * Internal gizmo used for interactions on the xz plane
  51333. */
  51334. yPlaneGizmo: PlaneDragGizmo;
  51335. /**
  51336. * Internal gizmo used for interactions on the xy plane
  51337. */
  51338. zPlaneGizmo: PlaneDragGizmo;
  51339. /**
  51340. * private variables
  51341. */
  51342. private _meshAttached;
  51343. private _updateGizmoRotationToMatchAttachedMesh;
  51344. private _snapDistance;
  51345. private _scaleRatio;
  51346. /** Fires an event when any of it's sub gizmos are dragged */
  51347. onDragStartObservable: Observable<unknown>;
  51348. /** Fires an event when any of it's sub gizmos are released from dragging */
  51349. onDragEndObservable: Observable<unknown>;
  51350. /**
  51351. * If set to true, planar drag is enabled
  51352. */
  51353. private _planarGizmoEnabled;
  51354. get attachedMesh(): Nullable<AbstractMesh>;
  51355. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51356. /**
  51357. * Creates a PositionGizmo
  51358. * @param gizmoLayer The utility layer the gizmo will be added to
  51359. */
  51360. constructor(gizmoLayer?: UtilityLayerRenderer);
  51361. /**
  51362. * If the planar drag gizmo is enabled
  51363. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51364. */
  51365. set planarGizmoEnabled(value: boolean);
  51366. get planarGizmoEnabled(): boolean;
  51367. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51368. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51369. /**
  51370. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51371. */
  51372. set snapDistance(value: number);
  51373. get snapDistance(): number;
  51374. /**
  51375. * Ratio for the scale of the gizmo (Default: 1)
  51376. */
  51377. set scaleRatio(value: number);
  51378. get scaleRatio(): number;
  51379. /**
  51380. * Disposes of the gizmo
  51381. */
  51382. dispose(): void;
  51383. /**
  51384. * CustomMeshes are not supported by this gizmo
  51385. * @param mesh The mesh to replace the default mesh of the gizmo
  51386. */
  51387. setCustomMesh(mesh: Mesh): void;
  51388. }
  51389. }
  51390. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51391. import { Observable } from "babylonjs/Misc/observable";
  51392. import { Nullable } from "babylonjs/types";
  51393. import { Vector3 } from "babylonjs/Maths/math.vector";
  51394. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51396. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51397. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51398. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51399. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51400. import { Scene } from "babylonjs/scene";
  51401. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51402. import { Color3 } from "babylonjs/Maths/math.color";
  51403. /**
  51404. * Single axis drag gizmo
  51405. */
  51406. export class AxisDragGizmo extends Gizmo {
  51407. /**
  51408. * Drag behavior responsible for the gizmos dragging interactions
  51409. */
  51410. dragBehavior: PointerDragBehavior;
  51411. private _pointerObserver;
  51412. /**
  51413. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51414. */
  51415. snapDistance: number;
  51416. /**
  51417. * Event that fires each time the gizmo snaps to a new location.
  51418. * * snapDistance is the the change in distance
  51419. */
  51420. onSnapObservable: Observable<{
  51421. snapDistance: number;
  51422. }>;
  51423. private _isEnabled;
  51424. private _parent;
  51425. private _arrow;
  51426. private _coloredMaterial;
  51427. private _hoverMaterial;
  51428. /** @hidden */
  51429. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51430. /** @hidden */
  51431. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51432. /**
  51433. * Creates an AxisDragGizmo
  51434. * @param gizmoLayer The utility layer the gizmo will be added to
  51435. * @param dragAxis The axis which the gizmo will be able to drag on
  51436. * @param color The color of the gizmo
  51437. */
  51438. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51439. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51440. /**
  51441. * If the gizmo is enabled
  51442. */
  51443. set isEnabled(value: boolean);
  51444. get isEnabled(): boolean;
  51445. /**
  51446. * Disposes of the gizmo
  51447. */
  51448. dispose(): void;
  51449. }
  51450. }
  51451. declare module "babylonjs/Debug/axesViewer" {
  51452. import { Vector3 } from "babylonjs/Maths/math.vector";
  51453. import { Nullable } from "babylonjs/types";
  51454. import { Scene } from "babylonjs/scene";
  51455. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51456. /**
  51457. * The Axes viewer will show 3 axes in a specific point in space
  51458. */
  51459. export class AxesViewer {
  51460. private _xAxis;
  51461. private _yAxis;
  51462. private _zAxis;
  51463. private _scaleLinesFactor;
  51464. private _instanced;
  51465. /**
  51466. * Gets the hosting scene
  51467. */
  51468. scene: Scene;
  51469. /**
  51470. * Gets or sets a number used to scale line length
  51471. */
  51472. scaleLines: number;
  51473. /** Gets the node hierarchy used to render x-axis */
  51474. get xAxis(): TransformNode;
  51475. /** Gets the node hierarchy used to render y-axis */
  51476. get yAxis(): TransformNode;
  51477. /** Gets the node hierarchy used to render z-axis */
  51478. get zAxis(): TransformNode;
  51479. /**
  51480. * Creates a new AxesViewer
  51481. * @param scene defines the hosting scene
  51482. * @param scaleLines defines a number used to scale line length (1 by default)
  51483. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51484. * @param xAxis defines the node hierarchy used to render the x-axis
  51485. * @param yAxis defines the node hierarchy used to render the y-axis
  51486. * @param zAxis defines the node hierarchy used to render the z-axis
  51487. */
  51488. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51489. /**
  51490. * Force the viewer to update
  51491. * @param position defines the position of the viewer
  51492. * @param xaxis defines the x axis of the viewer
  51493. * @param yaxis defines the y axis of the viewer
  51494. * @param zaxis defines the z axis of the viewer
  51495. */
  51496. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51497. /**
  51498. * Creates an instance of this axes viewer.
  51499. * @returns a new axes viewer with instanced meshes
  51500. */
  51501. createInstance(): AxesViewer;
  51502. /** Releases resources */
  51503. dispose(): void;
  51504. private static _SetRenderingGroupId;
  51505. }
  51506. }
  51507. declare module "babylonjs/Debug/boneAxesViewer" {
  51508. import { Nullable } from "babylonjs/types";
  51509. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51510. import { Vector3 } from "babylonjs/Maths/math.vector";
  51511. import { Mesh } from "babylonjs/Meshes/mesh";
  51512. import { Bone } from "babylonjs/Bones/bone";
  51513. import { Scene } from "babylonjs/scene";
  51514. /**
  51515. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51516. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51517. */
  51518. export class BoneAxesViewer extends AxesViewer {
  51519. /**
  51520. * Gets or sets the target mesh where to display the axes viewer
  51521. */
  51522. mesh: Nullable<Mesh>;
  51523. /**
  51524. * Gets or sets the target bone where to display the axes viewer
  51525. */
  51526. bone: Nullable<Bone>;
  51527. /** Gets current position */
  51528. pos: Vector3;
  51529. /** Gets direction of X axis */
  51530. xaxis: Vector3;
  51531. /** Gets direction of Y axis */
  51532. yaxis: Vector3;
  51533. /** Gets direction of Z axis */
  51534. zaxis: Vector3;
  51535. /**
  51536. * Creates a new BoneAxesViewer
  51537. * @param scene defines the hosting scene
  51538. * @param bone defines the target bone
  51539. * @param mesh defines the target mesh
  51540. * @param scaleLines defines a scaling factor for line length (1 by default)
  51541. */
  51542. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51543. /**
  51544. * Force the viewer to update
  51545. */
  51546. update(): void;
  51547. /** Releases resources */
  51548. dispose(): void;
  51549. }
  51550. }
  51551. declare module "babylonjs/Debug/debugLayer" {
  51552. import { Scene } from "babylonjs/scene";
  51553. /**
  51554. * Interface used to define scene explorer extensibility option
  51555. */
  51556. export interface IExplorerExtensibilityOption {
  51557. /**
  51558. * Define the option label
  51559. */
  51560. label: string;
  51561. /**
  51562. * Defines the action to execute on click
  51563. */
  51564. action: (entity: any) => void;
  51565. }
  51566. /**
  51567. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51568. */
  51569. export interface IExplorerExtensibilityGroup {
  51570. /**
  51571. * Defines a predicate to test if a given type mut be extended
  51572. */
  51573. predicate: (entity: any) => boolean;
  51574. /**
  51575. * Gets the list of options added to a type
  51576. */
  51577. entries: IExplorerExtensibilityOption[];
  51578. }
  51579. /**
  51580. * Interface used to define the options to use to create the Inspector
  51581. */
  51582. export interface IInspectorOptions {
  51583. /**
  51584. * Display in overlay mode (default: false)
  51585. */
  51586. overlay?: boolean;
  51587. /**
  51588. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51589. */
  51590. globalRoot?: HTMLElement;
  51591. /**
  51592. * Display the Scene explorer
  51593. */
  51594. showExplorer?: boolean;
  51595. /**
  51596. * Display the property inspector
  51597. */
  51598. showInspector?: boolean;
  51599. /**
  51600. * Display in embed mode (both panes on the right)
  51601. */
  51602. embedMode?: boolean;
  51603. /**
  51604. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51605. */
  51606. handleResize?: boolean;
  51607. /**
  51608. * Allow the panes to popup (default: true)
  51609. */
  51610. enablePopup?: boolean;
  51611. /**
  51612. * Allow the panes to be closed by users (default: true)
  51613. */
  51614. enableClose?: boolean;
  51615. /**
  51616. * Optional list of extensibility entries
  51617. */
  51618. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51619. /**
  51620. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51621. */
  51622. inspectorURL?: string;
  51623. /**
  51624. * Optional initial tab (default to DebugLayerTab.Properties)
  51625. */
  51626. initialTab?: DebugLayerTab;
  51627. }
  51628. module "babylonjs/scene" {
  51629. interface Scene {
  51630. /**
  51631. * @hidden
  51632. * Backing field
  51633. */
  51634. _debugLayer: DebugLayer;
  51635. /**
  51636. * Gets the debug layer (aka Inspector) associated with the scene
  51637. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51638. */
  51639. debugLayer: DebugLayer;
  51640. }
  51641. }
  51642. /**
  51643. * Enum of inspector action tab
  51644. */
  51645. export enum DebugLayerTab {
  51646. /**
  51647. * Properties tag (default)
  51648. */
  51649. Properties = 0,
  51650. /**
  51651. * Debug tab
  51652. */
  51653. Debug = 1,
  51654. /**
  51655. * Statistics tab
  51656. */
  51657. Statistics = 2,
  51658. /**
  51659. * Tools tab
  51660. */
  51661. Tools = 3,
  51662. /**
  51663. * Settings tab
  51664. */
  51665. Settings = 4
  51666. }
  51667. /**
  51668. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51669. * what is happening in your scene
  51670. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51671. */
  51672. export class DebugLayer {
  51673. /**
  51674. * Define the url to get the inspector script from.
  51675. * By default it uses the babylonjs CDN.
  51676. * @ignoreNaming
  51677. */
  51678. static InspectorURL: string;
  51679. private _scene;
  51680. private BJSINSPECTOR;
  51681. private _onPropertyChangedObservable?;
  51682. /**
  51683. * Observable triggered when a property is changed through the inspector.
  51684. */
  51685. get onPropertyChangedObservable(): any;
  51686. /**
  51687. * Instantiates a new debug layer.
  51688. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51689. * what is happening in your scene
  51690. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51691. * @param scene Defines the scene to inspect
  51692. */
  51693. constructor(scene: Scene);
  51694. /** Creates the inspector window. */
  51695. private _createInspector;
  51696. /**
  51697. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51698. * @param entity defines the entity to select
  51699. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51700. */
  51701. select(entity: any, lineContainerTitles?: string | string[]): void;
  51702. /** Get the inspector from bundle or global */
  51703. private _getGlobalInspector;
  51704. /**
  51705. * Get if the inspector is visible or not.
  51706. * @returns true if visible otherwise, false
  51707. */
  51708. isVisible(): boolean;
  51709. /**
  51710. * Hide the inspector and close its window.
  51711. */
  51712. hide(): void;
  51713. /**
  51714. * Update the scene in the inspector
  51715. */
  51716. setAsActiveScene(): void;
  51717. /**
  51718. * Launch the debugLayer.
  51719. * @param config Define the configuration of the inspector
  51720. * @return a promise fulfilled when the debug layer is visible
  51721. */
  51722. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51723. }
  51724. }
  51725. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51726. import { Nullable } from "babylonjs/types";
  51727. import { Scene } from "babylonjs/scene";
  51728. import { Vector4 } from "babylonjs/Maths/math.vector";
  51729. import { Color4 } from "babylonjs/Maths/math.color";
  51730. import { Mesh } from "babylonjs/Meshes/mesh";
  51731. /**
  51732. * Class containing static functions to help procedurally build meshes
  51733. */
  51734. export class BoxBuilder {
  51735. /**
  51736. * Creates a box mesh
  51737. * * The parameter `size` sets the size (float) of each box side (default 1)
  51738. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51739. * * 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)
  51740. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51742. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51744. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51745. * @param name defines the name of the mesh
  51746. * @param options defines the options used to create the mesh
  51747. * @param scene defines the hosting scene
  51748. * @returns the box mesh
  51749. */
  51750. static CreateBox(name: string, options: {
  51751. size?: number;
  51752. width?: number;
  51753. height?: number;
  51754. depth?: number;
  51755. faceUV?: Vector4[];
  51756. faceColors?: Color4[];
  51757. sideOrientation?: number;
  51758. frontUVs?: Vector4;
  51759. backUVs?: Vector4;
  51760. wrap?: boolean;
  51761. topBaseAt?: number;
  51762. bottomBaseAt?: number;
  51763. updatable?: boolean;
  51764. }, scene?: Nullable<Scene>): Mesh;
  51765. }
  51766. }
  51767. declare module "babylonjs/Debug/physicsViewer" {
  51768. import { Nullable } from "babylonjs/types";
  51769. import { Scene } from "babylonjs/scene";
  51770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51771. import { Mesh } from "babylonjs/Meshes/mesh";
  51772. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51773. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51774. /**
  51775. * Used to show the physics impostor around the specific mesh
  51776. */
  51777. export class PhysicsViewer {
  51778. /** @hidden */
  51779. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51780. /** @hidden */
  51781. protected _meshes: Array<Nullable<AbstractMesh>>;
  51782. /** @hidden */
  51783. protected _scene: Nullable<Scene>;
  51784. /** @hidden */
  51785. protected _numMeshes: number;
  51786. /** @hidden */
  51787. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51788. private _renderFunction;
  51789. private _utilityLayer;
  51790. private _debugBoxMesh;
  51791. private _debugSphereMesh;
  51792. private _debugCylinderMesh;
  51793. private _debugMaterial;
  51794. private _debugMeshMeshes;
  51795. /**
  51796. * Creates a new PhysicsViewer
  51797. * @param scene defines the hosting scene
  51798. */
  51799. constructor(scene: Scene);
  51800. /** @hidden */
  51801. protected _updateDebugMeshes(): void;
  51802. /**
  51803. * Renders a specified physic impostor
  51804. * @param impostor defines the impostor to render
  51805. * @param targetMesh defines the mesh represented by the impostor
  51806. * @returns the new debug mesh used to render the impostor
  51807. */
  51808. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51809. /**
  51810. * Hides a specified physic impostor
  51811. * @param impostor defines the impostor to hide
  51812. */
  51813. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51814. private _getDebugMaterial;
  51815. private _getDebugBoxMesh;
  51816. private _getDebugSphereMesh;
  51817. private _getDebugCylinderMesh;
  51818. private _getDebugMeshMesh;
  51819. private _getDebugMesh;
  51820. /** Releases all resources */
  51821. dispose(): void;
  51822. }
  51823. }
  51824. declare module "babylonjs/Debug/rayHelper" {
  51825. import { Nullable } from "babylonjs/types";
  51826. import { Ray } from "babylonjs/Culling/ray";
  51827. import { Vector3 } from "babylonjs/Maths/math.vector";
  51828. import { Color3 } from "babylonjs/Maths/math.color";
  51829. import { Scene } from "babylonjs/scene";
  51830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51831. import "babylonjs/Meshes/Builders/linesBuilder";
  51832. /**
  51833. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51834. * in order to better appreciate the issue one might have.
  51835. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51836. */
  51837. export class RayHelper {
  51838. /**
  51839. * Defines the ray we are currently tryin to visualize.
  51840. */
  51841. ray: Nullable<Ray>;
  51842. private _renderPoints;
  51843. private _renderLine;
  51844. private _renderFunction;
  51845. private _scene;
  51846. private _updateToMeshFunction;
  51847. private _attachedToMesh;
  51848. private _meshSpaceDirection;
  51849. private _meshSpaceOrigin;
  51850. /**
  51851. * Helper function to create a colored helper in a scene in one line.
  51852. * @param ray Defines the ray we are currently tryin to visualize
  51853. * @param scene Defines the scene the ray is used in
  51854. * @param color Defines the color we want to see the ray in
  51855. * @returns The newly created ray helper.
  51856. */
  51857. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51858. /**
  51859. * Instantiate a new ray helper.
  51860. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51861. * in order to better appreciate the issue one might have.
  51862. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51863. * @param ray Defines the ray we are currently tryin to visualize
  51864. */
  51865. constructor(ray: Ray);
  51866. /**
  51867. * Shows the ray we are willing to debug.
  51868. * @param scene Defines the scene the ray needs to be rendered in
  51869. * @param color Defines the color the ray needs to be rendered in
  51870. */
  51871. show(scene: Scene, color?: Color3): void;
  51872. /**
  51873. * Hides the ray we are debugging.
  51874. */
  51875. hide(): void;
  51876. private _render;
  51877. /**
  51878. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51879. * @param mesh Defines the mesh we want the helper attached to
  51880. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51881. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51882. * @param length Defines the length of the ray
  51883. */
  51884. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51885. /**
  51886. * Detach the ray helper from the mesh it has previously been attached to.
  51887. */
  51888. detachFromMesh(): void;
  51889. private _updateToMesh;
  51890. /**
  51891. * Dispose the helper and release its associated resources.
  51892. */
  51893. dispose(): void;
  51894. }
  51895. }
  51896. declare module "babylonjs/Debug/skeletonViewer" {
  51897. import { Color3 } from "babylonjs/Maths/math.color";
  51898. import { Scene } from "babylonjs/scene";
  51899. import { Nullable } from "babylonjs/types";
  51900. import { Skeleton } from "babylonjs/Bones/skeleton";
  51901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51902. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51903. /**
  51904. * Class used to render a debug view of a given skeleton
  51905. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51906. */
  51907. export class SkeletonViewer {
  51908. /** defines the skeleton to render */
  51909. skeleton: Skeleton;
  51910. /** defines the mesh attached to the skeleton */
  51911. mesh: AbstractMesh;
  51912. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51913. autoUpdateBonesMatrices: boolean;
  51914. /** defines the rendering group id to use with the viewer */
  51915. renderingGroupId: number;
  51916. /** Gets or sets the color used to render the skeleton */
  51917. color: Color3;
  51918. private _scene;
  51919. private _debugLines;
  51920. private _debugMesh;
  51921. private _isEnabled;
  51922. private _renderFunction;
  51923. private _utilityLayer;
  51924. /**
  51925. * Returns the mesh used to render the bones
  51926. */
  51927. get debugMesh(): Nullable<LinesMesh>;
  51928. /**
  51929. * Creates a new SkeletonViewer
  51930. * @param skeleton defines the skeleton to render
  51931. * @param mesh defines the mesh attached to the skeleton
  51932. * @param scene defines the hosting scene
  51933. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51934. * @param renderingGroupId defines the rendering group id to use with the viewer
  51935. */
  51936. constructor(
  51937. /** defines the skeleton to render */
  51938. skeleton: Skeleton,
  51939. /** defines the mesh attached to the skeleton */
  51940. mesh: AbstractMesh, scene: Scene,
  51941. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51942. autoUpdateBonesMatrices?: boolean,
  51943. /** defines the rendering group id to use with the viewer */
  51944. renderingGroupId?: number);
  51945. /** Gets or sets a boolean indicating if the viewer is enabled */
  51946. set isEnabled(value: boolean);
  51947. get isEnabled(): boolean;
  51948. private _getBonePosition;
  51949. private _getLinesForBonesWithLength;
  51950. private _getLinesForBonesNoLength;
  51951. /** Update the viewer to sync with current skeleton state */
  51952. update(): void;
  51953. /** Release associated resources */
  51954. dispose(): void;
  51955. }
  51956. }
  51957. declare module "babylonjs/Debug/index" {
  51958. export * from "babylonjs/Debug/axesViewer";
  51959. export * from "babylonjs/Debug/boneAxesViewer";
  51960. export * from "babylonjs/Debug/debugLayer";
  51961. export * from "babylonjs/Debug/physicsViewer";
  51962. export * from "babylonjs/Debug/rayHelper";
  51963. export * from "babylonjs/Debug/skeletonViewer";
  51964. }
  51965. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  51966. /**
  51967. * Enum for Device Types
  51968. */
  51969. export enum DeviceType {
  51970. /** Generic */
  51971. Generic = 0,
  51972. /** Keyboard */
  51973. Keyboard = 1,
  51974. /** Mouse */
  51975. Mouse = 2,
  51976. /** Touch Pointers */
  51977. Touch = 3,
  51978. /** PS4 Dual Shock */
  51979. DualShock = 4,
  51980. /** Xbox */
  51981. Xbox = 5,
  51982. /** Switch Controller */
  51983. Switch = 6
  51984. }
  51985. /**
  51986. * Enum for All Pointers (Touch/Mouse)
  51987. */
  51988. export enum PointerInput {
  51989. /** Horizontal Axis */
  51990. Horizontal = 0,
  51991. /** Vertical Axis */
  51992. Vertical = 1,
  51993. /** Left Click or Touch */
  51994. LeftClick = 2,
  51995. /** Middle Click */
  51996. MiddleClick = 3,
  51997. /** Right Click */
  51998. RightClick = 4,
  51999. /** Browser Back */
  52000. BrowserBack = 5,
  52001. /** Browser Forward */
  52002. BrowserForward = 6
  52003. }
  52004. /**
  52005. * Enum for Dual Shock Gamepad
  52006. */
  52007. export enum DualShockInput {
  52008. /** Cross */
  52009. Cross = 0,
  52010. /** Circle */
  52011. Circle = 1,
  52012. /** Square */
  52013. Square = 2,
  52014. /** Triangle */
  52015. Triangle = 3,
  52016. /** L1 */
  52017. L1 = 4,
  52018. /** R1 */
  52019. R1 = 5,
  52020. /** L2 */
  52021. L2 = 6,
  52022. /** R2 */
  52023. R2 = 7,
  52024. /** Share */
  52025. Share = 8,
  52026. /** Options */
  52027. Options = 9,
  52028. /** L3 */
  52029. L3 = 10,
  52030. /** R3 */
  52031. R3 = 11,
  52032. /** DPadUp */
  52033. DPadUp = 12,
  52034. /** DPadDown */
  52035. DPadDown = 13,
  52036. /** DPadLeft */
  52037. DPadLeft = 14,
  52038. /** DRight */
  52039. DPadRight = 15,
  52040. /** Home */
  52041. Home = 16,
  52042. /** TouchPad */
  52043. TouchPad = 17,
  52044. /** LStickXAxis */
  52045. LStickXAxis = 18,
  52046. /** LStickYAxis */
  52047. LStickYAxis = 19,
  52048. /** RStickXAxis */
  52049. RStickXAxis = 20,
  52050. /** RStickYAxis */
  52051. RStickYAxis = 21
  52052. }
  52053. /**
  52054. * Enum for Xbox Gamepad
  52055. */
  52056. export enum XboxInput {
  52057. /** A */
  52058. A = 0,
  52059. /** B */
  52060. B = 1,
  52061. /** X */
  52062. X = 2,
  52063. /** Y */
  52064. Y = 3,
  52065. /** LB */
  52066. LB = 4,
  52067. /** RB */
  52068. RB = 5,
  52069. /** LT */
  52070. LT = 6,
  52071. /** RT */
  52072. RT = 7,
  52073. /** Back */
  52074. Back = 8,
  52075. /** Start */
  52076. Start = 9,
  52077. /** LS */
  52078. LS = 10,
  52079. /** RS */
  52080. RS = 11,
  52081. /** DPadUp */
  52082. DPadUp = 12,
  52083. /** DPadDown */
  52084. DPadDown = 13,
  52085. /** DPadLeft */
  52086. DPadLeft = 14,
  52087. /** DRight */
  52088. DPadRight = 15,
  52089. /** Home */
  52090. Home = 16,
  52091. /** LStickXAxis */
  52092. LStickXAxis = 17,
  52093. /** LStickYAxis */
  52094. LStickYAxis = 18,
  52095. /** RStickXAxis */
  52096. RStickXAxis = 19,
  52097. /** RStickYAxis */
  52098. RStickYAxis = 20
  52099. }
  52100. /**
  52101. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52102. */
  52103. export enum SwitchInput {
  52104. /** B */
  52105. B = 0,
  52106. /** A */
  52107. A = 1,
  52108. /** Y */
  52109. Y = 2,
  52110. /** X */
  52111. X = 3,
  52112. /** L */
  52113. L = 4,
  52114. /** R */
  52115. R = 5,
  52116. /** ZL */
  52117. ZL = 6,
  52118. /** ZR */
  52119. ZR = 7,
  52120. /** Minus */
  52121. Minus = 8,
  52122. /** Plus */
  52123. Plus = 9,
  52124. /** LS */
  52125. LS = 10,
  52126. /** RS */
  52127. RS = 11,
  52128. /** DPadUp */
  52129. DPadUp = 12,
  52130. /** DPadDown */
  52131. DPadDown = 13,
  52132. /** DPadLeft */
  52133. DPadLeft = 14,
  52134. /** DRight */
  52135. DPadRight = 15,
  52136. /** Home */
  52137. Home = 16,
  52138. /** Capture */
  52139. Capture = 17,
  52140. /** LStickXAxis */
  52141. LStickXAxis = 18,
  52142. /** LStickYAxis */
  52143. LStickYAxis = 19,
  52144. /** RStickXAxis */
  52145. RStickXAxis = 20,
  52146. /** RStickYAxis */
  52147. RStickYAxis = 21
  52148. }
  52149. }
  52150. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52151. import { Engine } from "babylonjs/Engines/engine";
  52152. import { IDisposable } from "babylonjs/scene";
  52153. import { Nullable } from "babylonjs/types";
  52154. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52155. /**
  52156. * This class will take all inputs from Keyboard, Pointer, and
  52157. * any Gamepads and provide a polling system that all devices
  52158. * will use. This class assumes that there will only be one
  52159. * pointer device and one keyboard.
  52160. */
  52161. export class DeviceInputSystem implements IDisposable {
  52162. /**
  52163. * Callback to be triggered when a device is connected
  52164. */
  52165. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52166. /**
  52167. * Callback to be triggered when a device is disconnected
  52168. */
  52169. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52170. /**
  52171. * Callback to be triggered when event driven input is updated
  52172. */
  52173. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52174. private _inputs;
  52175. private _gamepads;
  52176. private _keyboardActive;
  52177. private _pointerActive;
  52178. private _elementToAttachTo;
  52179. private _keyboardDownEvent;
  52180. private _keyboardUpEvent;
  52181. private _pointerMoveEvent;
  52182. private _pointerDownEvent;
  52183. private _pointerUpEvent;
  52184. private _gamepadConnectedEvent;
  52185. private _gamepadDisconnectedEvent;
  52186. private static _MAX_KEYCODES;
  52187. private static _MAX_POINTER_INPUTS;
  52188. private constructor();
  52189. /**
  52190. * Creates a new DeviceInputSystem instance
  52191. * @param engine Engine to pull input element from
  52192. * @returns The new instance
  52193. */
  52194. static Create(engine: Engine): DeviceInputSystem;
  52195. /**
  52196. * Checks for current device input value, given an id and input index
  52197. * @param deviceName Id of connected device
  52198. * @param inputIndex Index of device input
  52199. * @returns Current value of input
  52200. */
  52201. /**
  52202. * Checks for current device input value, given an id and input index
  52203. * @param deviceType Enum specifiying device type
  52204. * @param deviceSlot "Slot" or index that device is referenced in
  52205. * @param inputIndex Id of input to be checked
  52206. * @returns Current value of input
  52207. */
  52208. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52209. /**
  52210. * Dispose of all the eventlisteners
  52211. */
  52212. dispose(): void;
  52213. /**
  52214. * Add device and inputs to device array
  52215. * @param deviceType Enum specifiying device type
  52216. * @param deviceSlot "Slot" or index that device is referenced in
  52217. * @param numberOfInputs Number of input entries to create for given device
  52218. */
  52219. private _registerDevice;
  52220. /**
  52221. * Given a specific device name, remove that device from the device map
  52222. * @param deviceType Enum specifiying device type
  52223. * @param deviceSlot "Slot" or index that device is referenced in
  52224. */
  52225. private _unregisterDevice;
  52226. /**
  52227. * Handle all actions that come from keyboard interaction
  52228. */
  52229. private _handleKeyActions;
  52230. /**
  52231. * Handle all actions that come from pointer interaction
  52232. */
  52233. private _handlePointerActions;
  52234. /**
  52235. * Handle all actions that come from gamepad interaction
  52236. */
  52237. private _handleGamepadActions;
  52238. /**
  52239. * Update all non-event based devices with each frame
  52240. * @param deviceType Enum specifiying device type
  52241. * @param deviceSlot "Slot" or index that device is referenced in
  52242. * @param inputIndex Id of input to be checked
  52243. */
  52244. private _updateDevice;
  52245. /**
  52246. * Gets DeviceType from the device name
  52247. * @param deviceName Name of Device from DeviceInputSystem
  52248. * @returns DeviceType enum value
  52249. */
  52250. private _getGamepadDeviceType;
  52251. }
  52252. }
  52253. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52254. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52255. /**
  52256. * Type to handle enforcement of inputs
  52257. */
  52258. 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;
  52259. }
  52260. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52261. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52262. import { Engine } from "babylonjs/Engines/engine";
  52263. import { IDisposable } from "babylonjs/scene";
  52264. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52265. import { Nullable } from "babylonjs/types";
  52266. import { Observable } from "babylonjs/Misc/observable";
  52267. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52268. /**
  52269. * Class that handles all input for a specific device
  52270. */
  52271. export class DeviceSource<T extends DeviceType> {
  52272. /** Type of device */
  52273. readonly deviceType: DeviceType;
  52274. /** "Slot" or index that device is referenced in */
  52275. readonly deviceSlot: number;
  52276. /**
  52277. * Observable to handle device input changes per device
  52278. */
  52279. readonly onInputChangedObservable: Observable<{
  52280. inputIndex: DeviceInput<T>;
  52281. previousState: Nullable<number>;
  52282. currentState: Nullable<number>;
  52283. }>;
  52284. private readonly _deviceInputSystem;
  52285. /**
  52286. * Default Constructor
  52287. * @param deviceInputSystem Reference to DeviceInputSystem
  52288. * @param deviceType Type of device
  52289. * @param deviceSlot "Slot" or index that device is referenced in
  52290. */
  52291. constructor(deviceInputSystem: DeviceInputSystem,
  52292. /** Type of device */
  52293. deviceType: DeviceType,
  52294. /** "Slot" or index that device is referenced in */
  52295. deviceSlot?: number);
  52296. /**
  52297. * Get input for specific input
  52298. * @param inputIndex index of specific input on device
  52299. * @returns Input value from DeviceInputSystem
  52300. */
  52301. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52302. }
  52303. /**
  52304. * Class to keep track of devices
  52305. */
  52306. export class DeviceSourceManager implements IDisposable {
  52307. /**
  52308. * Observable to be triggered when before a device is connected
  52309. */
  52310. readonly onBeforeDeviceConnectedObservable: Observable<{
  52311. deviceType: DeviceType;
  52312. deviceSlot: number;
  52313. }>;
  52314. /**
  52315. * Observable to be triggered when before a device is disconnected
  52316. */
  52317. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52318. deviceType: DeviceType;
  52319. deviceSlot: number;
  52320. }>;
  52321. /**
  52322. * Observable to be triggered when after a device is connected
  52323. */
  52324. readonly onAfterDeviceConnectedObservable: Observable<{
  52325. deviceType: DeviceType;
  52326. deviceSlot: number;
  52327. }>;
  52328. /**
  52329. * Observable to be triggered when after a device is disconnected
  52330. */
  52331. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52332. deviceType: DeviceType;
  52333. deviceSlot: number;
  52334. }>;
  52335. private readonly _devices;
  52336. private readonly _firstDevice;
  52337. private readonly _deviceInputSystem;
  52338. /**
  52339. * Default Constructor
  52340. * @param engine engine to pull input element from
  52341. */
  52342. constructor(engine: Engine);
  52343. /**
  52344. * Gets a DeviceSource, given a type and slot
  52345. * @param deviceType Enum specifying device type
  52346. * @param deviceSlot "Slot" or index that device is referenced in
  52347. * @returns DeviceSource object
  52348. */
  52349. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52350. /**
  52351. * Gets an array of DeviceSource objects for a given device type
  52352. * @param deviceType Enum specifying device type
  52353. * @returns Array of DeviceSource objects
  52354. */
  52355. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52356. /**
  52357. * Dispose of DeviceInputSystem and other parts
  52358. */
  52359. dispose(): void;
  52360. /**
  52361. * Function to add device name to device list
  52362. * @param deviceType Enum specifying device type
  52363. * @param deviceSlot "Slot" or index that device is referenced in
  52364. */
  52365. private _addDevice;
  52366. /**
  52367. * Function to remove device name to device list
  52368. * @param deviceType Enum specifying device type
  52369. * @param deviceSlot "Slot" or index that device is referenced in
  52370. */
  52371. private _removeDevice;
  52372. /**
  52373. * Updates array storing first connected device of each type
  52374. * @param type Type of Device
  52375. */
  52376. private _updateFirstDevices;
  52377. }
  52378. }
  52379. declare module "babylonjs/DeviceInput/index" {
  52380. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52381. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52382. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52383. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52384. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52385. }
  52386. declare module "babylonjs/Engines/nullEngine" {
  52387. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52388. import { Engine } from "babylonjs/Engines/engine";
  52389. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52390. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52391. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52392. import { Effect } from "babylonjs/Materials/effect";
  52393. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52394. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52395. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52396. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52397. /**
  52398. * Options to create the null engine
  52399. */
  52400. export class NullEngineOptions {
  52401. /**
  52402. * Render width (Default: 512)
  52403. */
  52404. renderWidth: number;
  52405. /**
  52406. * Render height (Default: 256)
  52407. */
  52408. renderHeight: number;
  52409. /**
  52410. * Texture size (Default: 512)
  52411. */
  52412. textureSize: number;
  52413. /**
  52414. * If delta time between frames should be constant
  52415. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52416. */
  52417. deterministicLockstep: boolean;
  52418. /**
  52419. * Maximum about of steps between frames (Default: 4)
  52420. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52421. */
  52422. lockstepMaxSteps: number;
  52423. }
  52424. /**
  52425. * The null engine class provides support for headless version of babylon.js.
  52426. * This can be used in server side scenario or for testing purposes
  52427. */
  52428. export class NullEngine extends Engine {
  52429. private _options;
  52430. /**
  52431. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52432. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52433. * @returns true if engine is in deterministic lock step mode
  52434. */
  52435. isDeterministicLockStep(): boolean;
  52436. /**
  52437. * Gets the max steps when engine is running in deterministic lock step
  52438. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52439. * @returns the max steps
  52440. */
  52441. getLockstepMaxSteps(): number;
  52442. /**
  52443. * Gets the current hardware scaling level.
  52444. * By default the hardware scaling level is computed from the window device ratio.
  52445. * 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.
  52446. * @returns a number indicating the current hardware scaling level
  52447. */
  52448. getHardwareScalingLevel(): number;
  52449. constructor(options?: NullEngineOptions);
  52450. /**
  52451. * Creates a vertex buffer
  52452. * @param vertices the data for the vertex buffer
  52453. * @returns the new WebGL static buffer
  52454. */
  52455. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52456. /**
  52457. * Creates a new index buffer
  52458. * @param indices defines the content of the index buffer
  52459. * @param updatable defines if the index buffer must be updatable
  52460. * @returns a new webGL buffer
  52461. */
  52462. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52463. /**
  52464. * Clear the current render buffer or the current render target (if any is set up)
  52465. * @param color defines the color to use
  52466. * @param backBuffer defines if the back buffer must be cleared
  52467. * @param depth defines if the depth buffer must be cleared
  52468. * @param stencil defines if the stencil buffer must be cleared
  52469. */
  52470. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52471. /**
  52472. * Gets the current render width
  52473. * @param useScreen defines if screen size must be used (or the current render target if any)
  52474. * @returns a number defining the current render width
  52475. */
  52476. getRenderWidth(useScreen?: boolean): number;
  52477. /**
  52478. * Gets the current render height
  52479. * @param useScreen defines if screen size must be used (or the current render target if any)
  52480. * @returns a number defining the current render height
  52481. */
  52482. getRenderHeight(useScreen?: boolean): number;
  52483. /**
  52484. * Set the WebGL's viewport
  52485. * @param viewport defines the viewport element to be used
  52486. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52487. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52488. */
  52489. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52490. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52491. /**
  52492. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52493. * @param pipelineContext defines the pipeline context to use
  52494. * @param uniformsNames defines the list of uniform names
  52495. * @returns an array of webGL uniform locations
  52496. */
  52497. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52498. /**
  52499. * Gets the lsit of active attributes for a given webGL program
  52500. * @param pipelineContext defines the pipeline context to use
  52501. * @param attributesNames defines the list of attribute names to get
  52502. * @returns an array of indices indicating the offset of each attribute
  52503. */
  52504. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52505. /**
  52506. * Binds an effect to the webGL context
  52507. * @param effect defines the effect to bind
  52508. */
  52509. bindSamplers(effect: Effect): void;
  52510. /**
  52511. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52512. * @param effect defines the effect to activate
  52513. */
  52514. enableEffect(effect: Effect): void;
  52515. /**
  52516. * Set various states to the webGL context
  52517. * @param culling defines backface culling state
  52518. * @param zOffset defines the value to apply to zOffset (0 by default)
  52519. * @param force defines if states must be applied even if cache is up to date
  52520. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52521. */
  52522. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52523. /**
  52524. * Set the value of an uniform to an array of int32
  52525. * @param uniform defines the webGL uniform location where to store the value
  52526. * @param array defines the array of int32 to store
  52527. */
  52528. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52529. /**
  52530. * Set the value of an uniform to an array of int32 (stored as vec2)
  52531. * @param uniform defines the webGL uniform location where to store the value
  52532. * @param array defines the array of int32 to store
  52533. */
  52534. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52535. /**
  52536. * Set the value of an uniform to an array of int32 (stored as vec3)
  52537. * @param uniform defines the webGL uniform location where to store the value
  52538. * @param array defines the array of int32 to store
  52539. */
  52540. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52541. /**
  52542. * Set the value of an uniform to an array of int32 (stored as vec4)
  52543. * @param uniform defines the webGL uniform location where to store the value
  52544. * @param array defines the array of int32 to store
  52545. */
  52546. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52547. /**
  52548. * Set the value of an uniform to an array of float32
  52549. * @param uniform defines the webGL uniform location where to store the value
  52550. * @param array defines the array of float32 to store
  52551. */
  52552. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52553. /**
  52554. * Set the value of an uniform to an array of float32 (stored as vec2)
  52555. * @param uniform defines the webGL uniform location where to store the value
  52556. * @param array defines the array of float32 to store
  52557. */
  52558. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52559. /**
  52560. * Set the value of an uniform to an array of float32 (stored as vec3)
  52561. * @param uniform defines the webGL uniform location where to store the value
  52562. * @param array defines the array of float32 to store
  52563. */
  52564. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52565. /**
  52566. * Set the value of an uniform to an array of float32 (stored as vec4)
  52567. * @param uniform defines the webGL uniform location where to store the value
  52568. * @param array defines the array of float32 to store
  52569. */
  52570. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52571. /**
  52572. * Set the value of an uniform to an array of number
  52573. * @param uniform defines the webGL uniform location where to store the value
  52574. * @param array defines the array of number to store
  52575. */
  52576. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52577. /**
  52578. * Set the value of an uniform to an array of number (stored as vec2)
  52579. * @param uniform defines the webGL uniform location where to store the value
  52580. * @param array defines the array of number to store
  52581. */
  52582. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52583. /**
  52584. * Set the value of an uniform to an array of number (stored as vec3)
  52585. * @param uniform defines the webGL uniform location where to store the value
  52586. * @param array defines the array of number to store
  52587. */
  52588. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52589. /**
  52590. * Set the value of an uniform to an array of number (stored as vec4)
  52591. * @param uniform defines the webGL uniform location where to store the value
  52592. * @param array defines the array of number to store
  52593. */
  52594. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52595. /**
  52596. * Set the value of an uniform to an array of float32 (stored as matrices)
  52597. * @param uniform defines the webGL uniform location where to store the value
  52598. * @param matrices defines the array of float32 to store
  52599. */
  52600. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52601. /**
  52602. * Set the value of an uniform to a matrix (3x3)
  52603. * @param uniform defines the webGL uniform location where to store the value
  52604. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52605. */
  52606. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52607. /**
  52608. * Set the value of an uniform to a matrix (2x2)
  52609. * @param uniform defines the webGL uniform location where to store the value
  52610. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52611. */
  52612. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52613. /**
  52614. * Set the value of an uniform to a number (float)
  52615. * @param uniform defines the webGL uniform location where to store the value
  52616. * @param value defines the float number to store
  52617. */
  52618. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52619. /**
  52620. * Set the value of an uniform to a vec2
  52621. * @param uniform defines the webGL uniform location where to store the value
  52622. * @param x defines the 1st component of the value
  52623. * @param y defines the 2nd component of the value
  52624. */
  52625. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52626. /**
  52627. * Set the value of an uniform to a vec3
  52628. * @param uniform defines the webGL uniform location where to store the value
  52629. * @param x defines the 1st component of the value
  52630. * @param y defines the 2nd component of the value
  52631. * @param z defines the 3rd component of the value
  52632. */
  52633. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52634. /**
  52635. * Set the value of an uniform to a boolean
  52636. * @param uniform defines the webGL uniform location where to store the value
  52637. * @param bool defines the boolean to store
  52638. */
  52639. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52640. /**
  52641. * Set the value of an uniform to a vec4
  52642. * @param uniform defines the webGL uniform location where to store the value
  52643. * @param x defines the 1st component of the value
  52644. * @param y defines the 2nd component of the value
  52645. * @param z defines the 3rd component of the value
  52646. * @param w defines the 4th component of the value
  52647. */
  52648. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52649. /**
  52650. * Sets the current alpha mode
  52651. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52652. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52653. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52654. */
  52655. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52656. /**
  52657. * Bind webGl buffers directly to the webGL context
  52658. * @param vertexBuffers defines the vertex buffer to bind
  52659. * @param indexBuffer defines the index buffer to bind
  52660. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52661. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52662. * @param effect defines the effect associated with the vertex buffer
  52663. */
  52664. bindBuffers(vertexBuffers: {
  52665. [key: string]: VertexBuffer;
  52666. }, indexBuffer: DataBuffer, effect: Effect): void;
  52667. /**
  52668. * Force the entire cache to be cleared
  52669. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52670. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52671. */
  52672. wipeCaches(bruteForce?: boolean): void;
  52673. /**
  52674. * Send a draw order
  52675. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52676. * @param indexStart defines the starting index
  52677. * @param indexCount defines the number of index to draw
  52678. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52679. */
  52680. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52681. /**
  52682. * Draw a list of indexed primitives
  52683. * @param fillMode defines the primitive to use
  52684. * @param indexStart defines the starting index
  52685. * @param indexCount defines the number of index to draw
  52686. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52687. */
  52688. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52689. /**
  52690. * Draw a list of unindexed primitives
  52691. * @param fillMode defines the primitive to use
  52692. * @param verticesStart defines the index of first vertex to draw
  52693. * @param verticesCount defines the count of vertices to draw
  52694. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52695. */
  52696. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52697. /** @hidden */
  52698. _createTexture(): WebGLTexture;
  52699. /** @hidden */
  52700. _releaseTexture(texture: InternalTexture): void;
  52701. /**
  52702. * Usually called from Texture.ts.
  52703. * Passed information to create a WebGLTexture
  52704. * @param urlArg defines a value which contains one of the following:
  52705. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52706. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52707. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52708. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52709. * @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)
  52710. * @param scene needed for loading to the correct scene
  52711. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52712. * @param onLoad optional callback to be called upon successful completion
  52713. * @param onError optional callback to be called upon failure
  52714. * @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
  52715. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52716. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52717. * @param forcedExtension defines the extension to use to pick the right loader
  52718. * @param mimeType defines an optional mime type
  52719. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52720. */
  52721. 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;
  52722. /**
  52723. * Creates a new render target texture
  52724. * @param size defines the size of the texture
  52725. * @param options defines the options used to create the texture
  52726. * @returns a new render target texture stored in an InternalTexture
  52727. */
  52728. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52729. /**
  52730. * Update the sampling mode of a given texture
  52731. * @param samplingMode defines the required sampling mode
  52732. * @param texture defines the texture to update
  52733. */
  52734. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52735. /**
  52736. * Binds the frame buffer to the specified texture.
  52737. * @param texture The texture to render to or null for the default canvas
  52738. * @param faceIndex The face of the texture to render to in case of cube texture
  52739. * @param requiredWidth The width of the target to render to
  52740. * @param requiredHeight The height of the target to render to
  52741. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52742. * @param lodLevel defines le lod level to bind to the frame buffer
  52743. */
  52744. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52745. /**
  52746. * Unbind the current render target texture from the webGL context
  52747. * @param texture defines the render target texture to unbind
  52748. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52749. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52750. */
  52751. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52752. /**
  52753. * Creates a dynamic vertex buffer
  52754. * @param vertices the data for the dynamic vertex buffer
  52755. * @returns the new WebGL dynamic buffer
  52756. */
  52757. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52758. /**
  52759. * Update the content of a dynamic texture
  52760. * @param texture defines the texture to update
  52761. * @param canvas defines the canvas containing the source
  52762. * @param invertY defines if data must be stored with Y axis inverted
  52763. * @param premulAlpha defines if alpha is stored as premultiplied
  52764. * @param format defines the format of the data
  52765. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52766. */
  52767. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52768. /**
  52769. * Gets a boolean indicating if all created effects are ready
  52770. * @returns true if all effects are ready
  52771. */
  52772. areAllEffectsReady(): boolean;
  52773. /**
  52774. * @hidden
  52775. * Get the current error code of the webGL context
  52776. * @returns the error code
  52777. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52778. */
  52779. getError(): number;
  52780. /** @hidden */
  52781. _getUnpackAlignement(): number;
  52782. /** @hidden */
  52783. _unpackFlipY(value: boolean): void;
  52784. /**
  52785. * Update a dynamic index buffer
  52786. * @param indexBuffer defines the target index buffer
  52787. * @param indices defines the data to update
  52788. * @param offset defines the offset in the target index buffer where update should start
  52789. */
  52790. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52791. /**
  52792. * Updates a dynamic vertex buffer.
  52793. * @param vertexBuffer the vertex buffer to update
  52794. * @param vertices the data used to update the vertex buffer
  52795. * @param byteOffset the byte offset of the data (optional)
  52796. * @param byteLength the byte length of the data (optional)
  52797. */
  52798. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52799. /** @hidden */
  52800. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52801. /** @hidden */
  52802. _bindTexture(channel: number, texture: InternalTexture): void;
  52803. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52804. /**
  52805. * 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
  52806. */
  52807. releaseEffects(): void;
  52808. displayLoadingUI(): void;
  52809. hideLoadingUI(): void;
  52810. /** @hidden */
  52811. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52812. /** @hidden */
  52813. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52814. /** @hidden */
  52815. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52816. /** @hidden */
  52817. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52818. }
  52819. }
  52820. declare module "babylonjs/Instrumentation/timeToken" {
  52821. import { Nullable } from "babylonjs/types";
  52822. /**
  52823. * @hidden
  52824. **/
  52825. export class _TimeToken {
  52826. _startTimeQuery: Nullable<WebGLQuery>;
  52827. _endTimeQuery: Nullable<WebGLQuery>;
  52828. _timeElapsedQuery: Nullable<WebGLQuery>;
  52829. _timeElapsedQueryEnded: boolean;
  52830. }
  52831. }
  52832. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52833. import { Nullable, int } from "babylonjs/types";
  52834. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52835. /** @hidden */
  52836. export class _OcclusionDataStorage {
  52837. /** @hidden */
  52838. occlusionInternalRetryCounter: number;
  52839. /** @hidden */
  52840. isOcclusionQueryInProgress: boolean;
  52841. /** @hidden */
  52842. isOccluded: boolean;
  52843. /** @hidden */
  52844. occlusionRetryCount: number;
  52845. /** @hidden */
  52846. occlusionType: number;
  52847. /** @hidden */
  52848. occlusionQueryAlgorithmType: number;
  52849. }
  52850. module "babylonjs/Engines/engine" {
  52851. interface Engine {
  52852. /**
  52853. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52854. * @return the new query
  52855. */
  52856. createQuery(): WebGLQuery;
  52857. /**
  52858. * Delete and release a webGL query
  52859. * @param query defines the query to delete
  52860. * @return the current engine
  52861. */
  52862. deleteQuery(query: WebGLQuery): Engine;
  52863. /**
  52864. * Check if a given query has resolved and got its value
  52865. * @param query defines the query to check
  52866. * @returns true if the query got its value
  52867. */
  52868. isQueryResultAvailable(query: WebGLQuery): boolean;
  52869. /**
  52870. * Gets the value of a given query
  52871. * @param query defines the query to check
  52872. * @returns the value of the query
  52873. */
  52874. getQueryResult(query: WebGLQuery): number;
  52875. /**
  52876. * Initiates an occlusion query
  52877. * @param algorithmType defines the algorithm to use
  52878. * @param query defines the query to use
  52879. * @returns the current engine
  52880. * @see http://doc.babylonjs.com/features/occlusionquery
  52881. */
  52882. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52883. /**
  52884. * Ends an occlusion query
  52885. * @see http://doc.babylonjs.com/features/occlusionquery
  52886. * @param algorithmType defines the algorithm to use
  52887. * @returns the current engine
  52888. */
  52889. endOcclusionQuery(algorithmType: number): Engine;
  52890. /**
  52891. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52892. * Please note that only one query can be issued at a time
  52893. * @returns a time token used to track the time span
  52894. */
  52895. startTimeQuery(): Nullable<_TimeToken>;
  52896. /**
  52897. * Ends a time query
  52898. * @param token defines the token used to measure the time span
  52899. * @returns the time spent (in ns)
  52900. */
  52901. endTimeQuery(token: _TimeToken): int;
  52902. /** @hidden */
  52903. _currentNonTimestampToken: Nullable<_TimeToken>;
  52904. /** @hidden */
  52905. _createTimeQuery(): WebGLQuery;
  52906. /** @hidden */
  52907. _deleteTimeQuery(query: WebGLQuery): void;
  52908. /** @hidden */
  52909. _getGlAlgorithmType(algorithmType: number): number;
  52910. /** @hidden */
  52911. _getTimeQueryResult(query: WebGLQuery): any;
  52912. /** @hidden */
  52913. _getTimeQueryAvailability(query: WebGLQuery): any;
  52914. }
  52915. }
  52916. module "babylonjs/Meshes/abstractMesh" {
  52917. interface AbstractMesh {
  52918. /**
  52919. * Backing filed
  52920. * @hidden
  52921. */
  52922. __occlusionDataStorage: _OcclusionDataStorage;
  52923. /**
  52924. * Access property
  52925. * @hidden
  52926. */
  52927. _occlusionDataStorage: _OcclusionDataStorage;
  52928. /**
  52929. * 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.
  52930. * The default value is -1 which means don't break the query and wait till the result
  52931. * @see http://doc.babylonjs.com/features/occlusionquery
  52932. */
  52933. occlusionRetryCount: number;
  52934. /**
  52935. * 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:
  52936. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52937. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52938. * * 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.
  52939. * @see http://doc.babylonjs.com/features/occlusionquery
  52940. */
  52941. occlusionType: number;
  52942. /**
  52943. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52944. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52945. * * 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.
  52946. * @see http://doc.babylonjs.com/features/occlusionquery
  52947. */
  52948. occlusionQueryAlgorithmType: number;
  52949. /**
  52950. * 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
  52951. * @see http://doc.babylonjs.com/features/occlusionquery
  52952. */
  52953. isOccluded: boolean;
  52954. /**
  52955. * Flag to check the progress status of the query
  52956. * @see http://doc.babylonjs.com/features/occlusionquery
  52957. */
  52958. isOcclusionQueryInProgress: boolean;
  52959. }
  52960. }
  52961. }
  52962. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  52963. import { Nullable } from "babylonjs/types";
  52964. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52965. /** @hidden */
  52966. export var _forceTransformFeedbackToBundle: boolean;
  52967. module "babylonjs/Engines/engine" {
  52968. interface Engine {
  52969. /**
  52970. * Creates a webGL transform feedback object
  52971. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52972. * @returns the webGL transform feedback object
  52973. */
  52974. createTransformFeedback(): WebGLTransformFeedback;
  52975. /**
  52976. * Delete a webGL transform feedback object
  52977. * @param value defines the webGL transform feedback object to delete
  52978. */
  52979. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52980. /**
  52981. * Bind a webGL transform feedback object to the webgl context
  52982. * @param value defines the webGL transform feedback object to bind
  52983. */
  52984. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52985. /**
  52986. * Begins a transform feedback operation
  52987. * @param usePoints defines if points or triangles must be used
  52988. */
  52989. beginTransformFeedback(usePoints: boolean): void;
  52990. /**
  52991. * Ends a transform feedback operation
  52992. */
  52993. endTransformFeedback(): void;
  52994. /**
  52995. * Specify the varyings to use with transform feedback
  52996. * @param program defines the associated webGL program
  52997. * @param value defines the list of strings representing the varying names
  52998. */
  52999. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  53000. /**
  53001. * Bind a webGL buffer for a transform feedback operation
  53002. * @param value defines the webGL buffer to bind
  53003. */
  53004. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  53005. }
  53006. }
  53007. }
  53008. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  53009. import { Scene } from "babylonjs/scene";
  53010. import { Engine } from "babylonjs/Engines/engine";
  53011. import { Texture } from "babylonjs/Materials/Textures/texture";
  53012. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53013. import "babylonjs/Engines/Extensions/engine.multiRender";
  53014. /**
  53015. * Creation options of the multi render target texture.
  53016. */
  53017. export interface IMultiRenderTargetOptions {
  53018. /**
  53019. * Define if the texture needs to create mip maps after render.
  53020. */
  53021. generateMipMaps?: boolean;
  53022. /**
  53023. * Define the types of all the draw buffers we want to create
  53024. */
  53025. types?: number[];
  53026. /**
  53027. * Define the sampling modes of all the draw buffers we want to create
  53028. */
  53029. samplingModes?: number[];
  53030. /**
  53031. * Define if a depth buffer is required
  53032. */
  53033. generateDepthBuffer?: boolean;
  53034. /**
  53035. * Define if a stencil buffer is required
  53036. */
  53037. generateStencilBuffer?: boolean;
  53038. /**
  53039. * Define if a depth texture is required instead of a depth buffer
  53040. */
  53041. generateDepthTexture?: boolean;
  53042. /**
  53043. * Define the number of desired draw buffers
  53044. */
  53045. textureCount?: number;
  53046. /**
  53047. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53048. */
  53049. doNotChangeAspectRatio?: boolean;
  53050. /**
  53051. * Define the default type of the buffers we are creating
  53052. */
  53053. defaultType?: number;
  53054. }
  53055. /**
  53056. * A multi render target, like a render target provides the ability to render to a texture.
  53057. * Unlike the render target, it can render to several draw buffers in one draw.
  53058. * This is specially interesting in deferred rendering or for any effects requiring more than
  53059. * just one color from a single pass.
  53060. */
  53061. export class MultiRenderTarget extends RenderTargetTexture {
  53062. private _internalTextures;
  53063. private _textures;
  53064. private _multiRenderTargetOptions;
  53065. /**
  53066. * Get if draw buffers are currently supported by the used hardware and browser.
  53067. */
  53068. get isSupported(): boolean;
  53069. /**
  53070. * Get the list of textures generated by the multi render target.
  53071. */
  53072. get textures(): Texture[];
  53073. /**
  53074. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53075. */
  53076. get depthTexture(): Texture;
  53077. /**
  53078. * Set the wrapping mode on U of all the textures we are rendering to.
  53079. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53080. */
  53081. set wrapU(wrap: number);
  53082. /**
  53083. * Set the wrapping mode on V of all the textures we are rendering to.
  53084. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53085. */
  53086. set wrapV(wrap: number);
  53087. /**
  53088. * Instantiate a new multi render target texture.
  53089. * A multi render target, like a render target provides the ability to render to a texture.
  53090. * Unlike the render target, it can render to several draw buffers in one draw.
  53091. * This is specially interesting in deferred rendering or for any effects requiring more than
  53092. * just one color from a single pass.
  53093. * @param name Define the name of the texture
  53094. * @param size Define the size of the buffers to render to
  53095. * @param count Define the number of target we are rendering into
  53096. * @param scene Define the scene the texture belongs to
  53097. * @param options Define the options used to create the multi render target
  53098. */
  53099. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53100. /** @hidden */
  53101. _rebuild(): void;
  53102. private _createInternalTextures;
  53103. private _createTextures;
  53104. /**
  53105. * Define the number of samples used if MSAA is enabled.
  53106. */
  53107. get samples(): number;
  53108. set samples(value: number);
  53109. /**
  53110. * Resize all the textures in the multi render target.
  53111. * Be carrefull as it will recreate all the data in the new texture.
  53112. * @param size Define the new size
  53113. */
  53114. resize(size: any): void;
  53115. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53116. /**
  53117. * Dispose the render targets and their associated resources
  53118. */
  53119. dispose(): void;
  53120. /**
  53121. * Release all the underlying texture used as draw buffers.
  53122. */
  53123. releaseInternalTextures(): void;
  53124. }
  53125. }
  53126. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53127. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53128. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53129. import { Nullable } from "babylonjs/types";
  53130. module "babylonjs/Engines/thinEngine" {
  53131. interface ThinEngine {
  53132. /**
  53133. * Unbind a list of render target textures from the webGL context
  53134. * This is used only when drawBuffer extension or webGL2 are active
  53135. * @param textures defines the render target textures to unbind
  53136. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53137. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53138. */
  53139. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53140. /**
  53141. * Create a multi render target texture
  53142. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  53143. * @param size defines the size of the texture
  53144. * @param options defines the creation options
  53145. * @returns the cube texture as an InternalTexture
  53146. */
  53147. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53148. /**
  53149. * Update the sample count for a given multiple render target texture
  53150. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53151. * @param textures defines the textures to update
  53152. * @param samples defines the sample count to set
  53153. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53154. */
  53155. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53156. }
  53157. }
  53158. }
  53159. declare module "babylonjs/Engines/Extensions/engine.views" {
  53160. import { Camera } from "babylonjs/Cameras/camera";
  53161. import { Nullable } from "babylonjs/types";
  53162. /**
  53163. * Class used to define an additional view for the engine
  53164. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53165. */
  53166. export class EngineView {
  53167. /** Defines the canvas where to render the view */
  53168. target: HTMLCanvasElement;
  53169. /** Defines an optional camera used to render the view (will use active camera else) */
  53170. camera?: Camera;
  53171. }
  53172. module "babylonjs/Engines/engine" {
  53173. interface Engine {
  53174. /**
  53175. * Gets or sets the HTML element to use for attaching events
  53176. */
  53177. inputElement: Nullable<HTMLElement>;
  53178. /**
  53179. * Gets the current engine view
  53180. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53181. */
  53182. activeView: Nullable<EngineView>;
  53183. /** Gets or sets the list of views */
  53184. views: EngineView[];
  53185. /**
  53186. * Register a new child canvas
  53187. * @param canvas defines the canvas to register
  53188. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53189. * @returns the associated view
  53190. */
  53191. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53192. /**
  53193. * Remove a registered child canvas
  53194. * @param canvas defines the canvas to remove
  53195. * @returns the current engine
  53196. */
  53197. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53198. }
  53199. }
  53200. }
  53201. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53202. import { Nullable } from "babylonjs/types";
  53203. module "babylonjs/Engines/engine" {
  53204. interface Engine {
  53205. /** @hidden */
  53206. _excludedCompressedTextures: string[];
  53207. /** @hidden */
  53208. _textureFormatInUse: string;
  53209. /**
  53210. * Gets the list of texture formats supported
  53211. */
  53212. readonly texturesSupported: Array<string>;
  53213. /**
  53214. * Gets the texture format in use
  53215. */
  53216. readonly textureFormatInUse: Nullable<string>;
  53217. /**
  53218. * Set the compressed texture extensions or file names to skip.
  53219. *
  53220. * @param skippedFiles defines the list of those texture files you want to skip
  53221. * Example: [".dds", ".env", "myfile.png"]
  53222. */
  53223. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53224. /**
  53225. * Set the compressed texture format to use, based on the formats you have, and the formats
  53226. * supported by the hardware / browser.
  53227. *
  53228. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53229. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53230. * to API arguments needed to compressed textures. This puts the burden on the container
  53231. * generator to house the arcane code for determining these for current & future formats.
  53232. *
  53233. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53234. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53235. *
  53236. * Note: The result of this call is not taken into account when a texture is base64.
  53237. *
  53238. * @param formatsAvailable defines the list of those format families you have created
  53239. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53240. *
  53241. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53242. * @returns The extension selected.
  53243. */
  53244. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53245. }
  53246. }
  53247. }
  53248. declare module "babylonjs/Engines/Extensions/index" {
  53249. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53250. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53251. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53252. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53253. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53254. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53255. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53256. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53257. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53258. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53259. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53260. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53261. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53262. export * from "babylonjs/Engines/Extensions/engine.views";
  53263. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53264. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53265. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53266. }
  53267. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53268. import { Nullable } from "babylonjs/types";
  53269. /**
  53270. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53271. */
  53272. export interface CubeMapInfo {
  53273. /**
  53274. * The pixel array for the front face.
  53275. * This is stored in format, left to right, up to down format.
  53276. */
  53277. front: Nullable<ArrayBufferView>;
  53278. /**
  53279. * The pixel array for the back face.
  53280. * This is stored in format, left to right, up to down format.
  53281. */
  53282. back: Nullable<ArrayBufferView>;
  53283. /**
  53284. * The pixel array for the left face.
  53285. * This is stored in format, left to right, up to down format.
  53286. */
  53287. left: Nullable<ArrayBufferView>;
  53288. /**
  53289. * The pixel array for the right face.
  53290. * This is stored in format, left to right, up to down format.
  53291. */
  53292. right: Nullable<ArrayBufferView>;
  53293. /**
  53294. * The pixel array for the up face.
  53295. * This is stored in format, left to right, up to down format.
  53296. */
  53297. up: Nullable<ArrayBufferView>;
  53298. /**
  53299. * The pixel array for the down face.
  53300. * This is stored in format, left to right, up to down format.
  53301. */
  53302. down: Nullable<ArrayBufferView>;
  53303. /**
  53304. * The size of the cubemap stored.
  53305. *
  53306. * Each faces will be size * size pixels.
  53307. */
  53308. size: number;
  53309. /**
  53310. * The format of the texture.
  53311. *
  53312. * RGBA, RGB.
  53313. */
  53314. format: number;
  53315. /**
  53316. * The type of the texture data.
  53317. *
  53318. * UNSIGNED_INT, FLOAT.
  53319. */
  53320. type: number;
  53321. /**
  53322. * Specifies whether the texture is in gamma space.
  53323. */
  53324. gammaSpace: boolean;
  53325. }
  53326. /**
  53327. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53328. */
  53329. export class PanoramaToCubeMapTools {
  53330. private static FACE_LEFT;
  53331. private static FACE_RIGHT;
  53332. private static FACE_FRONT;
  53333. private static FACE_BACK;
  53334. private static FACE_DOWN;
  53335. private static FACE_UP;
  53336. /**
  53337. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53338. *
  53339. * @param float32Array The source data.
  53340. * @param inputWidth The width of the input panorama.
  53341. * @param inputHeight The height of the input panorama.
  53342. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53343. * @return The cubemap data
  53344. */
  53345. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53346. private static CreateCubemapTexture;
  53347. private static CalcProjectionSpherical;
  53348. }
  53349. }
  53350. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53351. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53352. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53353. import { Nullable } from "babylonjs/types";
  53354. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53355. /**
  53356. * Helper class dealing with the extraction of spherical polynomial dataArray
  53357. * from a cube map.
  53358. */
  53359. export class CubeMapToSphericalPolynomialTools {
  53360. private static FileFaces;
  53361. /**
  53362. * Converts a texture to the according Spherical Polynomial data.
  53363. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53364. *
  53365. * @param texture The texture to extract the information from.
  53366. * @return The Spherical Polynomial data.
  53367. */
  53368. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53369. /**
  53370. * Converts a cubemap to the according Spherical Polynomial data.
  53371. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53372. *
  53373. * @param cubeInfo The Cube map to extract the information from.
  53374. * @return The Spherical Polynomial data.
  53375. */
  53376. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53377. }
  53378. }
  53379. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53380. import { Nullable } from "babylonjs/types";
  53381. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53382. module "babylonjs/Materials/Textures/baseTexture" {
  53383. interface BaseTexture {
  53384. /**
  53385. * Get the polynomial representation of the texture data.
  53386. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53387. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53388. */
  53389. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53390. }
  53391. }
  53392. }
  53393. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53394. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53395. /** @hidden */
  53396. export var rgbdEncodePixelShader: {
  53397. name: string;
  53398. shader: string;
  53399. };
  53400. }
  53401. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53402. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53403. /** @hidden */
  53404. export var rgbdDecodePixelShader: {
  53405. name: string;
  53406. shader: string;
  53407. };
  53408. }
  53409. declare module "babylonjs/Misc/environmentTextureTools" {
  53410. import { Nullable } from "babylonjs/types";
  53411. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53412. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53413. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53414. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53415. import "babylonjs/Engines/Extensions/engine.readTexture";
  53416. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53417. import "babylonjs/Shaders/rgbdEncode.fragment";
  53418. import "babylonjs/Shaders/rgbdDecode.fragment";
  53419. /**
  53420. * Raw texture data and descriptor sufficient for WebGL texture upload
  53421. */
  53422. export interface EnvironmentTextureInfo {
  53423. /**
  53424. * Version of the environment map
  53425. */
  53426. version: number;
  53427. /**
  53428. * Width of image
  53429. */
  53430. width: number;
  53431. /**
  53432. * Irradiance information stored in the file.
  53433. */
  53434. irradiance: any;
  53435. /**
  53436. * Specular information stored in the file.
  53437. */
  53438. specular: any;
  53439. }
  53440. /**
  53441. * Defines One Image in the file. It requires only the position in the file
  53442. * as well as the length.
  53443. */
  53444. interface BufferImageData {
  53445. /**
  53446. * Length of the image data.
  53447. */
  53448. length: number;
  53449. /**
  53450. * Position of the data from the null terminator delimiting the end of the JSON.
  53451. */
  53452. position: number;
  53453. }
  53454. /**
  53455. * Defines the specular data enclosed in the file.
  53456. * This corresponds to the version 1 of the data.
  53457. */
  53458. export interface EnvironmentTextureSpecularInfoV1 {
  53459. /**
  53460. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53461. */
  53462. specularDataPosition?: number;
  53463. /**
  53464. * This contains all the images data needed to reconstruct the cubemap.
  53465. */
  53466. mipmaps: Array<BufferImageData>;
  53467. /**
  53468. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53469. */
  53470. lodGenerationScale: number;
  53471. }
  53472. /**
  53473. * Sets of helpers addressing the serialization and deserialization of environment texture
  53474. * stored in a BabylonJS env file.
  53475. * Those files are usually stored as .env files.
  53476. */
  53477. export class EnvironmentTextureTools {
  53478. /**
  53479. * Magic number identifying the env file.
  53480. */
  53481. private static _MagicBytes;
  53482. /**
  53483. * Gets the environment info from an env file.
  53484. * @param data The array buffer containing the .env bytes.
  53485. * @returns the environment file info (the json header) if successfully parsed.
  53486. */
  53487. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53488. /**
  53489. * Creates an environment texture from a loaded cube texture.
  53490. * @param texture defines the cube texture to convert in env file
  53491. * @return a promise containing the environment data if succesfull.
  53492. */
  53493. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53494. /**
  53495. * Creates a JSON representation of the spherical data.
  53496. * @param texture defines the texture containing the polynomials
  53497. * @return the JSON representation of the spherical info
  53498. */
  53499. private static _CreateEnvTextureIrradiance;
  53500. /**
  53501. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53502. * @param data the image data
  53503. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53504. * @return the views described by info providing access to the underlying buffer
  53505. */
  53506. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53507. /**
  53508. * Uploads the texture info contained in the env file to the GPU.
  53509. * @param texture defines the internal texture to upload to
  53510. * @param data defines the data to load
  53511. * @param info defines the texture info retrieved through the GetEnvInfo method
  53512. * @returns a promise
  53513. */
  53514. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53515. private static _OnImageReadyAsync;
  53516. /**
  53517. * Uploads the levels of image data to the GPU.
  53518. * @param texture defines the internal texture to upload to
  53519. * @param imageData defines the array buffer views of image data [mipmap][face]
  53520. * @returns a promise
  53521. */
  53522. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53523. /**
  53524. * Uploads spherical polynomials information to the texture.
  53525. * @param texture defines the texture we are trying to upload the information to
  53526. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53527. */
  53528. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53529. /** @hidden */
  53530. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53531. }
  53532. }
  53533. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53534. /**
  53535. * Class used to inline functions in shader code
  53536. */
  53537. export class ShaderCodeInliner {
  53538. private static readonly _RegexpFindFunctionNameAndType;
  53539. private _sourceCode;
  53540. private _functionDescr;
  53541. private _numMaxIterations;
  53542. /** Gets or sets the token used to mark the functions to inline */
  53543. inlineToken: string;
  53544. /** Gets or sets the debug mode */
  53545. debug: boolean;
  53546. /** Gets the code after the inlining process */
  53547. get code(): string;
  53548. /**
  53549. * Initializes the inliner
  53550. * @param sourceCode shader code source to inline
  53551. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53552. */
  53553. constructor(sourceCode: string, numMaxIterations?: number);
  53554. /**
  53555. * Start the processing of the shader code
  53556. */
  53557. processCode(): void;
  53558. private _collectFunctions;
  53559. private _processInlining;
  53560. private _extractBetweenMarkers;
  53561. private _skipWhitespaces;
  53562. private _removeComments;
  53563. private _replaceFunctionCallsByCode;
  53564. private _findBackward;
  53565. private _escapeRegExp;
  53566. private _replaceNames;
  53567. }
  53568. }
  53569. declare module "babylonjs/Engines/nativeEngine" {
  53570. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53571. import { Engine } from "babylonjs/Engines/engine";
  53572. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53575. import { Effect } from "babylonjs/Materials/effect";
  53576. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53577. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53578. import { IColor4Like } from "babylonjs/Maths/math.like";
  53579. import { Scene } from "babylonjs/scene";
  53580. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53581. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53582. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53583. /**
  53584. * Container for accessors for natively-stored mesh data buffers.
  53585. */
  53586. class NativeDataBuffer extends DataBuffer {
  53587. /**
  53588. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53589. */
  53590. nativeIndexBuffer?: any;
  53591. /**
  53592. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53593. */
  53594. nativeVertexBuffer?: any;
  53595. }
  53596. /** @hidden */
  53597. class NativeTexture extends InternalTexture {
  53598. getInternalTexture(): InternalTexture;
  53599. getViewCount(): number;
  53600. }
  53601. /** @hidden */
  53602. export class NativeEngine extends Engine {
  53603. private readonly _native;
  53604. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53605. private readonly INVALID_HANDLE;
  53606. getHardwareScalingLevel(): number;
  53607. constructor();
  53608. dispose(): void;
  53609. /**
  53610. * Can be used to override the current requestAnimationFrame requester.
  53611. * @hidden
  53612. */
  53613. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53614. /**
  53615. * Override default engine behavior.
  53616. * @param color
  53617. * @param backBuffer
  53618. * @param depth
  53619. * @param stencil
  53620. */
  53621. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53622. /**
  53623. * Gets host document
  53624. * @returns the host document object
  53625. */
  53626. getHostDocument(): Nullable<Document>;
  53627. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53628. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53629. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53630. recordVertexArrayObject(vertexBuffers: {
  53631. [key: string]: VertexBuffer;
  53632. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53633. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53634. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53635. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53636. /**
  53637. * Draw a list of indexed primitives
  53638. * @param fillMode defines the primitive to use
  53639. * @param indexStart defines the starting index
  53640. * @param indexCount defines the number of index to draw
  53641. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53642. */
  53643. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53644. /**
  53645. * Draw a list of unindexed primitives
  53646. * @param fillMode defines the primitive to use
  53647. * @param verticesStart defines the index of first vertex to draw
  53648. * @param verticesCount defines the count of vertices to draw
  53649. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53650. */
  53651. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53652. createPipelineContext(): IPipelineContext;
  53653. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53654. /** @hidden */
  53655. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53656. /** @hidden */
  53657. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53658. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53659. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53660. protected _setProgram(program: WebGLProgram): void;
  53661. _releaseEffect(effect: Effect): void;
  53662. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53663. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53664. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53665. bindSamplers(effect: Effect): void;
  53666. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53667. getRenderWidth(useScreen?: boolean): number;
  53668. getRenderHeight(useScreen?: boolean): number;
  53669. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53670. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53671. /**
  53672. * Set the z offset to apply to current rendering
  53673. * @param value defines the offset to apply
  53674. */
  53675. setZOffset(value: number): void;
  53676. /**
  53677. * Gets the current value of the zOffset
  53678. * @returns the current zOffset state
  53679. */
  53680. getZOffset(): number;
  53681. /**
  53682. * Enable or disable depth buffering
  53683. * @param enable defines the state to set
  53684. */
  53685. setDepthBuffer(enable: boolean): void;
  53686. /**
  53687. * Gets a boolean indicating if depth writing is enabled
  53688. * @returns the current depth writing state
  53689. */
  53690. getDepthWrite(): boolean;
  53691. /**
  53692. * Enable or disable depth writing
  53693. * @param enable defines the state to set
  53694. */
  53695. setDepthWrite(enable: boolean): void;
  53696. /**
  53697. * Enable or disable color writing
  53698. * @param enable defines the state to set
  53699. */
  53700. setColorWrite(enable: boolean): void;
  53701. /**
  53702. * Gets a boolean indicating if color writing is enabled
  53703. * @returns the current color writing state
  53704. */
  53705. getColorWrite(): boolean;
  53706. /**
  53707. * Sets alpha constants used by some alpha blending modes
  53708. * @param r defines the red component
  53709. * @param g defines the green component
  53710. * @param b defines the blue component
  53711. * @param a defines the alpha component
  53712. */
  53713. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53714. /**
  53715. * Sets the current alpha mode
  53716. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53717. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53718. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53719. */
  53720. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53721. /**
  53722. * Gets the current alpha mode
  53723. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53724. * @returns the current alpha mode
  53725. */
  53726. getAlphaMode(): number;
  53727. setInt(uniform: WebGLUniformLocation, int: number): void;
  53728. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53729. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53730. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53731. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53732. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53733. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53734. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53735. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53736. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53737. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53738. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53739. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53740. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53741. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53742. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53743. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53744. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53745. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53746. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53747. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53748. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53749. wipeCaches(bruteForce?: boolean): void;
  53750. _createTexture(): WebGLTexture;
  53751. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53752. /**
  53753. * Usually called from Texture.ts.
  53754. * Passed information to create a WebGLTexture
  53755. * @param url defines a value which contains one of the following:
  53756. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53757. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53758. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53759. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53760. * @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)
  53761. * @param scene needed for loading to the correct scene
  53762. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53763. * @param onLoad optional callback to be called upon successful completion
  53764. * @param onError optional callback to be called upon failure
  53765. * @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
  53766. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53767. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53768. * @param forcedExtension defines the extension to use to pick the right loader
  53769. * @param mimeType defines an optional mime type
  53770. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53771. */
  53772. 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;
  53773. /**
  53774. * Creates a cube texture
  53775. * @param rootUrl defines the url where the files to load is located
  53776. * @param scene defines the current scene
  53777. * @param files defines the list of files to load (1 per face)
  53778. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53779. * @param onLoad defines an optional callback raised when the texture is loaded
  53780. * @param onError defines an optional callback raised if there is an issue to load the texture
  53781. * @param format defines the format of the data
  53782. * @param forcedExtension defines the extension to use to pick the right loader
  53783. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53784. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53785. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53786. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53787. * @returns the cube texture as an InternalTexture
  53788. */
  53789. 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;
  53790. private _getSamplingFilter;
  53791. private static _GetNativeTextureFormat;
  53792. createRenderTargetTexture(size: number | {
  53793. width: number;
  53794. height: number;
  53795. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53796. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53797. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53798. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53799. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53800. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53801. /**
  53802. * Updates a dynamic vertex buffer.
  53803. * @param vertexBuffer the vertex buffer to update
  53804. * @param data the data used to update the vertex buffer
  53805. * @param byteOffset the byte offset of the data (optional)
  53806. * @param byteLength the byte length of the data (optional)
  53807. */
  53808. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53809. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53810. private _updateAnisotropicLevel;
  53811. private _getAddressMode;
  53812. /** @hidden */
  53813. _bindTexture(channel: number, texture: InternalTexture): void;
  53814. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53815. releaseEffects(): void;
  53816. /** @hidden */
  53817. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53818. /** @hidden */
  53819. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53820. /** @hidden */
  53821. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53822. /** @hidden */
  53823. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53824. }
  53825. }
  53826. declare module "babylonjs/Engines/index" {
  53827. export * from "babylonjs/Engines/constants";
  53828. export * from "babylonjs/Engines/engineCapabilities";
  53829. export * from "babylonjs/Engines/instancingAttributeInfo";
  53830. export * from "babylonjs/Engines/thinEngine";
  53831. export * from "babylonjs/Engines/engine";
  53832. export * from "babylonjs/Engines/engineStore";
  53833. export * from "babylonjs/Engines/nullEngine";
  53834. export * from "babylonjs/Engines/Extensions/index";
  53835. export * from "babylonjs/Engines/IPipelineContext";
  53836. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53837. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53838. export * from "babylonjs/Engines/nativeEngine";
  53839. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  53840. }
  53841. declare module "babylonjs/Events/clipboardEvents" {
  53842. /**
  53843. * Gather the list of clipboard event types as constants.
  53844. */
  53845. export class ClipboardEventTypes {
  53846. /**
  53847. * The clipboard event is fired when a copy command is active (pressed).
  53848. */
  53849. static readonly COPY: number;
  53850. /**
  53851. * The clipboard event is fired when a cut command is active (pressed).
  53852. */
  53853. static readonly CUT: number;
  53854. /**
  53855. * The clipboard event is fired when a paste command is active (pressed).
  53856. */
  53857. static readonly PASTE: number;
  53858. }
  53859. /**
  53860. * This class is used to store clipboard related info for the onClipboardObservable event.
  53861. */
  53862. export class ClipboardInfo {
  53863. /**
  53864. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53865. */
  53866. type: number;
  53867. /**
  53868. * Defines the related dom event
  53869. */
  53870. event: ClipboardEvent;
  53871. /**
  53872. *Creates an instance of ClipboardInfo.
  53873. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53874. * @param event Defines the related dom event
  53875. */
  53876. constructor(
  53877. /**
  53878. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53879. */
  53880. type: number,
  53881. /**
  53882. * Defines the related dom event
  53883. */
  53884. event: ClipboardEvent);
  53885. /**
  53886. * Get the clipboard event's type from the keycode.
  53887. * @param keyCode Defines the keyCode for the current keyboard event.
  53888. * @return {number}
  53889. */
  53890. static GetTypeFromCharacter(keyCode: number): number;
  53891. }
  53892. }
  53893. declare module "babylonjs/Events/index" {
  53894. export * from "babylonjs/Events/keyboardEvents";
  53895. export * from "babylonjs/Events/pointerEvents";
  53896. export * from "babylonjs/Events/clipboardEvents";
  53897. }
  53898. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  53899. import { Scene } from "babylonjs/scene";
  53900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53901. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53902. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53903. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53904. /**
  53905. * Google Daydream controller
  53906. */
  53907. export class DaydreamController extends WebVRController {
  53908. /**
  53909. * Base Url for the controller model.
  53910. */
  53911. static MODEL_BASE_URL: string;
  53912. /**
  53913. * File name for the controller model.
  53914. */
  53915. static MODEL_FILENAME: string;
  53916. /**
  53917. * Gamepad Id prefix used to identify Daydream Controller.
  53918. */
  53919. static readonly GAMEPAD_ID_PREFIX: string;
  53920. /**
  53921. * Creates a new DaydreamController from a gamepad
  53922. * @param vrGamepad the gamepad that the controller should be created from
  53923. */
  53924. constructor(vrGamepad: any);
  53925. /**
  53926. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53927. * @param scene scene in which to add meshes
  53928. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53929. */
  53930. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53931. /**
  53932. * Called once for each button that changed state since the last frame
  53933. * @param buttonIdx Which button index changed
  53934. * @param state New state of the button
  53935. * @param changes Which properties on the state changed since last frame
  53936. */
  53937. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53938. }
  53939. }
  53940. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  53941. import { Scene } from "babylonjs/scene";
  53942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53943. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53944. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53945. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53946. /**
  53947. * Gear VR Controller
  53948. */
  53949. export class GearVRController extends WebVRController {
  53950. /**
  53951. * Base Url for the controller model.
  53952. */
  53953. static MODEL_BASE_URL: string;
  53954. /**
  53955. * File name for the controller model.
  53956. */
  53957. static MODEL_FILENAME: string;
  53958. /**
  53959. * Gamepad Id prefix used to identify this controller.
  53960. */
  53961. static readonly GAMEPAD_ID_PREFIX: string;
  53962. private readonly _buttonIndexToObservableNameMap;
  53963. /**
  53964. * Creates a new GearVRController from a gamepad
  53965. * @param vrGamepad the gamepad that the controller should be created from
  53966. */
  53967. constructor(vrGamepad: any);
  53968. /**
  53969. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53970. * @param scene scene in which to add meshes
  53971. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53972. */
  53973. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53974. /**
  53975. * Called once for each button that changed state since the last frame
  53976. * @param buttonIdx Which button index changed
  53977. * @param state New state of the button
  53978. * @param changes Which properties on the state changed since last frame
  53979. */
  53980. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53981. }
  53982. }
  53983. declare module "babylonjs/Gamepads/Controllers/genericController" {
  53984. import { Scene } from "babylonjs/scene";
  53985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53986. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53987. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53988. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53989. /**
  53990. * Generic Controller
  53991. */
  53992. export class GenericController extends WebVRController {
  53993. /**
  53994. * Base Url for the controller model.
  53995. */
  53996. static readonly MODEL_BASE_URL: string;
  53997. /**
  53998. * File name for the controller model.
  53999. */
  54000. static readonly MODEL_FILENAME: string;
  54001. /**
  54002. * Creates a new GenericController from a gamepad
  54003. * @param vrGamepad the gamepad that the controller should be created from
  54004. */
  54005. constructor(vrGamepad: any);
  54006. /**
  54007. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54008. * @param scene scene in which to add meshes
  54009. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54010. */
  54011. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54012. /**
  54013. * Called once for each button that changed state since the last frame
  54014. * @param buttonIdx Which button index changed
  54015. * @param state New state of the button
  54016. * @param changes Which properties on the state changed since last frame
  54017. */
  54018. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54019. }
  54020. }
  54021. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54022. import { Observable } from "babylonjs/Misc/observable";
  54023. import { Scene } from "babylonjs/scene";
  54024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54025. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54026. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54027. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54028. /**
  54029. * Oculus Touch Controller
  54030. */
  54031. export class OculusTouchController extends WebVRController {
  54032. /**
  54033. * Base Url for the controller model.
  54034. */
  54035. static MODEL_BASE_URL: string;
  54036. /**
  54037. * File name for the left controller model.
  54038. */
  54039. static MODEL_LEFT_FILENAME: string;
  54040. /**
  54041. * File name for the right controller model.
  54042. */
  54043. static MODEL_RIGHT_FILENAME: string;
  54044. /**
  54045. * Base Url for the Quest controller model.
  54046. */
  54047. static QUEST_MODEL_BASE_URL: string;
  54048. /**
  54049. * @hidden
  54050. * If the controllers are running on a device that needs the updated Quest controller models
  54051. */
  54052. static _IsQuest: boolean;
  54053. /**
  54054. * Fired when the secondary trigger on this controller is modified
  54055. */
  54056. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54057. /**
  54058. * Fired when the thumb rest on this controller is modified
  54059. */
  54060. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54061. /**
  54062. * Creates a new OculusTouchController from a gamepad
  54063. * @param vrGamepad the gamepad that the controller should be created from
  54064. */
  54065. constructor(vrGamepad: any);
  54066. /**
  54067. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54068. * @param scene scene in which to add meshes
  54069. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54070. */
  54071. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54072. /**
  54073. * Fired when the A button on this controller is modified
  54074. */
  54075. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54076. /**
  54077. * Fired when the B button on this controller is modified
  54078. */
  54079. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54080. /**
  54081. * Fired when the X button on this controller is modified
  54082. */
  54083. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54084. /**
  54085. * Fired when the Y button on this controller is modified
  54086. */
  54087. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54088. /**
  54089. * Called once for each button that changed state since the last frame
  54090. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54091. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54092. * 2) secondary trigger (same)
  54093. * 3) A (right) X (left), touch, pressed = value
  54094. * 4) B / Y
  54095. * 5) thumb rest
  54096. * @param buttonIdx Which button index changed
  54097. * @param state New state of the button
  54098. * @param changes Which properties on the state changed since last frame
  54099. */
  54100. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54101. }
  54102. }
  54103. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54104. import { Scene } from "babylonjs/scene";
  54105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54106. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54107. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54108. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54109. import { Observable } from "babylonjs/Misc/observable";
  54110. /**
  54111. * Vive Controller
  54112. */
  54113. export class ViveController extends WebVRController {
  54114. /**
  54115. * Base Url for the controller model.
  54116. */
  54117. static MODEL_BASE_URL: string;
  54118. /**
  54119. * File name for the controller model.
  54120. */
  54121. static MODEL_FILENAME: string;
  54122. /**
  54123. * Creates a new ViveController from a gamepad
  54124. * @param vrGamepad the gamepad that the controller should be created from
  54125. */
  54126. constructor(vrGamepad: any);
  54127. /**
  54128. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54129. * @param scene scene in which to add meshes
  54130. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54131. */
  54132. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54133. /**
  54134. * Fired when the left button on this controller is modified
  54135. */
  54136. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54137. /**
  54138. * Fired when the right button on this controller is modified
  54139. */
  54140. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54141. /**
  54142. * Fired when the menu button on this controller is modified
  54143. */
  54144. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54145. /**
  54146. * Called once for each button that changed state since the last frame
  54147. * Vive mapping:
  54148. * 0: touchpad
  54149. * 1: trigger
  54150. * 2: left AND right buttons
  54151. * 3: menu button
  54152. * @param buttonIdx Which button index changed
  54153. * @param state New state of the button
  54154. * @param changes Which properties on the state changed since last frame
  54155. */
  54156. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54157. }
  54158. }
  54159. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54160. import { Observable } from "babylonjs/Misc/observable";
  54161. import { Scene } from "babylonjs/scene";
  54162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54163. import { Ray } from "babylonjs/Culling/ray";
  54164. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54165. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54166. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54167. /**
  54168. * Defines the WindowsMotionController object that the state of the windows motion controller
  54169. */
  54170. export class WindowsMotionController extends WebVRController {
  54171. /**
  54172. * The base url used to load the left and right controller models
  54173. */
  54174. static MODEL_BASE_URL: string;
  54175. /**
  54176. * The name of the left controller model file
  54177. */
  54178. static MODEL_LEFT_FILENAME: string;
  54179. /**
  54180. * The name of the right controller model file
  54181. */
  54182. static MODEL_RIGHT_FILENAME: string;
  54183. /**
  54184. * The controller name prefix for this controller type
  54185. */
  54186. static readonly GAMEPAD_ID_PREFIX: string;
  54187. /**
  54188. * The controller id pattern for this controller type
  54189. */
  54190. private static readonly GAMEPAD_ID_PATTERN;
  54191. private _loadedMeshInfo;
  54192. protected readonly _mapping: {
  54193. buttons: string[];
  54194. buttonMeshNames: {
  54195. trigger: string;
  54196. menu: string;
  54197. grip: string;
  54198. thumbstick: string;
  54199. trackpad: string;
  54200. };
  54201. buttonObservableNames: {
  54202. trigger: string;
  54203. menu: string;
  54204. grip: string;
  54205. thumbstick: string;
  54206. trackpad: string;
  54207. };
  54208. axisMeshNames: string[];
  54209. pointingPoseMeshName: string;
  54210. };
  54211. /**
  54212. * Fired when the trackpad on this controller is clicked
  54213. */
  54214. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54215. /**
  54216. * Fired when the trackpad on this controller is modified
  54217. */
  54218. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54219. /**
  54220. * The current x and y values of this controller's trackpad
  54221. */
  54222. trackpad: StickValues;
  54223. /**
  54224. * Creates a new WindowsMotionController from a gamepad
  54225. * @param vrGamepad the gamepad that the controller should be created from
  54226. */
  54227. constructor(vrGamepad: any);
  54228. /**
  54229. * Fired when the trigger on this controller is modified
  54230. */
  54231. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54232. /**
  54233. * Fired when the menu button on this controller is modified
  54234. */
  54235. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54236. /**
  54237. * Fired when the grip button on this controller is modified
  54238. */
  54239. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54240. /**
  54241. * Fired when the thumbstick button on this controller is modified
  54242. */
  54243. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54244. /**
  54245. * Fired when the touchpad button on this controller is modified
  54246. */
  54247. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54248. /**
  54249. * Fired when the touchpad values on this controller are modified
  54250. */
  54251. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54252. protected _updateTrackpad(): void;
  54253. /**
  54254. * Called once per frame by the engine.
  54255. */
  54256. update(): void;
  54257. /**
  54258. * Called once for each button that changed state since the last frame
  54259. * @param buttonIdx Which button index changed
  54260. * @param state New state of the button
  54261. * @param changes Which properties on the state changed since last frame
  54262. */
  54263. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54264. /**
  54265. * Moves the buttons on the controller mesh based on their current state
  54266. * @param buttonName the name of the button to move
  54267. * @param buttonValue the value of the button which determines the buttons new position
  54268. */
  54269. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54270. /**
  54271. * Moves the axis on the controller mesh based on its current state
  54272. * @param axis the index of the axis
  54273. * @param axisValue the value of the axis which determines the meshes new position
  54274. * @hidden
  54275. */
  54276. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54277. /**
  54278. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54279. * @param scene scene in which to add meshes
  54280. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54281. */
  54282. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54283. /**
  54284. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54285. * can be transformed by button presses and axes values, based on this._mapping.
  54286. *
  54287. * @param scene scene in which the meshes exist
  54288. * @param meshes list of meshes that make up the controller model to process
  54289. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54290. */
  54291. private processModel;
  54292. private createMeshInfo;
  54293. /**
  54294. * Gets the ray of the controller in the direction the controller is pointing
  54295. * @param length the length the resulting ray should be
  54296. * @returns a ray in the direction the controller is pointing
  54297. */
  54298. getForwardRay(length?: number): Ray;
  54299. /**
  54300. * Disposes of the controller
  54301. */
  54302. dispose(): void;
  54303. }
  54304. /**
  54305. * This class represents a new windows motion controller in XR.
  54306. */
  54307. export class XRWindowsMotionController extends WindowsMotionController {
  54308. /**
  54309. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54310. */
  54311. protected readonly _mapping: {
  54312. buttons: string[];
  54313. buttonMeshNames: {
  54314. trigger: string;
  54315. menu: string;
  54316. grip: string;
  54317. thumbstick: string;
  54318. trackpad: string;
  54319. };
  54320. buttonObservableNames: {
  54321. trigger: string;
  54322. menu: string;
  54323. grip: string;
  54324. thumbstick: string;
  54325. trackpad: string;
  54326. };
  54327. axisMeshNames: string[];
  54328. pointingPoseMeshName: string;
  54329. };
  54330. /**
  54331. * Construct a new XR-Based windows motion controller
  54332. *
  54333. * @param gamepadInfo the gamepad object from the browser
  54334. */
  54335. constructor(gamepadInfo: any);
  54336. /**
  54337. * holds the thumbstick values (X,Y)
  54338. */
  54339. thumbstickValues: StickValues;
  54340. /**
  54341. * Fired when the thumbstick on this controller is clicked
  54342. */
  54343. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54344. /**
  54345. * Fired when the thumbstick on this controller is modified
  54346. */
  54347. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54348. /**
  54349. * Fired when the touchpad button on this controller is modified
  54350. */
  54351. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54352. /**
  54353. * Fired when the touchpad values on this controller are modified
  54354. */
  54355. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54356. /**
  54357. * Fired when the thumbstick button on this controller is modified
  54358. * here to prevent breaking changes
  54359. */
  54360. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54361. /**
  54362. * updating the thumbstick(!) and not the trackpad.
  54363. * This is named this way due to the difference between WebVR and XR and to avoid
  54364. * changing the parent class.
  54365. */
  54366. protected _updateTrackpad(): void;
  54367. /**
  54368. * Disposes the class with joy
  54369. */
  54370. dispose(): void;
  54371. }
  54372. }
  54373. declare module "babylonjs/Gamepads/Controllers/index" {
  54374. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54375. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54376. export * from "babylonjs/Gamepads/Controllers/genericController";
  54377. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54378. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54379. export * from "babylonjs/Gamepads/Controllers/viveController";
  54380. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54381. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54382. }
  54383. declare module "babylonjs/Gamepads/index" {
  54384. export * from "babylonjs/Gamepads/Controllers/index";
  54385. export * from "babylonjs/Gamepads/gamepad";
  54386. export * from "babylonjs/Gamepads/gamepadManager";
  54387. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54388. export * from "babylonjs/Gamepads/xboxGamepad";
  54389. export * from "babylonjs/Gamepads/dualShockGamepad";
  54390. }
  54391. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54392. import { Scene } from "babylonjs/scene";
  54393. import { Vector4 } from "babylonjs/Maths/math.vector";
  54394. import { Color4 } from "babylonjs/Maths/math.color";
  54395. import { Mesh } from "babylonjs/Meshes/mesh";
  54396. import { Nullable } from "babylonjs/types";
  54397. /**
  54398. * Class containing static functions to help procedurally build meshes
  54399. */
  54400. export class PolyhedronBuilder {
  54401. /**
  54402. * Creates a polyhedron mesh
  54403. * * 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
  54404. * * The parameter `size` (positive float, default 1) sets the polygon size
  54405. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54406. * * 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`
  54407. * * 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
  54408. * * 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)`)
  54409. * * 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
  54410. * * 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
  54411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54414. * @param name defines the name of the mesh
  54415. * @param options defines the options used to create the mesh
  54416. * @param scene defines the hosting scene
  54417. * @returns the polyhedron mesh
  54418. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54419. */
  54420. static CreatePolyhedron(name: string, options: {
  54421. type?: number;
  54422. size?: number;
  54423. sizeX?: number;
  54424. sizeY?: number;
  54425. sizeZ?: number;
  54426. custom?: any;
  54427. faceUV?: Vector4[];
  54428. faceColors?: Color4[];
  54429. flat?: boolean;
  54430. updatable?: boolean;
  54431. sideOrientation?: number;
  54432. frontUVs?: Vector4;
  54433. backUVs?: Vector4;
  54434. }, scene?: Nullable<Scene>): Mesh;
  54435. }
  54436. }
  54437. declare module "babylonjs/Gizmos/scaleGizmo" {
  54438. import { Observable } from "babylonjs/Misc/observable";
  54439. import { Nullable } from "babylonjs/types";
  54440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54441. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54442. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54443. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54444. /**
  54445. * Gizmo that enables scaling a mesh along 3 axis
  54446. */
  54447. export class ScaleGizmo extends Gizmo {
  54448. /**
  54449. * Internal gizmo used for interactions on the x axis
  54450. */
  54451. xGizmo: AxisScaleGizmo;
  54452. /**
  54453. * Internal gizmo used for interactions on the y axis
  54454. */
  54455. yGizmo: AxisScaleGizmo;
  54456. /**
  54457. * Internal gizmo used for interactions on the z axis
  54458. */
  54459. zGizmo: AxisScaleGizmo;
  54460. /**
  54461. * Internal gizmo used to scale all axis equally
  54462. */
  54463. uniformScaleGizmo: AxisScaleGizmo;
  54464. private _meshAttached;
  54465. private _updateGizmoRotationToMatchAttachedMesh;
  54466. private _snapDistance;
  54467. private _scaleRatio;
  54468. private _uniformScalingMesh;
  54469. private _octahedron;
  54470. private _sensitivity;
  54471. /** Fires an event when any of it's sub gizmos are dragged */
  54472. onDragStartObservable: Observable<unknown>;
  54473. /** Fires an event when any of it's sub gizmos are released from dragging */
  54474. onDragEndObservable: Observable<unknown>;
  54475. get attachedMesh(): Nullable<AbstractMesh>;
  54476. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54477. /**
  54478. * Creates a ScaleGizmo
  54479. * @param gizmoLayer The utility layer the gizmo will be added to
  54480. */
  54481. constructor(gizmoLayer?: UtilityLayerRenderer);
  54482. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54483. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54484. /**
  54485. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54486. */
  54487. set snapDistance(value: number);
  54488. get snapDistance(): number;
  54489. /**
  54490. * Ratio for the scale of the gizmo (Default: 1)
  54491. */
  54492. set scaleRatio(value: number);
  54493. get scaleRatio(): number;
  54494. /**
  54495. * Sensitivity factor for dragging (Default: 1)
  54496. */
  54497. set sensitivity(value: number);
  54498. get sensitivity(): number;
  54499. /**
  54500. * Disposes of the gizmo
  54501. */
  54502. dispose(): void;
  54503. }
  54504. }
  54505. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54506. import { Observable } from "babylonjs/Misc/observable";
  54507. import { Nullable } from "babylonjs/types";
  54508. import { Vector3 } from "babylonjs/Maths/math.vector";
  54509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54510. import { Mesh } from "babylonjs/Meshes/mesh";
  54511. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54512. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54513. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54514. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54515. import { Color3 } from "babylonjs/Maths/math.color";
  54516. /**
  54517. * Single axis scale gizmo
  54518. */
  54519. export class AxisScaleGizmo extends Gizmo {
  54520. /**
  54521. * Drag behavior responsible for the gizmos dragging interactions
  54522. */
  54523. dragBehavior: PointerDragBehavior;
  54524. private _pointerObserver;
  54525. /**
  54526. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54527. */
  54528. snapDistance: number;
  54529. /**
  54530. * Event that fires each time the gizmo snaps to a new location.
  54531. * * snapDistance is the the change in distance
  54532. */
  54533. onSnapObservable: Observable<{
  54534. snapDistance: number;
  54535. }>;
  54536. /**
  54537. * If the scaling operation should be done on all axis (default: false)
  54538. */
  54539. uniformScaling: boolean;
  54540. /**
  54541. * Custom sensitivity value for the drag strength
  54542. */
  54543. sensitivity: number;
  54544. private _isEnabled;
  54545. private _parent;
  54546. private _arrow;
  54547. private _coloredMaterial;
  54548. private _hoverMaterial;
  54549. /**
  54550. * Creates an AxisScaleGizmo
  54551. * @param gizmoLayer The utility layer the gizmo will be added to
  54552. * @param dragAxis The axis which the gizmo will be able to scale on
  54553. * @param color The color of the gizmo
  54554. */
  54555. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54556. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54557. /**
  54558. * If the gizmo is enabled
  54559. */
  54560. set isEnabled(value: boolean);
  54561. get isEnabled(): boolean;
  54562. /**
  54563. * Disposes of the gizmo
  54564. */
  54565. dispose(): void;
  54566. /**
  54567. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54568. * @param mesh The mesh to replace the default mesh of the gizmo
  54569. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54570. */
  54571. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54572. }
  54573. }
  54574. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54575. import { Observable } from "babylonjs/Misc/observable";
  54576. import { Nullable } from "babylonjs/types";
  54577. import { Vector3 } from "babylonjs/Maths/math.vector";
  54578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54579. import { Mesh } from "babylonjs/Meshes/mesh";
  54580. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54581. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54582. import { Color3 } from "babylonjs/Maths/math.color";
  54583. import "babylonjs/Meshes/Builders/boxBuilder";
  54584. /**
  54585. * Bounding box gizmo
  54586. */
  54587. export class BoundingBoxGizmo extends Gizmo {
  54588. private _lineBoundingBox;
  54589. private _rotateSpheresParent;
  54590. private _scaleBoxesParent;
  54591. private _boundingDimensions;
  54592. private _renderObserver;
  54593. private _pointerObserver;
  54594. private _scaleDragSpeed;
  54595. private _tmpQuaternion;
  54596. private _tmpVector;
  54597. private _tmpRotationMatrix;
  54598. /**
  54599. * 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)
  54600. */
  54601. ignoreChildren: boolean;
  54602. /**
  54603. * 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)
  54604. */
  54605. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54606. /**
  54607. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54608. */
  54609. rotationSphereSize: number;
  54610. /**
  54611. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54612. */
  54613. scaleBoxSize: number;
  54614. /**
  54615. * 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)
  54616. */
  54617. fixedDragMeshScreenSize: boolean;
  54618. /**
  54619. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54620. */
  54621. fixedDragMeshScreenSizeDistanceFactor: number;
  54622. /**
  54623. * Fired when a rotation sphere or scale box is dragged
  54624. */
  54625. onDragStartObservable: Observable<{}>;
  54626. /**
  54627. * Fired when a scale box is dragged
  54628. */
  54629. onScaleBoxDragObservable: Observable<{}>;
  54630. /**
  54631. * Fired when a scale box drag is ended
  54632. */
  54633. onScaleBoxDragEndObservable: Observable<{}>;
  54634. /**
  54635. * Fired when a rotation sphere is dragged
  54636. */
  54637. onRotationSphereDragObservable: Observable<{}>;
  54638. /**
  54639. * Fired when a rotation sphere drag is ended
  54640. */
  54641. onRotationSphereDragEndObservable: Observable<{}>;
  54642. /**
  54643. * 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)
  54644. */
  54645. scalePivot: Nullable<Vector3>;
  54646. /**
  54647. * Mesh used as a pivot to rotate the attached mesh
  54648. */
  54649. private _anchorMesh;
  54650. private _existingMeshScale;
  54651. private _dragMesh;
  54652. private pointerDragBehavior;
  54653. private coloredMaterial;
  54654. private hoverColoredMaterial;
  54655. /**
  54656. * Sets the color of the bounding box gizmo
  54657. * @param color the color to set
  54658. */
  54659. setColor(color: Color3): void;
  54660. /**
  54661. * Creates an BoundingBoxGizmo
  54662. * @param gizmoLayer The utility layer the gizmo will be added to
  54663. * @param color The color of the gizmo
  54664. */
  54665. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54666. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54667. private _selectNode;
  54668. /**
  54669. * Updates the bounding box information for the Gizmo
  54670. */
  54671. updateBoundingBox(): void;
  54672. private _updateRotationSpheres;
  54673. private _updateScaleBoxes;
  54674. /**
  54675. * Enables rotation on the specified axis and disables rotation on the others
  54676. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54677. */
  54678. setEnabledRotationAxis(axis: string): void;
  54679. /**
  54680. * Enables/disables scaling
  54681. * @param enable if scaling should be enabled
  54682. * @param homogeneousScaling defines if scaling should only be homogeneous
  54683. */
  54684. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54685. private _updateDummy;
  54686. /**
  54687. * Enables a pointer drag behavior on the bounding box of the gizmo
  54688. */
  54689. enableDragBehavior(): void;
  54690. /**
  54691. * Disposes of the gizmo
  54692. */
  54693. dispose(): void;
  54694. /**
  54695. * 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)
  54696. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54697. * @returns the bounding box mesh with the passed in mesh as a child
  54698. */
  54699. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54700. /**
  54701. * CustomMeshes are not supported by this gizmo
  54702. * @param mesh The mesh to replace the default mesh of the gizmo
  54703. */
  54704. setCustomMesh(mesh: Mesh): void;
  54705. }
  54706. }
  54707. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54708. import { Observable } from "babylonjs/Misc/observable";
  54709. import { Nullable } from "babylonjs/types";
  54710. import { Vector3 } from "babylonjs/Maths/math.vector";
  54711. import { Color3 } from "babylonjs/Maths/math.color";
  54712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54713. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54714. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54715. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54716. import "babylonjs/Meshes/Builders/linesBuilder";
  54717. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54718. /**
  54719. * Single plane rotation gizmo
  54720. */
  54721. export class PlaneRotationGizmo extends Gizmo {
  54722. /**
  54723. * Drag behavior responsible for the gizmos dragging interactions
  54724. */
  54725. dragBehavior: PointerDragBehavior;
  54726. private _pointerObserver;
  54727. /**
  54728. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54729. */
  54730. snapDistance: number;
  54731. /**
  54732. * Event that fires each time the gizmo snaps to a new location.
  54733. * * snapDistance is the the change in distance
  54734. */
  54735. onSnapObservable: Observable<{
  54736. snapDistance: number;
  54737. }>;
  54738. private _isEnabled;
  54739. private _parent;
  54740. /**
  54741. * Creates a PlaneRotationGizmo
  54742. * @param gizmoLayer The utility layer the gizmo will be added to
  54743. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54744. * @param color The color of the gizmo
  54745. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54746. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54747. */
  54748. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54749. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54750. /**
  54751. * If the gizmo is enabled
  54752. */
  54753. set isEnabled(value: boolean);
  54754. get isEnabled(): boolean;
  54755. /**
  54756. * Disposes of the gizmo
  54757. */
  54758. dispose(): void;
  54759. }
  54760. }
  54761. declare module "babylonjs/Gizmos/rotationGizmo" {
  54762. import { Observable } from "babylonjs/Misc/observable";
  54763. import { Nullable } from "babylonjs/types";
  54764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54765. import { Mesh } from "babylonjs/Meshes/mesh";
  54766. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54767. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54768. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54769. /**
  54770. * Gizmo that enables rotating a mesh along 3 axis
  54771. */
  54772. export class RotationGizmo extends Gizmo {
  54773. /**
  54774. * Internal gizmo used for interactions on the x axis
  54775. */
  54776. xGizmo: PlaneRotationGizmo;
  54777. /**
  54778. * Internal gizmo used for interactions on the y axis
  54779. */
  54780. yGizmo: PlaneRotationGizmo;
  54781. /**
  54782. * Internal gizmo used for interactions on the z axis
  54783. */
  54784. zGizmo: PlaneRotationGizmo;
  54785. /** Fires an event when any of it's sub gizmos are dragged */
  54786. onDragStartObservable: Observable<unknown>;
  54787. /** Fires an event when any of it's sub gizmos are released from dragging */
  54788. onDragEndObservable: Observable<unknown>;
  54789. private _meshAttached;
  54790. get attachedMesh(): Nullable<AbstractMesh>;
  54791. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54792. /**
  54793. * Creates a RotationGizmo
  54794. * @param gizmoLayer The utility layer the gizmo will be added to
  54795. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54796. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54797. */
  54798. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54799. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54800. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54801. /**
  54802. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54803. */
  54804. set snapDistance(value: number);
  54805. get snapDistance(): number;
  54806. /**
  54807. * Ratio for the scale of the gizmo (Default: 1)
  54808. */
  54809. set scaleRatio(value: number);
  54810. get scaleRatio(): number;
  54811. /**
  54812. * Disposes of the gizmo
  54813. */
  54814. dispose(): void;
  54815. /**
  54816. * CustomMeshes are not supported by this gizmo
  54817. * @param mesh The mesh to replace the default mesh of the gizmo
  54818. */
  54819. setCustomMesh(mesh: Mesh): void;
  54820. }
  54821. }
  54822. declare module "babylonjs/Gizmos/gizmoManager" {
  54823. import { Observable } from "babylonjs/Misc/observable";
  54824. import { Nullable } from "babylonjs/types";
  54825. import { Scene, IDisposable } from "babylonjs/scene";
  54826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54827. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54828. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54829. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54830. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54831. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54832. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54833. /**
  54834. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54835. */
  54836. export class GizmoManager implements IDisposable {
  54837. private scene;
  54838. /**
  54839. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54840. */
  54841. gizmos: {
  54842. positionGizmo: Nullable<PositionGizmo>;
  54843. rotationGizmo: Nullable<RotationGizmo>;
  54844. scaleGizmo: Nullable<ScaleGizmo>;
  54845. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54846. };
  54847. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54848. clearGizmoOnEmptyPointerEvent: boolean;
  54849. /** Fires an event when the manager is attached to a mesh */
  54850. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54851. private _gizmosEnabled;
  54852. private _pointerObserver;
  54853. private _attachedMesh;
  54854. private _boundingBoxColor;
  54855. private _defaultUtilityLayer;
  54856. private _defaultKeepDepthUtilityLayer;
  54857. /**
  54858. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54859. */
  54860. boundingBoxDragBehavior: SixDofDragBehavior;
  54861. /**
  54862. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54863. */
  54864. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54865. /**
  54866. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54867. */
  54868. usePointerToAttachGizmos: boolean;
  54869. /**
  54870. * Utility layer that the bounding box gizmo belongs to
  54871. */
  54872. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54873. /**
  54874. * Utility layer that all gizmos besides bounding box belong to
  54875. */
  54876. get utilityLayer(): UtilityLayerRenderer;
  54877. /**
  54878. * Instatiates a gizmo manager
  54879. * @param scene the scene to overlay the gizmos on top of
  54880. */
  54881. constructor(scene: Scene);
  54882. /**
  54883. * Attaches a set of gizmos to the specified mesh
  54884. * @param mesh The mesh the gizmo's should be attached to
  54885. */
  54886. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54887. /**
  54888. * If the position gizmo is enabled
  54889. */
  54890. set positionGizmoEnabled(value: boolean);
  54891. get positionGizmoEnabled(): boolean;
  54892. /**
  54893. * If the rotation gizmo is enabled
  54894. */
  54895. set rotationGizmoEnabled(value: boolean);
  54896. get rotationGizmoEnabled(): boolean;
  54897. /**
  54898. * If the scale gizmo is enabled
  54899. */
  54900. set scaleGizmoEnabled(value: boolean);
  54901. get scaleGizmoEnabled(): boolean;
  54902. /**
  54903. * If the boundingBox gizmo is enabled
  54904. */
  54905. set boundingBoxGizmoEnabled(value: boolean);
  54906. get boundingBoxGizmoEnabled(): boolean;
  54907. /**
  54908. * Disposes of the gizmo manager
  54909. */
  54910. dispose(): void;
  54911. }
  54912. }
  54913. declare module "babylonjs/Lights/directionalLight" {
  54914. import { Camera } from "babylonjs/Cameras/camera";
  54915. import { Scene } from "babylonjs/scene";
  54916. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54918. import { Light } from "babylonjs/Lights/light";
  54919. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54920. import { Effect } from "babylonjs/Materials/effect";
  54921. /**
  54922. * A directional light is defined by a direction (what a surprise!).
  54923. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54924. * 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.
  54925. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54926. */
  54927. export class DirectionalLight extends ShadowLight {
  54928. private _shadowFrustumSize;
  54929. /**
  54930. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54931. */
  54932. get shadowFrustumSize(): number;
  54933. /**
  54934. * Specifies a fix frustum size for the shadow generation.
  54935. */
  54936. set shadowFrustumSize(value: number);
  54937. private _shadowOrthoScale;
  54938. /**
  54939. * Gets the shadow projection scale against the optimal computed one.
  54940. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54941. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54942. */
  54943. get shadowOrthoScale(): number;
  54944. /**
  54945. * Sets the shadow projection scale against the optimal computed one.
  54946. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54947. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54948. */
  54949. set shadowOrthoScale(value: number);
  54950. /**
  54951. * Automatically compute the projection matrix to best fit (including all the casters)
  54952. * on each frame.
  54953. */
  54954. autoUpdateExtends: boolean;
  54955. /**
  54956. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54957. * on each frame. autoUpdateExtends must be set to true for this to work
  54958. */
  54959. autoCalcShadowZBounds: boolean;
  54960. private _orthoLeft;
  54961. private _orthoRight;
  54962. private _orthoTop;
  54963. private _orthoBottom;
  54964. /**
  54965. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54966. * The directional light is emitted from everywhere in the given direction.
  54967. * It can cast shadows.
  54968. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54969. * @param name The friendly name of the light
  54970. * @param direction The direction of the light
  54971. * @param scene The scene the light belongs to
  54972. */
  54973. constructor(name: string, direction: Vector3, scene: Scene);
  54974. /**
  54975. * Returns the string "DirectionalLight".
  54976. * @return The class name
  54977. */
  54978. getClassName(): string;
  54979. /**
  54980. * Returns the integer 1.
  54981. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54982. */
  54983. getTypeID(): number;
  54984. /**
  54985. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54986. * Returns the DirectionalLight Shadow projection matrix.
  54987. */
  54988. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54989. /**
  54990. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54991. * Returns the DirectionalLight Shadow projection matrix.
  54992. */
  54993. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54994. /**
  54995. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54996. * Returns the DirectionalLight Shadow projection matrix.
  54997. */
  54998. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54999. protected _buildUniformLayout(): void;
  55000. /**
  55001. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55002. * @param effect The effect to update
  55003. * @param lightIndex The index of the light in the effect to update
  55004. * @returns The directional light
  55005. */
  55006. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55007. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55008. /**
  55009. * Gets the minZ used for shadow according to both the scene and the light.
  55010. *
  55011. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55012. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55013. * @param activeCamera The camera we are returning the min for
  55014. * @returns the depth min z
  55015. */
  55016. getDepthMinZ(activeCamera: Camera): number;
  55017. /**
  55018. * Gets the maxZ used for shadow according to both the scene and the light.
  55019. *
  55020. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55021. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55022. * @param activeCamera The camera we are returning the max for
  55023. * @returns the depth max z
  55024. */
  55025. getDepthMaxZ(activeCamera: Camera): number;
  55026. /**
  55027. * Prepares the list of defines specific to the light type.
  55028. * @param defines the list of defines
  55029. * @param lightIndex defines the index of the light for the effect
  55030. */
  55031. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55032. }
  55033. }
  55034. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55035. import { Mesh } from "babylonjs/Meshes/mesh";
  55036. /**
  55037. * Class containing static functions to help procedurally build meshes
  55038. */
  55039. export class HemisphereBuilder {
  55040. /**
  55041. * Creates a hemisphere mesh
  55042. * @param name defines the name of the mesh
  55043. * @param options defines the options used to create the mesh
  55044. * @param scene defines the hosting scene
  55045. * @returns the hemisphere mesh
  55046. */
  55047. static CreateHemisphere(name: string, options: {
  55048. segments?: number;
  55049. diameter?: number;
  55050. sideOrientation?: number;
  55051. }, scene: any): Mesh;
  55052. }
  55053. }
  55054. declare module "babylonjs/Lights/spotLight" {
  55055. import { Nullable } from "babylonjs/types";
  55056. import { Scene } from "babylonjs/scene";
  55057. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55059. import { Effect } from "babylonjs/Materials/effect";
  55060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55061. import { Light } from "babylonjs/Lights/light";
  55062. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55063. /**
  55064. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55065. * These values define a cone of light starting from the position, emitting toward the direction.
  55066. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55067. * and the exponent defines the speed of the decay of the light with distance (reach).
  55068. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55069. */
  55070. export class SpotLight extends ShadowLight {
  55071. private _angle;
  55072. private _innerAngle;
  55073. private _cosHalfAngle;
  55074. private _lightAngleScale;
  55075. private _lightAngleOffset;
  55076. /**
  55077. * Gets the cone angle of the spot light in Radians.
  55078. */
  55079. get angle(): number;
  55080. /**
  55081. * Sets the cone angle of the spot light in Radians.
  55082. */
  55083. set angle(value: number);
  55084. /**
  55085. * Only used in gltf falloff mode, this defines the angle where
  55086. * the directional falloff will start before cutting at angle which could be seen
  55087. * as outer angle.
  55088. */
  55089. get innerAngle(): number;
  55090. /**
  55091. * Only used in gltf falloff mode, this defines the angle where
  55092. * the directional falloff will start before cutting at angle which could be seen
  55093. * as outer angle.
  55094. */
  55095. set innerAngle(value: number);
  55096. private _shadowAngleScale;
  55097. /**
  55098. * Allows scaling the angle of the light for shadow generation only.
  55099. */
  55100. get shadowAngleScale(): number;
  55101. /**
  55102. * Allows scaling the angle of the light for shadow generation only.
  55103. */
  55104. set shadowAngleScale(value: number);
  55105. /**
  55106. * The light decay speed with the distance from the emission spot.
  55107. */
  55108. exponent: number;
  55109. private _projectionTextureMatrix;
  55110. /**
  55111. * Allows reading the projecton texture
  55112. */
  55113. get projectionTextureMatrix(): Matrix;
  55114. protected _projectionTextureLightNear: number;
  55115. /**
  55116. * Gets the near clip of the Spotlight for texture projection.
  55117. */
  55118. get projectionTextureLightNear(): number;
  55119. /**
  55120. * Sets the near clip of the Spotlight for texture projection.
  55121. */
  55122. set projectionTextureLightNear(value: number);
  55123. protected _projectionTextureLightFar: number;
  55124. /**
  55125. * Gets the far clip of the Spotlight for texture projection.
  55126. */
  55127. get projectionTextureLightFar(): number;
  55128. /**
  55129. * Sets the far clip of the Spotlight for texture projection.
  55130. */
  55131. set projectionTextureLightFar(value: number);
  55132. protected _projectionTextureUpDirection: Vector3;
  55133. /**
  55134. * Gets the Up vector of the Spotlight for texture projection.
  55135. */
  55136. get projectionTextureUpDirection(): Vector3;
  55137. /**
  55138. * Sets the Up vector of the Spotlight for texture projection.
  55139. */
  55140. set projectionTextureUpDirection(value: Vector3);
  55141. private _projectionTexture;
  55142. /**
  55143. * Gets the projection texture of the light.
  55144. */
  55145. get projectionTexture(): Nullable<BaseTexture>;
  55146. /**
  55147. * Sets the projection texture of the light.
  55148. */
  55149. set projectionTexture(value: Nullable<BaseTexture>);
  55150. private _projectionTextureViewLightDirty;
  55151. private _projectionTextureProjectionLightDirty;
  55152. private _projectionTextureDirty;
  55153. private _projectionTextureViewTargetVector;
  55154. private _projectionTextureViewLightMatrix;
  55155. private _projectionTextureProjectionLightMatrix;
  55156. private _projectionTextureScalingMatrix;
  55157. /**
  55158. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55159. * It can cast shadows.
  55160. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55161. * @param name The light friendly name
  55162. * @param position The position of the spot light in the scene
  55163. * @param direction The direction of the light in the scene
  55164. * @param angle The cone angle of the light in Radians
  55165. * @param exponent The light decay speed with the distance from the emission spot
  55166. * @param scene The scene the lights belongs to
  55167. */
  55168. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55169. /**
  55170. * Returns the string "SpotLight".
  55171. * @returns the class name
  55172. */
  55173. getClassName(): string;
  55174. /**
  55175. * Returns the integer 2.
  55176. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55177. */
  55178. getTypeID(): number;
  55179. /**
  55180. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55181. */
  55182. protected _setDirection(value: Vector3): void;
  55183. /**
  55184. * Overrides the position setter to recompute the projection texture view light Matrix.
  55185. */
  55186. protected _setPosition(value: Vector3): void;
  55187. /**
  55188. * 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.
  55189. * Returns the SpotLight.
  55190. */
  55191. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55192. protected _computeProjectionTextureViewLightMatrix(): void;
  55193. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55194. /**
  55195. * Main function for light texture projection matrix computing.
  55196. */
  55197. protected _computeProjectionTextureMatrix(): void;
  55198. protected _buildUniformLayout(): void;
  55199. private _computeAngleValues;
  55200. /**
  55201. * Sets the passed Effect "effect" with the Light textures.
  55202. * @param effect The effect to update
  55203. * @param lightIndex The index of the light in the effect to update
  55204. * @returns The light
  55205. */
  55206. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55207. /**
  55208. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55209. * @param effect The effect to update
  55210. * @param lightIndex The index of the light in the effect to update
  55211. * @returns The spot light
  55212. */
  55213. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55214. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55215. /**
  55216. * Disposes the light and the associated resources.
  55217. */
  55218. dispose(): void;
  55219. /**
  55220. * Prepares the list of defines specific to the light type.
  55221. * @param defines the list of defines
  55222. * @param lightIndex defines the index of the light for the effect
  55223. */
  55224. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55225. }
  55226. }
  55227. declare module "babylonjs/Gizmos/lightGizmo" {
  55228. import { Nullable } from "babylonjs/types";
  55229. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55230. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55231. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55232. import { Light } from "babylonjs/Lights/light";
  55233. /**
  55234. * Gizmo that enables viewing a light
  55235. */
  55236. export class LightGizmo extends Gizmo {
  55237. private _lightMesh;
  55238. private _material;
  55239. private _cachedPosition;
  55240. private _cachedForward;
  55241. private _attachedMeshParent;
  55242. /**
  55243. * Creates a LightGizmo
  55244. * @param gizmoLayer The utility layer the gizmo will be added to
  55245. */
  55246. constructor(gizmoLayer?: UtilityLayerRenderer);
  55247. private _light;
  55248. /**
  55249. * The light that the gizmo is attached to
  55250. */
  55251. set light(light: Nullable<Light>);
  55252. get light(): Nullable<Light>;
  55253. /**
  55254. * Gets the material used to render the light gizmo
  55255. */
  55256. get material(): StandardMaterial;
  55257. /**
  55258. * @hidden
  55259. * Updates the gizmo to match the attached mesh's position/rotation
  55260. */
  55261. protected _update(): void;
  55262. private static _Scale;
  55263. /**
  55264. * Creates the lines for a light mesh
  55265. */
  55266. private static _CreateLightLines;
  55267. /**
  55268. * Disposes of the light gizmo
  55269. */
  55270. dispose(): void;
  55271. private static _CreateHemisphericLightMesh;
  55272. private static _CreatePointLightMesh;
  55273. private static _CreateSpotLightMesh;
  55274. private static _CreateDirectionalLightMesh;
  55275. }
  55276. }
  55277. declare module "babylonjs/Gizmos/index" {
  55278. export * from "babylonjs/Gizmos/axisDragGizmo";
  55279. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55280. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55281. export * from "babylonjs/Gizmos/gizmo";
  55282. export * from "babylonjs/Gizmos/gizmoManager";
  55283. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55284. export * from "babylonjs/Gizmos/positionGizmo";
  55285. export * from "babylonjs/Gizmos/rotationGizmo";
  55286. export * from "babylonjs/Gizmos/scaleGizmo";
  55287. export * from "babylonjs/Gizmos/lightGizmo";
  55288. export * from "babylonjs/Gizmos/planeDragGizmo";
  55289. }
  55290. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55291. /** @hidden */
  55292. export var backgroundFragmentDeclaration: {
  55293. name: string;
  55294. shader: string;
  55295. };
  55296. }
  55297. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55298. /** @hidden */
  55299. export var backgroundUboDeclaration: {
  55300. name: string;
  55301. shader: string;
  55302. };
  55303. }
  55304. declare module "babylonjs/Shaders/background.fragment" {
  55305. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55306. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55307. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55308. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55309. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55310. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55311. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55312. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55313. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55314. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55315. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55316. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55317. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55318. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55319. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55320. /** @hidden */
  55321. export var backgroundPixelShader: {
  55322. name: string;
  55323. shader: string;
  55324. };
  55325. }
  55326. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55327. /** @hidden */
  55328. export var backgroundVertexDeclaration: {
  55329. name: string;
  55330. shader: string;
  55331. };
  55332. }
  55333. declare module "babylonjs/Shaders/background.vertex" {
  55334. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55335. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55336. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55337. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55338. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55339. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55340. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55341. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55342. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55343. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55344. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55345. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55346. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55347. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55348. /** @hidden */
  55349. export var backgroundVertexShader: {
  55350. name: string;
  55351. shader: string;
  55352. };
  55353. }
  55354. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55355. import { Nullable, int, float } from "babylonjs/types";
  55356. import { Scene } from "babylonjs/scene";
  55357. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55358. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55360. import { Mesh } from "babylonjs/Meshes/mesh";
  55361. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55362. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55363. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55365. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55366. import { Color3 } from "babylonjs/Maths/math.color";
  55367. import "babylonjs/Shaders/background.fragment";
  55368. import "babylonjs/Shaders/background.vertex";
  55369. /**
  55370. * Background material used to create an efficient environement around your scene.
  55371. */
  55372. export class BackgroundMaterial extends PushMaterial {
  55373. /**
  55374. * Standard reflectance value at parallel view angle.
  55375. */
  55376. static StandardReflectance0: number;
  55377. /**
  55378. * Standard reflectance value at grazing angle.
  55379. */
  55380. static StandardReflectance90: number;
  55381. protected _primaryColor: Color3;
  55382. /**
  55383. * Key light Color (multiply against the environement texture)
  55384. */
  55385. primaryColor: Color3;
  55386. protected __perceptualColor: Nullable<Color3>;
  55387. /**
  55388. * Experimental Internal Use Only.
  55389. *
  55390. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55391. * This acts as a helper to set the primary color to a more "human friendly" value.
  55392. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55393. * output color as close as possible from the chosen value.
  55394. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55395. * part of lighting setup.)
  55396. */
  55397. get _perceptualColor(): Nullable<Color3>;
  55398. set _perceptualColor(value: Nullable<Color3>);
  55399. protected _primaryColorShadowLevel: float;
  55400. /**
  55401. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55402. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55403. */
  55404. get primaryColorShadowLevel(): float;
  55405. set primaryColorShadowLevel(value: float);
  55406. protected _primaryColorHighlightLevel: float;
  55407. /**
  55408. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55409. * The primary color is used at the level chosen to define what the white area would look.
  55410. */
  55411. get primaryColorHighlightLevel(): float;
  55412. set primaryColorHighlightLevel(value: float);
  55413. protected _reflectionTexture: Nullable<BaseTexture>;
  55414. /**
  55415. * Reflection Texture used in the material.
  55416. * Should be author in a specific way for the best result (refer to the documentation).
  55417. */
  55418. reflectionTexture: Nullable<BaseTexture>;
  55419. protected _reflectionBlur: float;
  55420. /**
  55421. * Reflection Texture level of blur.
  55422. *
  55423. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55424. * texture twice.
  55425. */
  55426. reflectionBlur: float;
  55427. protected _diffuseTexture: Nullable<BaseTexture>;
  55428. /**
  55429. * Diffuse Texture used in the material.
  55430. * Should be author in a specific way for the best result (refer to the documentation).
  55431. */
  55432. diffuseTexture: Nullable<BaseTexture>;
  55433. protected _shadowLights: Nullable<IShadowLight[]>;
  55434. /**
  55435. * Specify the list of lights casting shadow on the material.
  55436. * All scene shadow lights will be included if null.
  55437. */
  55438. shadowLights: Nullable<IShadowLight[]>;
  55439. protected _shadowLevel: float;
  55440. /**
  55441. * Helps adjusting the shadow to a softer level if required.
  55442. * 0 means black shadows and 1 means no shadows.
  55443. */
  55444. shadowLevel: float;
  55445. protected _sceneCenter: Vector3;
  55446. /**
  55447. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55448. * It is usually zero but might be interesting to modify according to your setup.
  55449. */
  55450. sceneCenter: Vector3;
  55451. protected _opacityFresnel: boolean;
  55452. /**
  55453. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55454. * This helps ensuring a nice transition when the camera goes under the ground.
  55455. */
  55456. opacityFresnel: boolean;
  55457. protected _reflectionFresnel: boolean;
  55458. /**
  55459. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55460. * This helps adding a mirror texture on the ground.
  55461. */
  55462. reflectionFresnel: boolean;
  55463. protected _reflectionFalloffDistance: number;
  55464. /**
  55465. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55466. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55467. */
  55468. reflectionFalloffDistance: number;
  55469. protected _reflectionAmount: number;
  55470. /**
  55471. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55472. */
  55473. reflectionAmount: number;
  55474. protected _reflectionReflectance0: number;
  55475. /**
  55476. * This specifies the weight of the reflection at grazing angle.
  55477. */
  55478. reflectionReflectance0: number;
  55479. protected _reflectionReflectance90: number;
  55480. /**
  55481. * This specifies the weight of the reflection at a perpendicular point of view.
  55482. */
  55483. reflectionReflectance90: number;
  55484. /**
  55485. * Sets the reflection reflectance fresnel values according to the default standard
  55486. * empirically know to work well :-)
  55487. */
  55488. set reflectionStandardFresnelWeight(value: number);
  55489. protected _useRGBColor: boolean;
  55490. /**
  55491. * Helps to directly use the maps channels instead of their level.
  55492. */
  55493. useRGBColor: boolean;
  55494. protected _enableNoise: boolean;
  55495. /**
  55496. * This helps reducing the banding effect that could occur on the background.
  55497. */
  55498. enableNoise: boolean;
  55499. /**
  55500. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55501. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55502. * Recommended to be keep at 1.0 except for special cases.
  55503. */
  55504. get fovMultiplier(): number;
  55505. set fovMultiplier(value: number);
  55506. private _fovMultiplier;
  55507. /**
  55508. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55509. */
  55510. useEquirectangularFOV: boolean;
  55511. private _maxSimultaneousLights;
  55512. /**
  55513. * Number of Simultaneous lights allowed on the material.
  55514. */
  55515. maxSimultaneousLights: int;
  55516. /**
  55517. * Default configuration related to image processing available in the Background Material.
  55518. */
  55519. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55520. /**
  55521. * Keep track of the image processing observer to allow dispose and replace.
  55522. */
  55523. private _imageProcessingObserver;
  55524. /**
  55525. * Attaches a new image processing configuration to the PBR Material.
  55526. * @param configuration (if null the scene configuration will be use)
  55527. */
  55528. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55529. /**
  55530. * Gets the image processing configuration used either in this material.
  55531. */
  55532. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55533. /**
  55534. * Sets the Default image processing configuration used either in the this material.
  55535. *
  55536. * If sets to null, the scene one is in use.
  55537. */
  55538. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55539. /**
  55540. * Gets wether the color curves effect is enabled.
  55541. */
  55542. get cameraColorCurvesEnabled(): boolean;
  55543. /**
  55544. * Sets wether the color curves effect is enabled.
  55545. */
  55546. set cameraColorCurvesEnabled(value: boolean);
  55547. /**
  55548. * Gets wether the color grading effect is enabled.
  55549. */
  55550. get cameraColorGradingEnabled(): boolean;
  55551. /**
  55552. * Gets wether the color grading effect is enabled.
  55553. */
  55554. set cameraColorGradingEnabled(value: boolean);
  55555. /**
  55556. * Gets wether tonemapping is enabled or not.
  55557. */
  55558. get cameraToneMappingEnabled(): boolean;
  55559. /**
  55560. * Sets wether tonemapping is enabled or not
  55561. */
  55562. set cameraToneMappingEnabled(value: boolean);
  55563. /**
  55564. * The camera exposure used on this material.
  55565. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55566. * This corresponds to a photographic exposure.
  55567. */
  55568. get cameraExposure(): float;
  55569. /**
  55570. * The camera exposure used on this material.
  55571. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55572. * This corresponds to a photographic exposure.
  55573. */
  55574. set cameraExposure(value: float);
  55575. /**
  55576. * Gets The camera contrast used on this material.
  55577. */
  55578. get cameraContrast(): float;
  55579. /**
  55580. * Sets The camera contrast used on this material.
  55581. */
  55582. set cameraContrast(value: float);
  55583. /**
  55584. * Gets the Color Grading 2D Lookup Texture.
  55585. */
  55586. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55587. /**
  55588. * Sets the Color Grading 2D Lookup Texture.
  55589. */
  55590. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55591. /**
  55592. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55593. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55594. * 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;
  55595. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55596. */
  55597. get cameraColorCurves(): Nullable<ColorCurves>;
  55598. /**
  55599. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55600. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55601. * 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;
  55602. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55603. */
  55604. set cameraColorCurves(value: Nullable<ColorCurves>);
  55605. /**
  55606. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55607. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55608. */
  55609. switchToBGR: boolean;
  55610. private _renderTargets;
  55611. private _reflectionControls;
  55612. private _white;
  55613. private _primaryShadowColor;
  55614. private _primaryHighlightColor;
  55615. /**
  55616. * Instantiates a Background Material in the given scene
  55617. * @param name The friendly name of the material
  55618. * @param scene The scene to add the material to
  55619. */
  55620. constructor(name: string, scene: Scene);
  55621. /**
  55622. * Gets a boolean indicating that current material needs to register RTT
  55623. */
  55624. get hasRenderTargetTextures(): boolean;
  55625. /**
  55626. * The entire material has been created in order to prevent overdraw.
  55627. * @returns false
  55628. */
  55629. needAlphaTesting(): boolean;
  55630. /**
  55631. * The entire material has been created in order to prevent overdraw.
  55632. * @returns true if blending is enable
  55633. */
  55634. needAlphaBlending(): boolean;
  55635. /**
  55636. * Checks wether the material is ready to be rendered for a given mesh.
  55637. * @param mesh The mesh to render
  55638. * @param subMesh The submesh to check against
  55639. * @param useInstances Specify wether or not the material is used with instances
  55640. * @returns true if all the dependencies are ready (Textures, Effects...)
  55641. */
  55642. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55643. /**
  55644. * Compute the primary color according to the chosen perceptual color.
  55645. */
  55646. private _computePrimaryColorFromPerceptualColor;
  55647. /**
  55648. * Compute the highlights and shadow colors according to their chosen levels.
  55649. */
  55650. private _computePrimaryColors;
  55651. /**
  55652. * Build the uniform buffer used in the material.
  55653. */
  55654. buildUniformLayout(): void;
  55655. /**
  55656. * Unbind the material.
  55657. */
  55658. unbind(): void;
  55659. /**
  55660. * Bind only the world matrix to the material.
  55661. * @param world The world matrix to bind.
  55662. */
  55663. bindOnlyWorldMatrix(world: Matrix): void;
  55664. /**
  55665. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55666. * @param world The world matrix to bind.
  55667. * @param subMesh The submesh to bind for.
  55668. */
  55669. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55670. /**
  55671. * Checks to see if a texture is used in the material.
  55672. * @param texture - Base texture to use.
  55673. * @returns - Boolean specifying if a texture is used in the material.
  55674. */
  55675. hasTexture(texture: BaseTexture): boolean;
  55676. /**
  55677. * Dispose the material.
  55678. * @param forceDisposeEffect Force disposal of the associated effect.
  55679. * @param forceDisposeTextures Force disposal of the associated textures.
  55680. */
  55681. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55682. /**
  55683. * Clones the material.
  55684. * @param name The cloned name.
  55685. * @returns The cloned material.
  55686. */
  55687. clone(name: string): BackgroundMaterial;
  55688. /**
  55689. * Serializes the current material to its JSON representation.
  55690. * @returns The JSON representation.
  55691. */
  55692. serialize(): any;
  55693. /**
  55694. * Gets the class name of the material
  55695. * @returns "BackgroundMaterial"
  55696. */
  55697. getClassName(): string;
  55698. /**
  55699. * Parse a JSON input to create back a background material.
  55700. * @param source The JSON data to parse
  55701. * @param scene The scene to create the parsed material in
  55702. * @param rootUrl The root url of the assets the material depends upon
  55703. * @returns the instantiated BackgroundMaterial.
  55704. */
  55705. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55706. }
  55707. }
  55708. declare module "babylonjs/Helpers/environmentHelper" {
  55709. import { Observable } from "babylonjs/Misc/observable";
  55710. import { Nullable } from "babylonjs/types";
  55711. import { Scene } from "babylonjs/scene";
  55712. import { Vector3 } from "babylonjs/Maths/math.vector";
  55713. import { Color3 } from "babylonjs/Maths/math.color";
  55714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55715. import { Mesh } from "babylonjs/Meshes/mesh";
  55716. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55717. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55718. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55719. import "babylonjs/Meshes/Builders/planeBuilder";
  55720. import "babylonjs/Meshes/Builders/boxBuilder";
  55721. /**
  55722. * Represents the different options available during the creation of
  55723. * a Environment helper.
  55724. *
  55725. * This can control the default ground, skybox and image processing setup of your scene.
  55726. */
  55727. export interface IEnvironmentHelperOptions {
  55728. /**
  55729. * Specifies whether or not to create a ground.
  55730. * True by default.
  55731. */
  55732. createGround: boolean;
  55733. /**
  55734. * Specifies the ground size.
  55735. * 15 by default.
  55736. */
  55737. groundSize: number;
  55738. /**
  55739. * The texture used on the ground for the main color.
  55740. * Comes from the BabylonJS CDN by default.
  55741. *
  55742. * Remarks: Can be either a texture or a url.
  55743. */
  55744. groundTexture: string | BaseTexture;
  55745. /**
  55746. * The color mixed in the ground texture by default.
  55747. * BabylonJS clearColor by default.
  55748. */
  55749. groundColor: Color3;
  55750. /**
  55751. * Specifies the ground opacity.
  55752. * 1 by default.
  55753. */
  55754. groundOpacity: number;
  55755. /**
  55756. * Enables the ground to receive shadows.
  55757. * True by default.
  55758. */
  55759. enableGroundShadow: boolean;
  55760. /**
  55761. * Helps preventing the shadow to be fully black on the ground.
  55762. * 0.5 by default.
  55763. */
  55764. groundShadowLevel: number;
  55765. /**
  55766. * Creates a mirror texture attach to the ground.
  55767. * false by default.
  55768. */
  55769. enableGroundMirror: boolean;
  55770. /**
  55771. * Specifies the ground mirror size ratio.
  55772. * 0.3 by default as the default kernel is 64.
  55773. */
  55774. groundMirrorSizeRatio: number;
  55775. /**
  55776. * Specifies the ground mirror blur kernel size.
  55777. * 64 by default.
  55778. */
  55779. groundMirrorBlurKernel: number;
  55780. /**
  55781. * Specifies the ground mirror visibility amount.
  55782. * 1 by default
  55783. */
  55784. groundMirrorAmount: number;
  55785. /**
  55786. * Specifies the ground mirror reflectance weight.
  55787. * This uses the standard weight of the background material to setup the fresnel effect
  55788. * of the mirror.
  55789. * 1 by default.
  55790. */
  55791. groundMirrorFresnelWeight: number;
  55792. /**
  55793. * Specifies the ground mirror Falloff distance.
  55794. * This can helps reducing the size of the reflection.
  55795. * 0 by Default.
  55796. */
  55797. groundMirrorFallOffDistance: number;
  55798. /**
  55799. * Specifies the ground mirror texture type.
  55800. * Unsigned Int by Default.
  55801. */
  55802. groundMirrorTextureType: number;
  55803. /**
  55804. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55805. * the shown objects.
  55806. */
  55807. groundYBias: number;
  55808. /**
  55809. * Specifies whether or not to create a skybox.
  55810. * True by default.
  55811. */
  55812. createSkybox: boolean;
  55813. /**
  55814. * Specifies the skybox size.
  55815. * 20 by default.
  55816. */
  55817. skyboxSize: number;
  55818. /**
  55819. * The texture used on the skybox for the main color.
  55820. * Comes from the BabylonJS CDN by default.
  55821. *
  55822. * Remarks: Can be either a texture or a url.
  55823. */
  55824. skyboxTexture: string | BaseTexture;
  55825. /**
  55826. * The color mixed in the skybox texture by default.
  55827. * BabylonJS clearColor by default.
  55828. */
  55829. skyboxColor: Color3;
  55830. /**
  55831. * The background rotation around the Y axis of the scene.
  55832. * This helps aligning the key lights of your scene with the background.
  55833. * 0 by default.
  55834. */
  55835. backgroundYRotation: number;
  55836. /**
  55837. * Compute automatically the size of the elements to best fit with the scene.
  55838. */
  55839. sizeAuto: boolean;
  55840. /**
  55841. * Default position of the rootMesh if autoSize is not true.
  55842. */
  55843. rootPosition: Vector3;
  55844. /**
  55845. * Sets up the image processing in the scene.
  55846. * true by default.
  55847. */
  55848. setupImageProcessing: boolean;
  55849. /**
  55850. * The texture used as your environment texture in the scene.
  55851. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55852. *
  55853. * Remarks: Can be either a texture or a url.
  55854. */
  55855. environmentTexture: string | BaseTexture;
  55856. /**
  55857. * The value of the exposure to apply to the scene.
  55858. * 0.6 by default if setupImageProcessing is true.
  55859. */
  55860. cameraExposure: number;
  55861. /**
  55862. * The value of the contrast to apply to the scene.
  55863. * 1.6 by default if setupImageProcessing is true.
  55864. */
  55865. cameraContrast: number;
  55866. /**
  55867. * Specifies whether or not tonemapping should be enabled in the scene.
  55868. * true by default if setupImageProcessing is true.
  55869. */
  55870. toneMappingEnabled: boolean;
  55871. }
  55872. /**
  55873. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55874. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55875. * It also helps with the default setup of your imageProcessing configuration.
  55876. */
  55877. export class EnvironmentHelper {
  55878. /**
  55879. * Default ground texture URL.
  55880. */
  55881. private static _groundTextureCDNUrl;
  55882. /**
  55883. * Default skybox texture URL.
  55884. */
  55885. private static _skyboxTextureCDNUrl;
  55886. /**
  55887. * Default environment texture URL.
  55888. */
  55889. private static _environmentTextureCDNUrl;
  55890. /**
  55891. * Creates the default options for the helper.
  55892. */
  55893. private static _getDefaultOptions;
  55894. private _rootMesh;
  55895. /**
  55896. * Gets the root mesh created by the helper.
  55897. */
  55898. get rootMesh(): Mesh;
  55899. private _skybox;
  55900. /**
  55901. * Gets the skybox created by the helper.
  55902. */
  55903. get skybox(): Nullable<Mesh>;
  55904. private _skyboxTexture;
  55905. /**
  55906. * Gets the skybox texture created by the helper.
  55907. */
  55908. get skyboxTexture(): Nullable<BaseTexture>;
  55909. private _skyboxMaterial;
  55910. /**
  55911. * Gets the skybox material created by the helper.
  55912. */
  55913. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55914. private _ground;
  55915. /**
  55916. * Gets the ground mesh created by the helper.
  55917. */
  55918. get ground(): Nullable<Mesh>;
  55919. private _groundTexture;
  55920. /**
  55921. * Gets the ground texture created by the helper.
  55922. */
  55923. get groundTexture(): Nullable<BaseTexture>;
  55924. private _groundMirror;
  55925. /**
  55926. * Gets the ground mirror created by the helper.
  55927. */
  55928. get groundMirror(): Nullable<MirrorTexture>;
  55929. /**
  55930. * Gets the ground mirror render list to helps pushing the meshes
  55931. * you wish in the ground reflection.
  55932. */
  55933. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55934. private _groundMaterial;
  55935. /**
  55936. * Gets the ground material created by the helper.
  55937. */
  55938. get groundMaterial(): Nullable<BackgroundMaterial>;
  55939. /**
  55940. * Stores the creation options.
  55941. */
  55942. private readonly _scene;
  55943. private _options;
  55944. /**
  55945. * This observable will be notified with any error during the creation of the environment,
  55946. * mainly texture creation errors.
  55947. */
  55948. onErrorObservable: Observable<{
  55949. message?: string;
  55950. exception?: any;
  55951. }>;
  55952. /**
  55953. * constructor
  55954. * @param options Defines the options we want to customize the helper
  55955. * @param scene The scene to add the material to
  55956. */
  55957. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55958. /**
  55959. * Updates the background according to the new options
  55960. * @param options
  55961. */
  55962. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55963. /**
  55964. * Sets the primary color of all the available elements.
  55965. * @param color the main color to affect to the ground and the background
  55966. */
  55967. setMainColor(color: Color3): void;
  55968. /**
  55969. * Setup the image processing according to the specified options.
  55970. */
  55971. private _setupImageProcessing;
  55972. /**
  55973. * Setup the environment texture according to the specified options.
  55974. */
  55975. private _setupEnvironmentTexture;
  55976. /**
  55977. * Setup the background according to the specified options.
  55978. */
  55979. private _setupBackground;
  55980. /**
  55981. * Get the scene sizes according to the setup.
  55982. */
  55983. private _getSceneSize;
  55984. /**
  55985. * Setup the ground according to the specified options.
  55986. */
  55987. private _setupGround;
  55988. /**
  55989. * Setup the ground material according to the specified options.
  55990. */
  55991. private _setupGroundMaterial;
  55992. /**
  55993. * Setup the ground diffuse texture according to the specified options.
  55994. */
  55995. private _setupGroundDiffuseTexture;
  55996. /**
  55997. * Setup the ground mirror texture according to the specified options.
  55998. */
  55999. private _setupGroundMirrorTexture;
  56000. /**
  56001. * Setup the ground to receive the mirror texture.
  56002. */
  56003. private _setupMirrorInGroundMaterial;
  56004. /**
  56005. * Setup the skybox according to the specified options.
  56006. */
  56007. private _setupSkybox;
  56008. /**
  56009. * Setup the skybox material according to the specified options.
  56010. */
  56011. private _setupSkyboxMaterial;
  56012. /**
  56013. * Setup the skybox reflection texture according to the specified options.
  56014. */
  56015. private _setupSkyboxReflectionTexture;
  56016. private _errorHandler;
  56017. /**
  56018. * Dispose all the elements created by the Helper.
  56019. */
  56020. dispose(): void;
  56021. }
  56022. }
  56023. declare module "babylonjs/Helpers/photoDome" {
  56024. import { Observable } from "babylonjs/Misc/observable";
  56025. import { Nullable } from "babylonjs/types";
  56026. import { Scene } from "babylonjs/scene";
  56027. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56028. import { Mesh } from "babylonjs/Meshes/mesh";
  56029. import { Texture } from "babylonjs/Materials/Textures/texture";
  56030. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56031. import "babylonjs/Meshes/Builders/sphereBuilder";
  56032. /**
  56033. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56034. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56035. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56036. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56037. */
  56038. export class PhotoDome extends TransformNode {
  56039. /**
  56040. * Define the image as a Monoscopic panoramic 360 image.
  56041. */
  56042. static readonly MODE_MONOSCOPIC: number;
  56043. /**
  56044. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56045. */
  56046. static readonly MODE_TOPBOTTOM: number;
  56047. /**
  56048. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56049. */
  56050. static readonly MODE_SIDEBYSIDE: number;
  56051. private _useDirectMapping;
  56052. /**
  56053. * The texture being displayed on the sphere
  56054. */
  56055. protected _photoTexture: Texture;
  56056. /**
  56057. * Gets or sets the texture being displayed on the sphere
  56058. */
  56059. get photoTexture(): Texture;
  56060. set photoTexture(value: Texture);
  56061. /**
  56062. * Observable raised when an error occured while loading the 360 image
  56063. */
  56064. onLoadErrorObservable: Observable<string>;
  56065. /**
  56066. * The skybox material
  56067. */
  56068. protected _material: BackgroundMaterial;
  56069. /**
  56070. * The surface used for the skybox
  56071. */
  56072. protected _mesh: Mesh;
  56073. /**
  56074. * Gets the mesh used for the skybox.
  56075. */
  56076. get mesh(): Mesh;
  56077. /**
  56078. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56079. * Also see the options.resolution property.
  56080. */
  56081. get fovMultiplier(): number;
  56082. set fovMultiplier(value: number);
  56083. private _imageMode;
  56084. /**
  56085. * Gets or set the current video mode for the video. It can be:
  56086. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56087. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56088. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56089. */
  56090. get imageMode(): number;
  56091. set imageMode(value: number);
  56092. /**
  56093. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56094. * @param name Element's name, child elements will append suffixes for their own names.
  56095. * @param urlsOfPhoto defines the url of the photo to display
  56096. * @param options defines an object containing optional or exposed sub element properties
  56097. * @param onError defines a callback called when an error occured while loading the texture
  56098. */
  56099. constructor(name: string, urlOfPhoto: string, options: {
  56100. resolution?: number;
  56101. size?: number;
  56102. useDirectMapping?: boolean;
  56103. faceForward?: boolean;
  56104. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56105. private _onBeforeCameraRenderObserver;
  56106. private _changeImageMode;
  56107. /**
  56108. * Releases resources associated with this node.
  56109. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56110. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56111. */
  56112. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56113. }
  56114. }
  56115. declare module "babylonjs/Misc/rgbdTextureTools" {
  56116. import "babylonjs/Shaders/rgbdDecode.fragment";
  56117. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56118. import { Texture } from "babylonjs/Materials/Textures/texture";
  56119. /**
  56120. * Class used to host RGBD texture specific utilities
  56121. */
  56122. export class RGBDTextureTools {
  56123. /**
  56124. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56125. * @param texture the texture to expand.
  56126. */
  56127. static ExpandRGBDTexture(texture: Texture): void;
  56128. }
  56129. }
  56130. declare module "babylonjs/Misc/brdfTextureTools" {
  56131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56132. import { Scene } from "babylonjs/scene";
  56133. /**
  56134. * Class used to host texture specific utilities
  56135. */
  56136. export class BRDFTextureTools {
  56137. /**
  56138. * Prevents texture cache collision
  56139. */
  56140. private static _instanceNumber;
  56141. /**
  56142. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56143. * @param scene defines the hosting scene
  56144. * @returns the environment BRDF texture
  56145. */
  56146. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56147. private static _environmentBRDFBase64Texture;
  56148. }
  56149. }
  56150. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56151. import { Nullable } from "babylonjs/types";
  56152. import { Color3 } from "babylonjs/Maths/math.color";
  56153. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56154. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56155. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56156. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56157. import { Engine } from "babylonjs/Engines/engine";
  56158. import { Scene } from "babylonjs/scene";
  56159. /**
  56160. * @hidden
  56161. */
  56162. export interface IMaterialClearCoatDefines {
  56163. CLEARCOAT: boolean;
  56164. CLEARCOAT_DEFAULTIOR: boolean;
  56165. CLEARCOAT_TEXTURE: boolean;
  56166. CLEARCOAT_TEXTUREDIRECTUV: number;
  56167. CLEARCOAT_BUMP: boolean;
  56168. CLEARCOAT_BUMPDIRECTUV: number;
  56169. CLEARCOAT_TINT: boolean;
  56170. CLEARCOAT_TINT_TEXTURE: boolean;
  56171. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56172. /** @hidden */
  56173. _areTexturesDirty: boolean;
  56174. }
  56175. /**
  56176. * Define the code related to the clear coat parameters of the pbr material.
  56177. */
  56178. export class PBRClearCoatConfiguration {
  56179. /**
  56180. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56181. * The default fits with a polyurethane material.
  56182. */
  56183. private static readonly _DefaultIndexOfRefraction;
  56184. private _isEnabled;
  56185. /**
  56186. * Defines if the clear coat is enabled in the material.
  56187. */
  56188. isEnabled: boolean;
  56189. /**
  56190. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56191. */
  56192. intensity: number;
  56193. /**
  56194. * Defines the clear coat layer roughness.
  56195. */
  56196. roughness: number;
  56197. private _indexOfRefraction;
  56198. /**
  56199. * Defines the index of refraction of the clear coat.
  56200. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56201. * The default fits with a polyurethane material.
  56202. * Changing the default value is more performance intensive.
  56203. */
  56204. indexOfRefraction: number;
  56205. private _texture;
  56206. /**
  56207. * Stores the clear coat values in a texture.
  56208. */
  56209. texture: Nullable<BaseTexture>;
  56210. private _bumpTexture;
  56211. /**
  56212. * Define the clear coat specific bump texture.
  56213. */
  56214. bumpTexture: Nullable<BaseTexture>;
  56215. private _isTintEnabled;
  56216. /**
  56217. * Defines if the clear coat tint is enabled in the material.
  56218. */
  56219. isTintEnabled: boolean;
  56220. /**
  56221. * Defines the clear coat tint of the material.
  56222. * This is only use if tint is enabled
  56223. */
  56224. tintColor: Color3;
  56225. /**
  56226. * Defines the distance at which the tint color should be found in the
  56227. * clear coat media.
  56228. * This is only use if tint is enabled
  56229. */
  56230. tintColorAtDistance: number;
  56231. /**
  56232. * Defines the clear coat layer thickness.
  56233. * This is only use if tint is enabled
  56234. */
  56235. tintThickness: number;
  56236. private _tintTexture;
  56237. /**
  56238. * Stores the clear tint values in a texture.
  56239. * rgb is tint
  56240. * a is a thickness factor
  56241. */
  56242. tintTexture: Nullable<BaseTexture>;
  56243. /** @hidden */
  56244. private _internalMarkAllSubMeshesAsTexturesDirty;
  56245. /** @hidden */
  56246. _markAllSubMeshesAsTexturesDirty(): void;
  56247. /**
  56248. * Instantiate a new istance of clear coat configuration.
  56249. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56250. */
  56251. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56252. /**
  56253. * Gets wehter the submesh is ready to be used or not.
  56254. * @param defines the list of "defines" to update.
  56255. * @param scene defines the scene the material belongs to.
  56256. * @param engine defines the engine the material belongs to.
  56257. * @param disableBumpMap defines wether the material disables bump or not.
  56258. * @returns - boolean indicating that the submesh is ready or not.
  56259. */
  56260. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56261. /**
  56262. * Checks to see if a texture is used in the material.
  56263. * @param defines the list of "defines" to update.
  56264. * @param scene defines the scene to the material belongs to.
  56265. */
  56266. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56267. /**
  56268. * Binds the material data.
  56269. * @param uniformBuffer defines the Uniform buffer to fill in.
  56270. * @param scene defines the scene the material belongs to.
  56271. * @param engine defines the engine the material belongs to.
  56272. * @param disableBumpMap defines wether the material disables bump or not.
  56273. * @param isFrozen defines wether the material is frozen or not.
  56274. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56275. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56276. */
  56277. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56278. /**
  56279. * Checks to see if a texture is used in the material.
  56280. * @param texture - Base texture to use.
  56281. * @returns - Boolean specifying if a texture is used in the material.
  56282. */
  56283. hasTexture(texture: BaseTexture): boolean;
  56284. /**
  56285. * Returns an array of the actively used textures.
  56286. * @param activeTextures Array of BaseTextures
  56287. */
  56288. getActiveTextures(activeTextures: BaseTexture[]): void;
  56289. /**
  56290. * Returns the animatable textures.
  56291. * @param animatables Array of animatable textures.
  56292. */
  56293. getAnimatables(animatables: IAnimatable[]): void;
  56294. /**
  56295. * Disposes the resources of the material.
  56296. * @param forceDisposeTextures - Forces the disposal of all textures.
  56297. */
  56298. dispose(forceDisposeTextures?: boolean): void;
  56299. /**
  56300. * Get the current class name of the texture useful for serialization or dynamic coding.
  56301. * @returns "PBRClearCoatConfiguration"
  56302. */
  56303. getClassName(): string;
  56304. /**
  56305. * Add fallbacks to the effect fallbacks list.
  56306. * @param defines defines the Base texture to use.
  56307. * @param fallbacks defines the current fallback list.
  56308. * @param currentRank defines the current fallback rank.
  56309. * @returns the new fallback rank.
  56310. */
  56311. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56312. /**
  56313. * Add the required uniforms to the current list.
  56314. * @param uniforms defines the current uniform list.
  56315. */
  56316. static AddUniforms(uniforms: string[]): void;
  56317. /**
  56318. * Add the required samplers to the current list.
  56319. * @param samplers defines the current sampler list.
  56320. */
  56321. static AddSamplers(samplers: string[]): void;
  56322. /**
  56323. * Add the required uniforms to the current buffer.
  56324. * @param uniformBuffer defines the current uniform buffer.
  56325. */
  56326. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56327. /**
  56328. * Makes a duplicate of the current configuration into another one.
  56329. * @param clearCoatConfiguration define the config where to copy the info
  56330. */
  56331. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56332. /**
  56333. * Serializes this clear coat configuration.
  56334. * @returns - An object with the serialized config.
  56335. */
  56336. serialize(): any;
  56337. /**
  56338. * Parses a anisotropy Configuration from a serialized object.
  56339. * @param source - Serialized object.
  56340. * @param scene Defines the scene we are parsing for
  56341. * @param rootUrl Defines the rootUrl to load from
  56342. */
  56343. parse(source: any, scene: Scene, rootUrl: string): void;
  56344. }
  56345. }
  56346. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56347. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56349. import { Vector2 } from "babylonjs/Maths/math.vector";
  56350. import { Scene } from "babylonjs/scene";
  56351. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56352. import { Nullable } from "babylonjs/types";
  56353. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56354. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56355. /**
  56356. * @hidden
  56357. */
  56358. export interface IMaterialAnisotropicDefines {
  56359. ANISOTROPIC: boolean;
  56360. ANISOTROPIC_TEXTURE: boolean;
  56361. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56362. MAINUV1: boolean;
  56363. _areTexturesDirty: boolean;
  56364. _needUVs: boolean;
  56365. }
  56366. /**
  56367. * Define the code related to the anisotropic parameters of the pbr material.
  56368. */
  56369. export class PBRAnisotropicConfiguration {
  56370. private _isEnabled;
  56371. /**
  56372. * Defines if the anisotropy is enabled in the material.
  56373. */
  56374. isEnabled: boolean;
  56375. /**
  56376. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56377. */
  56378. intensity: number;
  56379. /**
  56380. * Defines if the effect is along the tangents, bitangents or in between.
  56381. * By default, the effect is "strectching" the highlights along the tangents.
  56382. */
  56383. direction: Vector2;
  56384. private _texture;
  56385. /**
  56386. * Stores the anisotropy values in a texture.
  56387. * rg is direction (like normal from -1 to 1)
  56388. * b is a intensity
  56389. */
  56390. texture: Nullable<BaseTexture>;
  56391. /** @hidden */
  56392. private _internalMarkAllSubMeshesAsTexturesDirty;
  56393. /** @hidden */
  56394. _markAllSubMeshesAsTexturesDirty(): void;
  56395. /**
  56396. * Instantiate a new istance of anisotropy configuration.
  56397. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56398. */
  56399. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56400. /**
  56401. * Specifies that the submesh is ready to be used.
  56402. * @param defines the list of "defines" to update.
  56403. * @param scene defines the scene the material belongs to.
  56404. * @returns - boolean indicating that the submesh is ready or not.
  56405. */
  56406. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56407. /**
  56408. * Checks to see if a texture is used in the material.
  56409. * @param defines the list of "defines" to update.
  56410. * @param mesh the mesh we are preparing the defines for.
  56411. * @param scene defines the scene the material belongs to.
  56412. */
  56413. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56414. /**
  56415. * Binds the material data.
  56416. * @param uniformBuffer defines the Uniform buffer to fill in.
  56417. * @param scene defines the scene the material belongs to.
  56418. * @param isFrozen defines wether the material is frozen or not.
  56419. */
  56420. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56421. /**
  56422. * Checks to see if a texture is used in the material.
  56423. * @param texture - Base texture to use.
  56424. * @returns - Boolean specifying if a texture is used in the material.
  56425. */
  56426. hasTexture(texture: BaseTexture): boolean;
  56427. /**
  56428. * Returns an array of the actively used textures.
  56429. * @param activeTextures Array of BaseTextures
  56430. */
  56431. getActiveTextures(activeTextures: BaseTexture[]): void;
  56432. /**
  56433. * Returns the animatable textures.
  56434. * @param animatables Array of animatable textures.
  56435. */
  56436. getAnimatables(animatables: IAnimatable[]): void;
  56437. /**
  56438. * Disposes the resources of the material.
  56439. * @param forceDisposeTextures - Forces the disposal of all textures.
  56440. */
  56441. dispose(forceDisposeTextures?: boolean): void;
  56442. /**
  56443. * Get the current class name of the texture useful for serialization or dynamic coding.
  56444. * @returns "PBRAnisotropicConfiguration"
  56445. */
  56446. getClassName(): string;
  56447. /**
  56448. * Add fallbacks to the effect fallbacks list.
  56449. * @param defines defines the Base texture to use.
  56450. * @param fallbacks defines the current fallback list.
  56451. * @param currentRank defines the current fallback rank.
  56452. * @returns the new fallback rank.
  56453. */
  56454. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56455. /**
  56456. * Add the required uniforms to the current list.
  56457. * @param uniforms defines the current uniform list.
  56458. */
  56459. static AddUniforms(uniforms: string[]): void;
  56460. /**
  56461. * Add the required uniforms to the current buffer.
  56462. * @param uniformBuffer defines the current uniform buffer.
  56463. */
  56464. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56465. /**
  56466. * Add the required samplers to the current list.
  56467. * @param samplers defines the current sampler list.
  56468. */
  56469. static AddSamplers(samplers: string[]): void;
  56470. /**
  56471. * Makes a duplicate of the current configuration into another one.
  56472. * @param anisotropicConfiguration define the config where to copy the info
  56473. */
  56474. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56475. /**
  56476. * Serializes this anisotropy configuration.
  56477. * @returns - An object with the serialized config.
  56478. */
  56479. serialize(): any;
  56480. /**
  56481. * Parses a anisotropy Configuration from a serialized object.
  56482. * @param source - Serialized object.
  56483. * @param scene Defines the scene we are parsing for
  56484. * @param rootUrl Defines the rootUrl to load from
  56485. */
  56486. parse(source: any, scene: Scene, rootUrl: string): void;
  56487. }
  56488. }
  56489. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56490. import { Scene } from "babylonjs/scene";
  56491. /**
  56492. * @hidden
  56493. */
  56494. export interface IMaterialBRDFDefines {
  56495. BRDF_V_HEIGHT_CORRELATED: boolean;
  56496. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56497. SPHERICAL_HARMONICS: boolean;
  56498. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56499. /** @hidden */
  56500. _areMiscDirty: boolean;
  56501. }
  56502. /**
  56503. * Define the code related to the BRDF parameters of the pbr material.
  56504. */
  56505. export class PBRBRDFConfiguration {
  56506. /**
  56507. * Default value used for the energy conservation.
  56508. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56509. */
  56510. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56511. /**
  56512. * Default value used for the Smith Visibility Height Correlated mode.
  56513. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56514. */
  56515. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56516. /**
  56517. * Default value used for the IBL diffuse part.
  56518. * This can help switching back to the polynomials mode globally which is a tiny bit
  56519. * less GPU intensive at the drawback of a lower quality.
  56520. */
  56521. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56522. /**
  56523. * Default value used for activating energy conservation for the specular workflow.
  56524. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56525. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56526. */
  56527. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56528. private _useEnergyConservation;
  56529. /**
  56530. * Defines if the material uses energy conservation.
  56531. */
  56532. useEnergyConservation: boolean;
  56533. private _useSmithVisibilityHeightCorrelated;
  56534. /**
  56535. * LEGACY Mode set to false
  56536. * Defines if the material uses height smith correlated visibility term.
  56537. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56538. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56539. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56540. * Not relying on height correlated will also disable energy conservation.
  56541. */
  56542. useSmithVisibilityHeightCorrelated: boolean;
  56543. private _useSphericalHarmonics;
  56544. /**
  56545. * LEGACY Mode set to false
  56546. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56547. * diffuse part of the IBL.
  56548. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56549. * to the ground truth.
  56550. */
  56551. useSphericalHarmonics: boolean;
  56552. private _useSpecularGlossinessInputEnergyConservation;
  56553. /**
  56554. * Defines if the material uses energy conservation, when the specular workflow is active.
  56555. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56556. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56557. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56558. */
  56559. useSpecularGlossinessInputEnergyConservation: boolean;
  56560. /** @hidden */
  56561. private _internalMarkAllSubMeshesAsMiscDirty;
  56562. /** @hidden */
  56563. _markAllSubMeshesAsMiscDirty(): void;
  56564. /**
  56565. * Instantiate a new istance of clear coat configuration.
  56566. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56567. */
  56568. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56569. /**
  56570. * Checks to see if a texture is used in the material.
  56571. * @param defines the list of "defines" to update.
  56572. */
  56573. prepareDefines(defines: IMaterialBRDFDefines): void;
  56574. /**
  56575. * Get the current class name of the texture useful for serialization or dynamic coding.
  56576. * @returns "PBRClearCoatConfiguration"
  56577. */
  56578. getClassName(): string;
  56579. /**
  56580. * Makes a duplicate of the current configuration into another one.
  56581. * @param brdfConfiguration define the config where to copy the info
  56582. */
  56583. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56584. /**
  56585. * Serializes this BRDF configuration.
  56586. * @returns - An object with the serialized config.
  56587. */
  56588. serialize(): any;
  56589. /**
  56590. * Parses a anisotropy Configuration from a serialized object.
  56591. * @param source - Serialized object.
  56592. * @param scene Defines the scene we are parsing for
  56593. * @param rootUrl Defines the rootUrl to load from
  56594. */
  56595. parse(source: any, scene: Scene, rootUrl: string): void;
  56596. }
  56597. }
  56598. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56599. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56600. import { Color3 } from "babylonjs/Maths/math.color";
  56601. import { Scene } from "babylonjs/scene";
  56602. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56603. import { Nullable } from "babylonjs/types";
  56604. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56605. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56606. /**
  56607. * @hidden
  56608. */
  56609. export interface IMaterialSheenDefines {
  56610. SHEEN: boolean;
  56611. SHEEN_TEXTURE: boolean;
  56612. SHEEN_TEXTUREDIRECTUV: number;
  56613. SHEEN_LINKWITHALBEDO: boolean;
  56614. SHEEN_ROUGHNESS: boolean;
  56615. SHEEN_ALBEDOSCALING: boolean;
  56616. /** @hidden */
  56617. _areTexturesDirty: boolean;
  56618. }
  56619. /**
  56620. * Define the code related to the Sheen parameters of the pbr material.
  56621. */
  56622. export class PBRSheenConfiguration {
  56623. private _isEnabled;
  56624. /**
  56625. * Defines if the material uses sheen.
  56626. */
  56627. isEnabled: boolean;
  56628. private _linkSheenWithAlbedo;
  56629. /**
  56630. * Defines if the sheen is linked to the sheen color.
  56631. */
  56632. linkSheenWithAlbedo: boolean;
  56633. /**
  56634. * Defines the sheen intensity.
  56635. */
  56636. intensity: number;
  56637. /**
  56638. * Defines the sheen color.
  56639. */
  56640. color: Color3;
  56641. private _texture;
  56642. /**
  56643. * Stores the sheen tint values in a texture.
  56644. * rgb is tint
  56645. * a is a intensity
  56646. */
  56647. texture: Nullable<BaseTexture>;
  56648. private _roughness;
  56649. /**
  56650. * Defines the sheen roughness.
  56651. * It is not taken into account if linkSheenWithAlbedo is true.
  56652. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56653. */
  56654. roughness: Nullable<number>;
  56655. private _albedoScaling;
  56656. /**
  56657. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56658. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56659. * making it easier to setup and tweak the effect
  56660. */
  56661. albedoScaling: boolean;
  56662. /** @hidden */
  56663. private _internalMarkAllSubMeshesAsTexturesDirty;
  56664. /** @hidden */
  56665. _markAllSubMeshesAsTexturesDirty(): void;
  56666. /**
  56667. * Instantiate a new istance of clear coat configuration.
  56668. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56669. */
  56670. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56671. /**
  56672. * Specifies that the submesh is ready to be used.
  56673. * @param defines the list of "defines" to update.
  56674. * @param scene defines the scene the material belongs to.
  56675. * @returns - boolean indicating that the submesh is ready or not.
  56676. */
  56677. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56678. /**
  56679. * Checks to see if a texture is used in the material.
  56680. * @param defines the list of "defines" to update.
  56681. * @param scene defines the scene the material belongs to.
  56682. */
  56683. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56684. /**
  56685. * Binds the material data.
  56686. * @param uniformBuffer defines the Uniform buffer to fill in.
  56687. * @param scene defines the scene the material belongs to.
  56688. * @param isFrozen defines wether the material is frozen or not.
  56689. */
  56690. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56691. /**
  56692. * Checks to see if a texture is used in the material.
  56693. * @param texture - Base texture to use.
  56694. * @returns - Boolean specifying if a texture is used in the material.
  56695. */
  56696. hasTexture(texture: BaseTexture): boolean;
  56697. /**
  56698. * Returns an array of the actively used textures.
  56699. * @param activeTextures Array of BaseTextures
  56700. */
  56701. getActiveTextures(activeTextures: BaseTexture[]): void;
  56702. /**
  56703. * Returns the animatable textures.
  56704. * @param animatables Array of animatable textures.
  56705. */
  56706. getAnimatables(animatables: IAnimatable[]): void;
  56707. /**
  56708. * Disposes the resources of the material.
  56709. * @param forceDisposeTextures - Forces the disposal of all textures.
  56710. */
  56711. dispose(forceDisposeTextures?: boolean): void;
  56712. /**
  56713. * Get the current class name of the texture useful for serialization or dynamic coding.
  56714. * @returns "PBRSheenConfiguration"
  56715. */
  56716. getClassName(): string;
  56717. /**
  56718. * Add fallbacks to the effect fallbacks list.
  56719. * @param defines defines the Base texture to use.
  56720. * @param fallbacks defines the current fallback list.
  56721. * @param currentRank defines the current fallback rank.
  56722. * @returns the new fallback rank.
  56723. */
  56724. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56725. /**
  56726. * Add the required uniforms to the current list.
  56727. * @param uniforms defines the current uniform list.
  56728. */
  56729. static AddUniforms(uniforms: string[]): void;
  56730. /**
  56731. * Add the required uniforms to the current buffer.
  56732. * @param uniformBuffer defines the current uniform buffer.
  56733. */
  56734. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56735. /**
  56736. * Add the required samplers to the current list.
  56737. * @param samplers defines the current sampler list.
  56738. */
  56739. static AddSamplers(samplers: string[]): void;
  56740. /**
  56741. * Makes a duplicate of the current configuration into another one.
  56742. * @param sheenConfiguration define the config where to copy the info
  56743. */
  56744. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56745. /**
  56746. * Serializes this BRDF configuration.
  56747. * @returns - An object with the serialized config.
  56748. */
  56749. serialize(): any;
  56750. /**
  56751. * Parses a anisotropy Configuration from a serialized object.
  56752. * @param source - Serialized object.
  56753. * @param scene Defines the scene we are parsing for
  56754. * @param rootUrl Defines the rootUrl to load from
  56755. */
  56756. parse(source: any, scene: Scene, rootUrl: string): void;
  56757. }
  56758. }
  56759. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56760. import { Nullable } from "babylonjs/types";
  56761. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56762. import { Color3 } from "babylonjs/Maths/math.color";
  56763. import { SmartArray } from "babylonjs/Misc/smartArray";
  56764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56765. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56766. import { Effect } from "babylonjs/Materials/effect";
  56767. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56768. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56769. import { Engine } from "babylonjs/Engines/engine";
  56770. import { Scene } from "babylonjs/scene";
  56771. /**
  56772. * @hidden
  56773. */
  56774. export interface IMaterialSubSurfaceDefines {
  56775. SUBSURFACE: boolean;
  56776. SS_REFRACTION: boolean;
  56777. SS_TRANSLUCENCY: boolean;
  56778. SS_SCATTERING: boolean;
  56779. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56780. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56781. SS_REFRACTIONMAP_3D: boolean;
  56782. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56783. SS_LODINREFRACTIONALPHA: boolean;
  56784. SS_GAMMAREFRACTION: boolean;
  56785. SS_RGBDREFRACTION: boolean;
  56786. SS_LINEARSPECULARREFRACTION: boolean;
  56787. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56788. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56789. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56790. /** @hidden */
  56791. _areTexturesDirty: boolean;
  56792. }
  56793. /**
  56794. * Define the code related to the sub surface parameters of the pbr material.
  56795. */
  56796. export class PBRSubSurfaceConfiguration {
  56797. private _isRefractionEnabled;
  56798. /**
  56799. * Defines if the refraction is enabled in the material.
  56800. */
  56801. isRefractionEnabled: boolean;
  56802. private _isTranslucencyEnabled;
  56803. /**
  56804. * Defines if the translucency is enabled in the material.
  56805. */
  56806. isTranslucencyEnabled: boolean;
  56807. private _isScatteringEnabled;
  56808. /**
  56809. * Defines the refraction intensity of the material.
  56810. * The refraction when enabled replaces the Diffuse part of the material.
  56811. * The intensity helps transitionning between diffuse and refraction.
  56812. */
  56813. refractionIntensity: number;
  56814. /**
  56815. * Defines the translucency intensity of the material.
  56816. * When translucency has been enabled, this defines how much of the "translucency"
  56817. * is addded to the diffuse part of the material.
  56818. */
  56819. translucencyIntensity: number;
  56820. /**
  56821. * Defines the scattering intensity of the material.
  56822. * When scattering has been enabled, this defines how much of the "scattered light"
  56823. * is addded to the diffuse part of the material.
  56824. */
  56825. scatteringIntensity: number;
  56826. /**
  56827. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56828. */
  56829. useAlbedoToTintRefraction: boolean;
  56830. private _thicknessTexture;
  56831. /**
  56832. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56833. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56834. * 0 would mean minimumThickness
  56835. * 1 would mean maximumThickness
  56836. * The other channels might be use as a mask to vary the different effects intensity.
  56837. */
  56838. thicknessTexture: Nullable<BaseTexture>;
  56839. private _refractionTexture;
  56840. /**
  56841. * Defines the texture to use for refraction.
  56842. */
  56843. refractionTexture: Nullable<BaseTexture>;
  56844. private _indexOfRefraction;
  56845. /**
  56846. * Index of refraction of the material base layer.
  56847. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56848. *
  56849. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56850. *
  56851. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56852. */
  56853. indexOfRefraction: number;
  56854. private _volumeIndexOfRefraction;
  56855. /**
  56856. * Index of refraction of the material's volume.
  56857. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56858. *
  56859. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56860. * the volume will use the same IOR as the surface.
  56861. */
  56862. get volumeIndexOfRefraction(): number;
  56863. set volumeIndexOfRefraction(value: number);
  56864. private _invertRefractionY;
  56865. /**
  56866. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56867. */
  56868. invertRefractionY: boolean;
  56869. private _linkRefractionWithTransparency;
  56870. /**
  56871. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56872. * Materials half opaque for instance using refraction could benefit from this control.
  56873. */
  56874. linkRefractionWithTransparency: boolean;
  56875. /**
  56876. * Defines the minimum thickness stored in the thickness map.
  56877. * If no thickness map is defined, this value will be used to simulate thickness.
  56878. */
  56879. minimumThickness: number;
  56880. /**
  56881. * Defines the maximum thickness stored in the thickness map.
  56882. */
  56883. maximumThickness: number;
  56884. /**
  56885. * Defines the volume tint of the material.
  56886. * This is used for both translucency and scattering.
  56887. */
  56888. tintColor: Color3;
  56889. /**
  56890. * Defines the distance at which the tint color should be found in the media.
  56891. * This is used for refraction only.
  56892. */
  56893. tintColorAtDistance: number;
  56894. /**
  56895. * Defines how far each channel transmit through the media.
  56896. * It is defined as a color to simplify it selection.
  56897. */
  56898. diffusionDistance: Color3;
  56899. private _useMaskFromThicknessTexture;
  56900. /**
  56901. * Stores the intensity of the different subsurface effects in the thickness texture.
  56902. * * the green channel is the translucency intensity.
  56903. * * the blue channel is the scattering intensity.
  56904. * * the alpha channel is the refraction intensity.
  56905. */
  56906. useMaskFromThicknessTexture: boolean;
  56907. /** @hidden */
  56908. private _internalMarkAllSubMeshesAsTexturesDirty;
  56909. /** @hidden */
  56910. _markAllSubMeshesAsTexturesDirty(): void;
  56911. /**
  56912. * Instantiate a new istance of sub surface configuration.
  56913. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56914. */
  56915. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56916. /**
  56917. * Gets wehter the submesh is ready to be used or not.
  56918. * @param defines the list of "defines" to update.
  56919. * @param scene defines the scene the material belongs to.
  56920. * @returns - boolean indicating that the submesh is ready or not.
  56921. */
  56922. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56923. /**
  56924. * Checks to see if a texture is used in the material.
  56925. * @param defines the list of "defines" to update.
  56926. * @param scene defines the scene to the material belongs to.
  56927. */
  56928. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56929. /**
  56930. * Binds the material data.
  56931. * @param uniformBuffer defines the Uniform buffer to fill in.
  56932. * @param scene defines the scene the material belongs to.
  56933. * @param engine defines the engine the material belongs to.
  56934. * @param isFrozen defines whether the material is frozen or not.
  56935. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56936. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56937. */
  56938. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56939. /**
  56940. * Unbinds the material from the mesh.
  56941. * @param activeEffect defines the effect that should be unbound from.
  56942. * @returns true if unbound, otherwise false
  56943. */
  56944. unbind(activeEffect: Effect): boolean;
  56945. /**
  56946. * Returns the texture used for refraction or null if none is used.
  56947. * @param scene defines the scene the material belongs to.
  56948. * @returns - Refraction texture if present. If no refraction texture and refraction
  56949. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56950. */
  56951. private _getRefractionTexture;
  56952. /**
  56953. * Returns true if alpha blending should be disabled.
  56954. */
  56955. get disableAlphaBlending(): boolean;
  56956. /**
  56957. * Fills the list of render target textures.
  56958. * @param renderTargets the list of render targets to update
  56959. */
  56960. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56961. /**
  56962. * Checks to see if a texture is used in the material.
  56963. * @param texture - Base texture to use.
  56964. * @returns - Boolean specifying if a texture is used in the material.
  56965. */
  56966. hasTexture(texture: BaseTexture): boolean;
  56967. /**
  56968. * Gets a boolean indicating that current material needs to register RTT
  56969. * @returns true if this uses a render target otherwise false.
  56970. */
  56971. hasRenderTargetTextures(): boolean;
  56972. /**
  56973. * Returns an array of the actively used textures.
  56974. * @param activeTextures Array of BaseTextures
  56975. */
  56976. getActiveTextures(activeTextures: BaseTexture[]): void;
  56977. /**
  56978. * Returns the animatable textures.
  56979. * @param animatables Array of animatable textures.
  56980. */
  56981. getAnimatables(animatables: IAnimatable[]): void;
  56982. /**
  56983. * Disposes the resources of the material.
  56984. * @param forceDisposeTextures - Forces the disposal of all textures.
  56985. */
  56986. dispose(forceDisposeTextures?: boolean): void;
  56987. /**
  56988. * Get the current class name of the texture useful for serialization or dynamic coding.
  56989. * @returns "PBRSubSurfaceConfiguration"
  56990. */
  56991. getClassName(): string;
  56992. /**
  56993. * Add fallbacks to the effect fallbacks list.
  56994. * @param defines defines the Base texture to use.
  56995. * @param fallbacks defines the current fallback list.
  56996. * @param currentRank defines the current fallback rank.
  56997. * @returns the new fallback rank.
  56998. */
  56999. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57000. /**
  57001. * Add the required uniforms to the current list.
  57002. * @param uniforms defines the current uniform list.
  57003. */
  57004. static AddUniforms(uniforms: string[]): void;
  57005. /**
  57006. * Add the required samplers to the current list.
  57007. * @param samplers defines the current sampler list.
  57008. */
  57009. static AddSamplers(samplers: string[]): void;
  57010. /**
  57011. * Add the required uniforms to the current buffer.
  57012. * @param uniformBuffer defines the current uniform buffer.
  57013. */
  57014. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57015. /**
  57016. * Makes a duplicate of the current configuration into another one.
  57017. * @param configuration define the config where to copy the info
  57018. */
  57019. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57020. /**
  57021. * Serializes this Sub Surface configuration.
  57022. * @returns - An object with the serialized config.
  57023. */
  57024. serialize(): any;
  57025. /**
  57026. * Parses a anisotropy Configuration from a serialized object.
  57027. * @param source - Serialized object.
  57028. * @param scene Defines the scene we are parsing for
  57029. * @param rootUrl Defines the rootUrl to load from
  57030. */
  57031. parse(source: any, scene: Scene, rootUrl: string): void;
  57032. }
  57033. }
  57034. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57035. /** @hidden */
  57036. export var pbrFragmentDeclaration: {
  57037. name: string;
  57038. shader: string;
  57039. };
  57040. }
  57041. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57042. /** @hidden */
  57043. export var pbrUboDeclaration: {
  57044. name: string;
  57045. shader: string;
  57046. };
  57047. }
  57048. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57049. /** @hidden */
  57050. export var pbrFragmentExtraDeclaration: {
  57051. name: string;
  57052. shader: string;
  57053. };
  57054. }
  57055. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57056. /** @hidden */
  57057. export var pbrFragmentSamplersDeclaration: {
  57058. name: string;
  57059. shader: string;
  57060. };
  57061. }
  57062. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57063. /** @hidden */
  57064. export var importanceSampling: {
  57065. name: string;
  57066. shader: string;
  57067. };
  57068. }
  57069. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57070. /** @hidden */
  57071. export var pbrHelperFunctions: {
  57072. name: string;
  57073. shader: string;
  57074. };
  57075. }
  57076. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57077. /** @hidden */
  57078. export var harmonicsFunctions: {
  57079. name: string;
  57080. shader: string;
  57081. };
  57082. }
  57083. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57084. /** @hidden */
  57085. export var pbrDirectLightingSetupFunctions: {
  57086. name: string;
  57087. shader: string;
  57088. };
  57089. }
  57090. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57091. /** @hidden */
  57092. export var pbrDirectLightingFalloffFunctions: {
  57093. name: string;
  57094. shader: string;
  57095. };
  57096. }
  57097. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57098. /** @hidden */
  57099. export var pbrBRDFFunctions: {
  57100. name: string;
  57101. shader: string;
  57102. };
  57103. }
  57104. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57105. /** @hidden */
  57106. export var hdrFilteringFunctions: {
  57107. name: string;
  57108. shader: string;
  57109. };
  57110. }
  57111. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57112. /** @hidden */
  57113. export var pbrDirectLightingFunctions: {
  57114. name: string;
  57115. shader: string;
  57116. };
  57117. }
  57118. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57119. /** @hidden */
  57120. export var pbrIBLFunctions: {
  57121. name: string;
  57122. shader: string;
  57123. };
  57124. }
  57125. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57126. /** @hidden */
  57127. export var pbrBlockAlbedoOpacity: {
  57128. name: string;
  57129. shader: string;
  57130. };
  57131. }
  57132. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57133. /** @hidden */
  57134. export var pbrBlockReflectivity: {
  57135. name: string;
  57136. shader: string;
  57137. };
  57138. }
  57139. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57140. /** @hidden */
  57141. export var pbrBlockAmbientOcclusion: {
  57142. name: string;
  57143. shader: string;
  57144. };
  57145. }
  57146. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57147. /** @hidden */
  57148. export var pbrBlockAlphaFresnel: {
  57149. name: string;
  57150. shader: string;
  57151. };
  57152. }
  57153. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57154. /** @hidden */
  57155. export var pbrBlockAnisotropic: {
  57156. name: string;
  57157. shader: string;
  57158. };
  57159. }
  57160. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57161. /** @hidden */
  57162. export var pbrBlockReflection: {
  57163. name: string;
  57164. shader: string;
  57165. };
  57166. }
  57167. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57168. /** @hidden */
  57169. export var pbrBlockSheen: {
  57170. name: string;
  57171. shader: string;
  57172. };
  57173. }
  57174. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57175. /** @hidden */
  57176. export var pbrBlockClearcoat: {
  57177. name: string;
  57178. shader: string;
  57179. };
  57180. }
  57181. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57182. /** @hidden */
  57183. export var pbrBlockSubSurface: {
  57184. name: string;
  57185. shader: string;
  57186. };
  57187. }
  57188. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57189. /** @hidden */
  57190. export var pbrBlockNormalGeometric: {
  57191. name: string;
  57192. shader: string;
  57193. };
  57194. }
  57195. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57196. /** @hidden */
  57197. export var pbrBlockNormalFinal: {
  57198. name: string;
  57199. shader: string;
  57200. };
  57201. }
  57202. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57203. /** @hidden */
  57204. export var pbrBlockGeometryInfo: {
  57205. name: string;
  57206. shader: string;
  57207. };
  57208. }
  57209. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57210. /** @hidden */
  57211. export var pbrBlockReflectance0: {
  57212. name: string;
  57213. shader: string;
  57214. };
  57215. }
  57216. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57217. /** @hidden */
  57218. export var pbrBlockReflectance: {
  57219. name: string;
  57220. shader: string;
  57221. };
  57222. }
  57223. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57224. /** @hidden */
  57225. export var pbrBlockDirectLighting: {
  57226. name: string;
  57227. shader: string;
  57228. };
  57229. }
  57230. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57231. /** @hidden */
  57232. export var pbrBlockFinalLitComponents: {
  57233. name: string;
  57234. shader: string;
  57235. };
  57236. }
  57237. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57238. /** @hidden */
  57239. export var pbrBlockFinalUnlitComponents: {
  57240. name: string;
  57241. shader: string;
  57242. };
  57243. }
  57244. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57245. /** @hidden */
  57246. export var pbrBlockFinalColorComposition: {
  57247. name: string;
  57248. shader: string;
  57249. };
  57250. }
  57251. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57252. /** @hidden */
  57253. export var pbrBlockImageProcessing: {
  57254. name: string;
  57255. shader: string;
  57256. };
  57257. }
  57258. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57259. /** @hidden */
  57260. export var pbrDebug: {
  57261. name: string;
  57262. shader: string;
  57263. };
  57264. }
  57265. declare module "babylonjs/Shaders/pbr.fragment" {
  57266. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57267. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57268. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57269. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57270. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57271. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57272. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57274. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57275. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57276. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57277. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57278. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57279. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57280. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57281. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57282. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57283. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57284. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57285. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57286. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57287. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57288. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57289. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57290. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57291. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57292. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57293. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57294. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57295. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57296. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57297. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57298. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57299. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57300. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57301. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57302. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57303. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57304. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57305. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57306. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57307. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57308. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57309. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57310. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57311. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57312. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57313. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57314. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57315. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57316. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57317. /** @hidden */
  57318. export var pbrPixelShader: {
  57319. name: string;
  57320. shader: string;
  57321. };
  57322. }
  57323. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57324. /** @hidden */
  57325. export var pbrVertexDeclaration: {
  57326. name: string;
  57327. shader: string;
  57328. };
  57329. }
  57330. declare module "babylonjs/Shaders/pbr.vertex" {
  57331. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57332. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57333. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57334. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57335. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57336. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57337. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57338. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57339. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57340. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57341. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57342. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57343. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57344. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57345. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57346. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57347. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57348. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57349. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57350. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57351. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57352. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57353. /** @hidden */
  57354. export var pbrVertexShader: {
  57355. name: string;
  57356. shader: string;
  57357. };
  57358. }
  57359. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57360. import { Nullable } from "babylonjs/types";
  57361. import { Scene } from "babylonjs/scene";
  57362. import { Matrix } from "babylonjs/Maths/math.vector";
  57363. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57365. import { Mesh } from "babylonjs/Meshes/mesh";
  57366. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57367. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57368. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57369. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57370. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57371. import { Color3 } from "babylonjs/Maths/math.color";
  57372. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57373. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57374. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57375. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57377. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57378. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57379. import "babylonjs/Shaders/pbr.fragment";
  57380. import "babylonjs/Shaders/pbr.vertex";
  57381. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57382. /**
  57383. * Manages the defines for the PBR Material.
  57384. * @hidden
  57385. */
  57386. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57387. PBR: boolean;
  57388. NUM_SAMPLES: string;
  57389. REALTIME_FILTERING: boolean;
  57390. MAINUV1: boolean;
  57391. MAINUV2: boolean;
  57392. UV1: boolean;
  57393. UV2: boolean;
  57394. ALBEDO: boolean;
  57395. GAMMAALBEDO: boolean;
  57396. ALBEDODIRECTUV: number;
  57397. VERTEXCOLOR: boolean;
  57398. DETAIL: boolean;
  57399. DETAILDIRECTUV: number;
  57400. DETAIL_NORMALBLENDMETHOD: number;
  57401. AMBIENT: boolean;
  57402. AMBIENTDIRECTUV: number;
  57403. AMBIENTINGRAYSCALE: boolean;
  57404. OPACITY: boolean;
  57405. VERTEXALPHA: boolean;
  57406. OPACITYDIRECTUV: number;
  57407. OPACITYRGB: boolean;
  57408. ALPHATEST: boolean;
  57409. DEPTHPREPASS: boolean;
  57410. ALPHABLEND: boolean;
  57411. ALPHAFROMALBEDO: boolean;
  57412. ALPHATESTVALUE: string;
  57413. SPECULAROVERALPHA: boolean;
  57414. RADIANCEOVERALPHA: boolean;
  57415. ALPHAFRESNEL: boolean;
  57416. LINEARALPHAFRESNEL: boolean;
  57417. PREMULTIPLYALPHA: boolean;
  57418. EMISSIVE: boolean;
  57419. EMISSIVEDIRECTUV: number;
  57420. REFLECTIVITY: boolean;
  57421. REFLECTIVITYDIRECTUV: number;
  57422. SPECULARTERM: boolean;
  57423. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57424. MICROSURFACEAUTOMATIC: boolean;
  57425. LODBASEDMICROSFURACE: boolean;
  57426. MICROSURFACEMAP: boolean;
  57427. MICROSURFACEMAPDIRECTUV: number;
  57428. METALLICWORKFLOW: boolean;
  57429. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57430. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57431. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57432. AOSTOREINMETALMAPRED: boolean;
  57433. METALLIC_REFLECTANCE: boolean;
  57434. METALLIC_REFLECTANCEDIRECTUV: number;
  57435. ENVIRONMENTBRDF: boolean;
  57436. ENVIRONMENTBRDF_RGBD: boolean;
  57437. NORMAL: boolean;
  57438. TANGENT: boolean;
  57439. BUMP: boolean;
  57440. BUMPDIRECTUV: number;
  57441. OBJECTSPACE_NORMALMAP: boolean;
  57442. PARALLAX: boolean;
  57443. PARALLAXOCCLUSION: boolean;
  57444. NORMALXYSCALE: boolean;
  57445. LIGHTMAP: boolean;
  57446. LIGHTMAPDIRECTUV: number;
  57447. USELIGHTMAPASSHADOWMAP: boolean;
  57448. GAMMALIGHTMAP: boolean;
  57449. RGBDLIGHTMAP: boolean;
  57450. REFLECTION: boolean;
  57451. REFLECTIONMAP_3D: boolean;
  57452. REFLECTIONMAP_SPHERICAL: boolean;
  57453. REFLECTIONMAP_PLANAR: boolean;
  57454. REFLECTIONMAP_CUBIC: boolean;
  57455. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57456. REFLECTIONMAP_PROJECTION: boolean;
  57457. REFLECTIONMAP_SKYBOX: boolean;
  57458. REFLECTIONMAP_EXPLICIT: boolean;
  57459. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57460. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57461. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57462. INVERTCUBICMAP: boolean;
  57463. USESPHERICALFROMREFLECTIONMAP: boolean;
  57464. USEIRRADIANCEMAP: boolean;
  57465. SPHERICAL_HARMONICS: boolean;
  57466. USESPHERICALINVERTEX: boolean;
  57467. REFLECTIONMAP_OPPOSITEZ: boolean;
  57468. LODINREFLECTIONALPHA: boolean;
  57469. GAMMAREFLECTION: boolean;
  57470. RGBDREFLECTION: boolean;
  57471. LINEARSPECULARREFLECTION: boolean;
  57472. RADIANCEOCCLUSION: boolean;
  57473. HORIZONOCCLUSION: boolean;
  57474. INSTANCES: boolean;
  57475. THIN_INSTANCES: boolean;
  57476. NUM_BONE_INFLUENCERS: number;
  57477. BonesPerMesh: number;
  57478. BONETEXTURE: boolean;
  57479. NONUNIFORMSCALING: boolean;
  57480. MORPHTARGETS: boolean;
  57481. MORPHTARGETS_NORMAL: boolean;
  57482. MORPHTARGETS_TANGENT: boolean;
  57483. MORPHTARGETS_UV: boolean;
  57484. NUM_MORPH_INFLUENCERS: number;
  57485. IMAGEPROCESSING: boolean;
  57486. VIGNETTE: boolean;
  57487. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57488. VIGNETTEBLENDMODEOPAQUE: boolean;
  57489. TONEMAPPING: boolean;
  57490. TONEMAPPING_ACES: boolean;
  57491. CONTRAST: boolean;
  57492. COLORCURVES: boolean;
  57493. COLORGRADING: boolean;
  57494. COLORGRADING3D: boolean;
  57495. SAMPLER3DGREENDEPTH: boolean;
  57496. SAMPLER3DBGRMAP: boolean;
  57497. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57498. EXPOSURE: boolean;
  57499. MULTIVIEW: boolean;
  57500. USEPHYSICALLIGHTFALLOFF: boolean;
  57501. USEGLTFLIGHTFALLOFF: boolean;
  57502. TWOSIDEDLIGHTING: boolean;
  57503. SHADOWFLOAT: boolean;
  57504. CLIPPLANE: boolean;
  57505. CLIPPLANE2: boolean;
  57506. CLIPPLANE3: boolean;
  57507. CLIPPLANE4: boolean;
  57508. CLIPPLANE5: boolean;
  57509. CLIPPLANE6: boolean;
  57510. POINTSIZE: boolean;
  57511. FOG: boolean;
  57512. LOGARITHMICDEPTH: boolean;
  57513. FORCENORMALFORWARD: boolean;
  57514. SPECULARAA: boolean;
  57515. CLEARCOAT: boolean;
  57516. CLEARCOAT_DEFAULTIOR: boolean;
  57517. CLEARCOAT_TEXTURE: boolean;
  57518. CLEARCOAT_TEXTUREDIRECTUV: number;
  57519. CLEARCOAT_BUMP: boolean;
  57520. CLEARCOAT_BUMPDIRECTUV: number;
  57521. CLEARCOAT_TINT: boolean;
  57522. CLEARCOAT_TINT_TEXTURE: boolean;
  57523. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57524. ANISOTROPIC: boolean;
  57525. ANISOTROPIC_TEXTURE: boolean;
  57526. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57527. BRDF_V_HEIGHT_CORRELATED: boolean;
  57528. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57529. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57530. SHEEN: boolean;
  57531. SHEEN_TEXTURE: boolean;
  57532. SHEEN_TEXTUREDIRECTUV: number;
  57533. SHEEN_LINKWITHALBEDO: boolean;
  57534. SHEEN_ROUGHNESS: boolean;
  57535. SHEEN_ALBEDOSCALING: boolean;
  57536. SUBSURFACE: boolean;
  57537. SS_REFRACTION: boolean;
  57538. SS_TRANSLUCENCY: boolean;
  57539. SS_SCATTERING: boolean;
  57540. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57541. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57542. SS_REFRACTIONMAP_3D: boolean;
  57543. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57544. SS_LODINREFRACTIONALPHA: boolean;
  57545. SS_GAMMAREFRACTION: boolean;
  57546. SS_RGBDREFRACTION: boolean;
  57547. SS_LINEARSPECULARREFRACTION: boolean;
  57548. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57549. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57550. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57551. UNLIT: boolean;
  57552. DEBUGMODE: number;
  57553. /**
  57554. * Initializes the PBR Material defines.
  57555. */
  57556. constructor();
  57557. /**
  57558. * Resets the PBR Material defines.
  57559. */
  57560. reset(): void;
  57561. }
  57562. /**
  57563. * The Physically based material base class of BJS.
  57564. *
  57565. * This offers the main features of a standard PBR material.
  57566. * For more information, please refer to the documentation :
  57567. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57568. */
  57569. export abstract class PBRBaseMaterial extends PushMaterial {
  57570. /**
  57571. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57572. */
  57573. static readonly PBRMATERIAL_OPAQUE: number;
  57574. /**
  57575. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57576. */
  57577. static readonly PBRMATERIAL_ALPHATEST: number;
  57578. /**
  57579. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57580. */
  57581. static readonly PBRMATERIAL_ALPHABLEND: number;
  57582. /**
  57583. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57584. * They are also discarded below the alpha cutoff threshold to improve performances.
  57585. */
  57586. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57587. /**
  57588. * Defines the default value of how much AO map is occluding the analytical lights
  57589. * (point spot...).
  57590. */
  57591. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57592. /**
  57593. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57594. */
  57595. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57596. /**
  57597. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57598. * to enhance interoperability with other engines.
  57599. */
  57600. static readonly LIGHTFALLOFF_GLTF: number;
  57601. /**
  57602. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57603. * to enhance interoperability with other materials.
  57604. */
  57605. static readonly LIGHTFALLOFF_STANDARD: number;
  57606. /**
  57607. * Intensity of the direct lights e.g. the four lights available in your scene.
  57608. * This impacts both the direct diffuse and specular highlights.
  57609. */
  57610. protected _directIntensity: number;
  57611. /**
  57612. * Intensity of the emissive part of the material.
  57613. * This helps controlling the emissive effect without modifying the emissive color.
  57614. */
  57615. protected _emissiveIntensity: number;
  57616. /**
  57617. * Intensity of the environment e.g. how much the environment will light the object
  57618. * either through harmonics for rough material or through the refelction for shiny ones.
  57619. */
  57620. protected _environmentIntensity: number;
  57621. /**
  57622. * This is a special control allowing the reduction of the specular highlights coming from the
  57623. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57624. */
  57625. protected _specularIntensity: number;
  57626. /**
  57627. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57628. */
  57629. private _lightingInfos;
  57630. /**
  57631. * Debug Control allowing disabling the bump map on this material.
  57632. */
  57633. protected _disableBumpMap: boolean;
  57634. /**
  57635. * AKA Diffuse Texture in standard nomenclature.
  57636. */
  57637. protected _albedoTexture: Nullable<BaseTexture>;
  57638. /**
  57639. * AKA Occlusion Texture in other nomenclature.
  57640. */
  57641. protected _ambientTexture: Nullable<BaseTexture>;
  57642. /**
  57643. * AKA Occlusion Texture Intensity in other nomenclature.
  57644. */
  57645. protected _ambientTextureStrength: number;
  57646. /**
  57647. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57648. * 1 means it completely occludes it
  57649. * 0 mean it has no impact
  57650. */
  57651. protected _ambientTextureImpactOnAnalyticalLights: number;
  57652. /**
  57653. * Stores the alpha values in a texture.
  57654. */
  57655. protected _opacityTexture: Nullable<BaseTexture>;
  57656. /**
  57657. * Stores the reflection values in a texture.
  57658. */
  57659. protected _reflectionTexture: Nullable<BaseTexture>;
  57660. /**
  57661. * Stores the emissive values in a texture.
  57662. */
  57663. protected _emissiveTexture: Nullable<BaseTexture>;
  57664. /**
  57665. * AKA Specular texture in other nomenclature.
  57666. */
  57667. protected _reflectivityTexture: Nullable<BaseTexture>;
  57668. /**
  57669. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57670. */
  57671. protected _metallicTexture: Nullable<BaseTexture>;
  57672. /**
  57673. * Specifies the metallic scalar of the metallic/roughness workflow.
  57674. * Can also be used to scale the metalness values of the metallic texture.
  57675. */
  57676. protected _metallic: Nullable<number>;
  57677. /**
  57678. * Specifies the roughness scalar of the metallic/roughness workflow.
  57679. * Can also be used to scale the roughness values of the metallic texture.
  57680. */
  57681. protected _roughness: Nullable<number>;
  57682. /**
  57683. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57684. * By default the indexOfrefraction is used to compute F0;
  57685. *
  57686. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57687. *
  57688. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57689. * F90 = metallicReflectanceColor;
  57690. */
  57691. protected _metallicF0Factor: number;
  57692. /**
  57693. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57694. * By default the F90 is always 1;
  57695. *
  57696. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57697. *
  57698. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57699. * F90 = metallicReflectanceColor;
  57700. */
  57701. protected _metallicReflectanceColor: Color3;
  57702. /**
  57703. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57704. * This is multiply against the scalar values defined in the material.
  57705. */
  57706. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57707. /**
  57708. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57709. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57710. */
  57711. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57712. /**
  57713. * Stores surface normal data used to displace a mesh in a texture.
  57714. */
  57715. protected _bumpTexture: Nullable<BaseTexture>;
  57716. /**
  57717. * Stores the pre-calculated light information of a mesh in a texture.
  57718. */
  57719. protected _lightmapTexture: Nullable<BaseTexture>;
  57720. /**
  57721. * The color of a material in ambient lighting.
  57722. */
  57723. protected _ambientColor: Color3;
  57724. /**
  57725. * AKA Diffuse Color in other nomenclature.
  57726. */
  57727. protected _albedoColor: Color3;
  57728. /**
  57729. * AKA Specular Color in other nomenclature.
  57730. */
  57731. protected _reflectivityColor: Color3;
  57732. /**
  57733. * The color applied when light is reflected from a material.
  57734. */
  57735. protected _reflectionColor: Color3;
  57736. /**
  57737. * The color applied when light is emitted from a material.
  57738. */
  57739. protected _emissiveColor: Color3;
  57740. /**
  57741. * AKA Glossiness in other nomenclature.
  57742. */
  57743. protected _microSurface: number;
  57744. /**
  57745. * Specifies that the material will use the light map as a show map.
  57746. */
  57747. protected _useLightmapAsShadowmap: boolean;
  57748. /**
  57749. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57750. * makes the reflect vector face the model (under horizon).
  57751. */
  57752. protected _useHorizonOcclusion: boolean;
  57753. /**
  57754. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57755. * too much the area relying on ambient texture to define their ambient occlusion.
  57756. */
  57757. protected _useRadianceOcclusion: boolean;
  57758. /**
  57759. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57760. */
  57761. protected _useAlphaFromAlbedoTexture: boolean;
  57762. /**
  57763. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57764. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57765. */
  57766. protected _useSpecularOverAlpha: boolean;
  57767. /**
  57768. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57769. */
  57770. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57771. /**
  57772. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57773. */
  57774. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57775. /**
  57776. * Specifies if the metallic texture contains the roughness information in its green channel.
  57777. */
  57778. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57779. /**
  57780. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57781. */
  57782. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57783. /**
  57784. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57785. */
  57786. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57787. /**
  57788. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57789. */
  57790. protected _useAmbientInGrayScale: boolean;
  57791. /**
  57792. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57793. * The material will try to infer what glossiness each pixel should be.
  57794. */
  57795. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57796. /**
  57797. * Defines the falloff type used in this material.
  57798. * It by default is Physical.
  57799. */
  57800. protected _lightFalloff: number;
  57801. /**
  57802. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57803. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57804. */
  57805. protected _useRadianceOverAlpha: boolean;
  57806. /**
  57807. * Allows using an object space normal map (instead of tangent space).
  57808. */
  57809. protected _useObjectSpaceNormalMap: boolean;
  57810. /**
  57811. * Allows using the bump map in parallax mode.
  57812. */
  57813. protected _useParallax: boolean;
  57814. /**
  57815. * Allows using the bump map in parallax occlusion mode.
  57816. */
  57817. protected _useParallaxOcclusion: boolean;
  57818. /**
  57819. * Controls the scale bias of the parallax mode.
  57820. */
  57821. protected _parallaxScaleBias: number;
  57822. /**
  57823. * If sets to true, disables all the lights affecting the material.
  57824. */
  57825. protected _disableLighting: boolean;
  57826. /**
  57827. * Number of Simultaneous lights allowed on the material.
  57828. */
  57829. protected _maxSimultaneousLights: number;
  57830. /**
  57831. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57832. */
  57833. protected _invertNormalMapX: boolean;
  57834. /**
  57835. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57836. */
  57837. protected _invertNormalMapY: boolean;
  57838. /**
  57839. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57840. */
  57841. protected _twoSidedLighting: boolean;
  57842. /**
  57843. * Defines the alpha limits in alpha test mode.
  57844. */
  57845. protected _alphaCutOff: number;
  57846. /**
  57847. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57848. */
  57849. protected _forceAlphaTest: boolean;
  57850. /**
  57851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57852. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57853. */
  57854. protected _useAlphaFresnel: boolean;
  57855. /**
  57856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57857. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57858. */
  57859. protected _useLinearAlphaFresnel: boolean;
  57860. /**
  57861. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57862. * from cos thetav and roughness:
  57863. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57864. */
  57865. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57866. /**
  57867. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57868. */
  57869. protected _forceIrradianceInFragment: boolean;
  57870. private _realTimeFiltering;
  57871. /**
  57872. * Enables realtime filtering on the texture.
  57873. */
  57874. get realTimeFiltering(): boolean;
  57875. set realTimeFiltering(b: boolean);
  57876. private _realTimeFilteringQuality;
  57877. /**
  57878. * Quality switch for realtime filtering
  57879. */
  57880. get realTimeFilteringQuality(): number;
  57881. set realTimeFilteringQuality(n: number);
  57882. /**
  57883. * Force normal to face away from face.
  57884. */
  57885. protected _forceNormalForward: boolean;
  57886. /**
  57887. * Enables specular anti aliasing in the PBR shader.
  57888. * It will both interacts on the Geometry for analytical and IBL lighting.
  57889. * It also prefilter the roughness map based on the bump values.
  57890. */
  57891. protected _enableSpecularAntiAliasing: boolean;
  57892. /**
  57893. * Default configuration related to image processing available in the PBR Material.
  57894. */
  57895. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57896. /**
  57897. * Keep track of the image processing observer to allow dispose and replace.
  57898. */
  57899. private _imageProcessingObserver;
  57900. /**
  57901. * Attaches a new image processing configuration to the PBR Material.
  57902. * @param configuration
  57903. */
  57904. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57905. /**
  57906. * Stores the available render targets.
  57907. */
  57908. private _renderTargets;
  57909. /**
  57910. * Sets the global ambient color for the material used in lighting calculations.
  57911. */
  57912. private _globalAmbientColor;
  57913. /**
  57914. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57915. */
  57916. private _useLogarithmicDepth;
  57917. /**
  57918. * If set to true, no lighting calculations will be applied.
  57919. */
  57920. private _unlit;
  57921. private _debugMode;
  57922. /**
  57923. * @hidden
  57924. * This is reserved for the inspector.
  57925. * Defines the material debug mode.
  57926. * It helps seeing only some components of the material while troubleshooting.
  57927. */
  57928. debugMode: number;
  57929. /**
  57930. * @hidden
  57931. * This is reserved for the inspector.
  57932. * Specify from where on screen the debug mode should start.
  57933. * The value goes from -1 (full screen) to 1 (not visible)
  57934. * It helps with side by side comparison against the final render
  57935. * This defaults to -1
  57936. */
  57937. private debugLimit;
  57938. /**
  57939. * @hidden
  57940. * This is reserved for the inspector.
  57941. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57942. * You can use the factor to better multiply the final value.
  57943. */
  57944. private debugFactor;
  57945. /**
  57946. * Defines the clear coat layer parameters for the material.
  57947. */
  57948. readonly clearCoat: PBRClearCoatConfiguration;
  57949. /**
  57950. * Defines the anisotropic parameters for the material.
  57951. */
  57952. readonly anisotropy: PBRAnisotropicConfiguration;
  57953. /**
  57954. * Defines the BRDF parameters for the material.
  57955. */
  57956. readonly brdf: PBRBRDFConfiguration;
  57957. /**
  57958. * Defines the Sheen parameters for the material.
  57959. */
  57960. readonly sheen: PBRSheenConfiguration;
  57961. /**
  57962. * Defines the SubSurface parameters for the material.
  57963. */
  57964. readonly subSurface: PBRSubSurfaceConfiguration;
  57965. /**
  57966. * Defines the detail map parameters for the material.
  57967. */
  57968. readonly detailMap: DetailMapConfiguration;
  57969. protected _rebuildInParallel: boolean;
  57970. /**
  57971. * Instantiates a new PBRMaterial instance.
  57972. *
  57973. * @param name The material name
  57974. * @param scene The scene the material will be use in.
  57975. */
  57976. constructor(name: string, scene: Scene);
  57977. /**
  57978. * Gets a boolean indicating that current material needs to register RTT
  57979. */
  57980. get hasRenderTargetTextures(): boolean;
  57981. /**
  57982. * Gets the name of the material class.
  57983. */
  57984. getClassName(): string;
  57985. /**
  57986. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57987. */
  57988. get useLogarithmicDepth(): boolean;
  57989. /**
  57990. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57991. */
  57992. set useLogarithmicDepth(value: boolean);
  57993. /**
  57994. * Returns true if alpha blending should be disabled.
  57995. */
  57996. protected get _disableAlphaBlending(): boolean;
  57997. /**
  57998. * Specifies whether or not this material should be rendered in alpha blend mode.
  57999. */
  58000. needAlphaBlending(): boolean;
  58001. /**
  58002. * Specifies whether or not this material should be rendered in alpha test mode.
  58003. */
  58004. needAlphaTesting(): boolean;
  58005. /**
  58006. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58007. */
  58008. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58009. /**
  58010. * Gets the texture used for the alpha test.
  58011. */
  58012. getAlphaTestTexture(): Nullable<BaseTexture>;
  58013. /**
  58014. * Specifies that the submesh is ready to be used.
  58015. * @param mesh - BJS mesh.
  58016. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58017. * @param useInstances - Specifies that instances should be used.
  58018. * @returns - boolean indicating that the submesh is ready or not.
  58019. */
  58020. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58021. /**
  58022. * Specifies if the material uses metallic roughness workflow.
  58023. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58024. */
  58025. isMetallicWorkflow(): boolean;
  58026. private _prepareEffect;
  58027. private _prepareDefines;
  58028. /**
  58029. * Force shader compilation
  58030. */
  58031. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58032. /**
  58033. * Initializes the uniform buffer layout for the shader.
  58034. */
  58035. buildUniformLayout(): void;
  58036. /**
  58037. * Unbinds the material from the mesh
  58038. */
  58039. unbind(): void;
  58040. /**
  58041. * Binds the submesh data.
  58042. * @param world - The world matrix.
  58043. * @param mesh - The BJS mesh.
  58044. * @param subMesh - A submesh of the BJS mesh.
  58045. */
  58046. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58047. /**
  58048. * Returns the animatable textures.
  58049. * @returns - Array of animatable textures.
  58050. */
  58051. getAnimatables(): IAnimatable[];
  58052. /**
  58053. * Returns the texture used for reflections.
  58054. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58055. */
  58056. private _getReflectionTexture;
  58057. /**
  58058. * Returns an array of the actively used textures.
  58059. * @returns - Array of BaseTextures
  58060. */
  58061. getActiveTextures(): BaseTexture[];
  58062. /**
  58063. * Checks to see if a texture is used in the material.
  58064. * @param texture - Base texture to use.
  58065. * @returns - Boolean specifying if a texture is used in the material.
  58066. */
  58067. hasTexture(texture: BaseTexture): boolean;
  58068. /**
  58069. * Disposes the resources of the material.
  58070. * @param forceDisposeEffect - Forces the disposal of effects.
  58071. * @param forceDisposeTextures - Forces the disposal of all textures.
  58072. */
  58073. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58074. }
  58075. }
  58076. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58077. import { Nullable } from "babylonjs/types";
  58078. import { Scene } from "babylonjs/scene";
  58079. import { Color3 } from "babylonjs/Maths/math.color";
  58080. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58081. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58083. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58084. /**
  58085. * The Physically based material of BJS.
  58086. *
  58087. * This offers the main features of a standard PBR material.
  58088. * For more information, please refer to the documentation :
  58089. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58090. */
  58091. export class PBRMaterial extends PBRBaseMaterial {
  58092. /**
  58093. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58094. */
  58095. static readonly PBRMATERIAL_OPAQUE: number;
  58096. /**
  58097. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58098. */
  58099. static readonly PBRMATERIAL_ALPHATEST: number;
  58100. /**
  58101. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58102. */
  58103. static readonly PBRMATERIAL_ALPHABLEND: number;
  58104. /**
  58105. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58106. * They are also discarded below the alpha cutoff threshold to improve performances.
  58107. */
  58108. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58109. /**
  58110. * Defines the default value of how much AO map is occluding the analytical lights
  58111. * (point spot...).
  58112. */
  58113. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58114. /**
  58115. * Intensity of the direct lights e.g. the four lights available in your scene.
  58116. * This impacts both the direct diffuse and specular highlights.
  58117. */
  58118. directIntensity: number;
  58119. /**
  58120. * Intensity of the emissive part of the material.
  58121. * This helps controlling the emissive effect without modifying the emissive color.
  58122. */
  58123. emissiveIntensity: number;
  58124. /**
  58125. * Intensity of the environment e.g. how much the environment will light the object
  58126. * either through harmonics for rough material or through the refelction for shiny ones.
  58127. */
  58128. environmentIntensity: number;
  58129. /**
  58130. * This is a special control allowing the reduction of the specular highlights coming from the
  58131. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58132. */
  58133. specularIntensity: number;
  58134. /**
  58135. * Debug Control allowing disabling the bump map on this material.
  58136. */
  58137. disableBumpMap: boolean;
  58138. /**
  58139. * AKA Diffuse Texture in standard nomenclature.
  58140. */
  58141. albedoTexture: BaseTexture;
  58142. /**
  58143. * AKA Occlusion Texture in other nomenclature.
  58144. */
  58145. ambientTexture: BaseTexture;
  58146. /**
  58147. * AKA Occlusion Texture Intensity in other nomenclature.
  58148. */
  58149. ambientTextureStrength: number;
  58150. /**
  58151. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58152. * 1 means it completely occludes it
  58153. * 0 mean it has no impact
  58154. */
  58155. ambientTextureImpactOnAnalyticalLights: number;
  58156. /**
  58157. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58158. */
  58159. opacityTexture: BaseTexture;
  58160. /**
  58161. * Stores the reflection values in a texture.
  58162. */
  58163. reflectionTexture: Nullable<BaseTexture>;
  58164. /**
  58165. * Stores the emissive values in a texture.
  58166. */
  58167. emissiveTexture: BaseTexture;
  58168. /**
  58169. * AKA Specular texture in other nomenclature.
  58170. */
  58171. reflectivityTexture: BaseTexture;
  58172. /**
  58173. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58174. */
  58175. metallicTexture: BaseTexture;
  58176. /**
  58177. * Specifies the metallic scalar of the metallic/roughness workflow.
  58178. * Can also be used to scale the metalness values of the metallic texture.
  58179. */
  58180. metallic: Nullable<number>;
  58181. /**
  58182. * Specifies the roughness scalar of the metallic/roughness workflow.
  58183. * Can also be used to scale the roughness values of the metallic texture.
  58184. */
  58185. roughness: Nullable<number>;
  58186. /**
  58187. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58188. * By default the indexOfrefraction is used to compute F0;
  58189. *
  58190. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58191. *
  58192. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58193. * F90 = metallicReflectanceColor;
  58194. */
  58195. metallicF0Factor: number;
  58196. /**
  58197. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58198. * By default the F90 is always 1;
  58199. *
  58200. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58201. *
  58202. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58203. * F90 = metallicReflectanceColor;
  58204. */
  58205. metallicReflectanceColor: Color3;
  58206. /**
  58207. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58208. * This is multiply against the scalar values defined in the material.
  58209. */
  58210. metallicReflectanceTexture: Nullable<BaseTexture>;
  58211. /**
  58212. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58213. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58214. */
  58215. microSurfaceTexture: BaseTexture;
  58216. /**
  58217. * Stores surface normal data used to displace a mesh in a texture.
  58218. */
  58219. bumpTexture: BaseTexture;
  58220. /**
  58221. * Stores the pre-calculated light information of a mesh in a texture.
  58222. */
  58223. lightmapTexture: BaseTexture;
  58224. /**
  58225. * Stores the refracted light information in a texture.
  58226. */
  58227. get refractionTexture(): Nullable<BaseTexture>;
  58228. set refractionTexture(value: Nullable<BaseTexture>);
  58229. /**
  58230. * The color of a material in ambient lighting.
  58231. */
  58232. ambientColor: Color3;
  58233. /**
  58234. * AKA Diffuse Color in other nomenclature.
  58235. */
  58236. albedoColor: Color3;
  58237. /**
  58238. * AKA Specular Color in other nomenclature.
  58239. */
  58240. reflectivityColor: Color3;
  58241. /**
  58242. * The color reflected from the material.
  58243. */
  58244. reflectionColor: Color3;
  58245. /**
  58246. * The color emitted from the material.
  58247. */
  58248. emissiveColor: Color3;
  58249. /**
  58250. * AKA Glossiness in other nomenclature.
  58251. */
  58252. microSurface: number;
  58253. /**
  58254. * Index of refraction of the material base layer.
  58255. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58256. *
  58257. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58258. *
  58259. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58260. */
  58261. get indexOfRefraction(): number;
  58262. set indexOfRefraction(value: number);
  58263. /**
  58264. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58265. */
  58266. get invertRefractionY(): boolean;
  58267. set invertRefractionY(value: boolean);
  58268. /**
  58269. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58270. * Materials half opaque for instance using refraction could benefit from this control.
  58271. */
  58272. get linkRefractionWithTransparency(): boolean;
  58273. set linkRefractionWithTransparency(value: boolean);
  58274. /**
  58275. * If true, the light map contains occlusion information instead of lighting info.
  58276. */
  58277. useLightmapAsShadowmap: boolean;
  58278. /**
  58279. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58280. */
  58281. useAlphaFromAlbedoTexture: boolean;
  58282. /**
  58283. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58284. */
  58285. forceAlphaTest: boolean;
  58286. /**
  58287. * Defines the alpha limits in alpha test mode.
  58288. */
  58289. alphaCutOff: number;
  58290. /**
  58291. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58292. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58293. */
  58294. useSpecularOverAlpha: boolean;
  58295. /**
  58296. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58297. */
  58298. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58299. /**
  58300. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58301. */
  58302. useRoughnessFromMetallicTextureAlpha: boolean;
  58303. /**
  58304. * Specifies if the metallic texture contains the roughness information in its green channel.
  58305. */
  58306. useRoughnessFromMetallicTextureGreen: boolean;
  58307. /**
  58308. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58309. */
  58310. useMetallnessFromMetallicTextureBlue: boolean;
  58311. /**
  58312. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58313. */
  58314. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58315. /**
  58316. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58317. */
  58318. useAmbientInGrayScale: boolean;
  58319. /**
  58320. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58321. * The material will try to infer what glossiness each pixel should be.
  58322. */
  58323. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58324. /**
  58325. * BJS is using an harcoded light falloff based on a manually sets up range.
  58326. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58327. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58328. */
  58329. get usePhysicalLightFalloff(): boolean;
  58330. /**
  58331. * BJS is using an harcoded light falloff based on a manually sets up range.
  58332. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58333. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58334. */
  58335. set usePhysicalLightFalloff(value: boolean);
  58336. /**
  58337. * In order to support the falloff compatibility with gltf, a special mode has been added
  58338. * to reproduce the gltf light falloff.
  58339. */
  58340. get useGLTFLightFalloff(): boolean;
  58341. /**
  58342. * In order to support the falloff compatibility with gltf, a special mode has been added
  58343. * to reproduce the gltf light falloff.
  58344. */
  58345. set useGLTFLightFalloff(value: boolean);
  58346. /**
  58347. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58348. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58349. */
  58350. useRadianceOverAlpha: boolean;
  58351. /**
  58352. * Allows using an object space normal map (instead of tangent space).
  58353. */
  58354. useObjectSpaceNormalMap: boolean;
  58355. /**
  58356. * Allows using the bump map in parallax mode.
  58357. */
  58358. useParallax: boolean;
  58359. /**
  58360. * Allows using the bump map in parallax occlusion mode.
  58361. */
  58362. useParallaxOcclusion: boolean;
  58363. /**
  58364. * Controls the scale bias of the parallax mode.
  58365. */
  58366. parallaxScaleBias: number;
  58367. /**
  58368. * If sets to true, disables all the lights affecting the material.
  58369. */
  58370. disableLighting: boolean;
  58371. /**
  58372. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58373. */
  58374. forceIrradianceInFragment: boolean;
  58375. /**
  58376. * Number of Simultaneous lights allowed on the material.
  58377. */
  58378. maxSimultaneousLights: number;
  58379. /**
  58380. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58381. */
  58382. invertNormalMapX: boolean;
  58383. /**
  58384. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58385. */
  58386. invertNormalMapY: boolean;
  58387. /**
  58388. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58389. */
  58390. twoSidedLighting: boolean;
  58391. /**
  58392. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58393. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58394. */
  58395. useAlphaFresnel: boolean;
  58396. /**
  58397. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58398. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58399. */
  58400. useLinearAlphaFresnel: boolean;
  58401. /**
  58402. * Let user defines the brdf lookup texture used for IBL.
  58403. * A default 8bit version is embedded but you could point at :
  58404. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58405. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58406. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58407. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58408. */
  58409. environmentBRDFTexture: Nullable<BaseTexture>;
  58410. /**
  58411. * Force normal to face away from face.
  58412. */
  58413. forceNormalForward: boolean;
  58414. /**
  58415. * Enables specular anti aliasing in the PBR shader.
  58416. * It will both interacts on the Geometry for analytical and IBL lighting.
  58417. * It also prefilter the roughness map based on the bump values.
  58418. */
  58419. enableSpecularAntiAliasing: boolean;
  58420. /**
  58421. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58422. * makes the reflect vector face the model (under horizon).
  58423. */
  58424. useHorizonOcclusion: boolean;
  58425. /**
  58426. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58427. * too much the area relying on ambient texture to define their ambient occlusion.
  58428. */
  58429. useRadianceOcclusion: boolean;
  58430. /**
  58431. * If set to true, no lighting calculations will be applied.
  58432. */
  58433. unlit: boolean;
  58434. /**
  58435. * Gets the image processing configuration used either in this material.
  58436. */
  58437. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58438. /**
  58439. * Sets the Default image processing configuration used either in the this material.
  58440. *
  58441. * If sets to null, the scene one is in use.
  58442. */
  58443. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58444. /**
  58445. * Gets wether the color curves effect is enabled.
  58446. */
  58447. get cameraColorCurvesEnabled(): boolean;
  58448. /**
  58449. * Sets wether the color curves effect is enabled.
  58450. */
  58451. set cameraColorCurvesEnabled(value: boolean);
  58452. /**
  58453. * Gets wether the color grading effect is enabled.
  58454. */
  58455. get cameraColorGradingEnabled(): boolean;
  58456. /**
  58457. * Gets wether the color grading effect is enabled.
  58458. */
  58459. set cameraColorGradingEnabled(value: boolean);
  58460. /**
  58461. * Gets wether tonemapping is enabled or not.
  58462. */
  58463. get cameraToneMappingEnabled(): boolean;
  58464. /**
  58465. * Sets wether tonemapping is enabled or not
  58466. */
  58467. set cameraToneMappingEnabled(value: boolean);
  58468. /**
  58469. * The camera exposure used on this material.
  58470. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58471. * This corresponds to a photographic exposure.
  58472. */
  58473. get cameraExposure(): number;
  58474. /**
  58475. * The camera exposure used on this material.
  58476. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58477. * This corresponds to a photographic exposure.
  58478. */
  58479. set cameraExposure(value: number);
  58480. /**
  58481. * Gets The camera contrast used on this material.
  58482. */
  58483. get cameraContrast(): number;
  58484. /**
  58485. * Sets The camera contrast used on this material.
  58486. */
  58487. set cameraContrast(value: number);
  58488. /**
  58489. * Gets the Color Grading 2D Lookup Texture.
  58490. */
  58491. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58492. /**
  58493. * Sets the Color Grading 2D Lookup Texture.
  58494. */
  58495. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58496. /**
  58497. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58498. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58499. * 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;
  58500. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58501. */
  58502. get cameraColorCurves(): Nullable<ColorCurves>;
  58503. /**
  58504. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58505. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58506. * 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;
  58507. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58508. */
  58509. set cameraColorCurves(value: Nullable<ColorCurves>);
  58510. /**
  58511. * Instantiates a new PBRMaterial instance.
  58512. *
  58513. * @param name The material name
  58514. * @param scene The scene the material will be use in.
  58515. */
  58516. constructor(name: string, scene: Scene);
  58517. /**
  58518. * Returns the name of this material class.
  58519. */
  58520. getClassName(): string;
  58521. /**
  58522. * Makes a duplicate of the current material.
  58523. * @param name - name to use for the new material.
  58524. */
  58525. clone(name: string): PBRMaterial;
  58526. /**
  58527. * Serializes this PBR Material.
  58528. * @returns - An object with the serialized material.
  58529. */
  58530. serialize(): any;
  58531. /**
  58532. * Parses a PBR Material from a serialized object.
  58533. * @param source - Serialized object.
  58534. * @param scene - BJS scene instance.
  58535. * @param rootUrl - url for the scene object
  58536. * @returns - PBRMaterial
  58537. */
  58538. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58539. }
  58540. }
  58541. declare module "babylonjs/Misc/dds" {
  58542. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58543. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58544. import { Nullable } from "babylonjs/types";
  58545. import { Scene } from "babylonjs/scene";
  58546. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58547. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58548. /**
  58549. * Direct draw surface info
  58550. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58551. */
  58552. export interface DDSInfo {
  58553. /**
  58554. * Width of the texture
  58555. */
  58556. width: number;
  58557. /**
  58558. * Width of the texture
  58559. */
  58560. height: number;
  58561. /**
  58562. * Number of Mipmaps for the texture
  58563. * @see https://en.wikipedia.org/wiki/Mipmap
  58564. */
  58565. mipmapCount: number;
  58566. /**
  58567. * If the textures format is a known fourCC format
  58568. * @see https://www.fourcc.org/
  58569. */
  58570. isFourCC: boolean;
  58571. /**
  58572. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58573. */
  58574. isRGB: boolean;
  58575. /**
  58576. * If the texture is a lumincance format
  58577. */
  58578. isLuminance: boolean;
  58579. /**
  58580. * If this is a cube texture
  58581. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58582. */
  58583. isCube: boolean;
  58584. /**
  58585. * If the texture is a compressed format eg. FOURCC_DXT1
  58586. */
  58587. isCompressed: boolean;
  58588. /**
  58589. * The dxgiFormat of the texture
  58590. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58591. */
  58592. dxgiFormat: number;
  58593. /**
  58594. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58595. */
  58596. textureType: number;
  58597. /**
  58598. * Sphericle polynomial created for the dds texture
  58599. */
  58600. sphericalPolynomial?: SphericalPolynomial;
  58601. }
  58602. /**
  58603. * Class used to provide DDS decompression tools
  58604. */
  58605. export class DDSTools {
  58606. /**
  58607. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58608. */
  58609. static StoreLODInAlphaChannel: boolean;
  58610. /**
  58611. * Gets DDS information from an array buffer
  58612. * @param data defines the array buffer view to read data from
  58613. * @returns the DDS information
  58614. */
  58615. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58616. private static _FloatView;
  58617. private static _Int32View;
  58618. private static _ToHalfFloat;
  58619. private static _FromHalfFloat;
  58620. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58621. private static _GetHalfFloatRGBAArrayBuffer;
  58622. private static _GetFloatRGBAArrayBuffer;
  58623. private static _GetFloatAsUIntRGBAArrayBuffer;
  58624. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58625. private static _GetRGBAArrayBuffer;
  58626. private static _ExtractLongWordOrder;
  58627. private static _GetRGBArrayBuffer;
  58628. private static _GetLuminanceArrayBuffer;
  58629. /**
  58630. * Uploads DDS Levels to a Babylon Texture
  58631. * @hidden
  58632. */
  58633. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58634. }
  58635. module "babylonjs/Engines/thinEngine" {
  58636. interface ThinEngine {
  58637. /**
  58638. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58639. * @param rootUrl defines the url where the file to load is located
  58640. * @param scene defines the current scene
  58641. * @param lodScale defines scale to apply to the mip map selection
  58642. * @param lodOffset defines offset to apply to the mip map selection
  58643. * @param onLoad defines an optional callback raised when the texture is loaded
  58644. * @param onError defines an optional callback raised if there is an issue to load the texture
  58645. * @param format defines the format of the data
  58646. * @param forcedExtension defines the extension to use to pick the right loader
  58647. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58648. * @returns the cube texture as an InternalTexture
  58649. */
  58650. 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;
  58651. }
  58652. }
  58653. }
  58654. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58655. import { Nullable } from "babylonjs/types";
  58656. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58657. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58658. /**
  58659. * Implementation of the DDS Texture Loader.
  58660. * @hidden
  58661. */
  58662. export class _DDSTextureLoader implements IInternalTextureLoader {
  58663. /**
  58664. * Defines wether the loader supports cascade loading the different faces.
  58665. */
  58666. readonly supportCascades: boolean;
  58667. /**
  58668. * This returns if the loader support the current file information.
  58669. * @param extension defines the file extension of the file being loaded
  58670. * @returns true if the loader can load the specified file
  58671. */
  58672. canLoad(extension: string): boolean;
  58673. /**
  58674. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58675. * @param data contains the texture data
  58676. * @param texture defines the BabylonJS internal texture
  58677. * @param createPolynomials will be true if polynomials have been requested
  58678. * @param onLoad defines the callback to trigger once the texture is ready
  58679. * @param onError defines the callback to trigger in case of error
  58680. */
  58681. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58682. /**
  58683. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58684. * @param data contains the texture data
  58685. * @param texture defines the BabylonJS internal texture
  58686. * @param callback defines the method to call once ready to upload
  58687. */
  58688. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58689. }
  58690. }
  58691. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58692. import { Nullable } from "babylonjs/types";
  58693. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58694. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58695. /**
  58696. * Implementation of the ENV Texture Loader.
  58697. * @hidden
  58698. */
  58699. export class _ENVTextureLoader implements IInternalTextureLoader {
  58700. /**
  58701. * Defines wether the loader supports cascade loading the different faces.
  58702. */
  58703. readonly supportCascades: boolean;
  58704. /**
  58705. * This returns if the loader support the current file information.
  58706. * @param extension defines the file extension of the file being loaded
  58707. * @returns true if the loader can load the specified file
  58708. */
  58709. canLoad(extension: string): boolean;
  58710. /**
  58711. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58712. * @param data contains the texture data
  58713. * @param texture defines the BabylonJS internal texture
  58714. * @param createPolynomials will be true if polynomials have been requested
  58715. * @param onLoad defines the callback to trigger once the texture is ready
  58716. * @param onError defines the callback to trigger in case of error
  58717. */
  58718. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58719. /**
  58720. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58721. * @param data contains the texture data
  58722. * @param texture defines the BabylonJS internal texture
  58723. * @param callback defines the method to call once ready to upload
  58724. */
  58725. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58726. }
  58727. }
  58728. declare module "babylonjs/Misc/khronosTextureContainer" {
  58729. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58730. /**
  58731. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58732. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58733. */
  58734. export class KhronosTextureContainer {
  58735. /** contents of the KTX container file */
  58736. data: ArrayBufferView;
  58737. private static HEADER_LEN;
  58738. private static COMPRESSED_2D;
  58739. private static COMPRESSED_3D;
  58740. private static TEX_2D;
  58741. private static TEX_3D;
  58742. /**
  58743. * Gets the openGL type
  58744. */
  58745. glType: number;
  58746. /**
  58747. * Gets the openGL type size
  58748. */
  58749. glTypeSize: number;
  58750. /**
  58751. * Gets the openGL format
  58752. */
  58753. glFormat: number;
  58754. /**
  58755. * Gets the openGL internal format
  58756. */
  58757. glInternalFormat: number;
  58758. /**
  58759. * Gets the base internal format
  58760. */
  58761. glBaseInternalFormat: number;
  58762. /**
  58763. * Gets image width in pixel
  58764. */
  58765. pixelWidth: number;
  58766. /**
  58767. * Gets image height in pixel
  58768. */
  58769. pixelHeight: number;
  58770. /**
  58771. * Gets image depth in pixels
  58772. */
  58773. pixelDepth: number;
  58774. /**
  58775. * Gets the number of array elements
  58776. */
  58777. numberOfArrayElements: number;
  58778. /**
  58779. * Gets the number of faces
  58780. */
  58781. numberOfFaces: number;
  58782. /**
  58783. * Gets the number of mipmap levels
  58784. */
  58785. numberOfMipmapLevels: number;
  58786. /**
  58787. * Gets the bytes of key value data
  58788. */
  58789. bytesOfKeyValueData: number;
  58790. /**
  58791. * Gets the load type
  58792. */
  58793. loadType: number;
  58794. /**
  58795. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58796. */
  58797. isInvalid: boolean;
  58798. /**
  58799. * Creates a new KhronosTextureContainer
  58800. * @param data contents of the KTX container file
  58801. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58802. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58803. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58804. */
  58805. constructor(
  58806. /** contents of the KTX container file */
  58807. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58808. /**
  58809. * Uploads KTX content to a Babylon Texture.
  58810. * It is assumed that the texture has already been created & is currently bound
  58811. * @hidden
  58812. */
  58813. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58814. private _upload2DCompressedLevels;
  58815. /**
  58816. * Checks if the given data starts with a KTX file identifier.
  58817. * @param data the data to check
  58818. * @returns true if the data is a KTX file or false otherwise
  58819. */
  58820. static IsValid(data: ArrayBufferView): boolean;
  58821. }
  58822. }
  58823. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58824. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58825. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58826. /**
  58827. * Class for loading KTX2 files
  58828. * !!! Experimental Extension Subject to Changes !!!
  58829. * @hidden
  58830. */
  58831. export class KhronosTextureContainer2 {
  58832. private static _ModulePromise;
  58833. private static _TranscodeFormat;
  58834. constructor(engine: ThinEngine);
  58835. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58836. private _determineTranscodeFormat;
  58837. /**
  58838. * Checks if the given data starts with a KTX2 file identifier.
  58839. * @param data the data to check
  58840. * @returns true if the data is a KTX2 file or false otherwise
  58841. */
  58842. static IsValid(data: ArrayBufferView): boolean;
  58843. }
  58844. }
  58845. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58846. import { Nullable } from "babylonjs/types";
  58847. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58848. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58849. /**
  58850. * Implementation of the KTX Texture Loader.
  58851. * @hidden
  58852. */
  58853. export class _KTXTextureLoader implements IInternalTextureLoader {
  58854. /**
  58855. * Defines wether the loader supports cascade loading the different faces.
  58856. */
  58857. readonly supportCascades: boolean;
  58858. /**
  58859. * This returns if the loader support the current file information.
  58860. * @param extension defines the file extension of the file being loaded
  58861. * @returns true if the loader can load the specified file
  58862. */
  58863. canLoad(extension: string): boolean;
  58864. /**
  58865. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58866. * @param data contains the texture data
  58867. * @param texture defines the BabylonJS internal texture
  58868. * @param createPolynomials will be true if polynomials have been requested
  58869. * @param onLoad defines the callback to trigger once the texture is ready
  58870. * @param onError defines the callback to trigger in case of error
  58871. */
  58872. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58873. /**
  58874. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58875. * @param data contains the texture data
  58876. * @param texture defines the BabylonJS internal texture
  58877. * @param callback defines the method to call once ready to upload
  58878. */
  58879. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58880. }
  58881. }
  58882. declare module "babylonjs/Helpers/sceneHelpers" {
  58883. import { Nullable } from "babylonjs/types";
  58884. import { Mesh } from "babylonjs/Meshes/mesh";
  58885. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58886. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  58887. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  58888. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58889. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58890. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58891. import "babylonjs/Meshes/Builders/boxBuilder";
  58892. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  58893. /** @hidden */
  58894. export var _forceSceneHelpersToBundle: boolean;
  58895. module "babylonjs/scene" {
  58896. interface Scene {
  58897. /**
  58898. * Creates a default light for the scene.
  58899. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58900. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58901. */
  58902. createDefaultLight(replace?: boolean): void;
  58903. /**
  58904. * Creates a default camera for the scene.
  58905. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58906. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58907. * @param replace has default false, when true replaces the active camera in the scene
  58908. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58909. */
  58910. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58911. /**
  58912. * Creates a default camera and a default light.
  58913. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58914. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58915. * @param replace has the default false, when true replaces the active camera/light in the scene
  58916. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58917. */
  58918. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58919. /**
  58920. * Creates a new sky box
  58921. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58922. * @param environmentTexture defines the texture to use as environment texture
  58923. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58924. * @param scale defines the overall scale of the skybox
  58925. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58926. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58927. * @returns a new mesh holding the sky box
  58928. */
  58929. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58930. /**
  58931. * Creates a new environment
  58932. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58933. * @param options defines the options you can use to configure the environment
  58934. * @returns the new EnvironmentHelper
  58935. */
  58936. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58937. /**
  58938. * Creates a new VREXperienceHelper
  58939. * @see http://doc.babylonjs.com/how_to/webvr_helper
  58940. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58941. * @returns a new VREXperienceHelper
  58942. */
  58943. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58944. /**
  58945. * Creates a new WebXRDefaultExperience
  58946. * @see http://doc.babylonjs.com/how_to/webxr
  58947. * @param options experience options
  58948. * @returns a promise for a new WebXRDefaultExperience
  58949. */
  58950. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58951. }
  58952. }
  58953. }
  58954. declare module "babylonjs/Helpers/videoDome" {
  58955. import { Scene } from "babylonjs/scene";
  58956. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58957. import { Mesh } from "babylonjs/Meshes/mesh";
  58958. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  58959. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  58960. import "babylonjs/Meshes/Builders/sphereBuilder";
  58961. /**
  58962. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58963. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58964. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58965. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58966. */
  58967. export class VideoDome extends TransformNode {
  58968. /**
  58969. * Define the video source as a Monoscopic panoramic 360 video.
  58970. */
  58971. static readonly MODE_MONOSCOPIC: number;
  58972. /**
  58973. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58974. */
  58975. static readonly MODE_TOPBOTTOM: number;
  58976. /**
  58977. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58978. */
  58979. static readonly MODE_SIDEBYSIDE: number;
  58980. private _halfDome;
  58981. private _useDirectMapping;
  58982. /**
  58983. * The video texture being displayed on the sphere
  58984. */
  58985. protected _videoTexture: VideoTexture;
  58986. /**
  58987. * Gets the video texture being displayed on the sphere
  58988. */
  58989. get videoTexture(): VideoTexture;
  58990. /**
  58991. * The skybox material
  58992. */
  58993. protected _material: BackgroundMaterial;
  58994. /**
  58995. * The surface used for the skybox
  58996. */
  58997. protected _mesh: Mesh;
  58998. /**
  58999. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59000. */
  59001. private _halfDomeMask;
  59002. /**
  59003. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59004. * Also see the options.resolution property.
  59005. */
  59006. get fovMultiplier(): number;
  59007. set fovMultiplier(value: number);
  59008. private _videoMode;
  59009. /**
  59010. * Gets or set the current video mode for the video. It can be:
  59011. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59012. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59013. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59014. */
  59015. get videoMode(): number;
  59016. set videoMode(value: number);
  59017. /**
  59018. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59019. *
  59020. */
  59021. get halfDome(): boolean;
  59022. /**
  59023. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59024. */
  59025. set halfDome(enabled: boolean);
  59026. /**
  59027. * Oberserver used in Stereoscopic VR Mode.
  59028. */
  59029. private _onBeforeCameraRenderObserver;
  59030. /**
  59031. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59032. * @param name Element's name, child elements will append suffixes for their own names.
  59033. * @param urlsOrVideo defines the url(s) or the video element to use
  59034. * @param options An object containing optional or exposed sub element properties
  59035. */
  59036. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59037. resolution?: number;
  59038. clickToPlay?: boolean;
  59039. autoPlay?: boolean;
  59040. loop?: boolean;
  59041. size?: number;
  59042. poster?: string;
  59043. faceForward?: boolean;
  59044. useDirectMapping?: boolean;
  59045. halfDomeMode?: boolean;
  59046. }, scene: Scene);
  59047. private _changeVideoMode;
  59048. /**
  59049. * Releases resources associated with this node.
  59050. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59051. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59052. */
  59053. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59054. }
  59055. }
  59056. declare module "babylonjs/Helpers/index" {
  59057. export * from "babylonjs/Helpers/environmentHelper";
  59058. export * from "babylonjs/Helpers/photoDome";
  59059. export * from "babylonjs/Helpers/sceneHelpers";
  59060. export * from "babylonjs/Helpers/videoDome";
  59061. }
  59062. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59063. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59064. import { IDisposable } from "babylonjs/scene";
  59065. import { Engine } from "babylonjs/Engines/engine";
  59066. /**
  59067. * This class can be used to get instrumentation data from a Babylon engine
  59068. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59069. */
  59070. export class EngineInstrumentation implements IDisposable {
  59071. /**
  59072. * Define the instrumented engine.
  59073. */
  59074. engine: Engine;
  59075. private _captureGPUFrameTime;
  59076. private _gpuFrameTimeToken;
  59077. private _gpuFrameTime;
  59078. private _captureShaderCompilationTime;
  59079. private _shaderCompilationTime;
  59080. private _onBeginFrameObserver;
  59081. private _onEndFrameObserver;
  59082. private _onBeforeShaderCompilationObserver;
  59083. private _onAfterShaderCompilationObserver;
  59084. /**
  59085. * Gets the perf counter used for GPU frame time
  59086. */
  59087. get gpuFrameTimeCounter(): PerfCounter;
  59088. /**
  59089. * Gets the GPU frame time capture status
  59090. */
  59091. get captureGPUFrameTime(): boolean;
  59092. /**
  59093. * Enable or disable the GPU frame time capture
  59094. */
  59095. set captureGPUFrameTime(value: boolean);
  59096. /**
  59097. * Gets the perf counter used for shader compilation time
  59098. */
  59099. get shaderCompilationTimeCounter(): PerfCounter;
  59100. /**
  59101. * Gets the shader compilation time capture status
  59102. */
  59103. get captureShaderCompilationTime(): boolean;
  59104. /**
  59105. * Enable or disable the shader compilation time capture
  59106. */
  59107. set captureShaderCompilationTime(value: boolean);
  59108. /**
  59109. * Instantiates a new engine instrumentation.
  59110. * This class can be used to get instrumentation data from a Babylon engine
  59111. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59112. * @param engine Defines the engine to instrument
  59113. */
  59114. constructor(
  59115. /**
  59116. * Define the instrumented engine.
  59117. */
  59118. engine: Engine);
  59119. /**
  59120. * Dispose and release associated resources.
  59121. */
  59122. dispose(): void;
  59123. }
  59124. }
  59125. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59126. import { Scene, IDisposable } from "babylonjs/scene";
  59127. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59128. /**
  59129. * This class can be used to get instrumentation data from a Babylon engine
  59130. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59131. */
  59132. export class SceneInstrumentation implements IDisposable {
  59133. /**
  59134. * Defines the scene to instrument
  59135. */
  59136. scene: Scene;
  59137. private _captureActiveMeshesEvaluationTime;
  59138. private _activeMeshesEvaluationTime;
  59139. private _captureRenderTargetsRenderTime;
  59140. private _renderTargetsRenderTime;
  59141. private _captureFrameTime;
  59142. private _frameTime;
  59143. private _captureRenderTime;
  59144. private _renderTime;
  59145. private _captureInterFrameTime;
  59146. private _interFrameTime;
  59147. private _captureParticlesRenderTime;
  59148. private _particlesRenderTime;
  59149. private _captureSpritesRenderTime;
  59150. private _spritesRenderTime;
  59151. private _capturePhysicsTime;
  59152. private _physicsTime;
  59153. private _captureAnimationsTime;
  59154. private _animationsTime;
  59155. private _captureCameraRenderTime;
  59156. private _cameraRenderTime;
  59157. private _onBeforeActiveMeshesEvaluationObserver;
  59158. private _onAfterActiveMeshesEvaluationObserver;
  59159. private _onBeforeRenderTargetsRenderObserver;
  59160. private _onAfterRenderTargetsRenderObserver;
  59161. private _onAfterRenderObserver;
  59162. private _onBeforeDrawPhaseObserver;
  59163. private _onAfterDrawPhaseObserver;
  59164. private _onBeforeAnimationsObserver;
  59165. private _onBeforeParticlesRenderingObserver;
  59166. private _onAfterParticlesRenderingObserver;
  59167. private _onBeforeSpritesRenderingObserver;
  59168. private _onAfterSpritesRenderingObserver;
  59169. private _onBeforePhysicsObserver;
  59170. private _onAfterPhysicsObserver;
  59171. private _onAfterAnimationsObserver;
  59172. private _onBeforeCameraRenderObserver;
  59173. private _onAfterCameraRenderObserver;
  59174. /**
  59175. * Gets the perf counter used for active meshes evaluation time
  59176. */
  59177. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59178. /**
  59179. * Gets the active meshes evaluation time capture status
  59180. */
  59181. get captureActiveMeshesEvaluationTime(): boolean;
  59182. /**
  59183. * Enable or disable the active meshes evaluation time capture
  59184. */
  59185. set captureActiveMeshesEvaluationTime(value: boolean);
  59186. /**
  59187. * Gets the perf counter used for render targets render time
  59188. */
  59189. get renderTargetsRenderTimeCounter(): PerfCounter;
  59190. /**
  59191. * Gets the render targets render time capture status
  59192. */
  59193. get captureRenderTargetsRenderTime(): boolean;
  59194. /**
  59195. * Enable or disable the render targets render time capture
  59196. */
  59197. set captureRenderTargetsRenderTime(value: boolean);
  59198. /**
  59199. * Gets the perf counter used for particles render time
  59200. */
  59201. get particlesRenderTimeCounter(): PerfCounter;
  59202. /**
  59203. * Gets the particles render time capture status
  59204. */
  59205. get captureParticlesRenderTime(): boolean;
  59206. /**
  59207. * Enable or disable the particles render time capture
  59208. */
  59209. set captureParticlesRenderTime(value: boolean);
  59210. /**
  59211. * Gets the perf counter used for sprites render time
  59212. */
  59213. get spritesRenderTimeCounter(): PerfCounter;
  59214. /**
  59215. * Gets the sprites render time capture status
  59216. */
  59217. get captureSpritesRenderTime(): boolean;
  59218. /**
  59219. * Enable or disable the sprites render time capture
  59220. */
  59221. set captureSpritesRenderTime(value: boolean);
  59222. /**
  59223. * Gets the perf counter used for physics time
  59224. */
  59225. get physicsTimeCounter(): PerfCounter;
  59226. /**
  59227. * Gets the physics time capture status
  59228. */
  59229. get capturePhysicsTime(): boolean;
  59230. /**
  59231. * Enable or disable the physics time capture
  59232. */
  59233. set capturePhysicsTime(value: boolean);
  59234. /**
  59235. * Gets the perf counter used for animations time
  59236. */
  59237. get animationsTimeCounter(): PerfCounter;
  59238. /**
  59239. * Gets the animations time capture status
  59240. */
  59241. get captureAnimationsTime(): boolean;
  59242. /**
  59243. * Enable or disable the animations time capture
  59244. */
  59245. set captureAnimationsTime(value: boolean);
  59246. /**
  59247. * Gets the perf counter used for frame time capture
  59248. */
  59249. get frameTimeCounter(): PerfCounter;
  59250. /**
  59251. * Gets the frame time capture status
  59252. */
  59253. get captureFrameTime(): boolean;
  59254. /**
  59255. * Enable or disable the frame time capture
  59256. */
  59257. set captureFrameTime(value: boolean);
  59258. /**
  59259. * Gets the perf counter used for inter-frames time capture
  59260. */
  59261. get interFrameTimeCounter(): PerfCounter;
  59262. /**
  59263. * Gets the inter-frames time capture status
  59264. */
  59265. get captureInterFrameTime(): boolean;
  59266. /**
  59267. * Enable or disable the inter-frames time capture
  59268. */
  59269. set captureInterFrameTime(value: boolean);
  59270. /**
  59271. * Gets the perf counter used for render time capture
  59272. */
  59273. get renderTimeCounter(): PerfCounter;
  59274. /**
  59275. * Gets the render time capture status
  59276. */
  59277. get captureRenderTime(): boolean;
  59278. /**
  59279. * Enable or disable the render time capture
  59280. */
  59281. set captureRenderTime(value: boolean);
  59282. /**
  59283. * Gets the perf counter used for camera render time capture
  59284. */
  59285. get cameraRenderTimeCounter(): PerfCounter;
  59286. /**
  59287. * Gets the camera render time capture status
  59288. */
  59289. get captureCameraRenderTime(): boolean;
  59290. /**
  59291. * Enable or disable the camera render time capture
  59292. */
  59293. set captureCameraRenderTime(value: boolean);
  59294. /**
  59295. * Gets the perf counter used for draw calls
  59296. */
  59297. get drawCallsCounter(): PerfCounter;
  59298. /**
  59299. * Instantiates a new scene instrumentation.
  59300. * This class can be used to get instrumentation data from a Babylon engine
  59301. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59302. * @param scene Defines the scene to instrument
  59303. */
  59304. constructor(
  59305. /**
  59306. * Defines the scene to instrument
  59307. */
  59308. scene: Scene);
  59309. /**
  59310. * Dispose and release associated resources.
  59311. */
  59312. dispose(): void;
  59313. }
  59314. }
  59315. declare module "babylonjs/Instrumentation/index" {
  59316. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59317. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59318. export * from "babylonjs/Instrumentation/timeToken";
  59319. }
  59320. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59321. /** @hidden */
  59322. export var glowMapGenerationPixelShader: {
  59323. name: string;
  59324. shader: string;
  59325. };
  59326. }
  59327. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59328. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59329. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59330. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59331. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59332. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59333. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59334. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59335. /** @hidden */
  59336. export var glowMapGenerationVertexShader: {
  59337. name: string;
  59338. shader: string;
  59339. };
  59340. }
  59341. declare module "babylonjs/Layers/effectLayer" {
  59342. import { Observable } from "babylonjs/Misc/observable";
  59343. import { Nullable } from "babylonjs/types";
  59344. import { Camera } from "babylonjs/Cameras/camera";
  59345. import { Scene } from "babylonjs/scene";
  59346. import { ISize } from "babylonjs/Maths/math.size";
  59347. import { Color4 } from "babylonjs/Maths/math.color";
  59348. import { Engine } from "babylonjs/Engines/engine";
  59349. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59351. import { Mesh } from "babylonjs/Meshes/mesh";
  59352. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59353. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59354. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59355. import { Effect } from "babylonjs/Materials/effect";
  59356. import { Material } from "babylonjs/Materials/material";
  59357. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59358. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59359. /**
  59360. * Effect layer options. This helps customizing the behaviour
  59361. * of the effect layer.
  59362. */
  59363. export interface IEffectLayerOptions {
  59364. /**
  59365. * Multiplication factor apply to the canvas size to compute the render target size
  59366. * used to generated the objects (the smaller the faster).
  59367. */
  59368. mainTextureRatio: number;
  59369. /**
  59370. * Enforces a fixed size texture to ensure effect stability across devices.
  59371. */
  59372. mainTextureFixedSize?: number;
  59373. /**
  59374. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59375. */
  59376. alphaBlendingMode: number;
  59377. /**
  59378. * The camera attached to the layer.
  59379. */
  59380. camera: Nullable<Camera>;
  59381. /**
  59382. * The rendering group to draw the layer in.
  59383. */
  59384. renderingGroupId: number;
  59385. }
  59386. /**
  59387. * The effect layer Helps adding post process effect blended with the main pass.
  59388. *
  59389. * This can be for instance use to generate glow or higlight effects on the scene.
  59390. *
  59391. * The effect layer class can not be used directly and is intented to inherited from to be
  59392. * customized per effects.
  59393. */
  59394. export abstract class EffectLayer {
  59395. private _vertexBuffers;
  59396. private _indexBuffer;
  59397. private _cachedDefines;
  59398. private _effectLayerMapGenerationEffect;
  59399. private _effectLayerOptions;
  59400. private _mergeEffect;
  59401. protected _scene: Scene;
  59402. protected _engine: Engine;
  59403. protected _maxSize: number;
  59404. protected _mainTextureDesiredSize: ISize;
  59405. protected _mainTexture: RenderTargetTexture;
  59406. protected _shouldRender: boolean;
  59407. protected _postProcesses: PostProcess[];
  59408. protected _textures: BaseTexture[];
  59409. protected _emissiveTextureAndColor: {
  59410. texture: Nullable<BaseTexture>;
  59411. color: Color4;
  59412. };
  59413. /**
  59414. * The name of the layer
  59415. */
  59416. name: string;
  59417. /**
  59418. * The clear color of the texture used to generate the glow map.
  59419. */
  59420. neutralColor: Color4;
  59421. /**
  59422. * Specifies whether the highlight layer is enabled or not.
  59423. */
  59424. isEnabled: boolean;
  59425. /**
  59426. * Gets the camera attached to the layer.
  59427. */
  59428. get camera(): Nullable<Camera>;
  59429. /**
  59430. * Gets the rendering group id the layer should render in.
  59431. */
  59432. get renderingGroupId(): number;
  59433. set renderingGroupId(renderingGroupId: number);
  59434. /**
  59435. * An event triggered when the effect layer has been disposed.
  59436. */
  59437. onDisposeObservable: Observable<EffectLayer>;
  59438. /**
  59439. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59440. */
  59441. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59442. /**
  59443. * An event triggered when the generated texture is being merged in the scene.
  59444. */
  59445. onBeforeComposeObservable: Observable<EffectLayer>;
  59446. /**
  59447. * An event triggered when the mesh is rendered into the effect render target.
  59448. */
  59449. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59450. /**
  59451. * An event triggered after the mesh has been rendered into the effect render target.
  59452. */
  59453. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59454. /**
  59455. * An event triggered when the generated texture has been merged in the scene.
  59456. */
  59457. onAfterComposeObservable: Observable<EffectLayer>;
  59458. /**
  59459. * An event triggered when the efffect layer changes its size.
  59460. */
  59461. onSizeChangedObservable: Observable<EffectLayer>;
  59462. /** @hidden */
  59463. static _SceneComponentInitialization: (scene: Scene) => void;
  59464. /**
  59465. * Instantiates a new effect Layer and references it in the scene.
  59466. * @param name The name of the layer
  59467. * @param scene The scene to use the layer in
  59468. */
  59469. constructor(
  59470. /** The Friendly of the effect in the scene */
  59471. name: string, scene: Scene);
  59472. /**
  59473. * Get the effect name of the layer.
  59474. * @return The effect name
  59475. */
  59476. abstract getEffectName(): string;
  59477. /**
  59478. * Checks for the readiness of the element composing the layer.
  59479. * @param subMesh the mesh to check for
  59480. * @param useInstances specify whether or not to use instances to render the mesh
  59481. * @return true if ready otherwise, false
  59482. */
  59483. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59484. /**
  59485. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59486. * @returns true if the effect requires stencil during the main canvas render pass.
  59487. */
  59488. abstract needStencil(): boolean;
  59489. /**
  59490. * Create the merge effect. This is the shader use to blit the information back
  59491. * to the main canvas at the end of the scene rendering.
  59492. * @returns The effect containing the shader used to merge the effect on the main canvas
  59493. */
  59494. protected abstract _createMergeEffect(): Effect;
  59495. /**
  59496. * Creates the render target textures and post processes used in the effect layer.
  59497. */
  59498. protected abstract _createTextureAndPostProcesses(): void;
  59499. /**
  59500. * Implementation specific of rendering the generating effect on the main canvas.
  59501. * @param effect The effect used to render through
  59502. */
  59503. protected abstract _internalRender(effect: Effect): void;
  59504. /**
  59505. * Sets the required values for both the emissive texture and and the main color.
  59506. */
  59507. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59508. /**
  59509. * Free any resources and references associated to a mesh.
  59510. * Internal use
  59511. * @param mesh The mesh to free.
  59512. */
  59513. abstract _disposeMesh(mesh: Mesh): void;
  59514. /**
  59515. * Serializes this layer (Glow or Highlight for example)
  59516. * @returns a serialized layer object
  59517. */
  59518. abstract serialize?(): any;
  59519. /**
  59520. * Initializes the effect layer with the required options.
  59521. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59522. */
  59523. protected _init(options: Partial<IEffectLayerOptions>): void;
  59524. /**
  59525. * Generates the index buffer of the full screen quad blending to the main canvas.
  59526. */
  59527. private _generateIndexBuffer;
  59528. /**
  59529. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59530. */
  59531. private _generateVertexBuffer;
  59532. /**
  59533. * Sets the main texture desired size which is the closest power of two
  59534. * of the engine canvas size.
  59535. */
  59536. private _setMainTextureSize;
  59537. /**
  59538. * Creates the main texture for the effect layer.
  59539. */
  59540. protected _createMainTexture(): void;
  59541. /**
  59542. * Adds specific effects defines.
  59543. * @param defines The defines to add specifics to.
  59544. */
  59545. protected _addCustomEffectDefines(defines: string[]): void;
  59546. /**
  59547. * Checks for the readiness of the element composing the layer.
  59548. * @param subMesh the mesh to check for
  59549. * @param useInstances specify whether or not to use instances to render the mesh
  59550. * @param emissiveTexture the associated emissive texture used to generate the glow
  59551. * @return true if ready otherwise, false
  59552. */
  59553. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59554. /**
  59555. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59556. */
  59557. render(): void;
  59558. /**
  59559. * Determine if a given mesh will be used in the current effect.
  59560. * @param mesh mesh to test
  59561. * @returns true if the mesh will be used
  59562. */
  59563. hasMesh(mesh: AbstractMesh): boolean;
  59564. /**
  59565. * Returns true if the layer contains information to display, otherwise false.
  59566. * @returns true if the glow layer should be rendered
  59567. */
  59568. shouldRender(): boolean;
  59569. /**
  59570. * Returns true if the mesh should render, otherwise false.
  59571. * @param mesh The mesh to render
  59572. * @returns true if it should render otherwise false
  59573. */
  59574. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59575. /**
  59576. * Returns true if the mesh can be rendered, otherwise false.
  59577. * @param mesh The mesh to render
  59578. * @param material The material used on the mesh
  59579. * @returns true if it can be rendered otherwise false
  59580. */
  59581. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59582. /**
  59583. * Returns true if the mesh should render, otherwise false.
  59584. * @param mesh The mesh to render
  59585. * @returns true if it should render otherwise false
  59586. */
  59587. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59588. /**
  59589. * Renders the submesh passed in parameter to the generation map.
  59590. */
  59591. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59592. /**
  59593. * Defines whether the current material of the mesh should be use to render the effect.
  59594. * @param mesh defines the current mesh to render
  59595. */
  59596. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59597. /**
  59598. * Rebuild the required buffers.
  59599. * @hidden Internal use only.
  59600. */
  59601. _rebuild(): void;
  59602. /**
  59603. * Dispose only the render target textures and post process.
  59604. */
  59605. private _disposeTextureAndPostProcesses;
  59606. /**
  59607. * Dispose the highlight layer and free resources.
  59608. */
  59609. dispose(): void;
  59610. /**
  59611. * Gets the class name of the effect layer
  59612. * @returns the string with the class name of the effect layer
  59613. */
  59614. getClassName(): string;
  59615. /**
  59616. * Creates an effect layer from parsed effect layer data
  59617. * @param parsedEffectLayer defines effect layer data
  59618. * @param scene defines the current scene
  59619. * @param rootUrl defines the root URL containing the effect layer information
  59620. * @returns a parsed effect Layer
  59621. */
  59622. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59623. }
  59624. }
  59625. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59626. import { Scene } from "babylonjs/scene";
  59627. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59628. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59629. import { AbstractScene } from "babylonjs/abstractScene";
  59630. module "babylonjs/abstractScene" {
  59631. interface AbstractScene {
  59632. /**
  59633. * The list of effect layers (highlights/glow) added to the scene
  59634. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59635. * @see http://doc.babylonjs.com/how_to/glow_layer
  59636. */
  59637. effectLayers: Array<EffectLayer>;
  59638. /**
  59639. * Removes the given effect layer from this scene.
  59640. * @param toRemove defines the effect layer to remove
  59641. * @returns the index of the removed effect layer
  59642. */
  59643. removeEffectLayer(toRemove: EffectLayer): number;
  59644. /**
  59645. * Adds the given effect layer to this scene
  59646. * @param newEffectLayer defines the effect layer to add
  59647. */
  59648. addEffectLayer(newEffectLayer: EffectLayer): void;
  59649. }
  59650. }
  59651. /**
  59652. * Defines the layer scene component responsible to manage any effect layers
  59653. * in a given scene.
  59654. */
  59655. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59656. /**
  59657. * The component name helpfull to identify the component in the list of scene components.
  59658. */
  59659. readonly name: string;
  59660. /**
  59661. * The scene the component belongs to.
  59662. */
  59663. scene: Scene;
  59664. private _engine;
  59665. private _renderEffects;
  59666. private _needStencil;
  59667. private _previousStencilState;
  59668. /**
  59669. * Creates a new instance of the component for the given scene
  59670. * @param scene Defines the scene to register the component in
  59671. */
  59672. constructor(scene: Scene);
  59673. /**
  59674. * Registers the component in a given scene
  59675. */
  59676. register(): void;
  59677. /**
  59678. * Rebuilds the elements related to this component in case of
  59679. * context lost for instance.
  59680. */
  59681. rebuild(): void;
  59682. /**
  59683. * Serializes the component data to the specified json object
  59684. * @param serializationObject The object to serialize to
  59685. */
  59686. serialize(serializationObject: any): void;
  59687. /**
  59688. * Adds all the elements from the container to the scene
  59689. * @param container the container holding the elements
  59690. */
  59691. addFromContainer(container: AbstractScene): void;
  59692. /**
  59693. * Removes all the elements in the container from the scene
  59694. * @param container contains the elements to remove
  59695. * @param dispose if the removed element should be disposed (default: false)
  59696. */
  59697. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59698. /**
  59699. * Disposes the component and the associated ressources.
  59700. */
  59701. dispose(): void;
  59702. private _isReadyForMesh;
  59703. private _renderMainTexture;
  59704. private _setStencil;
  59705. private _setStencilBack;
  59706. private _draw;
  59707. private _drawCamera;
  59708. private _drawRenderingGroup;
  59709. }
  59710. }
  59711. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59712. /** @hidden */
  59713. export var glowMapMergePixelShader: {
  59714. name: string;
  59715. shader: string;
  59716. };
  59717. }
  59718. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59719. /** @hidden */
  59720. export var glowMapMergeVertexShader: {
  59721. name: string;
  59722. shader: string;
  59723. };
  59724. }
  59725. declare module "babylonjs/Layers/glowLayer" {
  59726. import { Nullable } from "babylonjs/types";
  59727. import { Camera } from "babylonjs/Cameras/camera";
  59728. import { Scene } from "babylonjs/scene";
  59729. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59731. import { Mesh } from "babylonjs/Meshes/mesh";
  59732. import { Texture } from "babylonjs/Materials/Textures/texture";
  59733. import { Effect } from "babylonjs/Materials/effect";
  59734. import { Material } from "babylonjs/Materials/material";
  59735. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59736. import { Color4 } from "babylonjs/Maths/math.color";
  59737. import "babylonjs/Shaders/glowMapMerge.fragment";
  59738. import "babylonjs/Shaders/glowMapMerge.vertex";
  59739. import "babylonjs/Layers/effectLayerSceneComponent";
  59740. module "babylonjs/abstractScene" {
  59741. interface AbstractScene {
  59742. /**
  59743. * Return a the first highlight layer of the scene with a given name.
  59744. * @param name The name of the highlight layer to look for.
  59745. * @return The highlight layer if found otherwise null.
  59746. */
  59747. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59748. }
  59749. }
  59750. /**
  59751. * Glow layer options. This helps customizing the behaviour
  59752. * of the glow layer.
  59753. */
  59754. export interface IGlowLayerOptions {
  59755. /**
  59756. * Multiplication factor apply to the canvas size to compute the render target size
  59757. * used to generated the glowing objects (the smaller the faster).
  59758. */
  59759. mainTextureRatio: number;
  59760. /**
  59761. * Enforces a fixed size texture to ensure resize independant blur.
  59762. */
  59763. mainTextureFixedSize?: number;
  59764. /**
  59765. * How big is the kernel of the blur texture.
  59766. */
  59767. blurKernelSize: number;
  59768. /**
  59769. * The camera attached to the layer.
  59770. */
  59771. camera: Nullable<Camera>;
  59772. /**
  59773. * Enable MSAA by chosing the number of samples.
  59774. */
  59775. mainTextureSamples?: number;
  59776. /**
  59777. * The rendering group to draw the layer in.
  59778. */
  59779. renderingGroupId: number;
  59780. }
  59781. /**
  59782. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59783. *
  59784. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59785. *
  59786. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59787. */
  59788. export class GlowLayer extends EffectLayer {
  59789. /**
  59790. * Effect Name of the layer.
  59791. */
  59792. static readonly EffectName: string;
  59793. /**
  59794. * The default blur kernel size used for the glow.
  59795. */
  59796. static DefaultBlurKernelSize: number;
  59797. /**
  59798. * The default texture size ratio used for the glow.
  59799. */
  59800. static DefaultTextureRatio: number;
  59801. /**
  59802. * Sets the kernel size of the blur.
  59803. */
  59804. set blurKernelSize(value: number);
  59805. /**
  59806. * Gets the kernel size of the blur.
  59807. */
  59808. get blurKernelSize(): number;
  59809. /**
  59810. * Sets the glow intensity.
  59811. */
  59812. set intensity(value: number);
  59813. /**
  59814. * Gets the glow intensity.
  59815. */
  59816. get intensity(): number;
  59817. private _options;
  59818. private _intensity;
  59819. private _horizontalBlurPostprocess1;
  59820. private _verticalBlurPostprocess1;
  59821. private _horizontalBlurPostprocess2;
  59822. private _verticalBlurPostprocess2;
  59823. private _blurTexture1;
  59824. private _blurTexture2;
  59825. private _postProcesses1;
  59826. private _postProcesses2;
  59827. private _includedOnlyMeshes;
  59828. private _excludedMeshes;
  59829. private _meshesUsingTheirOwnMaterials;
  59830. /**
  59831. * Callback used to let the user override the color selection on a per mesh basis
  59832. */
  59833. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59834. /**
  59835. * Callback used to let the user override the texture selection on a per mesh basis
  59836. */
  59837. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59838. /**
  59839. * Instantiates a new glow Layer and references it to the scene.
  59840. * @param name The name of the layer
  59841. * @param scene The scene to use the layer in
  59842. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59843. */
  59844. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59845. /**
  59846. * Get the effect name of the layer.
  59847. * @return The effect name
  59848. */
  59849. getEffectName(): string;
  59850. /**
  59851. * Create the merge effect. This is the shader use to blit the information back
  59852. * to the main canvas at the end of the scene rendering.
  59853. */
  59854. protected _createMergeEffect(): Effect;
  59855. /**
  59856. * Creates the render target textures and post processes used in the glow layer.
  59857. */
  59858. protected _createTextureAndPostProcesses(): void;
  59859. /**
  59860. * Checks for the readiness of the element composing the layer.
  59861. * @param subMesh the mesh to check for
  59862. * @param useInstances specify wether or not to use instances to render the mesh
  59863. * @param emissiveTexture the associated emissive texture used to generate the glow
  59864. * @return true if ready otherwise, false
  59865. */
  59866. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59867. /**
  59868. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59869. */
  59870. needStencil(): boolean;
  59871. /**
  59872. * Returns true if the mesh can be rendered, otherwise false.
  59873. * @param mesh The mesh to render
  59874. * @param material The material used on the mesh
  59875. * @returns true if it can be rendered otherwise false
  59876. */
  59877. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59878. /**
  59879. * Implementation specific of rendering the generating effect on the main canvas.
  59880. * @param effect The effect used to render through
  59881. */
  59882. protected _internalRender(effect: Effect): void;
  59883. /**
  59884. * Sets the required values for both the emissive texture and and the main color.
  59885. */
  59886. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59887. /**
  59888. * Returns true if the mesh should render, otherwise false.
  59889. * @param mesh The mesh to render
  59890. * @returns true if it should render otherwise false
  59891. */
  59892. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59893. /**
  59894. * Adds specific effects defines.
  59895. * @param defines The defines to add specifics to.
  59896. */
  59897. protected _addCustomEffectDefines(defines: string[]): void;
  59898. /**
  59899. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59900. * @param mesh The mesh to exclude from the glow layer
  59901. */
  59902. addExcludedMesh(mesh: Mesh): void;
  59903. /**
  59904. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59905. * @param mesh The mesh to remove
  59906. */
  59907. removeExcludedMesh(mesh: Mesh): void;
  59908. /**
  59909. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59910. * @param mesh The mesh to include in the glow layer
  59911. */
  59912. addIncludedOnlyMesh(mesh: Mesh): void;
  59913. /**
  59914. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59915. * @param mesh The mesh to remove
  59916. */
  59917. removeIncludedOnlyMesh(mesh: Mesh): void;
  59918. /**
  59919. * Determine if a given mesh will be used in the glow layer
  59920. * @param mesh The mesh to test
  59921. * @returns true if the mesh will be highlighted by the current glow layer
  59922. */
  59923. hasMesh(mesh: AbstractMesh): boolean;
  59924. /**
  59925. * Defines whether the current material of the mesh should be use to render the effect.
  59926. * @param mesh defines the current mesh to render
  59927. */
  59928. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59929. /**
  59930. * Add a mesh to be rendered through its own material and not with emissive only.
  59931. * @param mesh The mesh for which we need to use its material
  59932. */
  59933. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59934. /**
  59935. * Remove a mesh from being rendered through its own material and not with emissive only.
  59936. * @param mesh The mesh for which we need to not use its material
  59937. */
  59938. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59939. /**
  59940. * Free any resources and references associated to a mesh.
  59941. * Internal use
  59942. * @param mesh The mesh to free.
  59943. * @hidden
  59944. */
  59945. _disposeMesh(mesh: Mesh): void;
  59946. /**
  59947. * Gets the class name of the effect layer
  59948. * @returns the string with the class name of the effect layer
  59949. */
  59950. getClassName(): string;
  59951. /**
  59952. * Serializes this glow layer
  59953. * @returns a serialized glow layer object
  59954. */
  59955. serialize(): any;
  59956. /**
  59957. * Creates a Glow Layer from parsed glow layer data
  59958. * @param parsedGlowLayer defines glow layer data
  59959. * @param scene defines the current scene
  59960. * @param rootUrl defines the root URL containing the glow layer information
  59961. * @returns a parsed Glow Layer
  59962. */
  59963. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59964. }
  59965. }
  59966. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  59967. /** @hidden */
  59968. export var glowBlurPostProcessPixelShader: {
  59969. name: string;
  59970. shader: string;
  59971. };
  59972. }
  59973. declare module "babylonjs/Layers/highlightLayer" {
  59974. import { Observable } from "babylonjs/Misc/observable";
  59975. import { Nullable } from "babylonjs/types";
  59976. import { Camera } from "babylonjs/Cameras/camera";
  59977. import { Scene } from "babylonjs/scene";
  59978. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59980. import { Mesh } from "babylonjs/Meshes/mesh";
  59981. import { Effect } from "babylonjs/Materials/effect";
  59982. import { Material } from "babylonjs/Materials/material";
  59983. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59984. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59985. import "babylonjs/Shaders/glowMapMerge.fragment";
  59986. import "babylonjs/Shaders/glowMapMerge.vertex";
  59987. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  59988. module "babylonjs/abstractScene" {
  59989. interface AbstractScene {
  59990. /**
  59991. * Return a the first highlight layer of the scene with a given name.
  59992. * @param name The name of the highlight layer to look for.
  59993. * @return The highlight layer if found otherwise null.
  59994. */
  59995. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59996. }
  59997. }
  59998. /**
  59999. * Highlight layer options. This helps customizing the behaviour
  60000. * of the highlight layer.
  60001. */
  60002. export interface IHighlightLayerOptions {
  60003. /**
  60004. * Multiplication factor apply to the canvas size to compute the render target size
  60005. * used to generated the glowing objects (the smaller the faster).
  60006. */
  60007. mainTextureRatio: number;
  60008. /**
  60009. * Enforces a fixed size texture to ensure resize independant blur.
  60010. */
  60011. mainTextureFixedSize?: number;
  60012. /**
  60013. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60014. * of the picture to blur (the smaller the faster).
  60015. */
  60016. blurTextureSizeRatio: number;
  60017. /**
  60018. * How big in texel of the blur texture is the vertical blur.
  60019. */
  60020. blurVerticalSize: number;
  60021. /**
  60022. * How big in texel of the blur texture is the horizontal blur.
  60023. */
  60024. blurHorizontalSize: number;
  60025. /**
  60026. * Alpha blending mode used to apply the blur. Default is combine.
  60027. */
  60028. alphaBlendingMode: number;
  60029. /**
  60030. * The camera attached to the layer.
  60031. */
  60032. camera: Nullable<Camera>;
  60033. /**
  60034. * Should we display highlight as a solid stroke?
  60035. */
  60036. isStroke?: boolean;
  60037. /**
  60038. * The rendering group to draw the layer in.
  60039. */
  60040. renderingGroupId: number;
  60041. }
  60042. /**
  60043. * The highlight layer Helps adding a glow effect around a mesh.
  60044. *
  60045. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60046. * glowy meshes to your scene.
  60047. *
  60048. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60049. */
  60050. export class HighlightLayer extends EffectLayer {
  60051. name: string;
  60052. /**
  60053. * Effect Name of the highlight layer.
  60054. */
  60055. static readonly EffectName: string;
  60056. /**
  60057. * The neutral color used during the preparation of the glow effect.
  60058. * This is black by default as the blend operation is a blend operation.
  60059. */
  60060. static NeutralColor: Color4;
  60061. /**
  60062. * Stencil value used for glowing meshes.
  60063. */
  60064. static GlowingMeshStencilReference: number;
  60065. /**
  60066. * Stencil value used for the other meshes in the scene.
  60067. */
  60068. static NormalMeshStencilReference: number;
  60069. /**
  60070. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60071. */
  60072. innerGlow: boolean;
  60073. /**
  60074. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60075. */
  60076. outerGlow: boolean;
  60077. /**
  60078. * Specifies the horizontal size of the blur.
  60079. */
  60080. set blurHorizontalSize(value: number);
  60081. /**
  60082. * Specifies the vertical size of the blur.
  60083. */
  60084. set blurVerticalSize(value: number);
  60085. /**
  60086. * Gets the horizontal size of the blur.
  60087. */
  60088. get blurHorizontalSize(): number;
  60089. /**
  60090. * Gets the vertical size of the blur.
  60091. */
  60092. get blurVerticalSize(): number;
  60093. /**
  60094. * An event triggered when the highlight layer is being blurred.
  60095. */
  60096. onBeforeBlurObservable: Observable<HighlightLayer>;
  60097. /**
  60098. * An event triggered when the highlight layer has been blurred.
  60099. */
  60100. onAfterBlurObservable: Observable<HighlightLayer>;
  60101. private _instanceGlowingMeshStencilReference;
  60102. private _options;
  60103. private _downSamplePostprocess;
  60104. private _horizontalBlurPostprocess;
  60105. private _verticalBlurPostprocess;
  60106. private _blurTexture;
  60107. private _meshes;
  60108. private _excludedMeshes;
  60109. /**
  60110. * Instantiates a new highlight Layer and references it to the scene..
  60111. * @param name The name of the layer
  60112. * @param scene The scene to use the layer in
  60113. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60114. */
  60115. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60116. /**
  60117. * Get the effect name of the layer.
  60118. * @return The effect name
  60119. */
  60120. getEffectName(): string;
  60121. /**
  60122. * Create the merge effect. This is the shader use to blit the information back
  60123. * to the main canvas at the end of the scene rendering.
  60124. */
  60125. protected _createMergeEffect(): Effect;
  60126. /**
  60127. * Creates the render target textures and post processes used in the highlight layer.
  60128. */
  60129. protected _createTextureAndPostProcesses(): void;
  60130. /**
  60131. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60132. */
  60133. needStencil(): boolean;
  60134. /**
  60135. * Checks for the readiness of the element composing the layer.
  60136. * @param subMesh the mesh to check for
  60137. * @param useInstances specify wether or not to use instances to render the mesh
  60138. * @param emissiveTexture the associated emissive texture used to generate the glow
  60139. * @return true if ready otherwise, false
  60140. */
  60141. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60142. /**
  60143. * Implementation specific of rendering the generating effect on the main canvas.
  60144. * @param effect The effect used to render through
  60145. */
  60146. protected _internalRender(effect: Effect): void;
  60147. /**
  60148. * Returns true if the layer contains information to display, otherwise false.
  60149. */
  60150. shouldRender(): boolean;
  60151. /**
  60152. * Returns true if the mesh should render, otherwise false.
  60153. * @param mesh The mesh to render
  60154. * @returns true if it should render otherwise false
  60155. */
  60156. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60157. /**
  60158. * Adds specific effects defines.
  60159. * @param defines The defines to add specifics to.
  60160. */
  60161. protected _addCustomEffectDefines(defines: string[]): void;
  60162. /**
  60163. * Sets the required values for both the emissive texture and and the main color.
  60164. */
  60165. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60166. /**
  60167. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60168. * @param mesh The mesh to exclude from the highlight layer
  60169. */
  60170. addExcludedMesh(mesh: Mesh): void;
  60171. /**
  60172. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60173. * @param mesh The mesh to highlight
  60174. */
  60175. removeExcludedMesh(mesh: Mesh): void;
  60176. /**
  60177. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60178. * @param mesh mesh to test
  60179. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60180. */
  60181. hasMesh(mesh: AbstractMesh): boolean;
  60182. /**
  60183. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60184. * @param mesh The mesh to highlight
  60185. * @param color The color of the highlight
  60186. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60187. */
  60188. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60189. /**
  60190. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60191. * @param mesh The mesh to highlight
  60192. */
  60193. removeMesh(mesh: Mesh): void;
  60194. /**
  60195. * Remove all the meshes currently referenced in the highlight layer
  60196. */
  60197. removeAllMeshes(): void;
  60198. /**
  60199. * Force the stencil to the normal expected value for none glowing parts
  60200. */
  60201. private _defaultStencilReference;
  60202. /**
  60203. * Free any resources and references associated to a mesh.
  60204. * Internal use
  60205. * @param mesh The mesh to free.
  60206. * @hidden
  60207. */
  60208. _disposeMesh(mesh: Mesh): void;
  60209. /**
  60210. * Dispose the highlight layer and free resources.
  60211. */
  60212. dispose(): void;
  60213. /**
  60214. * Gets the class name of the effect layer
  60215. * @returns the string with the class name of the effect layer
  60216. */
  60217. getClassName(): string;
  60218. /**
  60219. * Serializes this Highlight layer
  60220. * @returns a serialized Highlight layer object
  60221. */
  60222. serialize(): any;
  60223. /**
  60224. * Creates a Highlight layer from parsed Highlight layer data
  60225. * @param parsedHightlightLayer defines the Highlight layer data
  60226. * @param scene defines the current scene
  60227. * @param rootUrl defines the root URL containing the Highlight layer information
  60228. * @returns a parsed Highlight layer
  60229. */
  60230. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60231. }
  60232. }
  60233. declare module "babylonjs/Layers/layerSceneComponent" {
  60234. import { Scene } from "babylonjs/scene";
  60235. import { ISceneComponent } from "babylonjs/sceneComponent";
  60236. import { Layer } from "babylonjs/Layers/layer";
  60237. import { AbstractScene } from "babylonjs/abstractScene";
  60238. module "babylonjs/abstractScene" {
  60239. interface AbstractScene {
  60240. /**
  60241. * The list of layers (background and foreground) of the scene
  60242. */
  60243. layers: Array<Layer>;
  60244. }
  60245. }
  60246. /**
  60247. * Defines the layer scene component responsible to manage any layers
  60248. * in a given scene.
  60249. */
  60250. export class LayerSceneComponent implements ISceneComponent {
  60251. /**
  60252. * The component name helpfull to identify the component in the list of scene components.
  60253. */
  60254. readonly name: string;
  60255. /**
  60256. * The scene the component belongs to.
  60257. */
  60258. scene: Scene;
  60259. private _engine;
  60260. /**
  60261. * Creates a new instance of the component for the given scene
  60262. * @param scene Defines the scene to register the component in
  60263. */
  60264. constructor(scene: Scene);
  60265. /**
  60266. * Registers the component in a given scene
  60267. */
  60268. register(): void;
  60269. /**
  60270. * Rebuilds the elements related to this component in case of
  60271. * context lost for instance.
  60272. */
  60273. rebuild(): void;
  60274. /**
  60275. * Disposes the component and the associated ressources.
  60276. */
  60277. dispose(): void;
  60278. private _draw;
  60279. private _drawCameraPredicate;
  60280. private _drawCameraBackground;
  60281. private _drawCameraForeground;
  60282. private _drawRenderTargetPredicate;
  60283. private _drawRenderTargetBackground;
  60284. private _drawRenderTargetForeground;
  60285. /**
  60286. * Adds all the elements from the container to the scene
  60287. * @param container the container holding the elements
  60288. */
  60289. addFromContainer(container: AbstractScene): void;
  60290. /**
  60291. * Removes all the elements in the container from the scene
  60292. * @param container contains the elements to remove
  60293. * @param dispose if the removed element should be disposed (default: false)
  60294. */
  60295. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60296. }
  60297. }
  60298. declare module "babylonjs/Shaders/layer.fragment" {
  60299. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60300. /** @hidden */
  60301. export var layerPixelShader: {
  60302. name: string;
  60303. shader: string;
  60304. };
  60305. }
  60306. declare module "babylonjs/Shaders/layer.vertex" {
  60307. /** @hidden */
  60308. export var layerVertexShader: {
  60309. name: string;
  60310. shader: string;
  60311. };
  60312. }
  60313. declare module "babylonjs/Layers/layer" {
  60314. import { Observable } from "babylonjs/Misc/observable";
  60315. import { Nullable } from "babylonjs/types";
  60316. import { Scene } from "babylonjs/scene";
  60317. import { Vector2 } from "babylonjs/Maths/math.vector";
  60318. import { Color4 } from "babylonjs/Maths/math.color";
  60319. import { Texture } from "babylonjs/Materials/Textures/texture";
  60320. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60321. import "babylonjs/Shaders/layer.fragment";
  60322. import "babylonjs/Shaders/layer.vertex";
  60323. /**
  60324. * This represents a full screen 2d layer.
  60325. * This can be useful to display a picture in the background of your scene for instance.
  60326. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60327. */
  60328. export class Layer {
  60329. /**
  60330. * Define the name of the layer.
  60331. */
  60332. name: string;
  60333. /**
  60334. * Define the texture the layer should display.
  60335. */
  60336. texture: Nullable<Texture>;
  60337. /**
  60338. * Is the layer in background or foreground.
  60339. */
  60340. isBackground: boolean;
  60341. /**
  60342. * Define the color of the layer (instead of texture).
  60343. */
  60344. color: Color4;
  60345. /**
  60346. * Define the scale of the layer in order to zoom in out of the texture.
  60347. */
  60348. scale: Vector2;
  60349. /**
  60350. * Define an offset for the layer in order to shift the texture.
  60351. */
  60352. offset: Vector2;
  60353. /**
  60354. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60355. */
  60356. alphaBlendingMode: number;
  60357. /**
  60358. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60359. * Alpha test will not mix with the background color in case of transparency.
  60360. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60361. */
  60362. alphaTest: boolean;
  60363. /**
  60364. * Define a mask to restrict the layer to only some of the scene cameras.
  60365. */
  60366. layerMask: number;
  60367. /**
  60368. * Define the list of render target the layer is visible into.
  60369. */
  60370. renderTargetTextures: RenderTargetTexture[];
  60371. /**
  60372. * Define if the layer is only used in renderTarget or if it also
  60373. * renders in the main frame buffer of the canvas.
  60374. */
  60375. renderOnlyInRenderTargetTextures: boolean;
  60376. private _scene;
  60377. private _vertexBuffers;
  60378. private _indexBuffer;
  60379. private _effect;
  60380. private _previousDefines;
  60381. /**
  60382. * An event triggered when the layer is disposed.
  60383. */
  60384. onDisposeObservable: Observable<Layer>;
  60385. private _onDisposeObserver;
  60386. /**
  60387. * Back compatibility with callback before the onDisposeObservable existed.
  60388. * The set callback will be triggered when the layer has been disposed.
  60389. */
  60390. set onDispose(callback: () => void);
  60391. /**
  60392. * An event triggered before rendering the scene
  60393. */
  60394. onBeforeRenderObservable: Observable<Layer>;
  60395. private _onBeforeRenderObserver;
  60396. /**
  60397. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60398. * The set callback will be triggered just before rendering the layer.
  60399. */
  60400. set onBeforeRender(callback: () => void);
  60401. /**
  60402. * An event triggered after rendering the scene
  60403. */
  60404. onAfterRenderObservable: Observable<Layer>;
  60405. private _onAfterRenderObserver;
  60406. /**
  60407. * Back compatibility with callback before the onAfterRenderObservable existed.
  60408. * The set callback will be triggered just after rendering the layer.
  60409. */
  60410. set onAfterRender(callback: () => void);
  60411. /**
  60412. * Instantiates a new layer.
  60413. * This represents a full screen 2d layer.
  60414. * This can be useful to display a picture in the background of your scene for instance.
  60415. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60416. * @param name Define the name of the layer in the scene
  60417. * @param imgUrl Define the url of the texture to display in the layer
  60418. * @param scene Define the scene the layer belongs to
  60419. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60420. * @param color Defines a color for the layer
  60421. */
  60422. constructor(
  60423. /**
  60424. * Define the name of the layer.
  60425. */
  60426. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60427. private _createIndexBuffer;
  60428. /** @hidden */
  60429. _rebuild(): void;
  60430. /**
  60431. * Renders the layer in the scene.
  60432. */
  60433. render(): void;
  60434. /**
  60435. * Disposes and releases the associated ressources.
  60436. */
  60437. dispose(): void;
  60438. }
  60439. }
  60440. declare module "babylonjs/Layers/index" {
  60441. export * from "babylonjs/Layers/effectLayer";
  60442. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60443. export * from "babylonjs/Layers/glowLayer";
  60444. export * from "babylonjs/Layers/highlightLayer";
  60445. export * from "babylonjs/Layers/layer";
  60446. export * from "babylonjs/Layers/layerSceneComponent";
  60447. }
  60448. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60449. /** @hidden */
  60450. export var lensFlarePixelShader: {
  60451. name: string;
  60452. shader: string;
  60453. };
  60454. }
  60455. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60456. /** @hidden */
  60457. export var lensFlareVertexShader: {
  60458. name: string;
  60459. shader: string;
  60460. };
  60461. }
  60462. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60463. import { Scene } from "babylonjs/scene";
  60464. import { Vector3 } from "babylonjs/Maths/math.vector";
  60465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60466. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60467. import "babylonjs/Shaders/lensFlare.fragment";
  60468. import "babylonjs/Shaders/lensFlare.vertex";
  60469. import { Viewport } from "babylonjs/Maths/math.viewport";
  60470. /**
  60471. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60472. * It is usually composed of several `lensFlare`.
  60473. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60474. */
  60475. export class LensFlareSystem {
  60476. /**
  60477. * Define the name of the lens flare system
  60478. */
  60479. name: string;
  60480. /**
  60481. * List of lens flares used in this system.
  60482. */
  60483. lensFlares: LensFlare[];
  60484. /**
  60485. * Define a limit from the border the lens flare can be visible.
  60486. */
  60487. borderLimit: number;
  60488. /**
  60489. * Define a viewport border we do not want to see the lens flare in.
  60490. */
  60491. viewportBorder: number;
  60492. /**
  60493. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60494. */
  60495. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60496. /**
  60497. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60498. */
  60499. layerMask: number;
  60500. /**
  60501. * Define the id of the lens flare system in the scene.
  60502. * (equal to name by default)
  60503. */
  60504. id: string;
  60505. private _scene;
  60506. private _emitter;
  60507. private _vertexBuffers;
  60508. private _indexBuffer;
  60509. private _effect;
  60510. private _positionX;
  60511. private _positionY;
  60512. private _isEnabled;
  60513. /** @hidden */
  60514. static _SceneComponentInitialization: (scene: Scene) => void;
  60515. /**
  60516. * Instantiates a lens flare system.
  60517. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60518. * It is usually composed of several `lensFlare`.
  60519. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60520. * @param name Define the name of the lens flare system in the scene
  60521. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60522. * @param scene Define the scene the lens flare system belongs to
  60523. */
  60524. constructor(
  60525. /**
  60526. * Define the name of the lens flare system
  60527. */
  60528. name: string, emitter: any, scene: Scene);
  60529. /**
  60530. * Define if the lens flare system is enabled.
  60531. */
  60532. get isEnabled(): boolean;
  60533. set isEnabled(value: boolean);
  60534. /**
  60535. * Get the scene the effects belongs to.
  60536. * @returns the scene holding the lens flare system
  60537. */
  60538. getScene(): Scene;
  60539. /**
  60540. * Get the emitter of the lens flare system.
  60541. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60542. * @returns the emitter of the lens flare system
  60543. */
  60544. getEmitter(): any;
  60545. /**
  60546. * Set the emitter of the lens flare system.
  60547. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60548. * @param newEmitter Define the new emitter of the system
  60549. */
  60550. setEmitter(newEmitter: any): void;
  60551. /**
  60552. * Get the lens flare system emitter position.
  60553. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60554. * @returns the position
  60555. */
  60556. getEmitterPosition(): Vector3;
  60557. /**
  60558. * @hidden
  60559. */
  60560. computeEffectivePosition(globalViewport: Viewport): boolean;
  60561. /** @hidden */
  60562. _isVisible(): boolean;
  60563. /**
  60564. * @hidden
  60565. */
  60566. render(): boolean;
  60567. /**
  60568. * Dispose and release the lens flare with its associated resources.
  60569. */
  60570. dispose(): void;
  60571. /**
  60572. * Parse a lens flare system from a JSON repressentation
  60573. * @param parsedLensFlareSystem Define the JSON to parse
  60574. * @param scene Define the scene the parsed system should be instantiated in
  60575. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60576. * @returns the parsed system
  60577. */
  60578. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60579. /**
  60580. * Serialize the current Lens Flare System into a JSON representation.
  60581. * @returns the serialized JSON
  60582. */
  60583. serialize(): any;
  60584. }
  60585. }
  60586. declare module "babylonjs/LensFlares/lensFlare" {
  60587. import { Nullable } from "babylonjs/types";
  60588. import { Color3 } from "babylonjs/Maths/math.color";
  60589. import { Texture } from "babylonjs/Materials/Textures/texture";
  60590. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60591. /**
  60592. * This represents one of the lens effect in a `lensFlareSystem`.
  60593. * It controls one of the indiviual texture used in the effect.
  60594. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60595. */
  60596. export class LensFlare {
  60597. /**
  60598. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60599. */
  60600. size: number;
  60601. /**
  60602. * 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.
  60603. */
  60604. position: number;
  60605. /**
  60606. * Define the lens color.
  60607. */
  60608. color: Color3;
  60609. /**
  60610. * Define the lens texture.
  60611. */
  60612. texture: Nullable<Texture>;
  60613. /**
  60614. * Define the alpha mode to render this particular lens.
  60615. */
  60616. alphaMode: number;
  60617. private _system;
  60618. /**
  60619. * Creates a new Lens Flare.
  60620. * This represents one of the lens effect in a `lensFlareSystem`.
  60621. * It controls one of the indiviual texture used in the effect.
  60622. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60623. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60624. * @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.
  60625. * @param color Define the lens color
  60626. * @param imgUrl Define the lens texture url
  60627. * @param system Define the `lensFlareSystem` this flare is part of
  60628. * @returns The newly created Lens Flare
  60629. */
  60630. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60631. /**
  60632. * Instantiates a new Lens Flare.
  60633. * This represents one of the lens effect in a `lensFlareSystem`.
  60634. * It controls one of the indiviual texture used in the effect.
  60635. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60636. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60637. * @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.
  60638. * @param color Define the lens color
  60639. * @param imgUrl Define the lens texture url
  60640. * @param system Define the `lensFlareSystem` this flare is part of
  60641. */
  60642. constructor(
  60643. /**
  60644. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60645. */
  60646. size: number,
  60647. /**
  60648. * 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.
  60649. */
  60650. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60651. /**
  60652. * Dispose and release the lens flare with its associated resources.
  60653. */
  60654. dispose(): void;
  60655. }
  60656. }
  60657. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60658. import { Nullable } from "babylonjs/types";
  60659. import { Scene } from "babylonjs/scene";
  60660. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60661. import { AbstractScene } from "babylonjs/abstractScene";
  60662. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60663. module "babylonjs/abstractScene" {
  60664. interface AbstractScene {
  60665. /**
  60666. * The list of lens flare system added to the scene
  60667. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60668. */
  60669. lensFlareSystems: Array<LensFlareSystem>;
  60670. /**
  60671. * Removes the given lens flare system from this scene.
  60672. * @param toRemove The lens flare system to remove
  60673. * @returns The index of the removed lens flare system
  60674. */
  60675. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60676. /**
  60677. * Adds the given lens flare system to this scene
  60678. * @param newLensFlareSystem The lens flare system to add
  60679. */
  60680. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60681. /**
  60682. * Gets a lens flare system using its name
  60683. * @param name defines the name to look for
  60684. * @returns the lens flare system or null if not found
  60685. */
  60686. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60687. /**
  60688. * Gets a lens flare system using its id
  60689. * @param id defines the id to look for
  60690. * @returns the lens flare system or null if not found
  60691. */
  60692. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60693. }
  60694. }
  60695. /**
  60696. * Defines the lens flare scene component responsible to manage any lens flares
  60697. * in a given scene.
  60698. */
  60699. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60700. /**
  60701. * The component name helpfull to identify the component in the list of scene components.
  60702. */
  60703. readonly name: string;
  60704. /**
  60705. * The scene the component belongs to.
  60706. */
  60707. scene: Scene;
  60708. /**
  60709. * Creates a new instance of the component for the given scene
  60710. * @param scene Defines the scene to register the component in
  60711. */
  60712. constructor(scene: Scene);
  60713. /**
  60714. * Registers the component in a given scene
  60715. */
  60716. register(): void;
  60717. /**
  60718. * Rebuilds the elements related to this component in case of
  60719. * context lost for instance.
  60720. */
  60721. rebuild(): void;
  60722. /**
  60723. * Adds all the elements from the container to the scene
  60724. * @param container the container holding the elements
  60725. */
  60726. addFromContainer(container: AbstractScene): void;
  60727. /**
  60728. * Removes all the elements in the container from the scene
  60729. * @param container contains the elements to remove
  60730. * @param dispose if the removed element should be disposed (default: false)
  60731. */
  60732. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60733. /**
  60734. * Serializes the component data to the specified json object
  60735. * @param serializationObject The object to serialize to
  60736. */
  60737. serialize(serializationObject: any): void;
  60738. /**
  60739. * Disposes the component and the associated ressources.
  60740. */
  60741. dispose(): void;
  60742. private _draw;
  60743. }
  60744. }
  60745. declare module "babylonjs/LensFlares/index" {
  60746. export * from "babylonjs/LensFlares/lensFlare";
  60747. export * from "babylonjs/LensFlares/lensFlareSystem";
  60748. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60749. }
  60750. declare module "babylonjs/Shaders/depth.fragment" {
  60751. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60752. /** @hidden */
  60753. export var depthPixelShader: {
  60754. name: string;
  60755. shader: string;
  60756. };
  60757. }
  60758. declare module "babylonjs/Shaders/depth.vertex" {
  60759. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60760. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60761. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60762. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60763. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60764. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60765. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60766. /** @hidden */
  60767. export var depthVertexShader: {
  60768. name: string;
  60769. shader: string;
  60770. };
  60771. }
  60772. declare module "babylonjs/Rendering/depthRenderer" {
  60773. import { Nullable } from "babylonjs/types";
  60774. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60775. import { Scene } from "babylonjs/scene";
  60776. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60777. import { Camera } from "babylonjs/Cameras/camera";
  60778. import "babylonjs/Shaders/depth.fragment";
  60779. import "babylonjs/Shaders/depth.vertex";
  60780. /**
  60781. * This represents a depth renderer in Babylon.
  60782. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60783. */
  60784. export class DepthRenderer {
  60785. private _scene;
  60786. private _depthMap;
  60787. private _effect;
  60788. private readonly _storeNonLinearDepth;
  60789. private readonly _clearColor;
  60790. /** Get if the depth renderer is using packed depth or not */
  60791. readonly isPacked: boolean;
  60792. private _cachedDefines;
  60793. private _camera;
  60794. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60795. enabled: boolean;
  60796. /**
  60797. * Specifiess that the depth renderer will only be used within
  60798. * the camera it is created for.
  60799. * This can help forcing its rendering during the camera processing.
  60800. */
  60801. useOnlyInActiveCamera: boolean;
  60802. /** @hidden */
  60803. static _SceneComponentInitialization: (scene: Scene) => void;
  60804. /**
  60805. * Instantiates a depth renderer
  60806. * @param scene The scene the renderer belongs to
  60807. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60808. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60809. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60810. */
  60811. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60812. /**
  60813. * Creates the depth rendering effect and checks if the effect is ready.
  60814. * @param subMesh The submesh to be used to render the depth map of
  60815. * @param useInstances If multiple world instances should be used
  60816. * @returns if the depth renderer is ready to render the depth map
  60817. */
  60818. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60819. /**
  60820. * Gets the texture which the depth map will be written to.
  60821. * @returns The depth map texture
  60822. */
  60823. getDepthMap(): RenderTargetTexture;
  60824. /**
  60825. * Disposes of the depth renderer.
  60826. */
  60827. dispose(): void;
  60828. }
  60829. }
  60830. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60831. /** @hidden */
  60832. export var minmaxReduxPixelShader: {
  60833. name: string;
  60834. shader: string;
  60835. };
  60836. }
  60837. declare module "babylonjs/Misc/minMaxReducer" {
  60838. import { Nullable } from "babylonjs/types";
  60839. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60840. import { Camera } from "babylonjs/Cameras/camera";
  60841. import { Observer } from "babylonjs/Misc/observable";
  60842. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60843. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60844. import { Observable } from "babylonjs/Misc/observable";
  60845. import "babylonjs/Shaders/minmaxRedux.fragment";
  60846. /**
  60847. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60848. * and maximum values from all values of the texture.
  60849. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60850. * The source values are read from the red channel of the texture.
  60851. */
  60852. export class MinMaxReducer {
  60853. /**
  60854. * Observable triggered when the computation has been performed
  60855. */
  60856. onAfterReductionPerformed: Observable<{
  60857. min: number;
  60858. max: number;
  60859. }>;
  60860. protected _camera: Camera;
  60861. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60862. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60863. protected _postProcessManager: PostProcessManager;
  60864. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60865. protected _forceFullscreenViewport: boolean;
  60866. /**
  60867. * Creates a min/max reducer
  60868. * @param camera The camera to use for the post processes
  60869. */
  60870. constructor(camera: Camera);
  60871. /**
  60872. * Gets the texture used to read the values from.
  60873. */
  60874. get sourceTexture(): Nullable<RenderTargetTexture>;
  60875. /**
  60876. * Sets the source texture to read the values from.
  60877. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60878. * because in such textures '1' value must not be taken into account to compute the maximum
  60879. * as this value is used to clear the texture.
  60880. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60881. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60882. * @param depthRedux Indicates if the texture is a depth texture or not
  60883. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60884. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60885. */
  60886. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60887. /**
  60888. * Defines the refresh rate of the computation.
  60889. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60890. */
  60891. get refreshRate(): number;
  60892. set refreshRate(value: number);
  60893. protected _activated: boolean;
  60894. /**
  60895. * Gets the activation status of the reducer
  60896. */
  60897. get activated(): boolean;
  60898. /**
  60899. * Activates the reduction computation.
  60900. * When activated, the observers registered in onAfterReductionPerformed are
  60901. * called after the compuation is performed
  60902. */
  60903. activate(): void;
  60904. /**
  60905. * Deactivates the reduction computation.
  60906. */
  60907. deactivate(): void;
  60908. /**
  60909. * Disposes the min/max reducer
  60910. * @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.
  60911. */
  60912. dispose(disposeAll?: boolean): void;
  60913. }
  60914. }
  60915. declare module "babylonjs/Misc/depthReducer" {
  60916. import { Nullable } from "babylonjs/types";
  60917. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60918. import { Camera } from "babylonjs/Cameras/camera";
  60919. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60920. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  60921. /**
  60922. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60923. */
  60924. export class DepthReducer extends MinMaxReducer {
  60925. private _depthRenderer;
  60926. private _depthRendererId;
  60927. /**
  60928. * Gets the depth renderer used for the computation.
  60929. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60930. */
  60931. get depthRenderer(): Nullable<DepthRenderer>;
  60932. /**
  60933. * Creates a depth reducer
  60934. * @param camera The camera used to render the depth texture
  60935. */
  60936. constructor(camera: Camera);
  60937. /**
  60938. * Sets the depth renderer to use to generate the depth map
  60939. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60940. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60941. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60942. */
  60943. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60944. /** @hidden */
  60945. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60946. /**
  60947. * Activates the reduction computation.
  60948. * When activated, the observers registered in onAfterReductionPerformed are
  60949. * called after the compuation is performed
  60950. */
  60951. activate(): void;
  60952. /**
  60953. * Deactivates the reduction computation.
  60954. */
  60955. deactivate(): void;
  60956. /**
  60957. * Disposes the depth reducer
  60958. * @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.
  60959. */
  60960. dispose(disposeAll?: boolean): void;
  60961. }
  60962. }
  60963. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  60964. import { Nullable } from "babylonjs/types";
  60965. import { Scene } from "babylonjs/scene";
  60966. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60967. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60969. import { Effect } from "babylonjs/Materials/effect";
  60970. import "babylonjs/Shaders/shadowMap.fragment";
  60971. import "babylonjs/Shaders/shadowMap.vertex";
  60972. import "babylonjs/Shaders/depthBoxBlur.fragment";
  60973. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  60974. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60975. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  60976. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60977. /**
  60978. * A CSM implementation allowing casting shadows on large scenes.
  60979. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60980. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60981. */
  60982. export class CascadedShadowGenerator extends ShadowGenerator {
  60983. private static readonly frustumCornersNDCSpace;
  60984. /**
  60985. * Name of the CSM class
  60986. */
  60987. static CLASSNAME: string;
  60988. /**
  60989. * Defines the default number of cascades used by the CSM.
  60990. */
  60991. static readonly DEFAULT_CASCADES_COUNT: number;
  60992. /**
  60993. * Defines the minimum number of cascades used by the CSM.
  60994. */
  60995. static readonly MIN_CASCADES_COUNT: number;
  60996. /**
  60997. * Defines the maximum number of cascades used by the CSM.
  60998. */
  60999. static readonly MAX_CASCADES_COUNT: number;
  61000. protected _validateFilter(filter: number): number;
  61001. /**
  61002. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61003. */
  61004. penumbraDarkness: number;
  61005. private _numCascades;
  61006. /**
  61007. * Gets or set the number of cascades used by the CSM.
  61008. */
  61009. get numCascades(): number;
  61010. set numCascades(value: number);
  61011. /**
  61012. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61013. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61014. */
  61015. stabilizeCascades: boolean;
  61016. private _freezeShadowCastersBoundingInfo;
  61017. private _freezeShadowCastersBoundingInfoObservable;
  61018. /**
  61019. * Enables or disables the shadow casters bounding info computation.
  61020. * If your shadow casters don't move, you can disable this feature.
  61021. * If it is enabled, the bounding box computation is done every frame.
  61022. */
  61023. get freezeShadowCastersBoundingInfo(): boolean;
  61024. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61025. private _scbiMin;
  61026. private _scbiMax;
  61027. protected _computeShadowCastersBoundingInfo(): void;
  61028. protected _shadowCastersBoundingInfo: BoundingInfo;
  61029. /**
  61030. * Gets or sets the shadow casters bounding info.
  61031. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61032. * so that the system won't overwrite the bounds you provide
  61033. */
  61034. get shadowCastersBoundingInfo(): BoundingInfo;
  61035. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61036. protected _breaksAreDirty: boolean;
  61037. protected _minDistance: number;
  61038. protected _maxDistance: number;
  61039. /**
  61040. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61041. *
  61042. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61043. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61044. * @param min minimal distance for the breaks (default to 0.)
  61045. * @param max maximal distance for the breaks (default to 1.)
  61046. */
  61047. setMinMaxDistance(min: number, max: number): void;
  61048. /** Gets the minimal distance used in the cascade break computation */
  61049. get minDistance(): number;
  61050. /** Gets the maximal distance used in the cascade break computation */
  61051. get maxDistance(): number;
  61052. /**
  61053. * Gets the class name of that object
  61054. * @returns "CascadedShadowGenerator"
  61055. */
  61056. getClassName(): string;
  61057. private _cascadeMinExtents;
  61058. private _cascadeMaxExtents;
  61059. /**
  61060. * Gets a cascade minimum extents
  61061. * @param cascadeIndex index of the cascade
  61062. * @returns the minimum cascade extents
  61063. */
  61064. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61065. /**
  61066. * Gets a cascade maximum extents
  61067. * @param cascadeIndex index of the cascade
  61068. * @returns the maximum cascade extents
  61069. */
  61070. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61071. private _cascades;
  61072. private _currentLayer;
  61073. private _viewSpaceFrustumsZ;
  61074. private _viewMatrices;
  61075. private _projectionMatrices;
  61076. private _transformMatrices;
  61077. private _transformMatricesAsArray;
  61078. private _frustumLengths;
  61079. private _lightSizeUVCorrection;
  61080. private _depthCorrection;
  61081. private _frustumCornersWorldSpace;
  61082. private _frustumCenter;
  61083. private _shadowCameraPos;
  61084. private _shadowMaxZ;
  61085. /**
  61086. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61087. * It defaults to camera.maxZ
  61088. */
  61089. get shadowMaxZ(): number;
  61090. /**
  61091. * Sets the shadow max z distance.
  61092. */
  61093. set shadowMaxZ(value: number);
  61094. protected _debug: boolean;
  61095. /**
  61096. * Gets or sets the debug flag.
  61097. * When enabled, the cascades are materialized by different colors on the screen.
  61098. */
  61099. get debug(): boolean;
  61100. set debug(dbg: boolean);
  61101. private _depthClamp;
  61102. /**
  61103. * Gets or sets the depth clamping value.
  61104. *
  61105. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61106. * to account for the shadow casters far away.
  61107. *
  61108. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61109. */
  61110. get depthClamp(): boolean;
  61111. set depthClamp(value: boolean);
  61112. private _cascadeBlendPercentage;
  61113. /**
  61114. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61115. * It defaults to 0.1 (10% blending).
  61116. */
  61117. get cascadeBlendPercentage(): number;
  61118. set cascadeBlendPercentage(value: number);
  61119. private _lambda;
  61120. /**
  61121. * Gets or set the lambda parameter.
  61122. * This parameter is used to split the camera frustum and create the cascades.
  61123. * 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.
  61124. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61125. */
  61126. get lambda(): number;
  61127. set lambda(value: number);
  61128. /**
  61129. * Gets the view matrix corresponding to a given cascade
  61130. * @param cascadeNum cascade to retrieve the view matrix from
  61131. * @returns the cascade view matrix
  61132. */
  61133. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61134. /**
  61135. * Gets the projection matrix corresponding to a given cascade
  61136. * @param cascadeNum cascade to retrieve the projection matrix from
  61137. * @returns the cascade projection matrix
  61138. */
  61139. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61140. /**
  61141. * Gets the transformation matrix corresponding to a given cascade
  61142. * @param cascadeNum cascade to retrieve the transformation matrix from
  61143. * @returns the cascade transformation matrix
  61144. */
  61145. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61146. private _depthRenderer;
  61147. /**
  61148. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61149. *
  61150. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61151. *
  61152. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61153. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61154. * @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
  61155. */
  61156. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61157. private _depthReducer;
  61158. private _autoCalcDepthBounds;
  61159. /**
  61160. * Gets or sets the autoCalcDepthBounds property.
  61161. *
  61162. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61163. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61164. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61165. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61166. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61167. */
  61168. get autoCalcDepthBounds(): boolean;
  61169. set autoCalcDepthBounds(value: boolean);
  61170. /**
  61171. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61172. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61173. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61174. * for setting the refresh rate on the renderer yourself!
  61175. */
  61176. get autoCalcDepthBoundsRefreshRate(): number;
  61177. set autoCalcDepthBoundsRefreshRate(value: number);
  61178. /**
  61179. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61180. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61181. * you change the camera near/far planes!
  61182. */
  61183. splitFrustum(): void;
  61184. private _splitFrustum;
  61185. private _computeMatrices;
  61186. private _computeFrustumInWorldSpace;
  61187. private _computeCascadeFrustum;
  61188. /**
  61189. * Support test.
  61190. */
  61191. static get IsSupported(): boolean;
  61192. /** @hidden */
  61193. static _SceneComponentInitialization: (scene: Scene) => void;
  61194. /**
  61195. * Creates a Cascaded Shadow Generator object.
  61196. * A ShadowGenerator is the required tool to use the shadows.
  61197. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61198. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61199. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61200. * @param light The directional light object generating the shadows.
  61201. * @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.
  61202. */
  61203. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61204. protected _initializeGenerator(): void;
  61205. protected _createTargetRenderTexture(): void;
  61206. protected _initializeShadowMap(): void;
  61207. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61208. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61209. /**
  61210. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61211. * @param defines Defines of the material we want to update
  61212. * @param lightIndex Index of the light in the enabled light list of the material
  61213. */
  61214. prepareDefines(defines: any, lightIndex: number): void;
  61215. /**
  61216. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61217. * defined in the generator but impacting the effect).
  61218. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61219. * @param effect The effect we are binfing the information for
  61220. */
  61221. bindShadowLight(lightIndex: string, effect: Effect): void;
  61222. /**
  61223. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61224. * (eq to view projection * shadow projection matrices)
  61225. * @returns The transform matrix used to create the shadow map
  61226. */
  61227. getTransformMatrix(): Matrix;
  61228. /**
  61229. * Disposes the ShadowGenerator.
  61230. * Returns nothing.
  61231. */
  61232. dispose(): void;
  61233. /**
  61234. * Serializes the shadow generator setup to a json object.
  61235. * @returns The serialized JSON object
  61236. */
  61237. serialize(): any;
  61238. /**
  61239. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61240. * @param parsedShadowGenerator The JSON object to parse
  61241. * @param scene The scene to create the shadow map for
  61242. * @returns The parsed shadow generator
  61243. */
  61244. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61245. }
  61246. }
  61247. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61248. import { Scene } from "babylonjs/scene";
  61249. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61250. import { AbstractScene } from "babylonjs/abstractScene";
  61251. /**
  61252. * Defines the shadow generator component responsible to manage any shadow generators
  61253. * in a given scene.
  61254. */
  61255. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61256. /**
  61257. * The component name helpfull to identify the component in the list of scene components.
  61258. */
  61259. readonly name: string;
  61260. /**
  61261. * The scene the component belongs to.
  61262. */
  61263. scene: Scene;
  61264. /**
  61265. * Creates a new instance of the component for the given scene
  61266. * @param scene Defines the scene to register the component in
  61267. */
  61268. constructor(scene: Scene);
  61269. /**
  61270. * Registers the component in a given scene
  61271. */
  61272. register(): void;
  61273. /**
  61274. * Rebuilds the elements related to this component in case of
  61275. * context lost for instance.
  61276. */
  61277. rebuild(): void;
  61278. /**
  61279. * Serializes the component data to the specified json object
  61280. * @param serializationObject The object to serialize to
  61281. */
  61282. serialize(serializationObject: any): void;
  61283. /**
  61284. * Adds all the elements from the container to the scene
  61285. * @param container the container holding the elements
  61286. */
  61287. addFromContainer(container: AbstractScene): void;
  61288. /**
  61289. * Removes all the elements in the container from the scene
  61290. * @param container contains the elements to remove
  61291. * @param dispose if the removed element should be disposed (default: false)
  61292. */
  61293. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61294. /**
  61295. * Rebuilds the elements related to this component in case of
  61296. * context lost for instance.
  61297. */
  61298. dispose(): void;
  61299. private _gatherRenderTargets;
  61300. }
  61301. }
  61302. declare module "babylonjs/Lights/Shadows/index" {
  61303. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61304. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61305. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61306. }
  61307. declare module "babylonjs/Lights/pointLight" {
  61308. import { Scene } from "babylonjs/scene";
  61309. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61311. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61312. import { Effect } from "babylonjs/Materials/effect";
  61313. /**
  61314. * A point light is a light defined by an unique point in world space.
  61315. * The light is emitted in every direction from this point.
  61316. * A good example of a point light is a standard light bulb.
  61317. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61318. */
  61319. export class PointLight extends ShadowLight {
  61320. private _shadowAngle;
  61321. /**
  61322. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61323. * This specifies what angle the shadow will use to be created.
  61324. *
  61325. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61326. */
  61327. get shadowAngle(): number;
  61328. /**
  61329. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61330. * This specifies what angle the shadow will use to be created.
  61331. *
  61332. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61333. */
  61334. set shadowAngle(value: number);
  61335. /**
  61336. * Gets the direction if it has been set.
  61337. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61338. */
  61339. get direction(): Vector3;
  61340. /**
  61341. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61342. */
  61343. set direction(value: Vector3);
  61344. /**
  61345. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61346. * A PointLight emits the light in every direction.
  61347. * It can cast shadows.
  61348. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61349. * ```javascript
  61350. * var pointLight = new PointLight("pl", camera.position, scene);
  61351. * ```
  61352. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61353. * @param name The light friendly name
  61354. * @param position The position of the point light in the scene
  61355. * @param scene The scene the lights belongs to
  61356. */
  61357. constructor(name: string, position: Vector3, scene: Scene);
  61358. /**
  61359. * Returns the string "PointLight"
  61360. * @returns the class name
  61361. */
  61362. getClassName(): string;
  61363. /**
  61364. * Returns the integer 0.
  61365. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61366. */
  61367. getTypeID(): number;
  61368. /**
  61369. * Specifies wether or not the shadowmap should be a cube texture.
  61370. * @returns true if the shadowmap needs to be a cube texture.
  61371. */
  61372. needCube(): boolean;
  61373. /**
  61374. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61375. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61376. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61377. */
  61378. getShadowDirection(faceIndex?: number): Vector3;
  61379. /**
  61380. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61381. * - fov = PI / 2
  61382. * - aspect ratio : 1.0
  61383. * - z-near and far equal to the active camera minZ and maxZ.
  61384. * Returns the PointLight.
  61385. */
  61386. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61387. protected _buildUniformLayout(): void;
  61388. /**
  61389. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61390. * @param effect The effect to update
  61391. * @param lightIndex The index of the light in the effect to update
  61392. * @returns The point light
  61393. */
  61394. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61395. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61396. /**
  61397. * Prepares the list of defines specific to the light type.
  61398. * @param defines the list of defines
  61399. * @param lightIndex defines the index of the light for the effect
  61400. */
  61401. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61402. }
  61403. }
  61404. declare module "babylonjs/Lights/index" {
  61405. export * from "babylonjs/Lights/light";
  61406. export * from "babylonjs/Lights/shadowLight";
  61407. export * from "babylonjs/Lights/Shadows/index";
  61408. export * from "babylonjs/Lights/directionalLight";
  61409. export * from "babylonjs/Lights/hemisphericLight";
  61410. export * from "babylonjs/Lights/pointLight";
  61411. export * from "babylonjs/Lights/spotLight";
  61412. }
  61413. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61414. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61415. /**
  61416. * Header information of HDR texture files.
  61417. */
  61418. export interface HDRInfo {
  61419. /**
  61420. * The height of the texture in pixels.
  61421. */
  61422. height: number;
  61423. /**
  61424. * The width of the texture in pixels.
  61425. */
  61426. width: number;
  61427. /**
  61428. * The index of the beginning of the data in the binary file.
  61429. */
  61430. dataPosition: number;
  61431. }
  61432. /**
  61433. * This groups tools to convert HDR texture to native colors array.
  61434. */
  61435. export class HDRTools {
  61436. private static Ldexp;
  61437. private static Rgbe2float;
  61438. private static readStringLine;
  61439. /**
  61440. * Reads header information from an RGBE texture stored in a native array.
  61441. * More information on this format are available here:
  61442. * https://en.wikipedia.org/wiki/RGBE_image_format
  61443. *
  61444. * @param uint8array The binary file stored in native array.
  61445. * @return The header information.
  61446. */
  61447. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61448. /**
  61449. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61450. * This RGBE texture needs to store the information as a panorama.
  61451. *
  61452. * More information on this format are available here:
  61453. * https://en.wikipedia.org/wiki/RGBE_image_format
  61454. *
  61455. * @param buffer The binary file stored in an array buffer.
  61456. * @param size The expected size of the extracted cubemap.
  61457. * @return The Cube Map information.
  61458. */
  61459. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61460. /**
  61461. * Returns the pixels data extracted from an RGBE texture.
  61462. * This pixels will be stored left to right up to down in the R G B order in one array.
  61463. *
  61464. * More information on this format are available here:
  61465. * https://en.wikipedia.org/wiki/RGBE_image_format
  61466. *
  61467. * @param uint8array The binary file stored in an array buffer.
  61468. * @param hdrInfo The header information of the file.
  61469. * @return The pixels data in RGB right to left up to down order.
  61470. */
  61471. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61472. private static RGBE_ReadPixels_RLE;
  61473. }
  61474. }
  61475. declare module "babylonjs/Materials/effectRenderer" {
  61476. import { Nullable } from "babylonjs/types";
  61477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61478. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61479. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61480. import { Viewport } from "babylonjs/Maths/math.viewport";
  61481. import { Observable } from "babylonjs/Misc/observable";
  61482. import { Effect } from "babylonjs/Materials/effect";
  61483. import "babylonjs/Shaders/postprocess.vertex";
  61484. /**
  61485. * Effect Render Options
  61486. */
  61487. export interface IEffectRendererOptions {
  61488. /**
  61489. * Defines the vertices positions.
  61490. */
  61491. positions?: number[];
  61492. /**
  61493. * Defines the indices.
  61494. */
  61495. indices?: number[];
  61496. }
  61497. /**
  61498. * Helper class to render one or more effects.
  61499. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61500. */
  61501. export class EffectRenderer {
  61502. private engine;
  61503. private static _DefaultOptions;
  61504. private _vertexBuffers;
  61505. private _indexBuffer;
  61506. private _fullscreenViewport;
  61507. /**
  61508. * Creates an effect renderer
  61509. * @param engine the engine to use for rendering
  61510. * @param options defines the options of the effect renderer
  61511. */
  61512. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61513. /**
  61514. * Sets the current viewport in normalized coordinates 0-1
  61515. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61516. */
  61517. setViewport(viewport?: Viewport): void;
  61518. /**
  61519. * Binds the embedded attributes buffer to the effect.
  61520. * @param effect Defines the effect to bind the attributes for
  61521. */
  61522. bindBuffers(effect: Effect): void;
  61523. /**
  61524. * Sets the current effect wrapper to use during draw.
  61525. * The effect needs to be ready before calling this api.
  61526. * This also sets the default full screen position attribute.
  61527. * @param effectWrapper Defines the effect to draw with
  61528. */
  61529. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61530. /**
  61531. * Restores engine states
  61532. */
  61533. restoreStates(): void;
  61534. /**
  61535. * Draws a full screen quad.
  61536. */
  61537. draw(): void;
  61538. private isRenderTargetTexture;
  61539. /**
  61540. * renders one or more effects to a specified texture
  61541. * @param effectWrapper the effect to renderer
  61542. * @param outputTexture texture to draw to, if null it will render to the screen.
  61543. */
  61544. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61545. /**
  61546. * Disposes of the effect renderer
  61547. */
  61548. dispose(): void;
  61549. }
  61550. /**
  61551. * Options to create an EffectWrapper
  61552. */
  61553. interface EffectWrapperCreationOptions {
  61554. /**
  61555. * Engine to use to create the effect
  61556. */
  61557. engine: ThinEngine;
  61558. /**
  61559. * Fragment shader for the effect
  61560. */
  61561. fragmentShader: string;
  61562. /**
  61563. * Use the shader store instead of direct source code
  61564. */
  61565. useShaderStore?: boolean;
  61566. /**
  61567. * Vertex shader for the effect
  61568. */
  61569. vertexShader?: string;
  61570. /**
  61571. * Attributes to use in the shader
  61572. */
  61573. attributeNames?: Array<string>;
  61574. /**
  61575. * Uniforms to use in the shader
  61576. */
  61577. uniformNames?: Array<string>;
  61578. /**
  61579. * Texture sampler names to use in the shader
  61580. */
  61581. samplerNames?: Array<string>;
  61582. /**
  61583. * Defines to use in the shader
  61584. */
  61585. defines?: Array<string>;
  61586. /**
  61587. * Callback when effect is compiled
  61588. */
  61589. onCompiled?: Nullable<(effect: Effect) => void>;
  61590. /**
  61591. * The friendly name of the effect displayed in Spector.
  61592. */
  61593. name?: string;
  61594. }
  61595. /**
  61596. * Wraps an effect to be used for rendering
  61597. */
  61598. export class EffectWrapper {
  61599. /**
  61600. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61601. */
  61602. onApplyObservable: Observable<{}>;
  61603. /**
  61604. * The underlying effect
  61605. */
  61606. effect: Effect;
  61607. /**
  61608. * Creates an effect to be renderer
  61609. * @param creationOptions options to create the effect
  61610. */
  61611. constructor(creationOptions: EffectWrapperCreationOptions);
  61612. /**
  61613. * Disposes of the effect wrapper
  61614. */
  61615. dispose(): void;
  61616. }
  61617. }
  61618. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61619. /** @hidden */
  61620. export var hdrFilteringVertexShader: {
  61621. name: string;
  61622. shader: string;
  61623. };
  61624. }
  61625. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61626. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61627. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61628. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61629. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61630. /** @hidden */
  61631. export var hdrFilteringPixelShader: {
  61632. name: string;
  61633. shader: string;
  61634. };
  61635. }
  61636. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61637. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61638. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61639. import { Nullable } from "babylonjs/types";
  61640. import "babylonjs/Shaders/hdrFiltering.vertex";
  61641. import "babylonjs/Shaders/hdrFiltering.fragment";
  61642. /**
  61643. * Options for texture filtering
  61644. */
  61645. interface IHDRFilteringOptions {
  61646. /**
  61647. * Scales pixel intensity for the input HDR map.
  61648. */
  61649. hdrScale?: number;
  61650. /**
  61651. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61652. */
  61653. quality?: number;
  61654. }
  61655. /**
  61656. * Filters HDR maps to get correct renderings of PBR reflections
  61657. */
  61658. export class HDRFiltering {
  61659. private _engine;
  61660. private _effectRenderer;
  61661. private _effectWrapper;
  61662. private _lodGenerationOffset;
  61663. private _lodGenerationScale;
  61664. /**
  61665. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61666. * you care about baking speed.
  61667. */
  61668. quality: number;
  61669. /**
  61670. * Scales pixel intensity for the input HDR map.
  61671. */
  61672. hdrScale: number;
  61673. /**
  61674. * Instantiates HDR filter for reflection maps
  61675. *
  61676. * @param engine Thin engine
  61677. * @param options Options
  61678. */
  61679. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61680. private _createRenderTarget;
  61681. private _prefilterInternal;
  61682. private _createEffect;
  61683. /**
  61684. * Get a value indicating if the filter is ready to be used
  61685. * @param texture Texture to filter
  61686. * @returns true if the filter is ready
  61687. */
  61688. isReady(texture: BaseTexture): boolean;
  61689. /**
  61690. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61691. * Prefiltering will be invoked at the end of next rendering pass.
  61692. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61693. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61694. * @param texture Texture to filter
  61695. * @param onFinished Callback when filtering is done
  61696. * @return Promise called when prefiltering is done
  61697. */
  61698. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61699. }
  61700. }
  61701. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61702. import { Nullable } from "babylonjs/types";
  61703. import { Scene } from "babylonjs/scene";
  61704. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61706. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61707. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61708. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61709. /**
  61710. * This represents a texture coming from an HDR input.
  61711. *
  61712. * The only supported format is currently panorama picture stored in RGBE format.
  61713. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61714. */
  61715. export class HDRCubeTexture extends BaseTexture {
  61716. private static _facesMapping;
  61717. private _generateHarmonics;
  61718. private _noMipmap;
  61719. private _prefilterOnLoad;
  61720. private _textureMatrix;
  61721. private _size;
  61722. private _onLoad;
  61723. private _onError;
  61724. /**
  61725. * The texture URL.
  61726. */
  61727. url: string;
  61728. /**
  61729. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61730. */
  61731. coordinatesMode: number;
  61732. protected _isBlocking: boolean;
  61733. /**
  61734. * Sets wether or not the texture is blocking during loading.
  61735. */
  61736. set isBlocking(value: boolean);
  61737. /**
  61738. * Gets wether or not the texture is blocking during loading.
  61739. */
  61740. get isBlocking(): boolean;
  61741. protected _rotationY: number;
  61742. /**
  61743. * Sets texture matrix rotation angle around Y axis in radians.
  61744. */
  61745. set rotationY(value: number);
  61746. /**
  61747. * Gets texture matrix rotation angle around Y axis radians.
  61748. */
  61749. get rotationY(): number;
  61750. /**
  61751. * Gets or sets the center of the bounding box associated with the cube texture
  61752. * It must define where the camera used to render the texture was set
  61753. */
  61754. boundingBoxPosition: Vector3;
  61755. private _boundingBoxSize;
  61756. /**
  61757. * Gets or sets the size of the bounding box associated with the cube texture
  61758. * When defined, the cubemap will switch to local mode
  61759. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61760. * @example https://www.babylonjs-playground.com/#RNASML
  61761. */
  61762. set boundingBoxSize(value: Vector3);
  61763. get boundingBoxSize(): Vector3;
  61764. /**
  61765. * Instantiates an HDRTexture from the following parameters.
  61766. *
  61767. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61768. * @param sceneOrEngine The scene or engine the texture will be used in
  61769. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61770. * @param noMipmap Forces to not generate the mipmap if true
  61771. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61772. * @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)
  61773. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61774. */
  61775. 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>);
  61776. /**
  61777. * Get the current class name of the texture useful for serialization or dynamic coding.
  61778. * @returns "HDRCubeTexture"
  61779. */
  61780. getClassName(): string;
  61781. /**
  61782. * Occurs when the file is raw .hdr file.
  61783. */
  61784. private loadTexture;
  61785. clone(): HDRCubeTexture;
  61786. delayLoad(): void;
  61787. /**
  61788. * Get the texture reflection matrix used to rotate/transform the reflection.
  61789. * @returns the reflection matrix
  61790. */
  61791. getReflectionTextureMatrix(): Matrix;
  61792. /**
  61793. * Set the texture reflection matrix used to rotate/transform the reflection.
  61794. * @param value Define the reflection matrix to set
  61795. */
  61796. setReflectionTextureMatrix(value: Matrix): void;
  61797. /**
  61798. * Parses a JSON representation of an HDR Texture in order to create the texture
  61799. * @param parsedTexture Define the JSON representation
  61800. * @param scene Define the scene the texture should be created in
  61801. * @param rootUrl Define the root url in case we need to load relative dependencies
  61802. * @returns the newly created texture after parsing
  61803. */
  61804. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61805. serialize(): any;
  61806. }
  61807. }
  61808. declare module "babylonjs/Physics/physicsEngine" {
  61809. import { Nullable } from "babylonjs/types";
  61810. import { Vector3 } from "babylonjs/Maths/math.vector";
  61811. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61812. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61813. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61814. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61815. /**
  61816. * Class used to control physics engine
  61817. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61818. */
  61819. export class PhysicsEngine implements IPhysicsEngine {
  61820. private _physicsPlugin;
  61821. /**
  61822. * Global value used to control the smallest number supported by the simulation
  61823. */
  61824. static Epsilon: number;
  61825. private _impostors;
  61826. private _joints;
  61827. private _subTimeStep;
  61828. /**
  61829. * Gets the gravity vector used by the simulation
  61830. */
  61831. gravity: Vector3;
  61832. /**
  61833. * Factory used to create the default physics plugin.
  61834. * @returns The default physics plugin
  61835. */
  61836. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61837. /**
  61838. * Creates a new Physics Engine
  61839. * @param gravity defines the gravity vector used by the simulation
  61840. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61841. */
  61842. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61843. /**
  61844. * Sets the gravity vector used by the simulation
  61845. * @param gravity defines the gravity vector to use
  61846. */
  61847. setGravity(gravity: Vector3): void;
  61848. /**
  61849. * Set the time step of the physics engine.
  61850. * Default is 1/60.
  61851. * To slow it down, enter 1/600 for example.
  61852. * To speed it up, 1/30
  61853. * @param newTimeStep defines the new timestep to apply to this world.
  61854. */
  61855. setTimeStep(newTimeStep?: number): void;
  61856. /**
  61857. * Get the time step of the physics engine.
  61858. * @returns the current time step
  61859. */
  61860. getTimeStep(): number;
  61861. /**
  61862. * Set the sub time step of the physics engine.
  61863. * Default is 0 meaning there is no sub steps
  61864. * To increase physics resolution precision, set a small value (like 1 ms)
  61865. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61866. */
  61867. setSubTimeStep(subTimeStep?: number): void;
  61868. /**
  61869. * Get the sub time step of the physics engine.
  61870. * @returns the current sub time step
  61871. */
  61872. getSubTimeStep(): number;
  61873. /**
  61874. * Release all resources
  61875. */
  61876. dispose(): void;
  61877. /**
  61878. * Gets the name of the current physics plugin
  61879. * @returns the name of the plugin
  61880. */
  61881. getPhysicsPluginName(): string;
  61882. /**
  61883. * Adding a new impostor for the impostor tracking.
  61884. * This will be done by the impostor itself.
  61885. * @param impostor the impostor to add
  61886. */
  61887. addImpostor(impostor: PhysicsImpostor): void;
  61888. /**
  61889. * Remove an impostor from the engine.
  61890. * This impostor and its mesh will not longer be updated by the physics engine.
  61891. * @param impostor the impostor to remove
  61892. */
  61893. removeImpostor(impostor: PhysicsImpostor): void;
  61894. /**
  61895. * Add a joint to the physics engine
  61896. * @param mainImpostor defines the main impostor to which the joint is added.
  61897. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61898. * @param joint defines the joint that will connect both impostors.
  61899. */
  61900. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61901. /**
  61902. * Removes a joint from the simulation
  61903. * @param mainImpostor defines the impostor used with the joint
  61904. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61905. * @param joint defines the joint to remove
  61906. */
  61907. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61908. /**
  61909. * Called by the scene. No need to call it.
  61910. * @param delta defines the timespam between frames
  61911. */
  61912. _step(delta: number): void;
  61913. /**
  61914. * Gets the current plugin used to run the simulation
  61915. * @returns current plugin
  61916. */
  61917. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61918. /**
  61919. * Gets the list of physic impostors
  61920. * @returns an array of PhysicsImpostor
  61921. */
  61922. getImpostors(): Array<PhysicsImpostor>;
  61923. /**
  61924. * Gets the impostor for a physics enabled object
  61925. * @param object defines the object impersonated by the impostor
  61926. * @returns the PhysicsImpostor or null if not found
  61927. */
  61928. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61929. /**
  61930. * Gets the impostor for a physics body object
  61931. * @param body defines physics body used by the impostor
  61932. * @returns the PhysicsImpostor or null if not found
  61933. */
  61934. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61935. /**
  61936. * Does a raycast in the physics world
  61937. * @param from when should the ray start?
  61938. * @param to when should the ray end?
  61939. * @returns PhysicsRaycastResult
  61940. */
  61941. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61942. }
  61943. }
  61944. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  61945. import { Nullable } from "babylonjs/types";
  61946. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61948. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61949. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61950. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61951. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61952. /** @hidden */
  61953. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61954. private _useDeltaForWorldStep;
  61955. world: any;
  61956. name: string;
  61957. private _physicsMaterials;
  61958. private _fixedTimeStep;
  61959. private _cannonRaycastResult;
  61960. private _raycastResult;
  61961. private _physicsBodysToRemoveAfterStep;
  61962. private _firstFrame;
  61963. BJSCANNON: any;
  61964. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61965. setGravity(gravity: Vector3): void;
  61966. setTimeStep(timeStep: number): void;
  61967. getTimeStep(): number;
  61968. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61969. private _removeMarkedPhysicsBodiesFromWorld;
  61970. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61971. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61972. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61973. private _processChildMeshes;
  61974. removePhysicsBody(impostor: PhysicsImpostor): void;
  61975. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61976. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61977. private _addMaterial;
  61978. private _checkWithEpsilon;
  61979. private _createShape;
  61980. private _createHeightmap;
  61981. private _minus90X;
  61982. private _plus90X;
  61983. private _tmpPosition;
  61984. private _tmpDeltaPosition;
  61985. private _tmpUnityRotation;
  61986. private _updatePhysicsBodyTransformation;
  61987. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61988. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61989. isSupported(): boolean;
  61990. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61991. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61992. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61993. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61994. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61995. getBodyMass(impostor: PhysicsImpostor): number;
  61996. getBodyFriction(impostor: PhysicsImpostor): number;
  61997. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61998. getBodyRestitution(impostor: PhysicsImpostor): number;
  61999. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62000. sleepBody(impostor: PhysicsImpostor): void;
  62001. wakeUpBody(impostor: PhysicsImpostor): void;
  62002. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62003. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62004. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62005. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62006. getRadius(impostor: PhysicsImpostor): number;
  62007. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62008. dispose(): void;
  62009. private _extendNamespace;
  62010. /**
  62011. * Does a raycast in the physics world
  62012. * @param from when should the ray start?
  62013. * @param to when should the ray end?
  62014. * @returns PhysicsRaycastResult
  62015. */
  62016. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62017. }
  62018. }
  62019. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62020. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62021. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62022. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62024. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62025. import { Nullable } from "babylonjs/types";
  62026. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62027. /** @hidden */
  62028. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62029. private _useDeltaForWorldStep;
  62030. world: any;
  62031. name: string;
  62032. BJSOIMO: any;
  62033. private _raycastResult;
  62034. private _fixedTimeStep;
  62035. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62036. setGravity(gravity: Vector3): void;
  62037. setTimeStep(timeStep: number): void;
  62038. getTimeStep(): number;
  62039. private _tmpImpostorsArray;
  62040. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62041. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62042. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62043. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62044. private _tmpPositionVector;
  62045. removePhysicsBody(impostor: PhysicsImpostor): void;
  62046. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62047. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62048. isSupported(): boolean;
  62049. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62050. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62051. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62052. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62053. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62054. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62055. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62056. getBodyMass(impostor: PhysicsImpostor): number;
  62057. getBodyFriction(impostor: PhysicsImpostor): number;
  62058. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62059. getBodyRestitution(impostor: PhysicsImpostor): number;
  62060. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62061. sleepBody(impostor: PhysicsImpostor): void;
  62062. wakeUpBody(impostor: PhysicsImpostor): void;
  62063. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62064. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62065. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62066. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62067. getRadius(impostor: PhysicsImpostor): number;
  62068. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62069. dispose(): void;
  62070. /**
  62071. * Does a raycast in the physics world
  62072. * @param from when should the ray start?
  62073. * @param to when should the ray end?
  62074. * @returns PhysicsRaycastResult
  62075. */
  62076. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62077. }
  62078. }
  62079. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62080. import { Nullable } from "babylonjs/types";
  62081. import { Scene } from "babylonjs/scene";
  62082. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62083. import { Color4 } from "babylonjs/Maths/math.color";
  62084. import { Mesh } from "babylonjs/Meshes/mesh";
  62085. /**
  62086. * Class containing static functions to help procedurally build meshes
  62087. */
  62088. export class RibbonBuilder {
  62089. /**
  62090. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62091. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62092. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62093. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62094. * * 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
  62095. * * 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
  62096. * * 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
  62097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62100. * * 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
  62101. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62102. * * 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
  62103. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62105. * @param name defines the name of the mesh
  62106. * @param options defines the options used to create the mesh
  62107. * @param scene defines the hosting scene
  62108. * @returns the ribbon mesh
  62109. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62110. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62111. */
  62112. static CreateRibbon(name: string, options: {
  62113. pathArray: Vector3[][];
  62114. closeArray?: boolean;
  62115. closePath?: boolean;
  62116. offset?: number;
  62117. updatable?: boolean;
  62118. sideOrientation?: number;
  62119. frontUVs?: Vector4;
  62120. backUVs?: Vector4;
  62121. instance?: Mesh;
  62122. invertUV?: boolean;
  62123. uvs?: Vector2[];
  62124. colors?: Color4[];
  62125. }, scene?: Nullable<Scene>): Mesh;
  62126. }
  62127. }
  62128. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62129. import { Nullable } from "babylonjs/types";
  62130. import { Scene } from "babylonjs/scene";
  62131. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62132. import { Mesh } from "babylonjs/Meshes/mesh";
  62133. /**
  62134. * Class containing static functions to help procedurally build meshes
  62135. */
  62136. export class ShapeBuilder {
  62137. /**
  62138. * 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.
  62139. * * 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.
  62140. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62141. * * 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.
  62142. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62143. * * 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
  62144. * * 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
  62145. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62150. * @param name defines the name of the mesh
  62151. * @param options defines the options used to create the mesh
  62152. * @param scene defines the hosting scene
  62153. * @returns the extruded shape mesh
  62154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62155. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62156. */
  62157. static ExtrudeShape(name: string, options: {
  62158. shape: Vector3[];
  62159. path: Vector3[];
  62160. scale?: number;
  62161. rotation?: number;
  62162. cap?: number;
  62163. updatable?: boolean;
  62164. sideOrientation?: number;
  62165. frontUVs?: Vector4;
  62166. backUVs?: Vector4;
  62167. instance?: Mesh;
  62168. invertUV?: boolean;
  62169. }, scene?: Nullable<Scene>): Mesh;
  62170. /**
  62171. * Creates an custom extruded shape mesh.
  62172. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62173. * * 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.
  62174. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62175. * * 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
  62176. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62177. * * 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
  62178. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62179. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62180. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62181. * * 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
  62182. * * 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
  62183. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62186. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62188. * @param name defines the name of the mesh
  62189. * @param options defines the options used to create the mesh
  62190. * @param scene defines the hosting scene
  62191. * @returns the custom extruded shape mesh
  62192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62193. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62194. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62195. */
  62196. static ExtrudeShapeCustom(name: string, options: {
  62197. shape: Vector3[];
  62198. path: Vector3[];
  62199. scaleFunction?: any;
  62200. rotationFunction?: any;
  62201. ribbonCloseArray?: boolean;
  62202. ribbonClosePath?: boolean;
  62203. cap?: number;
  62204. updatable?: boolean;
  62205. sideOrientation?: number;
  62206. frontUVs?: Vector4;
  62207. backUVs?: Vector4;
  62208. instance?: Mesh;
  62209. invertUV?: boolean;
  62210. }, scene?: Nullable<Scene>): Mesh;
  62211. private static _ExtrudeShapeGeneric;
  62212. }
  62213. }
  62214. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62215. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62216. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62217. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62218. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62219. import { Nullable } from "babylonjs/types";
  62220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62221. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62222. /**
  62223. * AmmoJS Physics plugin
  62224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62225. * @see https://github.com/kripken/ammo.js/
  62226. */
  62227. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62228. private _useDeltaForWorldStep;
  62229. /**
  62230. * Reference to the Ammo library
  62231. */
  62232. bjsAMMO: any;
  62233. /**
  62234. * Created ammoJS world which physics bodies are added to
  62235. */
  62236. world: any;
  62237. /**
  62238. * Name of the plugin
  62239. */
  62240. name: string;
  62241. private _timeStep;
  62242. private _fixedTimeStep;
  62243. private _maxSteps;
  62244. private _tmpQuaternion;
  62245. private _tmpAmmoTransform;
  62246. private _tmpAmmoQuaternion;
  62247. private _tmpAmmoConcreteContactResultCallback;
  62248. private _collisionConfiguration;
  62249. private _dispatcher;
  62250. private _overlappingPairCache;
  62251. private _solver;
  62252. private _softBodySolver;
  62253. private _tmpAmmoVectorA;
  62254. private _tmpAmmoVectorB;
  62255. private _tmpAmmoVectorC;
  62256. private _tmpAmmoVectorD;
  62257. private _tmpContactCallbackResult;
  62258. private _tmpAmmoVectorRCA;
  62259. private _tmpAmmoVectorRCB;
  62260. private _raycastResult;
  62261. private static readonly DISABLE_COLLISION_FLAG;
  62262. private static readonly KINEMATIC_FLAG;
  62263. private static readonly DISABLE_DEACTIVATION_FLAG;
  62264. /**
  62265. * Initializes the ammoJS plugin
  62266. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62267. * @param ammoInjection can be used to inject your own ammo reference
  62268. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62269. */
  62270. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62271. /**
  62272. * Sets the gravity of the physics world (m/(s^2))
  62273. * @param gravity Gravity to set
  62274. */
  62275. setGravity(gravity: Vector3): void;
  62276. /**
  62277. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62278. * @param timeStep timestep to use in seconds
  62279. */
  62280. setTimeStep(timeStep: number): void;
  62281. /**
  62282. * 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)
  62283. * @param fixedTimeStep fixedTimeStep to use in seconds
  62284. */
  62285. setFixedTimeStep(fixedTimeStep: number): void;
  62286. /**
  62287. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62288. * @param maxSteps the maximum number of steps by the physics engine per frame
  62289. */
  62290. setMaxSteps(maxSteps: number): void;
  62291. /**
  62292. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62293. * @returns the current timestep in seconds
  62294. */
  62295. getTimeStep(): number;
  62296. /**
  62297. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62298. */
  62299. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62300. private _isImpostorInContact;
  62301. private _isImpostorPairInContact;
  62302. private _stepSimulation;
  62303. /**
  62304. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62305. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62306. * After the step the babylon meshes are set to the position of the physics imposters
  62307. * @param delta amount of time to step forward
  62308. * @param impostors array of imposters to update before/after the step
  62309. */
  62310. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62311. /**
  62312. * Update babylon mesh to match physics world object
  62313. * @param impostor imposter to match
  62314. */
  62315. private _afterSoftStep;
  62316. /**
  62317. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62318. * @param impostor imposter to match
  62319. */
  62320. private _ropeStep;
  62321. /**
  62322. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62323. * @param impostor imposter to match
  62324. */
  62325. private _softbodyOrClothStep;
  62326. private _tmpMatrix;
  62327. /**
  62328. * Applies an impulse on the imposter
  62329. * @param impostor imposter to apply impulse to
  62330. * @param force amount of force to be applied to the imposter
  62331. * @param contactPoint the location to apply the impulse on the imposter
  62332. */
  62333. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62334. /**
  62335. * Applies a force on the imposter
  62336. * @param impostor imposter to apply force
  62337. * @param force amount of force to be applied to the imposter
  62338. * @param contactPoint the location to apply the force on the imposter
  62339. */
  62340. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62341. /**
  62342. * Creates a physics body using the plugin
  62343. * @param impostor the imposter to create the physics body on
  62344. */
  62345. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62346. /**
  62347. * Removes the physics body from the imposter and disposes of the body's memory
  62348. * @param impostor imposter to remove the physics body from
  62349. */
  62350. removePhysicsBody(impostor: PhysicsImpostor): void;
  62351. /**
  62352. * Generates a joint
  62353. * @param impostorJoint the imposter joint to create the joint with
  62354. */
  62355. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62356. /**
  62357. * Removes a joint
  62358. * @param impostorJoint the imposter joint to remove the joint from
  62359. */
  62360. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62361. private _addMeshVerts;
  62362. /**
  62363. * Initialise the soft body vertices to match its object's (mesh) vertices
  62364. * Softbody vertices (nodes) are in world space and to match this
  62365. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62366. * @param impostor to create the softbody for
  62367. */
  62368. private _softVertexData;
  62369. /**
  62370. * Create an impostor's soft body
  62371. * @param impostor to create the softbody for
  62372. */
  62373. private _createSoftbody;
  62374. /**
  62375. * Create cloth for an impostor
  62376. * @param impostor to create the softbody for
  62377. */
  62378. private _createCloth;
  62379. /**
  62380. * Create rope for an impostor
  62381. * @param impostor to create the softbody for
  62382. */
  62383. private _createRope;
  62384. /**
  62385. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62386. * @param impostor to create the custom physics shape for
  62387. */
  62388. private _createCustom;
  62389. private _addHullVerts;
  62390. private _createShape;
  62391. /**
  62392. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62393. * @param impostor imposter containing the physics body and babylon object
  62394. */
  62395. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62396. /**
  62397. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62398. * @param impostor imposter containing the physics body and babylon object
  62399. * @param newPosition new position
  62400. * @param newRotation new rotation
  62401. */
  62402. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62403. /**
  62404. * If this plugin is supported
  62405. * @returns true if its supported
  62406. */
  62407. isSupported(): boolean;
  62408. /**
  62409. * Sets the linear velocity of the physics body
  62410. * @param impostor imposter to set the velocity on
  62411. * @param velocity velocity to set
  62412. */
  62413. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62414. /**
  62415. * Sets the angular velocity of the physics body
  62416. * @param impostor imposter to set the velocity on
  62417. * @param velocity velocity to set
  62418. */
  62419. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62420. /**
  62421. * gets the linear velocity
  62422. * @param impostor imposter to get linear velocity from
  62423. * @returns linear velocity
  62424. */
  62425. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62426. /**
  62427. * gets the angular velocity
  62428. * @param impostor imposter to get angular velocity from
  62429. * @returns angular velocity
  62430. */
  62431. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62432. /**
  62433. * Sets the mass of physics body
  62434. * @param impostor imposter to set the mass on
  62435. * @param mass mass to set
  62436. */
  62437. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62438. /**
  62439. * Gets the mass of the physics body
  62440. * @param impostor imposter to get the mass from
  62441. * @returns mass
  62442. */
  62443. getBodyMass(impostor: PhysicsImpostor): number;
  62444. /**
  62445. * Gets friction of the impostor
  62446. * @param impostor impostor to get friction from
  62447. * @returns friction value
  62448. */
  62449. getBodyFriction(impostor: PhysicsImpostor): number;
  62450. /**
  62451. * Sets friction of the impostor
  62452. * @param impostor impostor to set friction on
  62453. * @param friction friction value
  62454. */
  62455. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62456. /**
  62457. * Gets restitution of the impostor
  62458. * @param impostor impostor to get restitution from
  62459. * @returns restitution value
  62460. */
  62461. getBodyRestitution(impostor: PhysicsImpostor): number;
  62462. /**
  62463. * Sets resitution of the impostor
  62464. * @param impostor impostor to set resitution on
  62465. * @param restitution resitution value
  62466. */
  62467. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62468. /**
  62469. * Gets pressure inside the impostor
  62470. * @param impostor impostor to get pressure from
  62471. * @returns pressure value
  62472. */
  62473. getBodyPressure(impostor: PhysicsImpostor): number;
  62474. /**
  62475. * Sets pressure inside a soft body impostor
  62476. * Cloth and rope must remain 0 pressure
  62477. * @param impostor impostor to set pressure on
  62478. * @param pressure pressure value
  62479. */
  62480. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62481. /**
  62482. * Gets stiffness of the impostor
  62483. * @param impostor impostor to get stiffness from
  62484. * @returns pressure value
  62485. */
  62486. getBodyStiffness(impostor: PhysicsImpostor): number;
  62487. /**
  62488. * Sets stiffness of the impostor
  62489. * @param impostor impostor to set stiffness on
  62490. * @param stiffness stiffness value from 0 to 1
  62491. */
  62492. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62493. /**
  62494. * Gets velocityIterations of the impostor
  62495. * @param impostor impostor to get velocity iterations from
  62496. * @returns velocityIterations value
  62497. */
  62498. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62499. /**
  62500. * Sets velocityIterations of the impostor
  62501. * @param impostor impostor to set velocity iterations on
  62502. * @param velocityIterations velocityIterations value
  62503. */
  62504. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62505. /**
  62506. * Gets positionIterations of the impostor
  62507. * @param impostor impostor to get position iterations from
  62508. * @returns positionIterations value
  62509. */
  62510. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62511. /**
  62512. * Sets positionIterations of the impostor
  62513. * @param impostor impostor to set position on
  62514. * @param positionIterations positionIterations value
  62515. */
  62516. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62517. /**
  62518. * Append an anchor to a cloth object
  62519. * @param impostor is the cloth impostor to add anchor to
  62520. * @param otherImpostor is the rigid impostor to anchor to
  62521. * @param width ratio across width from 0 to 1
  62522. * @param height ratio up height from 0 to 1
  62523. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62524. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62525. */
  62526. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62527. /**
  62528. * Append an hook to a rope object
  62529. * @param impostor is the rope impostor to add hook to
  62530. * @param otherImpostor is the rigid impostor to hook to
  62531. * @param length ratio along the rope from 0 to 1
  62532. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62533. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62534. */
  62535. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62536. /**
  62537. * Sleeps the physics body and stops it from being active
  62538. * @param impostor impostor to sleep
  62539. */
  62540. sleepBody(impostor: PhysicsImpostor): void;
  62541. /**
  62542. * Activates the physics body
  62543. * @param impostor impostor to activate
  62544. */
  62545. wakeUpBody(impostor: PhysicsImpostor): void;
  62546. /**
  62547. * Updates the distance parameters of the joint
  62548. * @param joint joint to update
  62549. * @param maxDistance maximum distance of the joint
  62550. * @param minDistance minimum distance of the joint
  62551. */
  62552. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62553. /**
  62554. * Sets a motor on the joint
  62555. * @param joint joint to set motor on
  62556. * @param speed speed of the motor
  62557. * @param maxForce maximum force of the motor
  62558. * @param motorIndex index of the motor
  62559. */
  62560. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62561. /**
  62562. * Sets the motors limit
  62563. * @param joint joint to set limit on
  62564. * @param upperLimit upper limit
  62565. * @param lowerLimit lower limit
  62566. */
  62567. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62568. /**
  62569. * Syncs the position and rotation of a mesh with the impostor
  62570. * @param mesh mesh to sync
  62571. * @param impostor impostor to update the mesh with
  62572. */
  62573. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62574. /**
  62575. * Gets the radius of the impostor
  62576. * @param impostor impostor to get radius from
  62577. * @returns the radius
  62578. */
  62579. getRadius(impostor: PhysicsImpostor): number;
  62580. /**
  62581. * Gets the box size of the impostor
  62582. * @param impostor impostor to get box size from
  62583. * @param result the resulting box size
  62584. */
  62585. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62586. /**
  62587. * Disposes of the impostor
  62588. */
  62589. dispose(): void;
  62590. /**
  62591. * Does a raycast in the physics world
  62592. * @param from when should the ray start?
  62593. * @param to when should the ray end?
  62594. * @returns PhysicsRaycastResult
  62595. */
  62596. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62597. }
  62598. }
  62599. declare module "babylonjs/Probes/reflectionProbe" {
  62600. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62601. import { Vector3 } from "babylonjs/Maths/math.vector";
  62602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62603. import { Nullable } from "babylonjs/types";
  62604. import { Scene } from "babylonjs/scene";
  62605. module "babylonjs/abstractScene" {
  62606. interface AbstractScene {
  62607. /**
  62608. * The list of reflection probes added to the scene
  62609. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62610. */
  62611. reflectionProbes: Array<ReflectionProbe>;
  62612. /**
  62613. * Removes the given reflection probe from this scene.
  62614. * @param toRemove The reflection probe to remove
  62615. * @returns The index of the removed reflection probe
  62616. */
  62617. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62618. /**
  62619. * Adds the given reflection probe to this scene.
  62620. * @param newReflectionProbe The reflection probe to add
  62621. */
  62622. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62623. }
  62624. }
  62625. /**
  62626. * Class used to generate realtime reflection / refraction cube textures
  62627. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62628. */
  62629. export class ReflectionProbe {
  62630. /** defines the name of the probe */
  62631. name: string;
  62632. private _scene;
  62633. private _renderTargetTexture;
  62634. private _projectionMatrix;
  62635. private _viewMatrix;
  62636. private _target;
  62637. private _add;
  62638. private _attachedMesh;
  62639. private _invertYAxis;
  62640. /** Gets or sets probe position (center of the cube map) */
  62641. position: Vector3;
  62642. /**
  62643. * Creates a new reflection probe
  62644. * @param name defines the name of the probe
  62645. * @param size defines the texture resolution (for each face)
  62646. * @param scene defines the hosting scene
  62647. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62648. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62649. */
  62650. constructor(
  62651. /** defines the name of the probe */
  62652. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62653. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62654. get samples(): number;
  62655. set samples(value: number);
  62656. /** Gets or sets the refresh rate to use (on every frame by default) */
  62657. get refreshRate(): number;
  62658. set refreshRate(value: number);
  62659. /**
  62660. * Gets the hosting scene
  62661. * @returns a Scene
  62662. */
  62663. getScene(): Scene;
  62664. /** Gets the internal CubeTexture used to render to */
  62665. get cubeTexture(): RenderTargetTexture;
  62666. /** Gets the list of meshes to render */
  62667. get renderList(): Nullable<AbstractMesh[]>;
  62668. /**
  62669. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62670. * @param mesh defines the mesh to attach to
  62671. */
  62672. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62673. /**
  62674. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62675. * @param renderingGroupId The rendering group id corresponding to its index
  62676. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62677. */
  62678. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62679. /**
  62680. * Clean all associated resources
  62681. */
  62682. dispose(): void;
  62683. /**
  62684. * Converts the reflection probe information to a readable string for debug purpose.
  62685. * @param fullDetails Supports for multiple levels of logging within scene loading
  62686. * @returns the human readable reflection probe info
  62687. */
  62688. toString(fullDetails?: boolean): string;
  62689. /**
  62690. * Get the class name of the relfection probe.
  62691. * @returns "ReflectionProbe"
  62692. */
  62693. getClassName(): string;
  62694. /**
  62695. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62696. * @returns The JSON representation of the texture
  62697. */
  62698. serialize(): any;
  62699. /**
  62700. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62701. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62702. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62703. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62704. * @returns The parsed reflection probe if successful
  62705. */
  62706. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62707. }
  62708. }
  62709. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62710. /** @hidden */
  62711. export var _BabylonLoaderRegistered: boolean;
  62712. /**
  62713. * Helps setting up some configuration for the babylon file loader.
  62714. */
  62715. export class BabylonFileLoaderConfiguration {
  62716. /**
  62717. * The loader does not allow injecting custom physix engine into the plugins.
  62718. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62719. * So you could set this variable to your engine import to make it work.
  62720. */
  62721. static LoaderInjectedPhysicsEngine: any;
  62722. }
  62723. }
  62724. declare module "babylonjs/Loading/Plugins/index" {
  62725. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62726. }
  62727. declare module "babylonjs/Loading/index" {
  62728. export * from "babylonjs/Loading/loadingScreen";
  62729. export * from "babylonjs/Loading/Plugins/index";
  62730. export * from "babylonjs/Loading/sceneLoader";
  62731. export * from "babylonjs/Loading/sceneLoaderFlags";
  62732. }
  62733. declare module "babylonjs/Materials/Background/index" {
  62734. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62735. }
  62736. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62737. import { Scene } from "babylonjs/scene";
  62738. import { Color3 } from "babylonjs/Maths/math.color";
  62739. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62741. /**
  62742. * The Physically based simple base material of BJS.
  62743. *
  62744. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62745. * It is used as the base class for both the specGloss and metalRough conventions.
  62746. */
  62747. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62748. /**
  62749. * Number of Simultaneous lights allowed on the material.
  62750. */
  62751. maxSimultaneousLights: number;
  62752. /**
  62753. * If sets to true, disables all the lights affecting the material.
  62754. */
  62755. disableLighting: boolean;
  62756. /**
  62757. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62758. */
  62759. environmentTexture: BaseTexture;
  62760. /**
  62761. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62762. */
  62763. invertNormalMapX: boolean;
  62764. /**
  62765. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62766. */
  62767. invertNormalMapY: boolean;
  62768. /**
  62769. * Normal map used in the model.
  62770. */
  62771. normalTexture: BaseTexture;
  62772. /**
  62773. * Emissivie color used to self-illuminate the model.
  62774. */
  62775. emissiveColor: Color3;
  62776. /**
  62777. * Emissivie texture used to self-illuminate the model.
  62778. */
  62779. emissiveTexture: BaseTexture;
  62780. /**
  62781. * Occlusion Channel Strenght.
  62782. */
  62783. occlusionStrength: number;
  62784. /**
  62785. * Occlusion Texture of the material (adding extra occlusion effects).
  62786. */
  62787. occlusionTexture: BaseTexture;
  62788. /**
  62789. * Defines the alpha limits in alpha test mode.
  62790. */
  62791. alphaCutOff: number;
  62792. /**
  62793. * Gets the current double sided mode.
  62794. */
  62795. get doubleSided(): boolean;
  62796. /**
  62797. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62798. */
  62799. set doubleSided(value: boolean);
  62800. /**
  62801. * Stores the pre-calculated light information of a mesh in a texture.
  62802. */
  62803. lightmapTexture: BaseTexture;
  62804. /**
  62805. * If true, the light map contains occlusion information instead of lighting info.
  62806. */
  62807. useLightmapAsShadowmap: boolean;
  62808. /**
  62809. * Instantiates a new PBRMaterial instance.
  62810. *
  62811. * @param name The material name
  62812. * @param scene The scene the material will be use in.
  62813. */
  62814. constructor(name: string, scene: Scene);
  62815. getClassName(): string;
  62816. }
  62817. }
  62818. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62819. import { Scene } from "babylonjs/scene";
  62820. import { Color3 } from "babylonjs/Maths/math.color";
  62821. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62822. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62823. /**
  62824. * The PBR material of BJS following the metal roughness convention.
  62825. *
  62826. * This fits to the PBR convention in the GLTF definition:
  62827. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62828. */
  62829. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62830. /**
  62831. * The base color has two different interpretations depending on the value of metalness.
  62832. * When the material is a metal, the base color is the specific measured reflectance value
  62833. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62834. * of the material.
  62835. */
  62836. baseColor: Color3;
  62837. /**
  62838. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62839. * well as opacity information in the alpha channel.
  62840. */
  62841. baseTexture: BaseTexture;
  62842. /**
  62843. * Specifies the metallic scalar value of the material.
  62844. * Can also be used to scale the metalness values of the metallic texture.
  62845. */
  62846. metallic: number;
  62847. /**
  62848. * Specifies the roughness scalar value of the material.
  62849. * Can also be used to scale the roughness values of the metallic texture.
  62850. */
  62851. roughness: number;
  62852. /**
  62853. * Texture containing both the metallic value in the B channel and the
  62854. * roughness value in the G channel to keep better precision.
  62855. */
  62856. metallicRoughnessTexture: BaseTexture;
  62857. /**
  62858. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62859. *
  62860. * @param name The material name
  62861. * @param scene The scene the material will be use in.
  62862. */
  62863. constructor(name: string, scene: Scene);
  62864. /**
  62865. * Return the currrent class name of the material.
  62866. */
  62867. getClassName(): string;
  62868. /**
  62869. * Makes a duplicate of the current material.
  62870. * @param name - name to use for the new material.
  62871. */
  62872. clone(name: string): PBRMetallicRoughnessMaterial;
  62873. /**
  62874. * Serialize the material to a parsable JSON object.
  62875. */
  62876. serialize(): any;
  62877. /**
  62878. * Parses a JSON object correponding to the serialize function.
  62879. */
  62880. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62881. }
  62882. }
  62883. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  62884. import { Scene } from "babylonjs/scene";
  62885. import { Color3 } from "babylonjs/Maths/math.color";
  62886. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62887. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62888. /**
  62889. * The PBR material of BJS following the specular glossiness convention.
  62890. *
  62891. * This fits to the PBR convention in the GLTF definition:
  62892. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62893. */
  62894. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62895. /**
  62896. * Specifies the diffuse color of the material.
  62897. */
  62898. diffuseColor: Color3;
  62899. /**
  62900. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62901. * channel.
  62902. */
  62903. diffuseTexture: BaseTexture;
  62904. /**
  62905. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62906. */
  62907. specularColor: Color3;
  62908. /**
  62909. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62910. */
  62911. glossiness: number;
  62912. /**
  62913. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62914. */
  62915. specularGlossinessTexture: BaseTexture;
  62916. /**
  62917. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62918. *
  62919. * @param name The material name
  62920. * @param scene The scene the material will be use in.
  62921. */
  62922. constructor(name: string, scene: Scene);
  62923. /**
  62924. * Return the currrent class name of the material.
  62925. */
  62926. getClassName(): string;
  62927. /**
  62928. * Makes a duplicate of the current material.
  62929. * @param name - name to use for the new material.
  62930. */
  62931. clone(name: string): PBRSpecularGlossinessMaterial;
  62932. /**
  62933. * Serialize the material to a parsable JSON object.
  62934. */
  62935. serialize(): any;
  62936. /**
  62937. * Parses a JSON object correponding to the serialize function.
  62938. */
  62939. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62940. }
  62941. }
  62942. declare module "babylonjs/Materials/PBR/index" {
  62943. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62944. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62945. export * from "babylonjs/Materials/PBR/pbrMaterial";
  62946. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  62947. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  62948. }
  62949. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  62950. import { Nullable } from "babylonjs/types";
  62951. import { Scene } from "babylonjs/scene";
  62952. import { Matrix } from "babylonjs/Maths/math.vector";
  62953. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62954. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62955. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62956. /**
  62957. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62958. * It can help converting any input color in a desired output one. This can then be used to create effects
  62959. * from sepia, black and white to sixties or futuristic rendering...
  62960. *
  62961. * The only supported format is currently 3dl.
  62962. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62963. */
  62964. export class ColorGradingTexture extends BaseTexture {
  62965. /**
  62966. * The texture URL.
  62967. */
  62968. url: string;
  62969. /**
  62970. * Empty line regex stored for GC.
  62971. */
  62972. private static _noneEmptyLineRegex;
  62973. private _textureMatrix;
  62974. private _onLoad;
  62975. /**
  62976. * Instantiates a ColorGradingTexture from the following parameters.
  62977. *
  62978. * @param url The location of the color gradind data (currently only supporting 3dl)
  62979. * @param sceneOrEngine The scene or engine the texture will be used in
  62980. * @param onLoad defines a callback triggered when the texture has been loaded
  62981. */
  62982. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62983. /**
  62984. * Fires the onload event from the constructor if requested.
  62985. */
  62986. private _triggerOnLoad;
  62987. /**
  62988. * Returns the texture matrix used in most of the material.
  62989. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62990. */
  62991. getTextureMatrix(): Matrix;
  62992. /**
  62993. * Occurs when the file being loaded is a .3dl LUT file.
  62994. */
  62995. private load3dlTexture;
  62996. /**
  62997. * Starts the loading process of the texture.
  62998. */
  62999. private loadTexture;
  63000. /**
  63001. * Clones the color gradind texture.
  63002. */
  63003. clone(): ColorGradingTexture;
  63004. /**
  63005. * Called during delayed load for textures.
  63006. */
  63007. delayLoad(): void;
  63008. /**
  63009. * Parses a color grading texture serialized by Babylon.
  63010. * @param parsedTexture The texture information being parsedTexture
  63011. * @param scene The scene to load the texture in
  63012. * @param rootUrl The root url of the data assets to load
  63013. * @return A color gradind texture
  63014. */
  63015. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63016. /**
  63017. * Serializes the LUT texture to json format.
  63018. */
  63019. serialize(): any;
  63020. }
  63021. }
  63022. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63023. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63024. import { Scene } from "babylonjs/scene";
  63025. import { Nullable } from "babylonjs/types";
  63026. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63027. /**
  63028. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63029. */
  63030. export class EquiRectangularCubeTexture extends BaseTexture {
  63031. /** The six faces of the cube. */
  63032. private static _FacesMapping;
  63033. private _noMipmap;
  63034. private _onLoad;
  63035. private _onError;
  63036. /** The size of the cubemap. */
  63037. private _size;
  63038. /** The buffer of the image. */
  63039. private _buffer;
  63040. /** The width of the input image. */
  63041. private _width;
  63042. /** The height of the input image. */
  63043. private _height;
  63044. /** The URL to the image. */
  63045. url: string;
  63046. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63047. coordinatesMode: number;
  63048. /**
  63049. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63050. * @param url The location of the image
  63051. * @param scene The scene the texture will be used in
  63052. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63053. * @param noMipmap Forces to not generate the mipmap if true
  63054. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63055. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63056. * @param onLoad — defines a callback called when texture is loaded
  63057. * @param onError — defines a callback called if there is an error
  63058. */
  63059. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63060. /**
  63061. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63062. */
  63063. private loadImage;
  63064. /**
  63065. * Convert the image buffer into a cubemap and create a CubeTexture.
  63066. */
  63067. private loadTexture;
  63068. /**
  63069. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63070. * @param buffer The ArrayBuffer that should be converted.
  63071. * @returns The buffer as Float32Array.
  63072. */
  63073. private getFloat32ArrayFromArrayBuffer;
  63074. /**
  63075. * Get the current class name of the texture useful for serialization or dynamic coding.
  63076. * @returns "EquiRectangularCubeTexture"
  63077. */
  63078. getClassName(): string;
  63079. /**
  63080. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63081. * @returns A clone of the current EquiRectangularCubeTexture.
  63082. */
  63083. clone(): EquiRectangularCubeTexture;
  63084. }
  63085. }
  63086. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63087. import { Nullable } from "babylonjs/types";
  63088. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63089. import { Matrix } from "babylonjs/Maths/math.vector";
  63090. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63091. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63092. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63093. import { Scene } from "babylonjs/scene";
  63094. /**
  63095. * Defines the options related to the creation of an HtmlElementTexture
  63096. */
  63097. export interface IHtmlElementTextureOptions {
  63098. /**
  63099. * Defines wether mip maps should be created or not.
  63100. */
  63101. generateMipMaps?: boolean;
  63102. /**
  63103. * Defines the sampling mode of the texture.
  63104. */
  63105. samplingMode?: number;
  63106. /**
  63107. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63108. */
  63109. engine: Nullable<ThinEngine>;
  63110. /**
  63111. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63112. */
  63113. scene: Nullable<Scene>;
  63114. }
  63115. /**
  63116. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63117. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63118. * is automatically managed.
  63119. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63120. * in your application.
  63121. *
  63122. * As the update is not automatic, you need to call them manually.
  63123. */
  63124. export class HtmlElementTexture extends BaseTexture {
  63125. /**
  63126. * The texture URL.
  63127. */
  63128. element: HTMLVideoElement | HTMLCanvasElement;
  63129. private static readonly DefaultOptions;
  63130. private _textureMatrix;
  63131. private _isVideo;
  63132. private _generateMipMaps;
  63133. private _samplingMode;
  63134. /**
  63135. * Instantiates a HtmlElementTexture from the following parameters.
  63136. *
  63137. * @param name Defines the name of the texture
  63138. * @param element Defines the video or canvas the texture is filled with
  63139. * @param options Defines the other none mandatory texture creation options
  63140. */
  63141. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63142. private _createInternalTexture;
  63143. /**
  63144. * Returns the texture matrix used in most of the material.
  63145. */
  63146. getTextureMatrix(): Matrix;
  63147. /**
  63148. * Updates the content of the texture.
  63149. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63150. */
  63151. update(invertY?: Nullable<boolean>): void;
  63152. }
  63153. }
  63154. declare module "babylonjs/Misc/tga" {
  63155. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63156. /**
  63157. * Based on jsTGALoader - Javascript loader for TGA file
  63158. * By Vincent Thibault
  63159. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63160. */
  63161. export class TGATools {
  63162. private static _TYPE_INDEXED;
  63163. private static _TYPE_RGB;
  63164. private static _TYPE_GREY;
  63165. private static _TYPE_RLE_INDEXED;
  63166. private static _TYPE_RLE_RGB;
  63167. private static _TYPE_RLE_GREY;
  63168. private static _ORIGIN_MASK;
  63169. private static _ORIGIN_SHIFT;
  63170. private static _ORIGIN_BL;
  63171. private static _ORIGIN_BR;
  63172. private static _ORIGIN_UL;
  63173. private static _ORIGIN_UR;
  63174. /**
  63175. * Gets the header of a TGA file
  63176. * @param data defines the TGA data
  63177. * @returns the header
  63178. */
  63179. static GetTGAHeader(data: Uint8Array): any;
  63180. /**
  63181. * Uploads TGA content to a Babylon Texture
  63182. * @hidden
  63183. */
  63184. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63185. /** @hidden */
  63186. 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;
  63187. /** @hidden */
  63188. 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;
  63189. /** @hidden */
  63190. 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;
  63191. /** @hidden */
  63192. 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;
  63193. /** @hidden */
  63194. 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;
  63195. /** @hidden */
  63196. 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;
  63197. }
  63198. }
  63199. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63200. import { Nullable } from "babylonjs/types";
  63201. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63202. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63203. /**
  63204. * Implementation of the TGA Texture Loader.
  63205. * @hidden
  63206. */
  63207. export class _TGATextureLoader implements IInternalTextureLoader {
  63208. /**
  63209. * Defines wether the loader supports cascade loading the different faces.
  63210. */
  63211. readonly supportCascades: boolean;
  63212. /**
  63213. * This returns if the loader support the current file information.
  63214. * @param extension defines the file extension of the file being loaded
  63215. * @returns true if the loader can load the specified file
  63216. */
  63217. canLoad(extension: string): boolean;
  63218. /**
  63219. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63220. * @param data contains the texture data
  63221. * @param texture defines the BabylonJS internal texture
  63222. * @param createPolynomials will be true if polynomials have been requested
  63223. * @param onLoad defines the callback to trigger once the texture is ready
  63224. * @param onError defines the callback to trigger in case of error
  63225. */
  63226. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63227. /**
  63228. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63229. * @param data contains the texture data
  63230. * @param texture defines the BabylonJS internal texture
  63231. * @param callback defines the method to call once ready to upload
  63232. */
  63233. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63234. }
  63235. }
  63236. declare module "babylonjs/Misc/basis" {
  63237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63238. /**
  63239. * Info about the .basis files
  63240. */
  63241. class BasisFileInfo {
  63242. /**
  63243. * If the file has alpha
  63244. */
  63245. hasAlpha: boolean;
  63246. /**
  63247. * Info about each image of the basis file
  63248. */
  63249. images: Array<{
  63250. levels: Array<{
  63251. width: number;
  63252. height: number;
  63253. transcodedPixels: ArrayBufferView;
  63254. }>;
  63255. }>;
  63256. }
  63257. /**
  63258. * Result of transcoding a basis file
  63259. */
  63260. class TranscodeResult {
  63261. /**
  63262. * Info about the .basis file
  63263. */
  63264. fileInfo: BasisFileInfo;
  63265. /**
  63266. * Format to use when loading the file
  63267. */
  63268. format: number;
  63269. }
  63270. /**
  63271. * Configuration options for the Basis transcoder
  63272. */
  63273. export class BasisTranscodeConfiguration {
  63274. /**
  63275. * Supported compression formats used to determine the supported output format of the transcoder
  63276. */
  63277. supportedCompressionFormats?: {
  63278. /**
  63279. * etc1 compression format
  63280. */
  63281. etc1?: boolean;
  63282. /**
  63283. * s3tc compression format
  63284. */
  63285. s3tc?: boolean;
  63286. /**
  63287. * pvrtc compression format
  63288. */
  63289. pvrtc?: boolean;
  63290. /**
  63291. * etc2 compression format
  63292. */
  63293. etc2?: boolean;
  63294. };
  63295. /**
  63296. * If mipmap levels should be loaded for transcoded images (Default: true)
  63297. */
  63298. loadMipmapLevels?: boolean;
  63299. /**
  63300. * Index of a single image to load (Default: all images)
  63301. */
  63302. loadSingleImage?: number;
  63303. }
  63304. /**
  63305. * Used to load .Basis files
  63306. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63307. */
  63308. export class BasisTools {
  63309. private static _IgnoreSupportedFormats;
  63310. /**
  63311. * URL to use when loading the basis transcoder
  63312. */
  63313. static JSModuleURL: string;
  63314. /**
  63315. * URL to use when loading the wasm module for the transcoder
  63316. */
  63317. static WasmModuleURL: string;
  63318. /**
  63319. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63320. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63321. * @returns internal format corresponding to the Basis format
  63322. */
  63323. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63324. private static _WorkerPromise;
  63325. private static _Worker;
  63326. private static _actionId;
  63327. private static _CreateWorkerAsync;
  63328. /**
  63329. * Transcodes a loaded image file to compressed pixel data
  63330. * @param data image data to transcode
  63331. * @param config configuration options for the transcoding
  63332. * @returns a promise resulting in the transcoded image
  63333. */
  63334. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63335. /**
  63336. * Loads a texture from the transcode result
  63337. * @param texture texture load to
  63338. * @param transcodeResult the result of transcoding the basis file to load from
  63339. */
  63340. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63341. }
  63342. }
  63343. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63344. import { Nullable } from "babylonjs/types";
  63345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63346. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63347. /**
  63348. * Loader for .basis file format
  63349. */
  63350. export class _BasisTextureLoader implements IInternalTextureLoader {
  63351. /**
  63352. * Defines whether the loader supports cascade loading the different faces.
  63353. */
  63354. readonly supportCascades: boolean;
  63355. /**
  63356. * This returns if the loader support the current file information.
  63357. * @param extension defines the file extension of the file being loaded
  63358. * @returns true if the loader can load the specified file
  63359. */
  63360. canLoad(extension: string): boolean;
  63361. /**
  63362. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63363. * @param data contains the texture data
  63364. * @param texture defines the BabylonJS internal texture
  63365. * @param createPolynomials will be true if polynomials have been requested
  63366. * @param onLoad defines the callback to trigger once the texture is ready
  63367. * @param onError defines the callback to trigger in case of error
  63368. */
  63369. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63370. /**
  63371. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63372. * @param data contains the texture data
  63373. * @param texture defines the BabylonJS internal texture
  63374. * @param callback defines the method to call once ready to upload
  63375. */
  63376. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63377. }
  63378. }
  63379. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63380. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63381. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63382. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63383. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63384. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63385. }
  63386. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63387. import { Vector2 } from "babylonjs/Maths/math.vector";
  63388. /**
  63389. * Defines the basic options interface of a TexturePacker Frame
  63390. */
  63391. export interface ITexturePackerFrame {
  63392. /**
  63393. * The frame ID
  63394. */
  63395. id: number;
  63396. /**
  63397. * The frames Scale
  63398. */
  63399. scale: Vector2;
  63400. /**
  63401. * The Frames offset
  63402. */
  63403. offset: Vector2;
  63404. }
  63405. /**
  63406. * This is a support class for frame Data on texture packer sets.
  63407. */
  63408. export class TexturePackerFrame implements ITexturePackerFrame {
  63409. /**
  63410. * The frame ID
  63411. */
  63412. id: number;
  63413. /**
  63414. * The frames Scale
  63415. */
  63416. scale: Vector2;
  63417. /**
  63418. * The Frames offset
  63419. */
  63420. offset: Vector2;
  63421. /**
  63422. * Initializes a texture package frame.
  63423. * @param id The numerical frame identifier
  63424. * @param scale Scalar Vector2 for UV frame
  63425. * @param offset Vector2 for the frame position in UV units.
  63426. * @returns TexturePackerFrame
  63427. */
  63428. constructor(id: number, scale: Vector2, offset: Vector2);
  63429. }
  63430. }
  63431. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63433. import { Scene } from "babylonjs/scene";
  63434. import { Nullable } from "babylonjs/types";
  63435. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63436. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63437. /**
  63438. * Defines the basic options interface of a TexturePacker
  63439. */
  63440. export interface ITexturePackerOptions {
  63441. /**
  63442. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63443. */
  63444. map?: string[];
  63445. /**
  63446. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63447. */
  63448. uvsIn?: string;
  63449. /**
  63450. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63451. */
  63452. uvsOut?: string;
  63453. /**
  63454. * number representing the layout style. Defaults to LAYOUT_STRIP
  63455. */
  63456. layout?: number;
  63457. /**
  63458. * number of columns if using custom column count layout(2). This defaults to 4.
  63459. */
  63460. colnum?: number;
  63461. /**
  63462. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63463. */
  63464. updateInputMeshes?: boolean;
  63465. /**
  63466. * boolean flag to dispose all the source textures. Defaults to true.
  63467. */
  63468. disposeSources?: boolean;
  63469. /**
  63470. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63471. */
  63472. fillBlanks?: boolean;
  63473. /**
  63474. * string value representing the context fill style color. Defaults to 'black'.
  63475. */
  63476. customFillColor?: string;
  63477. /**
  63478. * Width and Height Value of each Frame in the TexturePacker Sets
  63479. */
  63480. frameSize?: number;
  63481. /**
  63482. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63483. */
  63484. paddingRatio?: number;
  63485. /**
  63486. * Number that declares the fill method for the padding gutter.
  63487. */
  63488. paddingMode?: number;
  63489. /**
  63490. * If in SUBUV_COLOR padding mode what color to use.
  63491. */
  63492. paddingColor?: Color3 | Color4;
  63493. }
  63494. /**
  63495. * Defines the basic interface of a TexturePacker JSON File
  63496. */
  63497. export interface ITexturePackerJSON {
  63498. /**
  63499. * The frame ID
  63500. */
  63501. name: string;
  63502. /**
  63503. * The base64 channel data
  63504. */
  63505. sets: any;
  63506. /**
  63507. * The options of the Packer
  63508. */
  63509. options: ITexturePackerOptions;
  63510. /**
  63511. * The frame data of the Packer
  63512. */
  63513. frames: Array<number>;
  63514. }
  63515. /**
  63516. * This is a support class that generates a series of packed texture sets.
  63517. * @see https://doc.babylonjs.com/babylon101/materials
  63518. */
  63519. export class TexturePacker {
  63520. /** Packer Layout Constant 0 */
  63521. static readonly LAYOUT_STRIP: number;
  63522. /** Packer Layout Constant 1 */
  63523. static readonly LAYOUT_POWER2: number;
  63524. /** Packer Layout Constant 2 */
  63525. static readonly LAYOUT_COLNUM: number;
  63526. /** Packer Layout Constant 0 */
  63527. static readonly SUBUV_WRAP: number;
  63528. /** Packer Layout Constant 1 */
  63529. static readonly SUBUV_EXTEND: number;
  63530. /** Packer Layout Constant 2 */
  63531. static readonly SUBUV_COLOR: number;
  63532. /** The Name of the Texture Package */
  63533. name: string;
  63534. /** The scene scope of the TexturePacker */
  63535. scene: Scene;
  63536. /** The Meshes to target */
  63537. meshes: AbstractMesh[];
  63538. /** Arguments passed with the Constructor */
  63539. options: ITexturePackerOptions;
  63540. /** The promise that is started upon initialization */
  63541. promise: Nullable<Promise<TexturePacker | string>>;
  63542. /** The Container object for the channel sets that are generated */
  63543. sets: object;
  63544. /** The Container array for the frames that are generated */
  63545. frames: TexturePackerFrame[];
  63546. /** The expected number of textures the system is parsing. */
  63547. private _expecting;
  63548. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63549. private _paddingValue;
  63550. /**
  63551. * Initializes a texture package series from an array of meshes or a single mesh.
  63552. * @param name The name of the package
  63553. * @param meshes The target meshes to compose the package from
  63554. * @param options The arguments that texture packer should follow while building.
  63555. * @param scene The scene which the textures are scoped to.
  63556. * @returns TexturePacker
  63557. */
  63558. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63559. /**
  63560. * Starts the package process
  63561. * @param resolve The promises resolution function
  63562. * @returns TexturePacker
  63563. */
  63564. private _createFrames;
  63565. /**
  63566. * Calculates the Size of the Channel Sets
  63567. * @returns Vector2
  63568. */
  63569. private _calculateSize;
  63570. /**
  63571. * Calculates the UV data for the frames.
  63572. * @param baseSize the base frameSize
  63573. * @param padding the base frame padding
  63574. * @param dtSize size of the Dynamic Texture for that channel
  63575. * @param dtUnits is 1/dtSize
  63576. * @param update flag to update the input meshes
  63577. */
  63578. private _calculateMeshUVFrames;
  63579. /**
  63580. * Calculates the frames Offset.
  63581. * @param index of the frame
  63582. * @returns Vector2
  63583. */
  63584. private _getFrameOffset;
  63585. /**
  63586. * Updates a Mesh to the frame data
  63587. * @param mesh that is the target
  63588. * @param frameID or the frame index
  63589. */
  63590. private _updateMeshUV;
  63591. /**
  63592. * Updates a Meshes materials to use the texture packer channels
  63593. * @param m is the mesh to target
  63594. * @param force all channels on the packer to be set.
  63595. */
  63596. private _updateTextureReferences;
  63597. /**
  63598. * Public method to set a Mesh to a frame
  63599. * @param m that is the target
  63600. * @param frameID or the frame index
  63601. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63602. */
  63603. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63604. /**
  63605. * Starts the async promise to compile the texture packer.
  63606. * @returns Promise<void>
  63607. */
  63608. processAsync(): Promise<void>;
  63609. /**
  63610. * Disposes all textures associated with this packer
  63611. */
  63612. dispose(): void;
  63613. /**
  63614. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63615. * @param imageType is the image type to use.
  63616. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63617. */
  63618. download(imageType?: string, quality?: number): void;
  63619. /**
  63620. * Public method to load a texturePacker JSON file.
  63621. * @param data of the JSON file in string format.
  63622. */
  63623. updateFromJSON(data: string): void;
  63624. }
  63625. }
  63626. declare module "babylonjs/Materials/Textures/Packer/index" {
  63627. export * from "babylonjs/Materials/Textures/Packer/packer";
  63628. export * from "babylonjs/Materials/Textures/Packer/frame";
  63629. }
  63630. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63631. import { Scene } from "babylonjs/scene";
  63632. import { Texture } from "babylonjs/Materials/Textures/texture";
  63633. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63634. /**
  63635. * 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.
  63636. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63637. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63638. */
  63639. export class CustomProceduralTexture extends ProceduralTexture {
  63640. private _animate;
  63641. private _time;
  63642. private _config;
  63643. private _texturePath;
  63644. /**
  63645. * Instantiates a new Custom Procedural Texture.
  63646. * 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.
  63647. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63648. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63649. * @param name Define the name of the texture
  63650. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63651. * @param size Define the size of the texture to create
  63652. * @param scene Define the scene the texture belongs to
  63653. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63654. * @param generateMipMaps Define if the texture should creates mip maps or not
  63655. */
  63656. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63657. private _loadJson;
  63658. /**
  63659. * Is the texture ready to be used ? (rendered at least once)
  63660. * @returns true if ready, otherwise, false.
  63661. */
  63662. isReady(): boolean;
  63663. /**
  63664. * Render the texture to its associated render target.
  63665. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63666. */
  63667. render(useCameraPostProcess?: boolean): void;
  63668. /**
  63669. * Update the list of dependant textures samplers in the shader.
  63670. */
  63671. updateTextures(): void;
  63672. /**
  63673. * Update the uniform values of the procedural texture in the shader.
  63674. */
  63675. updateShaderUniforms(): void;
  63676. /**
  63677. * Define if the texture animates or not.
  63678. */
  63679. get animate(): boolean;
  63680. set animate(value: boolean);
  63681. }
  63682. }
  63683. declare module "babylonjs/Shaders/noise.fragment" {
  63684. /** @hidden */
  63685. export var noisePixelShader: {
  63686. name: string;
  63687. shader: string;
  63688. };
  63689. }
  63690. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63691. import { Nullable } from "babylonjs/types";
  63692. import { Scene } from "babylonjs/scene";
  63693. import { Texture } from "babylonjs/Materials/Textures/texture";
  63694. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63695. import "babylonjs/Shaders/noise.fragment";
  63696. /**
  63697. * Class used to generate noise procedural textures
  63698. */
  63699. export class NoiseProceduralTexture extends ProceduralTexture {
  63700. private _time;
  63701. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63702. brightness: number;
  63703. /** Defines the number of octaves to process */
  63704. octaves: number;
  63705. /** Defines the level of persistence (0.8 by default) */
  63706. persistence: number;
  63707. /** Gets or sets animation speed factor (default is 1) */
  63708. animationSpeedFactor: number;
  63709. /**
  63710. * Creates a new NoiseProceduralTexture
  63711. * @param name defines the name fo the texture
  63712. * @param size defines the size of the texture (default is 256)
  63713. * @param scene defines the hosting scene
  63714. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63715. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63716. */
  63717. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63718. private _updateShaderUniforms;
  63719. protected _getDefines(): string;
  63720. /** Generate the current state of the procedural texture */
  63721. render(useCameraPostProcess?: boolean): void;
  63722. /**
  63723. * Serializes this noise procedural texture
  63724. * @returns a serialized noise procedural texture object
  63725. */
  63726. serialize(): any;
  63727. /**
  63728. * Clone the texture.
  63729. * @returns the cloned texture
  63730. */
  63731. clone(): NoiseProceduralTexture;
  63732. /**
  63733. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63734. * @param parsedTexture defines parsed texture data
  63735. * @param scene defines the current scene
  63736. * @param rootUrl defines the root URL containing noise procedural texture information
  63737. * @returns a parsed NoiseProceduralTexture
  63738. */
  63739. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63740. }
  63741. }
  63742. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63743. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63744. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63745. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63746. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63747. }
  63748. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63749. import { Nullable } from "babylonjs/types";
  63750. import { Scene } from "babylonjs/scene";
  63751. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63752. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63753. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63754. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63755. /**
  63756. * Raw cube texture where the raw buffers are passed in
  63757. */
  63758. export class RawCubeTexture extends CubeTexture {
  63759. /**
  63760. * Creates a cube texture where the raw buffers are passed in.
  63761. * @param scene defines the scene the texture is attached to
  63762. * @param data defines the array of data to use to create each face
  63763. * @param size defines the size of the textures
  63764. * @param format defines the format of the data
  63765. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63766. * @param generateMipMaps defines if the engine should generate the mip levels
  63767. * @param invertY defines if data must be stored with Y axis inverted
  63768. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63769. * @param compression defines the compression used (null by default)
  63770. */
  63771. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63772. /**
  63773. * Updates the raw cube texture.
  63774. * @param data defines the data to store
  63775. * @param format defines the data format
  63776. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63777. * @param invertY defines if data must be stored with Y axis inverted
  63778. * @param compression defines the compression used (null by default)
  63779. * @param level defines which level of the texture to update
  63780. */
  63781. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63782. /**
  63783. * Updates a raw cube texture with RGBD encoded data.
  63784. * @param data defines the array of data [mipmap][face] to use to create each face
  63785. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63786. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63787. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63788. * @returns a promsie that resolves when the operation is complete
  63789. */
  63790. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63791. /**
  63792. * Clones the raw cube texture.
  63793. * @return a new cube texture
  63794. */
  63795. clone(): CubeTexture;
  63796. /** @hidden */
  63797. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63798. }
  63799. }
  63800. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63801. import { Scene } from "babylonjs/scene";
  63802. import { Texture } from "babylonjs/Materials/Textures/texture";
  63803. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63804. /**
  63805. * Class used to store 2D array textures containing user data
  63806. */
  63807. export class RawTexture2DArray extends Texture {
  63808. /** Gets or sets the texture format to use */
  63809. format: number;
  63810. /**
  63811. * Create a new RawTexture2DArray
  63812. * @param data defines the data of the texture
  63813. * @param width defines the width of the texture
  63814. * @param height defines the height of the texture
  63815. * @param depth defines the number of layers of the texture
  63816. * @param format defines the texture format to use
  63817. * @param scene defines the hosting scene
  63818. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63819. * @param invertY defines if texture must be stored with Y axis inverted
  63820. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63821. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63822. */
  63823. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63824. /** Gets or sets the texture format to use */
  63825. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63826. /**
  63827. * Update the texture with new data
  63828. * @param data defines the data to store in the texture
  63829. */
  63830. update(data: ArrayBufferView): void;
  63831. }
  63832. }
  63833. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63834. import { Scene } from "babylonjs/scene";
  63835. import { Texture } from "babylonjs/Materials/Textures/texture";
  63836. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63837. /**
  63838. * Class used to store 3D textures containing user data
  63839. */
  63840. export class RawTexture3D extends Texture {
  63841. /** Gets or sets the texture format to use */
  63842. format: number;
  63843. /**
  63844. * Create a new RawTexture3D
  63845. * @param data defines the data of the texture
  63846. * @param width defines the width of the texture
  63847. * @param height defines the height of the texture
  63848. * @param depth defines the depth of the texture
  63849. * @param format defines the texture format to use
  63850. * @param scene defines the hosting scene
  63851. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63852. * @param invertY defines if texture must be stored with Y axis inverted
  63853. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63854. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63855. */
  63856. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63857. /** Gets or sets the texture format to use */
  63858. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63859. /**
  63860. * Update the texture with new data
  63861. * @param data defines the data to store in the texture
  63862. */
  63863. update(data: ArrayBufferView): void;
  63864. }
  63865. }
  63866. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63867. import { Scene } from "babylonjs/scene";
  63868. import { Plane } from "babylonjs/Maths/math.plane";
  63869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63870. /**
  63871. * Creates a refraction texture used by refraction channel of the standard material.
  63872. * It is like a mirror but to see through a material.
  63873. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63874. */
  63875. export class RefractionTexture extends RenderTargetTexture {
  63876. /**
  63877. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63878. * 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.
  63879. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63880. */
  63881. refractionPlane: Plane;
  63882. /**
  63883. * Define how deep under the surface we should see.
  63884. */
  63885. depth: number;
  63886. /**
  63887. * Creates a refraction texture used by refraction channel of the standard material.
  63888. * It is like a mirror but to see through a material.
  63889. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63890. * @param name Define the texture name
  63891. * @param size Define the size of the underlying texture
  63892. * @param scene Define the scene the refraction belongs to
  63893. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63894. */
  63895. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63896. /**
  63897. * Clone the refraction texture.
  63898. * @returns the cloned texture
  63899. */
  63900. clone(): RefractionTexture;
  63901. /**
  63902. * Serialize the texture to a JSON representation you could use in Parse later on
  63903. * @returns the serialized JSON representation
  63904. */
  63905. serialize(): any;
  63906. }
  63907. }
  63908. declare module "babylonjs/Materials/Textures/index" {
  63909. export * from "babylonjs/Materials/Textures/baseTexture";
  63910. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  63911. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  63912. export * from "babylonjs/Materials/Textures/cubeTexture";
  63913. export * from "babylonjs/Materials/Textures/dynamicTexture";
  63914. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63915. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  63916. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  63917. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  63918. export * from "babylonjs/Materials/Textures/internalTexture";
  63919. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  63920. export * from "babylonjs/Materials/Textures/Loaders/index";
  63921. export * from "babylonjs/Materials/Textures/mirrorTexture";
  63922. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  63923. export * from "babylonjs/Materials/Textures/Packer/index";
  63924. export * from "babylonjs/Materials/Textures/Procedurals/index";
  63925. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  63926. export * from "babylonjs/Materials/Textures/rawTexture";
  63927. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  63928. export * from "babylonjs/Materials/Textures/rawTexture3D";
  63929. export * from "babylonjs/Materials/Textures/refractionTexture";
  63930. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  63931. export * from "babylonjs/Materials/Textures/texture";
  63932. export * from "babylonjs/Materials/Textures/videoTexture";
  63933. }
  63934. declare module "babylonjs/Materials/Node/Enums/index" {
  63935. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  63936. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  63937. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  63938. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  63939. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  63940. }
  63941. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  63942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63945. import { Mesh } from "babylonjs/Meshes/mesh";
  63946. import { Effect } from "babylonjs/Materials/effect";
  63947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63948. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63949. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63950. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63951. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63952. /**
  63953. * Block used to add support for vertex skinning (bones)
  63954. */
  63955. export class BonesBlock extends NodeMaterialBlock {
  63956. /**
  63957. * Creates a new BonesBlock
  63958. * @param name defines the block name
  63959. */
  63960. constructor(name: string);
  63961. /**
  63962. * Initialize the block and prepare the context for build
  63963. * @param state defines the state that will be used for the build
  63964. */
  63965. initialize(state: NodeMaterialBuildState): void;
  63966. /**
  63967. * Gets the current class name
  63968. * @returns the class name
  63969. */
  63970. getClassName(): string;
  63971. /**
  63972. * Gets the matrix indices input component
  63973. */
  63974. get matricesIndices(): NodeMaterialConnectionPoint;
  63975. /**
  63976. * Gets the matrix weights input component
  63977. */
  63978. get matricesWeights(): NodeMaterialConnectionPoint;
  63979. /**
  63980. * Gets the extra matrix indices input component
  63981. */
  63982. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63983. /**
  63984. * Gets the extra matrix weights input component
  63985. */
  63986. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63987. /**
  63988. * Gets the world input component
  63989. */
  63990. get world(): NodeMaterialConnectionPoint;
  63991. /**
  63992. * Gets the output component
  63993. */
  63994. get output(): NodeMaterialConnectionPoint;
  63995. autoConfigure(material: NodeMaterial): void;
  63996. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63997. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63999. protected _buildBlock(state: NodeMaterialBuildState): this;
  64000. }
  64001. }
  64002. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64005. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64007. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64008. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64009. /**
  64010. * Block used to add support for instances
  64011. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64012. */
  64013. export class InstancesBlock extends NodeMaterialBlock {
  64014. /**
  64015. * Creates a new InstancesBlock
  64016. * @param name defines the block name
  64017. */
  64018. constructor(name: string);
  64019. /**
  64020. * Gets the current class name
  64021. * @returns the class name
  64022. */
  64023. getClassName(): string;
  64024. /**
  64025. * Gets the first world row input component
  64026. */
  64027. get world0(): NodeMaterialConnectionPoint;
  64028. /**
  64029. * Gets the second world row input component
  64030. */
  64031. get world1(): NodeMaterialConnectionPoint;
  64032. /**
  64033. * Gets the third world row input component
  64034. */
  64035. get world2(): NodeMaterialConnectionPoint;
  64036. /**
  64037. * Gets the forth world row input component
  64038. */
  64039. get world3(): NodeMaterialConnectionPoint;
  64040. /**
  64041. * Gets the world input component
  64042. */
  64043. get world(): NodeMaterialConnectionPoint;
  64044. /**
  64045. * Gets the output component
  64046. */
  64047. get output(): NodeMaterialConnectionPoint;
  64048. /**
  64049. * Gets the isntanceID component
  64050. */
  64051. get instanceID(): NodeMaterialConnectionPoint;
  64052. autoConfigure(material: NodeMaterial): void;
  64053. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64054. protected _buildBlock(state: NodeMaterialBuildState): this;
  64055. }
  64056. }
  64057. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64062. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64063. import { Effect } from "babylonjs/Materials/effect";
  64064. import { Mesh } from "babylonjs/Meshes/mesh";
  64065. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64066. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64067. /**
  64068. * Block used to add morph targets support to vertex shader
  64069. */
  64070. export class MorphTargetsBlock extends NodeMaterialBlock {
  64071. private _repeatableContentAnchor;
  64072. /**
  64073. * Create a new MorphTargetsBlock
  64074. * @param name defines the block name
  64075. */
  64076. constructor(name: string);
  64077. /**
  64078. * Gets the current class name
  64079. * @returns the class name
  64080. */
  64081. getClassName(): string;
  64082. /**
  64083. * Gets the position input component
  64084. */
  64085. get position(): NodeMaterialConnectionPoint;
  64086. /**
  64087. * Gets the normal input component
  64088. */
  64089. get normal(): NodeMaterialConnectionPoint;
  64090. /**
  64091. * Gets the tangent input component
  64092. */
  64093. get tangent(): NodeMaterialConnectionPoint;
  64094. /**
  64095. * Gets the tangent input component
  64096. */
  64097. get uv(): NodeMaterialConnectionPoint;
  64098. /**
  64099. * Gets the position output component
  64100. */
  64101. get positionOutput(): NodeMaterialConnectionPoint;
  64102. /**
  64103. * Gets the normal output component
  64104. */
  64105. get normalOutput(): NodeMaterialConnectionPoint;
  64106. /**
  64107. * Gets the tangent output component
  64108. */
  64109. get tangentOutput(): NodeMaterialConnectionPoint;
  64110. /**
  64111. * Gets the tangent output component
  64112. */
  64113. get uvOutput(): NodeMaterialConnectionPoint;
  64114. initialize(state: NodeMaterialBuildState): void;
  64115. autoConfigure(material: NodeMaterial): void;
  64116. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64117. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64118. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64119. protected _buildBlock(state: NodeMaterialBuildState): this;
  64120. }
  64121. }
  64122. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64126. import { Nullable } from "babylonjs/types";
  64127. import { Scene } from "babylonjs/scene";
  64128. import { Effect } from "babylonjs/Materials/effect";
  64129. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64130. import { Mesh } from "babylonjs/Meshes/mesh";
  64131. import { Light } from "babylonjs/Lights/light";
  64132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64133. /**
  64134. * Block used to get data information from a light
  64135. */
  64136. export class LightInformationBlock extends NodeMaterialBlock {
  64137. private _lightDataUniformName;
  64138. private _lightColorUniformName;
  64139. private _lightTypeDefineName;
  64140. /**
  64141. * Gets or sets the light associated with this block
  64142. */
  64143. light: Nullable<Light>;
  64144. /**
  64145. * Creates a new LightInformationBlock
  64146. * @param name defines the block name
  64147. */
  64148. constructor(name: string);
  64149. /**
  64150. * Gets the current class name
  64151. * @returns the class name
  64152. */
  64153. getClassName(): string;
  64154. /**
  64155. * Gets the world position input component
  64156. */
  64157. get worldPosition(): NodeMaterialConnectionPoint;
  64158. /**
  64159. * Gets the direction output component
  64160. */
  64161. get direction(): NodeMaterialConnectionPoint;
  64162. /**
  64163. * Gets the direction output component
  64164. */
  64165. get color(): NodeMaterialConnectionPoint;
  64166. /**
  64167. * Gets the direction output component
  64168. */
  64169. get intensity(): NodeMaterialConnectionPoint;
  64170. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64172. protected _buildBlock(state: NodeMaterialBuildState): this;
  64173. serialize(): any;
  64174. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64175. }
  64176. }
  64177. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64178. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64179. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64180. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64181. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64182. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64183. }
  64184. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64185. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64186. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64187. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64189. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64190. import { Effect } from "babylonjs/Materials/effect";
  64191. import { Mesh } from "babylonjs/Meshes/mesh";
  64192. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64193. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64194. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64195. /**
  64196. * Block used to add image processing support to fragment shader
  64197. */
  64198. export class ImageProcessingBlock extends NodeMaterialBlock {
  64199. /**
  64200. * Create a new ImageProcessingBlock
  64201. * @param name defines the block name
  64202. */
  64203. constructor(name: string);
  64204. /**
  64205. * Gets the current class name
  64206. * @returns the class name
  64207. */
  64208. getClassName(): string;
  64209. /**
  64210. * Gets the color input component
  64211. */
  64212. get color(): NodeMaterialConnectionPoint;
  64213. /**
  64214. * Gets the output component
  64215. */
  64216. get output(): NodeMaterialConnectionPoint;
  64217. /**
  64218. * Initialize the block and prepare the context for build
  64219. * @param state defines the state that will be used for the build
  64220. */
  64221. initialize(state: NodeMaterialBuildState): void;
  64222. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64224. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64225. protected _buildBlock(state: NodeMaterialBuildState): this;
  64226. }
  64227. }
  64228. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64231. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64232. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64234. import { Effect } from "babylonjs/Materials/effect";
  64235. import { Mesh } from "babylonjs/Meshes/mesh";
  64236. import { Scene } from "babylonjs/scene";
  64237. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64238. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64239. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64240. /**
  64241. * Block used to pertub normals based on a normal map
  64242. */
  64243. export class PerturbNormalBlock extends NodeMaterialBlock {
  64244. private _tangentSpaceParameterName;
  64245. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64246. invertX: boolean;
  64247. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64248. invertY: boolean;
  64249. /**
  64250. * Create a new PerturbNormalBlock
  64251. * @param name defines the block name
  64252. */
  64253. constructor(name: string);
  64254. /**
  64255. * Gets the current class name
  64256. * @returns the class name
  64257. */
  64258. getClassName(): string;
  64259. /**
  64260. * Gets the world position input component
  64261. */
  64262. get worldPosition(): NodeMaterialConnectionPoint;
  64263. /**
  64264. * Gets the world normal input component
  64265. */
  64266. get worldNormal(): NodeMaterialConnectionPoint;
  64267. /**
  64268. * Gets the world tangent input component
  64269. */
  64270. get worldTangent(): NodeMaterialConnectionPoint;
  64271. /**
  64272. * Gets the uv input component
  64273. */
  64274. get uv(): NodeMaterialConnectionPoint;
  64275. /**
  64276. * Gets the normal map color input component
  64277. */
  64278. get normalMapColor(): NodeMaterialConnectionPoint;
  64279. /**
  64280. * Gets the strength input component
  64281. */
  64282. get strength(): NodeMaterialConnectionPoint;
  64283. /**
  64284. * Gets the output component
  64285. */
  64286. get output(): NodeMaterialConnectionPoint;
  64287. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64288. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64289. autoConfigure(material: NodeMaterial): void;
  64290. protected _buildBlock(state: NodeMaterialBuildState): this;
  64291. protected _dumpPropertiesCode(): string;
  64292. serialize(): any;
  64293. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64294. }
  64295. }
  64296. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64298. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64299. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64300. /**
  64301. * Block used to discard a pixel if a value is smaller than a cutoff
  64302. */
  64303. export class DiscardBlock extends NodeMaterialBlock {
  64304. /**
  64305. * Create a new DiscardBlock
  64306. * @param name defines the block name
  64307. */
  64308. constructor(name: string);
  64309. /**
  64310. * Gets the current class name
  64311. * @returns the class name
  64312. */
  64313. getClassName(): string;
  64314. /**
  64315. * Gets the color input component
  64316. */
  64317. get value(): NodeMaterialConnectionPoint;
  64318. /**
  64319. * Gets the cutoff input component
  64320. */
  64321. get cutoff(): NodeMaterialConnectionPoint;
  64322. protected _buildBlock(state: NodeMaterialBuildState): this;
  64323. }
  64324. }
  64325. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64329. /**
  64330. * Block used to test if the fragment shader is front facing
  64331. */
  64332. export class FrontFacingBlock extends NodeMaterialBlock {
  64333. /**
  64334. * Creates a new FrontFacingBlock
  64335. * @param name defines the block name
  64336. */
  64337. constructor(name: string);
  64338. /**
  64339. * Gets the current class name
  64340. * @returns the class name
  64341. */
  64342. getClassName(): string;
  64343. /**
  64344. * Gets the output component
  64345. */
  64346. get output(): NodeMaterialConnectionPoint;
  64347. protected _buildBlock(state: NodeMaterialBuildState): this;
  64348. }
  64349. }
  64350. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64354. /**
  64355. * Block used to get the derivative value on x and y of a given input
  64356. */
  64357. export class DerivativeBlock extends NodeMaterialBlock {
  64358. /**
  64359. * Create a new DerivativeBlock
  64360. * @param name defines the block name
  64361. */
  64362. constructor(name: string);
  64363. /**
  64364. * Gets the current class name
  64365. * @returns the class name
  64366. */
  64367. getClassName(): string;
  64368. /**
  64369. * Gets the input component
  64370. */
  64371. get input(): NodeMaterialConnectionPoint;
  64372. /**
  64373. * Gets the derivative output on x
  64374. */
  64375. get dx(): NodeMaterialConnectionPoint;
  64376. /**
  64377. * Gets the derivative output on y
  64378. */
  64379. get dy(): NodeMaterialConnectionPoint;
  64380. protected _buildBlock(state: NodeMaterialBuildState): this;
  64381. }
  64382. }
  64383. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64384. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64385. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64386. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64387. /**
  64388. * Block used to make gl_FragCoord available
  64389. */
  64390. export class FragCoordBlock extends NodeMaterialBlock {
  64391. /**
  64392. * Creates a new FragCoordBlock
  64393. * @param name defines the block name
  64394. */
  64395. constructor(name: string);
  64396. /**
  64397. * Gets the current class name
  64398. * @returns the class name
  64399. */
  64400. getClassName(): string;
  64401. /**
  64402. * Gets the xy component
  64403. */
  64404. get xy(): NodeMaterialConnectionPoint;
  64405. /**
  64406. * Gets the xyz component
  64407. */
  64408. get xyz(): NodeMaterialConnectionPoint;
  64409. /**
  64410. * Gets the xyzw component
  64411. */
  64412. get xyzw(): NodeMaterialConnectionPoint;
  64413. /**
  64414. * Gets the x component
  64415. */
  64416. get x(): NodeMaterialConnectionPoint;
  64417. /**
  64418. * Gets the y component
  64419. */
  64420. get y(): NodeMaterialConnectionPoint;
  64421. /**
  64422. * Gets the z component
  64423. */
  64424. get z(): NodeMaterialConnectionPoint;
  64425. /**
  64426. * Gets the w component
  64427. */
  64428. get output(): NodeMaterialConnectionPoint;
  64429. protected writeOutputs(state: NodeMaterialBuildState): string;
  64430. protected _buildBlock(state: NodeMaterialBuildState): this;
  64431. }
  64432. }
  64433. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64437. import { Effect } from "babylonjs/Materials/effect";
  64438. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64439. import { Mesh } from "babylonjs/Meshes/mesh";
  64440. /**
  64441. * Block used to get the screen sizes
  64442. */
  64443. export class ScreenSizeBlock extends NodeMaterialBlock {
  64444. private _varName;
  64445. private _scene;
  64446. /**
  64447. * Creates a new ScreenSizeBlock
  64448. * @param name defines the block name
  64449. */
  64450. constructor(name: string);
  64451. /**
  64452. * Gets the current class name
  64453. * @returns the class name
  64454. */
  64455. getClassName(): string;
  64456. /**
  64457. * Gets the xy component
  64458. */
  64459. get xy(): NodeMaterialConnectionPoint;
  64460. /**
  64461. * Gets the x component
  64462. */
  64463. get x(): NodeMaterialConnectionPoint;
  64464. /**
  64465. * Gets the y component
  64466. */
  64467. get y(): NodeMaterialConnectionPoint;
  64468. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64469. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64470. protected _buildBlock(state: NodeMaterialBuildState): this;
  64471. }
  64472. }
  64473. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64474. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64475. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64476. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64477. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64478. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64479. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64480. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64481. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64482. }
  64483. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64486. import { Mesh } from "babylonjs/Meshes/mesh";
  64487. import { Effect } from "babylonjs/Materials/effect";
  64488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64490. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64491. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64492. /**
  64493. * Block used to add support for scene fog
  64494. */
  64495. export class FogBlock extends NodeMaterialBlock {
  64496. private _fogDistanceName;
  64497. private _fogParameters;
  64498. /**
  64499. * Create a new FogBlock
  64500. * @param name defines the block name
  64501. */
  64502. constructor(name: string);
  64503. /**
  64504. * Gets the current class name
  64505. * @returns the class name
  64506. */
  64507. getClassName(): string;
  64508. /**
  64509. * Gets the world position input component
  64510. */
  64511. get worldPosition(): NodeMaterialConnectionPoint;
  64512. /**
  64513. * Gets the view input component
  64514. */
  64515. get view(): NodeMaterialConnectionPoint;
  64516. /**
  64517. * Gets the color input component
  64518. */
  64519. get input(): NodeMaterialConnectionPoint;
  64520. /**
  64521. * Gets the fog color input component
  64522. */
  64523. get fogColor(): NodeMaterialConnectionPoint;
  64524. /**
  64525. * Gets the output component
  64526. */
  64527. get output(): NodeMaterialConnectionPoint;
  64528. autoConfigure(material: NodeMaterial): void;
  64529. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64530. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64531. protected _buildBlock(state: NodeMaterialBuildState): this;
  64532. }
  64533. }
  64534. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64536. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64537. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64539. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64540. import { Effect } from "babylonjs/Materials/effect";
  64541. import { Mesh } from "babylonjs/Meshes/mesh";
  64542. import { Light } from "babylonjs/Lights/light";
  64543. import { Nullable } from "babylonjs/types";
  64544. import { Scene } from "babylonjs/scene";
  64545. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64546. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64547. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64548. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64549. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64550. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64551. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64552. /**
  64553. * Block used to add light in the fragment shader
  64554. */
  64555. export class LightBlock extends NodeMaterialBlock {
  64556. private _lightId;
  64557. /**
  64558. * Gets or sets the light associated with this block
  64559. */
  64560. light: Nullable<Light>;
  64561. /**
  64562. * Create a new LightBlock
  64563. * @param name defines the block name
  64564. */
  64565. constructor(name: string);
  64566. /**
  64567. * Gets the current class name
  64568. * @returns the class name
  64569. */
  64570. getClassName(): string;
  64571. /**
  64572. * Gets the world position input component
  64573. */
  64574. get worldPosition(): NodeMaterialConnectionPoint;
  64575. /**
  64576. * Gets the world normal input component
  64577. */
  64578. get worldNormal(): NodeMaterialConnectionPoint;
  64579. /**
  64580. * Gets the camera (or eye) position component
  64581. */
  64582. get cameraPosition(): NodeMaterialConnectionPoint;
  64583. /**
  64584. * Gets the glossiness component
  64585. */
  64586. get glossiness(): NodeMaterialConnectionPoint;
  64587. /**
  64588. * Gets the glossinness power component
  64589. */
  64590. get glossPower(): NodeMaterialConnectionPoint;
  64591. /**
  64592. * Gets the diffuse color component
  64593. */
  64594. get diffuseColor(): NodeMaterialConnectionPoint;
  64595. /**
  64596. * Gets the specular color component
  64597. */
  64598. get specularColor(): NodeMaterialConnectionPoint;
  64599. /**
  64600. * Gets the diffuse output component
  64601. */
  64602. get diffuseOutput(): NodeMaterialConnectionPoint;
  64603. /**
  64604. * Gets the specular output component
  64605. */
  64606. get specularOutput(): NodeMaterialConnectionPoint;
  64607. /**
  64608. * Gets the shadow output component
  64609. */
  64610. get shadow(): NodeMaterialConnectionPoint;
  64611. autoConfigure(material: NodeMaterial): void;
  64612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64613. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64614. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64615. private _injectVertexCode;
  64616. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64617. serialize(): any;
  64618. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64619. }
  64620. }
  64621. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64624. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64625. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64626. /**
  64627. * Block used to read a reflection texture from a sampler
  64628. */
  64629. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64630. /**
  64631. * Create a new ReflectionTextureBlock
  64632. * @param name defines the block name
  64633. */
  64634. constructor(name: string);
  64635. /**
  64636. * Gets the current class name
  64637. * @returns the class name
  64638. */
  64639. getClassName(): string;
  64640. /**
  64641. * Gets the world position input component
  64642. */
  64643. get position(): NodeMaterialConnectionPoint;
  64644. /**
  64645. * Gets the world position input component
  64646. */
  64647. get worldPosition(): NodeMaterialConnectionPoint;
  64648. /**
  64649. * Gets the world normal input component
  64650. */
  64651. get worldNormal(): NodeMaterialConnectionPoint;
  64652. /**
  64653. * Gets the world input component
  64654. */
  64655. get world(): NodeMaterialConnectionPoint;
  64656. /**
  64657. * Gets the camera (or eye) position component
  64658. */
  64659. get cameraPosition(): NodeMaterialConnectionPoint;
  64660. /**
  64661. * Gets the view input component
  64662. */
  64663. get view(): NodeMaterialConnectionPoint;
  64664. /**
  64665. * Gets the rgb output component
  64666. */
  64667. get rgb(): NodeMaterialConnectionPoint;
  64668. /**
  64669. * Gets the r output component
  64670. */
  64671. get r(): NodeMaterialConnectionPoint;
  64672. /**
  64673. * Gets the g output component
  64674. */
  64675. get g(): NodeMaterialConnectionPoint;
  64676. /**
  64677. * Gets the b output component
  64678. */
  64679. get b(): NodeMaterialConnectionPoint;
  64680. autoConfigure(material: NodeMaterial): void;
  64681. protected _buildBlock(state: NodeMaterialBuildState): this;
  64682. }
  64683. }
  64684. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64685. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64686. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64687. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64688. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64689. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64690. }
  64691. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64692. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64693. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64694. }
  64695. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64697. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64698. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64699. /**
  64700. * Block used to add 2 vectors
  64701. */
  64702. export class AddBlock extends NodeMaterialBlock {
  64703. /**
  64704. * Creates a new AddBlock
  64705. * @param name defines the block name
  64706. */
  64707. constructor(name: string);
  64708. /**
  64709. * Gets the current class name
  64710. * @returns the class name
  64711. */
  64712. getClassName(): string;
  64713. /**
  64714. * Gets the left operand input component
  64715. */
  64716. get left(): NodeMaterialConnectionPoint;
  64717. /**
  64718. * Gets the right operand input component
  64719. */
  64720. get right(): NodeMaterialConnectionPoint;
  64721. /**
  64722. * Gets the output component
  64723. */
  64724. get output(): NodeMaterialConnectionPoint;
  64725. protected _buildBlock(state: NodeMaterialBuildState): this;
  64726. }
  64727. }
  64728. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64729. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64730. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64731. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64732. /**
  64733. * Block used to scale a vector by a float
  64734. */
  64735. export class ScaleBlock extends NodeMaterialBlock {
  64736. /**
  64737. * Creates a new ScaleBlock
  64738. * @param name defines the block name
  64739. */
  64740. constructor(name: string);
  64741. /**
  64742. * Gets the current class name
  64743. * @returns the class name
  64744. */
  64745. getClassName(): string;
  64746. /**
  64747. * Gets the input component
  64748. */
  64749. get input(): NodeMaterialConnectionPoint;
  64750. /**
  64751. * Gets the factor input component
  64752. */
  64753. get factor(): NodeMaterialConnectionPoint;
  64754. /**
  64755. * Gets the output component
  64756. */
  64757. get output(): NodeMaterialConnectionPoint;
  64758. protected _buildBlock(state: NodeMaterialBuildState): this;
  64759. }
  64760. }
  64761. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64765. import { Scene } from "babylonjs/scene";
  64766. /**
  64767. * Block used to clamp a float
  64768. */
  64769. export class ClampBlock extends NodeMaterialBlock {
  64770. /** Gets or sets the minimum range */
  64771. minimum: number;
  64772. /** Gets or sets the maximum range */
  64773. maximum: number;
  64774. /**
  64775. * Creates a new ClampBlock
  64776. * @param name defines the block name
  64777. */
  64778. constructor(name: string);
  64779. /**
  64780. * Gets the current class name
  64781. * @returns the class name
  64782. */
  64783. getClassName(): string;
  64784. /**
  64785. * Gets the value input component
  64786. */
  64787. get value(): NodeMaterialConnectionPoint;
  64788. /**
  64789. * Gets the output component
  64790. */
  64791. get output(): NodeMaterialConnectionPoint;
  64792. protected _buildBlock(state: NodeMaterialBuildState): this;
  64793. protected _dumpPropertiesCode(): string;
  64794. serialize(): any;
  64795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64796. }
  64797. }
  64798. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64802. /**
  64803. * Block used to apply a cross product between 2 vectors
  64804. */
  64805. export class CrossBlock extends NodeMaterialBlock {
  64806. /**
  64807. * Creates a new CrossBlock
  64808. * @param name defines the block name
  64809. */
  64810. constructor(name: string);
  64811. /**
  64812. * Gets the current class name
  64813. * @returns the class name
  64814. */
  64815. getClassName(): string;
  64816. /**
  64817. * Gets the left operand input component
  64818. */
  64819. get left(): NodeMaterialConnectionPoint;
  64820. /**
  64821. * Gets the right operand input component
  64822. */
  64823. get right(): NodeMaterialConnectionPoint;
  64824. /**
  64825. * Gets the output component
  64826. */
  64827. get output(): NodeMaterialConnectionPoint;
  64828. protected _buildBlock(state: NodeMaterialBuildState): this;
  64829. }
  64830. }
  64831. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64835. /**
  64836. * Block used to apply a dot product between 2 vectors
  64837. */
  64838. export class DotBlock extends NodeMaterialBlock {
  64839. /**
  64840. * Creates a new DotBlock
  64841. * @param name defines the block name
  64842. */
  64843. constructor(name: string);
  64844. /**
  64845. * Gets the current class name
  64846. * @returns the class name
  64847. */
  64848. getClassName(): string;
  64849. /**
  64850. * Gets the left operand input component
  64851. */
  64852. get left(): NodeMaterialConnectionPoint;
  64853. /**
  64854. * Gets the right operand input component
  64855. */
  64856. get right(): NodeMaterialConnectionPoint;
  64857. /**
  64858. * Gets the output component
  64859. */
  64860. get output(): NodeMaterialConnectionPoint;
  64861. protected _buildBlock(state: NodeMaterialBuildState): this;
  64862. }
  64863. }
  64864. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  64865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64866. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64867. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64868. /**
  64869. * Block used to normalize a vector
  64870. */
  64871. export class NormalizeBlock extends NodeMaterialBlock {
  64872. /**
  64873. * Creates a new NormalizeBlock
  64874. * @param name defines the block name
  64875. */
  64876. constructor(name: string);
  64877. /**
  64878. * Gets the current class name
  64879. * @returns the class name
  64880. */
  64881. getClassName(): string;
  64882. /**
  64883. * Gets the input component
  64884. */
  64885. get input(): NodeMaterialConnectionPoint;
  64886. /**
  64887. * Gets the output component
  64888. */
  64889. get output(): NodeMaterialConnectionPoint;
  64890. protected _buildBlock(state: NodeMaterialBuildState): this;
  64891. }
  64892. }
  64893. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  64894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64895. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64896. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64897. import { Scene } from "babylonjs/scene";
  64898. /**
  64899. * Operations supported by the Trigonometry block
  64900. */
  64901. export enum TrigonometryBlockOperations {
  64902. /** Cos */
  64903. Cos = 0,
  64904. /** Sin */
  64905. Sin = 1,
  64906. /** Abs */
  64907. Abs = 2,
  64908. /** Exp */
  64909. Exp = 3,
  64910. /** Exp2 */
  64911. Exp2 = 4,
  64912. /** Round */
  64913. Round = 5,
  64914. /** Floor */
  64915. Floor = 6,
  64916. /** Ceiling */
  64917. Ceiling = 7,
  64918. /** Square root */
  64919. Sqrt = 8,
  64920. /** Log */
  64921. Log = 9,
  64922. /** Tangent */
  64923. Tan = 10,
  64924. /** Arc tangent */
  64925. ArcTan = 11,
  64926. /** Arc cosinus */
  64927. ArcCos = 12,
  64928. /** Arc sinus */
  64929. ArcSin = 13,
  64930. /** Fraction */
  64931. Fract = 14,
  64932. /** Sign */
  64933. Sign = 15,
  64934. /** To radians (from degrees) */
  64935. Radians = 16,
  64936. /** To degrees (from radians) */
  64937. Degrees = 17
  64938. }
  64939. /**
  64940. * Block used to apply trigonometry operation to floats
  64941. */
  64942. export class TrigonometryBlock extends NodeMaterialBlock {
  64943. /**
  64944. * Gets or sets the operation applied by the block
  64945. */
  64946. operation: TrigonometryBlockOperations;
  64947. /**
  64948. * Creates a new TrigonometryBlock
  64949. * @param name defines the block name
  64950. */
  64951. constructor(name: string);
  64952. /**
  64953. * Gets the current class name
  64954. * @returns the class name
  64955. */
  64956. getClassName(): string;
  64957. /**
  64958. * Gets the input component
  64959. */
  64960. get input(): NodeMaterialConnectionPoint;
  64961. /**
  64962. * Gets the output component
  64963. */
  64964. get output(): NodeMaterialConnectionPoint;
  64965. protected _buildBlock(state: NodeMaterialBuildState): this;
  64966. serialize(): any;
  64967. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64968. protected _dumpPropertiesCode(): string;
  64969. }
  64970. }
  64971. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  64972. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64973. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64975. /**
  64976. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64977. */
  64978. export class ColorMergerBlock extends NodeMaterialBlock {
  64979. /**
  64980. * Create a new ColorMergerBlock
  64981. * @param name defines the block name
  64982. */
  64983. constructor(name: string);
  64984. /**
  64985. * Gets the current class name
  64986. * @returns the class name
  64987. */
  64988. getClassName(): string;
  64989. /**
  64990. * Gets the rgb component (input)
  64991. */
  64992. get rgbIn(): NodeMaterialConnectionPoint;
  64993. /**
  64994. * Gets the r component (input)
  64995. */
  64996. get r(): NodeMaterialConnectionPoint;
  64997. /**
  64998. * Gets the g component (input)
  64999. */
  65000. get g(): NodeMaterialConnectionPoint;
  65001. /**
  65002. * Gets the b component (input)
  65003. */
  65004. get b(): NodeMaterialConnectionPoint;
  65005. /**
  65006. * Gets the a component (input)
  65007. */
  65008. get a(): NodeMaterialConnectionPoint;
  65009. /**
  65010. * Gets the rgba component (output)
  65011. */
  65012. get rgba(): NodeMaterialConnectionPoint;
  65013. /**
  65014. * Gets the rgb component (output)
  65015. */
  65016. get rgbOut(): NodeMaterialConnectionPoint;
  65017. /**
  65018. * Gets the rgb component (output)
  65019. * @deprecated Please use rgbOut instead.
  65020. */
  65021. get rgb(): NodeMaterialConnectionPoint;
  65022. protected _buildBlock(state: NodeMaterialBuildState): this;
  65023. }
  65024. }
  65025. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65026. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65027. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65028. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65029. /**
  65030. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65031. */
  65032. export class VectorSplitterBlock extends NodeMaterialBlock {
  65033. /**
  65034. * Create a new VectorSplitterBlock
  65035. * @param name defines the block name
  65036. */
  65037. constructor(name: string);
  65038. /**
  65039. * Gets the current class name
  65040. * @returns the class name
  65041. */
  65042. getClassName(): string;
  65043. /**
  65044. * Gets the xyzw component (input)
  65045. */
  65046. get xyzw(): NodeMaterialConnectionPoint;
  65047. /**
  65048. * Gets the xyz component (input)
  65049. */
  65050. get xyzIn(): NodeMaterialConnectionPoint;
  65051. /**
  65052. * Gets the xy component (input)
  65053. */
  65054. get xyIn(): NodeMaterialConnectionPoint;
  65055. /**
  65056. * Gets the xyz component (output)
  65057. */
  65058. get xyzOut(): NodeMaterialConnectionPoint;
  65059. /**
  65060. * Gets the xy component (output)
  65061. */
  65062. get xyOut(): NodeMaterialConnectionPoint;
  65063. /**
  65064. * Gets the x component (output)
  65065. */
  65066. get x(): NodeMaterialConnectionPoint;
  65067. /**
  65068. * Gets the y component (output)
  65069. */
  65070. get y(): NodeMaterialConnectionPoint;
  65071. /**
  65072. * Gets the z component (output)
  65073. */
  65074. get z(): NodeMaterialConnectionPoint;
  65075. /**
  65076. * Gets the w component (output)
  65077. */
  65078. get w(): NodeMaterialConnectionPoint;
  65079. protected _inputRename(name: string): string;
  65080. protected _outputRename(name: string): string;
  65081. protected _buildBlock(state: NodeMaterialBuildState): this;
  65082. }
  65083. }
  65084. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65088. /**
  65089. * Block used to lerp between 2 values
  65090. */
  65091. export class LerpBlock extends NodeMaterialBlock {
  65092. /**
  65093. * Creates a new LerpBlock
  65094. * @param name defines the block name
  65095. */
  65096. constructor(name: string);
  65097. /**
  65098. * Gets the current class name
  65099. * @returns the class name
  65100. */
  65101. getClassName(): string;
  65102. /**
  65103. * Gets the left operand input component
  65104. */
  65105. get left(): NodeMaterialConnectionPoint;
  65106. /**
  65107. * Gets the right operand input component
  65108. */
  65109. get right(): NodeMaterialConnectionPoint;
  65110. /**
  65111. * Gets the gradient operand input component
  65112. */
  65113. get gradient(): NodeMaterialConnectionPoint;
  65114. /**
  65115. * Gets the output component
  65116. */
  65117. get output(): NodeMaterialConnectionPoint;
  65118. protected _buildBlock(state: NodeMaterialBuildState): this;
  65119. }
  65120. }
  65121. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65125. /**
  65126. * Block used to divide 2 vectors
  65127. */
  65128. export class DivideBlock extends NodeMaterialBlock {
  65129. /**
  65130. * Creates a new DivideBlock
  65131. * @param name defines the block name
  65132. */
  65133. constructor(name: string);
  65134. /**
  65135. * Gets the current class name
  65136. * @returns the class name
  65137. */
  65138. getClassName(): string;
  65139. /**
  65140. * Gets the left operand input component
  65141. */
  65142. get left(): NodeMaterialConnectionPoint;
  65143. /**
  65144. * Gets the right operand input component
  65145. */
  65146. get right(): NodeMaterialConnectionPoint;
  65147. /**
  65148. * Gets the output component
  65149. */
  65150. get output(): NodeMaterialConnectionPoint;
  65151. protected _buildBlock(state: NodeMaterialBuildState): this;
  65152. }
  65153. }
  65154. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65158. /**
  65159. * Block used to subtract 2 vectors
  65160. */
  65161. export class SubtractBlock extends NodeMaterialBlock {
  65162. /**
  65163. * Creates a new SubtractBlock
  65164. * @param name defines the block name
  65165. */
  65166. constructor(name: string);
  65167. /**
  65168. * Gets the current class name
  65169. * @returns the class name
  65170. */
  65171. getClassName(): string;
  65172. /**
  65173. * Gets the left operand input component
  65174. */
  65175. get left(): NodeMaterialConnectionPoint;
  65176. /**
  65177. * Gets the right operand input component
  65178. */
  65179. get right(): NodeMaterialConnectionPoint;
  65180. /**
  65181. * Gets the output component
  65182. */
  65183. get output(): NodeMaterialConnectionPoint;
  65184. protected _buildBlock(state: NodeMaterialBuildState): this;
  65185. }
  65186. }
  65187. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65190. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65191. /**
  65192. * Block used to step a value
  65193. */
  65194. export class StepBlock extends NodeMaterialBlock {
  65195. /**
  65196. * Creates a new StepBlock
  65197. * @param name defines the block name
  65198. */
  65199. constructor(name: string);
  65200. /**
  65201. * Gets the current class name
  65202. * @returns the class name
  65203. */
  65204. getClassName(): string;
  65205. /**
  65206. * Gets the value operand input component
  65207. */
  65208. get value(): NodeMaterialConnectionPoint;
  65209. /**
  65210. * Gets the edge operand input component
  65211. */
  65212. get edge(): NodeMaterialConnectionPoint;
  65213. /**
  65214. * Gets the output component
  65215. */
  65216. get output(): NodeMaterialConnectionPoint;
  65217. protected _buildBlock(state: NodeMaterialBuildState): this;
  65218. }
  65219. }
  65220. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65221. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65222. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65224. /**
  65225. * Block used to get the opposite (1 - x) of a value
  65226. */
  65227. export class OneMinusBlock extends NodeMaterialBlock {
  65228. /**
  65229. * Creates a new OneMinusBlock
  65230. * @param name defines the block name
  65231. */
  65232. constructor(name: string);
  65233. /**
  65234. * Gets the current class name
  65235. * @returns the class name
  65236. */
  65237. getClassName(): string;
  65238. /**
  65239. * Gets the input component
  65240. */
  65241. get input(): NodeMaterialConnectionPoint;
  65242. /**
  65243. * Gets the output component
  65244. */
  65245. get output(): NodeMaterialConnectionPoint;
  65246. protected _buildBlock(state: NodeMaterialBuildState): this;
  65247. }
  65248. }
  65249. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65250. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65251. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65252. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65253. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65254. /**
  65255. * Block used to get the view direction
  65256. */
  65257. export class ViewDirectionBlock extends NodeMaterialBlock {
  65258. /**
  65259. * Creates a new ViewDirectionBlock
  65260. * @param name defines the block name
  65261. */
  65262. constructor(name: string);
  65263. /**
  65264. * Gets the current class name
  65265. * @returns the class name
  65266. */
  65267. getClassName(): string;
  65268. /**
  65269. * Gets the world position component
  65270. */
  65271. get worldPosition(): NodeMaterialConnectionPoint;
  65272. /**
  65273. * Gets the camera position component
  65274. */
  65275. get cameraPosition(): NodeMaterialConnectionPoint;
  65276. /**
  65277. * Gets the output component
  65278. */
  65279. get output(): NodeMaterialConnectionPoint;
  65280. autoConfigure(material: NodeMaterial): void;
  65281. protected _buildBlock(state: NodeMaterialBuildState): this;
  65282. }
  65283. }
  65284. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65286. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65287. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65288. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65289. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65290. /**
  65291. * Block used to compute fresnel value
  65292. */
  65293. export class FresnelBlock extends NodeMaterialBlock {
  65294. /**
  65295. * Create a new FresnelBlock
  65296. * @param name defines the block name
  65297. */
  65298. constructor(name: string);
  65299. /**
  65300. * Gets the current class name
  65301. * @returns the class name
  65302. */
  65303. getClassName(): string;
  65304. /**
  65305. * Gets the world normal input component
  65306. */
  65307. get worldNormal(): NodeMaterialConnectionPoint;
  65308. /**
  65309. * Gets the view direction input component
  65310. */
  65311. get viewDirection(): NodeMaterialConnectionPoint;
  65312. /**
  65313. * Gets the bias input component
  65314. */
  65315. get bias(): NodeMaterialConnectionPoint;
  65316. /**
  65317. * Gets the camera (or eye) position component
  65318. */
  65319. get power(): NodeMaterialConnectionPoint;
  65320. /**
  65321. * Gets the fresnel output component
  65322. */
  65323. get fresnel(): NodeMaterialConnectionPoint;
  65324. autoConfigure(material: NodeMaterial): void;
  65325. protected _buildBlock(state: NodeMaterialBuildState): this;
  65326. }
  65327. }
  65328. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65329. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65330. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65331. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65332. /**
  65333. * Block used to get the max of 2 values
  65334. */
  65335. export class MaxBlock extends NodeMaterialBlock {
  65336. /**
  65337. * Creates a new MaxBlock
  65338. * @param name defines the block name
  65339. */
  65340. constructor(name: string);
  65341. /**
  65342. * Gets the current class name
  65343. * @returns the class name
  65344. */
  65345. getClassName(): string;
  65346. /**
  65347. * Gets the left operand input component
  65348. */
  65349. get left(): NodeMaterialConnectionPoint;
  65350. /**
  65351. * Gets the right operand input component
  65352. */
  65353. get right(): NodeMaterialConnectionPoint;
  65354. /**
  65355. * Gets the output component
  65356. */
  65357. get output(): NodeMaterialConnectionPoint;
  65358. protected _buildBlock(state: NodeMaterialBuildState): this;
  65359. }
  65360. }
  65361. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65362. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65363. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65364. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65365. /**
  65366. * Block used to get the min of 2 values
  65367. */
  65368. export class MinBlock extends NodeMaterialBlock {
  65369. /**
  65370. * Creates a new MinBlock
  65371. * @param name defines the block name
  65372. */
  65373. constructor(name: string);
  65374. /**
  65375. * Gets the current class name
  65376. * @returns the class name
  65377. */
  65378. getClassName(): string;
  65379. /**
  65380. * Gets the left operand input component
  65381. */
  65382. get left(): NodeMaterialConnectionPoint;
  65383. /**
  65384. * Gets the right operand input component
  65385. */
  65386. get right(): NodeMaterialConnectionPoint;
  65387. /**
  65388. * Gets the output component
  65389. */
  65390. get output(): NodeMaterialConnectionPoint;
  65391. protected _buildBlock(state: NodeMaterialBuildState): this;
  65392. }
  65393. }
  65394. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65396. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65398. /**
  65399. * Block used to get the distance between 2 values
  65400. */
  65401. export class DistanceBlock extends NodeMaterialBlock {
  65402. /**
  65403. * Creates a new DistanceBlock
  65404. * @param name defines the block name
  65405. */
  65406. constructor(name: string);
  65407. /**
  65408. * Gets the current class name
  65409. * @returns the class name
  65410. */
  65411. getClassName(): string;
  65412. /**
  65413. * Gets the left operand input component
  65414. */
  65415. get left(): NodeMaterialConnectionPoint;
  65416. /**
  65417. * Gets the right operand input component
  65418. */
  65419. get right(): NodeMaterialConnectionPoint;
  65420. /**
  65421. * Gets the output component
  65422. */
  65423. get output(): NodeMaterialConnectionPoint;
  65424. protected _buildBlock(state: NodeMaterialBuildState): this;
  65425. }
  65426. }
  65427. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65429. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65430. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65431. /**
  65432. * Block used to get the length of a vector
  65433. */
  65434. export class LengthBlock extends NodeMaterialBlock {
  65435. /**
  65436. * Creates a new LengthBlock
  65437. * @param name defines the block name
  65438. */
  65439. constructor(name: string);
  65440. /**
  65441. * Gets the current class name
  65442. * @returns the class name
  65443. */
  65444. getClassName(): string;
  65445. /**
  65446. * Gets the value input component
  65447. */
  65448. get value(): NodeMaterialConnectionPoint;
  65449. /**
  65450. * Gets the output component
  65451. */
  65452. get output(): NodeMaterialConnectionPoint;
  65453. protected _buildBlock(state: NodeMaterialBuildState): this;
  65454. }
  65455. }
  65456. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65458. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65459. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65460. /**
  65461. * Block used to get negative version of a value (i.e. x * -1)
  65462. */
  65463. export class NegateBlock extends NodeMaterialBlock {
  65464. /**
  65465. * Creates a new NegateBlock
  65466. * @param name defines the block name
  65467. */
  65468. constructor(name: string);
  65469. /**
  65470. * Gets the current class name
  65471. * @returns the class name
  65472. */
  65473. getClassName(): string;
  65474. /**
  65475. * Gets the value input component
  65476. */
  65477. get value(): NodeMaterialConnectionPoint;
  65478. /**
  65479. * Gets the output component
  65480. */
  65481. get output(): NodeMaterialConnectionPoint;
  65482. protected _buildBlock(state: NodeMaterialBuildState): this;
  65483. }
  65484. }
  65485. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65486. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65487. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65489. /**
  65490. * Block used to get the value of the first parameter raised to the power of the second
  65491. */
  65492. export class PowBlock extends NodeMaterialBlock {
  65493. /**
  65494. * Creates a new PowBlock
  65495. * @param name defines the block name
  65496. */
  65497. constructor(name: string);
  65498. /**
  65499. * Gets the current class name
  65500. * @returns the class name
  65501. */
  65502. getClassName(): string;
  65503. /**
  65504. * Gets the value operand input component
  65505. */
  65506. get value(): NodeMaterialConnectionPoint;
  65507. /**
  65508. * Gets the power operand input component
  65509. */
  65510. get power(): NodeMaterialConnectionPoint;
  65511. /**
  65512. * Gets the output component
  65513. */
  65514. get output(): NodeMaterialConnectionPoint;
  65515. protected _buildBlock(state: NodeMaterialBuildState): this;
  65516. }
  65517. }
  65518. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65522. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65523. /**
  65524. * Block used to get a random number
  65525. */
  65526. export class RandomNumberBlock extends NodeMaterialBlock {
  65527. /**
  65528. * Creates a new RandomNumberBlock
  65529. * @param name defines the block name
  65530. */
  65531. constructor(name: string);
  65532. /**
  65533. * Gets the current class name
  65534. * @returns the class name
  65535. */
  65536. getClassName(): string;
  65537. /**
  65538. * Gets the seed input component
  65539. */
  65540. get seed(): NodeMaterialConnectionPoint;
  65541. /**
  65542. * Gets the output component
  65543. */
  65544. get output(): NodeMaterialConnectionPoint;
  65545. protected _buildBlock(state: NodeMaterialBuildState): this;
  65546. }
  65547. }
  65548. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65549. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65550. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65552. /**
  65553. * Block used to compute arc tangent of 2 values
  65554. */
  65555. export class ArcTan2Block extends NodeMaterialBlock {
  65556. /**
  65557. * Creates a new ArcTan2Block
  65558. * @param name defines the block name
  65559. */
  65560. constructor(name: string);
  65561. /**
  65562. * Gets the current class name
  65563. * @returns the class name
  65564. */
  65565. getClassName(): string;
  65566. /**
  65567. * Gets the x operand input component
  65568. */
  65569. get x(): NodeMaterialConnectionPoint;
  65570. /**
  65571. * Gets the y operand input component
  65572. */
  65573. get y(): NodeMaterialConnectionPoint;
  65574. /**
  65575. * Gets the output component
  65576. */
  65577. get output(): NodeMaterialConnectionPoint;
  65578. protected _buildBlock(state: NodeMaterialBuildState): this;
  65579. }
  65580. }
  65581. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65585. /**
  65586. * Block used to smooth step a value
  65587. */
  65588. export class SmoothStepBlock extends NodeMaterialBlock {
  65589. /**
  65590. * Creates a new SmoothStepBlock
  65591. * @param name defines the block name
  65592. */
  65593. constructor(name: string);
  65594. /**
  65595. * Gets the current class name
  65596. * @returns the class name
  65597. */
  65598. getClassName(): string;
  65599. /**
  65600. * Gets the value operand input component
  65601. */
  65602. get value(): NodeMaterialConnectionPoint;
  65603. /**
  65604. * Gets the first edge operand input component
  65605. */
  65606. get edge0(): NodeMaterialConnectionPoint;
  65607. /**
  65608. * Gets the second edge operand input component
  65609. */
  65610. get edge1(): NodeMaterialConnectionPoint;
  65611. /**
  65612. * Gets the output component
  65613. */
  65614. get output(): NodeMaterialConnectionPoint;
  65615. protected _buildBlock(state: NodeMaterialBuildState): this;
  65616. }
  65617. }
  65618. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65622. /**
  65623. * Block used to get the reciprocal (1 / x) of a value
  65624. */
  65625. export class ReciprocalBlock extends NodeMaterialBlock {
  65626. /**
  65627. * Creates a new ReciprocalBlock
  65628. * @param name defines the block name
  65629. */
  65630. constructor(name: string);
  65631. /**
  65632. * Gets the current class name
  65633. * @returns the class name
  65634. */
  65635. getClassName(): string;
  65636. /**
  65637. * Gets the input component
  65638. */
  65639. get input(): NodeMaterialConnectionPoint;
  65640. /**
  65641. * Gets the output component
  65642. */
  65643. get output(): NodeMaterialConnectionPoint;
  65644. protected _buildBlock(state: NodeMaterialBuildState): this;
  65645. }
  65646. }
  65647. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65651. /**
  65652. * Block used to replace a color by another one
  65653. */
  65654. export class ReplaceColorBlock extends NodeMaterialBlock {
  65655. /**
  65656. * Creates a new ReplaceColorBlock
  65657. * @param name defines the block name
  65658. */
  65659. constructor(name: string);
  65660. /**
  65661. * Gets the current class name
  65662. * @returns the class name
  65663. */
  65664. getClassName(): string;
  65665. /**
  65666. * Gets the value input component
  65667. */
  65668. get value(): NodeMaterialConnectionPoint;
  65669. /**
  65670. * Gets the reference input component
  65671. */
  65672. get reference(): NodeMaterialConnectionPoint;
  65673. /**
  65674. * Gets the distance input component
  65675. */
  65676. get distance(): NodeMaterialConnectionPoint;
  65677. /**
  65678. * Gets the replacement input component
  65679. */
  65680. get replacement(): NodeMaterialConnectionPoint;
  65681. /**
  65682. * Gets the output component
  65683. */
  65684. get output(): NodeMaterialConnectionPoint;
  65685. protected _buildBlock(state: NodeMaterialBuildState): this;
  65686. }
  65687. }
  65688. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65692. /**
  65693. * Block used to posterize a value
  65694. * @see https://en.wikipedia.org/wiki/Posterization
  65695. */
  65696. export class PosterizeBlock extends NodeMaterialBlock {
  65697. /**
  65698. * Creates a new PosterizeBlock
  65699. * @param name defines the block name
  65700. */
  65701. constructor(name: string);
  65702. /**
  65703. * Gets the current class name
  65704. * @returns the class name
  65705. */
  65706. getClassName(): string;
  65707. /**
  65708. * Gets the value input component
  65709. */
  65710. get value(): NodeMaterialConnectionPoint;
  65711. /**
  65712. * Gets the steps input component
  65713. */
  65714. get steps(): NodeMaterialConnectionPoint;
  65715. /**
  65716. * Gets the output component
  65717. */
  65718. get output(): NodeMaterialConnectionPoint;
  65719. protected _buildBlock(state: NodeMaterialBuildState): this;
  65720. }
  65721. }
  65722. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65726. import { Scene } from "babylonjs/scene";
  65727. /**
  65728. * Operations supported by the Wave block
  65729. */
  65730. export enum WaveBlockKind {
  65731. /** SawTooth */
  65732. SawTooth = 0,
  65733. /** Square */
  65734. Square = 1,
  65735. /** Triangle */
  65736. Triangle = 2
  65737. }
  65738. /**
  65739. * Block used to apply wave operation to floats
  65740. */
  65741. export class WaveBlock extends NodeMaterialBlock {
  65742. /**
  65743. * Gets or sets the kibnd of wave to be applied by the block
  65744. */
  65745. kind: WaveBlockKind;
  65746. /**
  65747. * Creates a new WaveBlock
  65748. * @param name defines the block name
  65749. */
  65750. constructor(name: string);
  65751. /**
  65752. * Gets the current class name
  65753. * @returns the class name
  65754. */
  65755. getClassName(): string;
  65756. /**
  65757. * Gets the input component
  65758. */
  65759. get input(): NodeMaterialConnectionPoint;
  65760. /**
  65761. * Gets the output component
  65762. */
  65763. get output(): NodeMaterialConnectionPoint;
  65764. protected _buildBlock(state: NodeMaterialBuildState): this;
  65765. serialize(): any;
  65766. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65767. }
  65768. }
  65769. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65770. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65771. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65772. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65773. import { Color3 } from "babylonjs/Maths/math.color";
  65774. import { Scene } from "babylonjs/scene";
  65775. /**
  65776. * Class used to store a color step for the GradientBlock
  65777. */
  65778. export class GradientBlockColorStep {
  65779. /**
  65780. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65781. */
  65782. step: number;
  65783. /**
  65784. * Gets or sets the color associated with this step
  65785. */
  65786. color: Color3;
  65787. /**
  65788. * Creates a new GradientBlockColorStep
  65789. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65790. * @param color defines the color associated with this step
  65791. */
  65792. constructor(
  65793. /**
  65794. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65795. */
  65796. step: number,
  65797. /**
  65798. * Gets or sets the color associated with this step
  65799. */
  65800. color: Color3);
  65801. }
  65802. /**
  65803. * Block used to return a color from a gradient based on an input value between 0 and 1
  65804. */
  65805. export class GradientBlock extends NodeMaterialBlock {
  65806. /**
  65807. * Gets or sets the list of color steps
  65808. */
  65809. colorSteps: GradientBlockColorStep[];
  65810. /**
  65811. * Creates a new GradientBlock
  65812. * @param name defines the block name
  65813. */
  65814. constructor(name: string);
  65815. /**
  65816. * Gets the current class name
  65817. * @returns the class name
  65818. */
  65819. getClassName(): string;
  65820. /**
  65821. * Gets the gradient input component
  65822. */
  65823. get gradient(): NodeMaterialConnectionPoint;
  65824. /**
  65825. * Gets the output component
  65826. */
  65827. get output(): NodeMaterialConnectionPoint;
  65828. private _writeColorConstant;
  65829. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65830. serialize(): any;
  65831. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65832. protected _dumpPropertiesCode(): string;
  65833. }
  65834. }
  65835. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  65836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65838. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65839. /**
  65840. * Block used to normalize lerp between 2 values
  65841. */
  65842. export class NLerpBlock extends NodeMaterialBlock {
  65843. /**
  65844. * Creates a new NLerpBlock
  65845. * @param name defines the block name
  65846. */
  65847. constructor(name: string);
  65848. /**
  65849. * Gets the current class name
  65850. * @returns the class name
  65851. */
  65852. getClassName(): string;
  65853. /**
  65854. * Gets the left operand input component
  65855. */
  65856. get left(): NodeMaterialConnectionPoint;
  65857. /**
  65858. * Gets the right operand input component
  65859. */
  65860. get right(): NodeMaterialConnectionPoint;
  65861. /**
  65862. * Gets the gradient operand input component
  65863. */
  65864. get gradient(): NodeMaterialConnectionPoint;
  65865. /**
  65866. * Gets the output component
  65867. */
  65868. get output(): NodeMaterialConnectionPoint;
  65869. protected _buildBlock(state: NodeMaterialBuildState): this;
  65870. }
  65871. }
  65872. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  65873. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65874. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65875. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65876. import { Scene } from "babylonjs/scene";
  65877. /**
  65878. * block used to Generate a Worley Noise 3D Noise Pattern
  65879. */
  65880. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65881. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65882. manhattanDistance: boolean;
  65883. /**
  65884. * Creates a new WorleyNoise3DBlock
  65885. * @param name defines the block name
  65886. */
  65887. constructor(name: string);
  65888. /**
  65889. * Gets the current class name
  65890. * @returns the class name
  65891. */
  65892. getClassName(): string;
  65893. /**
  65894. * Gets the seed input component
  65895. */
  65896. get seed(): NodeMaterialConnectionPoint;
  65897. /**
  65898. * Gets the jitter input component
  65899. */
  65900. get jitter(): NodeMaterialConnectionPoint;
  65901. /**
  65902. * Gets the output component
  65903. */
  65904. get output(): NodeMaterialConnectionPoint;
  65905. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65906. /**
  65907. * Exposes the properties to the UI?
  65908. */
  65909. protected _dumpPropertiesCode(): string;
  65910. /**
  65911. * Exposes the properties to the Seralize?
  65912. */
  65913. serialize(): any;
  65914. /**
  65915. * Exposes the properties to the deseralize?
  65916. */
  65917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65918. }
  65919. }
  65920. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  65921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65924. /**
  65925. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65926. */
  65927. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65928. /**
  65929. * Creates a new SimplexPerlin3DBlock
  65930. * @param name defines the block name
  65931. */
  65932. constructor(name: string);
  65933. /**
  65934. * Gets the current class name
  65935. * @returns the class name
  65936. */
  65937. getClassName(): string;
  65938. /**
  65939. * Gets the seed operand input component
  65940. */
  65941. get seed(): NodeMaterialConnectionPoint;
  65942. /**
  65943. * Gets the output component
  65944. */
  65945. get output(): NodeMaterialConnectionPoint;
  65946. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65947. }
  65948. }
  65949. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  65950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65953. /**
  65954. * Block used to blend normals
  65955. */
  65956. export class NormalBlendBlock extends NodeMaterialBlock {
  65957. /**
  65958. * Creates a new NormalBlendBlock
  65959. * @param name defines the block name
  65960. */
  65961. constructor(name: string);
  65962. /**
  65963. * Gets the current class name
  65964. * @returns the class name
  65965. */
  65966. getClassName(): string;
  65967. /**
  65968. * Gets the first input component
  65969. */
  65970. get normalMap0(): NodeMaterialConnectionPoint;
  65971. /**
  65972. * Gets the second input component
  65973. */
  65974. get normalMap1(): NodeMaterialConnectionPoint;
  65975. /**
  65976. * Gets the output component
  65977. */
  65978. get output(): NodeMaterialConnectionPoint;
  65979. protected _buildBlock(state: NodeMaterialBuildState): this;
  65980. }
  65981. }
  65982. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  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 } from "babylonjs/Materials/Node/nodeMaterial";
  65987. /**
  65988. * Block used to rotate a 2d vector by a given angle
  65989. */
  65990. export class Rotate2dBlock extends NodeMaterialBlock {
  65991. /**
  65992. * Creates a new Rotate2dBlock
  65993. * @param name defines the block name
  65994. */
  65995. constructor(name: string);
  65996. /**
  65997. * Gets the current class name
  65998. * @returns the class name
  65999. */
  66000. getClassName(): string;
  66001. /**
  66002. * Gets the input vector
  66003. */
  66004. get input(): NodeMaterialConnectionPoint;
  66005. /**
  66006. * Gets the input angle
  66007. */
  66008. get angle(): NodeMaterialConnectionPoint;
  66009. /**
  66010. * Gets the output component
  66011. */
  66012. get output(): NodeMaterialConnectionPoint;
  66013. autoConfigure(material: NodeMaterial): void;
  66014. protected _buildBlock(state: NodeMaterialBuildState): this;
  66015. }
  66016. }
  66017. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66018. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66019. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66020. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66021. /**
  66022. * Block used to get the reflected vector from a direction and a normal
  66023. */
  66024. export class ReflectBlock extends NodeMaterialBlock {
  66025. /**
  66026. * Creates a new ReflectBlock
  66027. * @param name defines the block name
  66028. */
  66029. constructor(name: string);
  66030. /**
  66031. * Gets the current class name
  66032. * @returns the class name
  66033. */
  66034. getClassName(): string;
  66035. /**
  66036. * Gets the incident component
  66037. */
  66038. get incident(): NodeMaterialConnectionPoint;
  66039. /**
  66040. * Gets the normal component
  66041. */
  66042. get normal(): NodeMaterialConnectionPoint;
  66043. /**
  66044. * Gets the output component
  66045. */
  66046. get output(): NodeMaterialConnectionPoint;
  66047. protected _buildBlock(state: NodeMaterialBuildState): this;
  66048. }
  66049. }
  66050. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66051. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66052. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66053. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66054. /**
  66055. * Block used to get the refracted vector from a direction and a normal
  66056. */
  66057. export class RefractBlock extends NodeMaterialBlock {
  66058. /**
  66059. * Creates a new RefractBlock
  66060. * @param name defines the block name
  66061. */
  66062. constructor(name: string);
  66063. /**
  66064. * Gets the current class name
  66065. * @returns the class name
  66066. */
  66067. getClassName(): string;
  66068. /**
  66069. * Gets the incident component
  66070. */
  66071. get incident(): NodeMaterialConnectionPoint;
  66072. /**
  66073. * Gets the normal component
  66074. */
  66075. get normal(): NodeMaterialConnectionPoint;
  66076. /**
  66077. * Gets the index of refraction component
  66078. */
  66079. get ior(): NodeMaterialConnectionPoint;
  66080. /**
  66081. * Gets the output component
  66082. */
  66083. get output(): NodeMaterialConnectionPoint;
  66084. protected _buildBlock(state: NodeMaterialBuildState): this;
  66085. }
  66086. }
  66087. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66091. /**
  66092. * Block used to desaturate a color
  66093. */
  66094. export class DesaturateBlock extends NodeMaterialBlock {
  66095. /**
  66096. * Creates a new DesaturateBlock
  66097. * @param name defines the block name
  66098. */
  66099. constructor(name: string);
  66100. /**
  66101. * Gets the current class name
  66102. * @returns the class name
  66103. */
  66104. getClassName(): string;
  66105. /**
  66106. * Gets the color operand input component
  66107. */
  66108. get color(): NodeMaterialConnectionPoint;
  66109. /**
  66110. * Gets the level operand input component
  66111. */
  66112. get level(): NodeMaterialConnectionPoint;
  66113. /**
  66114. * Gets the output component
  66115. */
  66116. get output(): NodeMaterialConnectionPoint;
  66117. protected _buildBlock(state: NodeMaterialBuildState): this;
  66118. }
  66119. }
  66120. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66124. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66125. import { Nullable } from "babylonjs/types";
  66126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66127. import { Scene } from "babylonjs/scene";
  66128. /**
  66129. * Block used to implement the ambient occlusion module of the PBR material
  66130. */
  66131. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66132. /**
  66133. * Create a new AmbientOcclusionBlock
  66134. * @param name defines the block name
  66135. */
  66136. constructor(name: string);
  66137. /**
  66138. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66139. */
  66140. useAmbientInGrayScale: boolean;
  66141. /**
  66142. * Initialize the block and prepare the context for build
  66143. * @param state defines the state that will be used for the build
  66144. */
  66145. initialize(state: NodeMaterialBuildState): void;
  66146. /**
  66147. * Gets the current class name
  66148. * @returns the class name
  66149. */
  66150. getClassName(): string;
  66151. /**
  66152. * Gets the texture input component
  66153. */
  66154. get texture(): NodeMaterialConnectionPoint;
  66155. /**
  66156. * Gets the texture intensity component
  66157. */
  66158. get intensity(): NodeMaterialConnectionPoint;
  66159. /**
  66160. * Gets the direct light intensity input component
  66161. */
  66162. get directLightIntensity(): NodeMaterialConnectionPoint;
  66163. /**
  66164. * Gets the ambient occlusion object output component
  66165. */
  66166. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66167. /**
  66168. * Gets the main code of the block (fragment side)
  66169. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66170. * @returns the shader code
  66171. */
  66172. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66173. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66174. protected _buildBlock(state: NodeMaterialBuildState): this;
  66175. protected _dumpPropertiesCode(): string;
  66176. serialize(): any;
  66177. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66178. }
  66179. }
  66180. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66181. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66182. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66183. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66184. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66186. import { Nullable } from "babylonjs/types";
  66187. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66188. import { Mesh } from "babylonjs/Meshes/mesh";
  66189. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66190. import { Effect } from "babylonjs/Materials/effect";
  66191. import { Scene } from "babylonjs/scene";
  66192. /**
  66193. * Block used to implement the reflection module of the PBR material
  66194. */
  66195. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66196. /** @hidden */
  66197. _defineLODReflectionAlpha: string;
  66198. /** @hidden */
  66199. _defineLinearSpecularReflection: string;
  66200. private _vEnvironmentIrradianceName;
  66201. /** @hidden */
  66202. _vReflectionMicrosurfaceInfosName: string;
  66203. /** @hidden */
  66204. _vReflectionInfosName: string;
  66205. /** @hidden */
  66206. _vReflectionFilteringInfoName: string;
  66207. private _scene;
  66208. /**
  66209. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66210. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66211. * It's less burden on the user side in the editor part.
  66212. */
  66213. /** @hidden */
  66214. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66215. /** @hidden */
  66216. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66217. /** @hidden */
  66218. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66219. /**
  66220. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66221. * diffuse part of the IBL.
  66222. */
  66223. useSphericalHarmonics: boolean;
  66224. /**
  66225. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66226. */
  66227. forceIrradianceInFragment: boolean;
  66228. /**
  66229. * Create a new ReflectionBlock
  66230. * @param name defines the block name
  66231. */
  66232. constructor(name: string);
  66233. /**
  66234. * Gets the current class name
  66235. * @returns the class name
  66236. */
  66237. getClassName(): string;
  66238. /**
  66239. * Gets the position input component
  66240. */
  66241. get position(): NodeMaterialConnectionPoint;
  66242. /**
  66243. * Gets the world position input component
  66244. */
  66245. get worldPosition(): NodeMaterialConnectionPoint;
  66246. /**
  66247. * Gets the world normal input component
  66248. */
  66249. get worldNormal(): NodeMaterialConnectionPoint;
  66250. /**
  66251. * Gets the world input component
  66252. */
  66253. get world(): NodeMaterialConnectionPoint;
  66254. /**
  66255. * Gets the camera (or eye) position component
  66256. */
  66257. get cameraPosition(): NodeMaterialConnectionPoint;
  66258. /**
  66259. * Gets the view input component
  66260. */
  66261. get view(): NodeMaterialConnectionPoint;
  66262. /**
  66263. * Gets the color input component
  66264. */
  66265. get color(): NodeMaterialConnectionPoint;
  66266. /**
  66267. * Gets the reflection object output component
  66268. */
  66269. get reflection(): NodeMaterialConnectionPoint;
  66270. /**
  66271. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66272. */
  66273. get hasTexture(): boolean;
  66274. /**
  66275. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66276. */
  66277. get reflectionColor(): string;
  66278. protected _getTexture(): Nullable<BaseTexture>;
  66279. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66280. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66281. /**
  66282. * Gets the code to inject in the vertex shader
  66283. * @param state current state of the node material building
  66284. * @returns the shader code
  66285. */
  66286. handleVertexSide(state: NodeMaterialBuildState): string;
  66287. /**
  66288. * Gets the main code of the block (fragment side)
  66289. * @param state current state of the node material building
  66290. * @param normalVarName name of the existing variable corresponding to the normal
  66291. * @returns the shader code
  66292. */
  66293. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66294. protected _buildBlock(state: NodeMaterialBuildState): this;
  66295. protected _dumpPropertiesCode(): string;
  66296. serialize(): any;
  66297. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66298. }
  66299. }
  66300. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66304. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66306. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66307. import { Scene } from "babylonjs/scene";
  66308. import { Nullable } from "babylonjs/types";
  66309. /**
  66310. * Block used to implement the sheen module of the PBR material
  66311. */
  66312. export class SheenBlock extends NodeMaterialBlock {
  66313. /**
  66314. * Create a new SheenBlock
  66315. * @param name defines the block name
  66316. */
  66317. constructor(name: string);
  66318. /**
  66319. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66320. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66321. * making it easier to setup and tweak the effect
  66322. */
  66323. albedoScaling: boolean;
  66324. /**
  66325. * Defines if the sheen is linked to the sheen color.
  66326. */
  66327. linkSheenWithAlbedo: boolean;
  66328. /**
  66329. * Initialize the block and prepare the context for build
  66330. * @param state defines the state that will be used for the build
  66331. */
  66332. initialize(state: NodeMaterialBuildState): void;
  66333. /**
  66334. * Gets the current class name
  66335. * @returns the class name
  66336. */
  66337. getClassName(): string;
  66338. /**
  66339. * Gets the intensity input component
  66340. */
  66341. get intensity(): NodeMaterialConnectionPoint;
  66342. /**
  66343. * Gets the color input component
  66344. */
  66345. get color(): NodeMaterialConnectionPoint;
  66346. /**
  66347. * Gets the roughness input component
  66348. */
  66349. get roughness(): NodeMaterialConnectionPoint;
  66350. /**
  66351. * Gets the sheen object output component
  66352. */
  66353. get sheen(): NodeMaterialConnectionPoint;
  66354. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66355. /**
  66356. * Gets the main code of the block (fragment side)
  66357. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66358. * @returns the shader code
  66359. */
  66360. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66361. protected _buildBlock(state: NodeMaterialBuildState): this;
  66362. protected _dumpPropertiesCode(): string;
  66363. serialize(): any;
  66364. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66365. }
  66366. }
  66367. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66368. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66370. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66372. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66373. import { Scene } from "babylonjs/scene";
  66374. import { Nullable } from "babylonjs/types";
  66375. import { Mesh } from "babylonjs/Meshes/mesh";
  66376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66377. import { Effect } from "babylonjs/Materials/effect";
  66378. /**
  66379. * Block used to implement the reflectivity module of the PBR material
  66380. */
  66381. export class ReflectivityBlock extends NodeMaterialBlock {
  66382. private _metallicReflectanceColor;
  66383. private _metallicF0Factor;
  66384. /** @hidden */
  66385. _vMetallicReflectanceFactorsName: string;
  66386. /**
  66387. * The property below is set by the main PBR block prior to calling methods of this class.
  66388. */
  66389. /** @hidden */
  66390. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66391. /**
  66392. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66393. */
  66394. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66395. /**
  66396. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66397. */
  66398. useMetallnessFromMetallicTextureBlue: boolean;
  66399. /**
  66400. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66401. */
  66402. useRoughnessFromMetallicTextureAlpha: boolean;
  66403. /**
  66404. * Specifies if the metallic texture contains the roughness information in its green channel.
  66405. */
  66406. useRoughnessFromMetallicTextureGreen: boolean;
  66407. /**
  66408. * Create a new ReflectivityBlock
  66409. * @param name defines the block name
  66410. */
  66411. constructor(name: string);
  66412. /**
  66413. * Initialize the block and prepare the context for build
  66414. * @param state defines the state that will be used for the build
  66415. */
  66416. initialize(state: NodeMaterialBuildState): void;
  66417. /**
  66418. * Gets the current class name
  66419. * @returns the class name
  66420. */
  66421. getClassName(): string;
  66422. /**
  66423. * Gets the metallic input component
  66424. */
  66425. get metallic(): NodeMaterialConnectionPoint;
  66426. /**
  66427. * Gets the roughness input component
  66428. */
  66429. get roughness(): NodeMaterialConnectionPoint;
  66430. /**
  66431. * Gets the texture input component
  66432. */
  66433. get texture(): NodeMaterialConnectionPoint;
  66434. /**
  66435. * Gets the reflectivity object output component
  66436. */
  66437. get reflectivity(): NodeMaterialConnectionPoint;
  66438. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66439. /**
  66440. * Gets the main code of the block (fragment side)
  66441. * @param state current state of the node material building
  66442. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66443. * @returns the shader code
  66444. */
  66445. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66446. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66447. protected _buildBlock(state: NodeMaterialBuildState): this;
  66448. protected _dumpPropertiesCode(): string;
  66449. serialize(): any;
  66450. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66451. }
  66452. }
  66453. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66454. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66459. /**
  66460. * Block used to implement the anisotropy module of the PBR material
  66461. */
  66462. export class AnisotropyBlock extends NodeMaterialBlock {
  66463. /**
  66464. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66465. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66466. * It's less burden on the user side in the editor part.
  66467. */
  66468. /** @hidden */
  66469. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66470. /** @hidden */
  66471. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66472. /**
  66473. * Create a new AnisotropyBlock
  66474. * @param name defines the block name
  66475. */
  66476. constructor(name: string);
  66477. /**
  66478. * Initialize the block and prepare the context for build
  66479. * @param state defines the state that will be used for the build
  66480. */
  66481. initialize(state: NodeMaterialBuildState): void;
  66482. /**
  66483. * Gets the current class name
  66484. * @returns the class name
  66485. */
  66486. getClassName(): string;
  66487. /**
  66488. * Gets the intensity input component
  66489. */
  66490. get intensity(): NodeMaterialConnectionPoint;
  66491. /**
  66492. * Gets the direction input component
  66493. */
  66494. get direction(): NodeMaterialConnectionPoint;
  66495. /**
  66496. * Gets the texture input component
  66497. */
  66498. get texture(): NodeMaterialConnectionPoint;
  66499. /**
  66500. * Gets the uv input component
  66501. */
  66502. get uv(): NodeMaterialConnectionPoint;
  66503. /**
  66504. * Gets the worldTangent input component
  66505. */
  66506. get worldTangent(): NodeMaterialConnectionPoint;
  66507. /**
  66508. * Gets the anisotropy object output component
  66509. */
  66510. get anisotropy(): NodeMaterialConnectionPoint;
  66511. private _generateTBNSpace;
  66512. /**
  66513. * Gets the main code of the block (fragment side)
  66514. * @param state current state of the node material building
  66515. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66516. * @returns the shader code
  66517. */
  66518. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66519. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66520. protected _buildBlock(state: NodeMaterialBuildState): this;
  66521. }
  66522. }
  66523. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66526. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66527. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66529. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66530. import { Nullable } from "babylonjs/types";
  66531. import { Mesh } from "babylonjs/Meshes/mesh";
  66532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66533. import { Effect } from "babylonjs/Materials/effect";
  66534. /**
  66535. * Block used to implement the clear coat module of the PBR material
  66536. */
  66537. export class ClearCoatBlock extends NodeMaterialBlock {
  66538. private _scene;
  66539. /**
  66540. * Create a new ClearCoatBlock
  66541. * @param name defines the block name
  66542. */
  66543. constructor(name: string);
  66544. /**
  66545. * Initialize the block and prepare the context for build
  66546. * @param state defines the state that will be used for the build
  66547. */
  66548. initialize(state: NodeMaterialBuildState): void;
  66549. /**
  66550. * Gets the current class name
  66551. * @returns the class name
  66552. */
  66553. getClassName(): string;
  66554. /**
  66555. * Gets the intensity input component
  66556. */
  66557. get intensity(): NodeMaterialConnectionPoint;
  66558. /**
  66559. * Gets the roughness input component
  66560. */
  66561. get roughness(): NodeMaterialConnectionPoint;
  66562. /**
  66563. * Gets the ior input component
  66564. */
  66565. get ior(): NodeMaterialConnectionPoint;
  66566. /**
  66567. * Gets the texture input component
  66568. */
  66569. get texture(): NodeMaterialConnectionPoint;
  66570. /**
  66571. * Gets the bump texture input component
  66572. */
  66573. get bumpTexture(): NodeMaterialConnectionPoint;
  66574. /**
  66575. * Gets the uv input component
  66576. */
  66577. get uv(): NodeMaterialConnectionPoint;
  66578. /**
  66579. * Gets the tint color input component
  66580. */
  66581. get tintColor(): NodeMaterialConnectionPoint;
  66582. /**
  66583. * Gets the tint "at distance" input component
  66584. */
  66585. get tintAtDistance(): NodeMaterialConnectionPoint;
  66586. /**
  66587. * Gets the tint thickness input component
  66588. */
  66589. get tintThickness(): NodeMaterialConnectionPoint;
  66590. /**
  66591. * Gets the world tangent input component
  66592. */
  66593. get worldTangent(): NodeMaterialConnectionPoint;
  66594. /**
  66595. * Gets the clear coat object output component
  66596. */
  66597. get clearcoat(): NodeMaterialConnectionPoint;
  66598. autoConfigure(material: NodeMaterial): void;
  66599. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66601. private _generateTBNSpace;
  66602. /**
  66603. * Gets the main code of the block (fragment side)
  66604. * @param state current state of the node material building
  66605. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66606. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66607. * @param worldPosVarName name of the variable holding the world position
  66608. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66609. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66610. * @param worldNormalVarName name of the variable holding the world normal
  66611. * @returns the shader code
  66612. */
  66613. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66614. protected _buildBlock(state: NodeMaterialBuildState): this;
  66615. }
  66616. }
  66617. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66621. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66623. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66624. import { Nullable } from "babylonjs/types";
  66625. /**
  66626. * Block used to implement the sub surface module of the PBR material
  66627. */
  66628. export class SubSurfaceBlock extends NodeMaterialBlock {
  66629. /**
  66630. * Create a new SubSurfaceBlock
  66631. * @param name defines the block name
  66632. */
  66633. constructor(name: string);
  66634. /**
  66635. * Stores the intensity of the different subsurface effects in the thickness texture.
  66636. * * the green channel is the translucency intensity.
  66637. * * the blue channel is the scattering intensity.
  66638. * * the alpha channel is the refraction intensity.
  66639. */
  66640. useMaskFromThicknessTexture: boolean;
  66641. /**
  66642. * Initialize the block and prepare the context for build
  66643. * @param state defines the state that will be used for the build
  66644. */
  66645. initialize(state: NodeMaterialBuildState): void;
  66646. /**
  66647. * Gets the current class name
  66648. * @returns the class name
  66649. */
  66650. getClassName(): string;
  66651. /**
  66652. * Gets the min thickness input component
  66653. */
  66654. get minThickness(): NodeMaterialConnectionPoint;
  66655. /**
  66656. * Gets the max thickness input component
  66657. */
  66658. get maxThickness(): NodeMaterialConnectionPoint;
  66659. /**
  66660. * Gets the thickness texture component
  66661. */
  66662. get thicknessTexture(): NodeMaterialConnectionPoint;
  66663. /**
  66664. * Gets the tint color input component
  66665. */
  66666. get tintColor(): NodeMaterialConnectionPoint;
  66667. /**
  66668. * Gets the translucency intensity input component
  66669. */
  66670. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66671. /**
  66672. * Gets the translucency diffusion distance input component
  66673. */
  66674. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66675. /**
  66676. * Gets the refraction object parameters
  66677. */
  66678. get refraction(): NodeMaterialConnectionPoint;
  66679. /**
  66680. * Gets the sub surface object output component
  66681. */
  66682. get subsurface(): NodeMaterialConnectionPoint;
  66683. autoConfigure(material: NodeMaterial): void;
  66684. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66685. /**
  66686. * Gets the main code of the block (fragment side)
  66687. * @param state current state of the node material building
  66688. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66689. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66690. * @param worldPosVarName name of the variable holding the world position
  66691. * @returns the shader code
  66692. */
  66693. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66694. protected _buildBlock(state: NodeMaterialBuildState): this;
  66695. }
  66696. }
  66697. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66698. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66699. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66700. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66701. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66702. import { Light } from "babylonjs/Lights/light";
  66703. import { Nullable } from "babylonjs/types";
  66704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66705. import { Effect } from "babylonjs/Materials/effect";
  66706. import { Mesh } from "babylonjs/Meshes/mesh";
  66707. import { Scene } from "babylonjs/scene";
  66708. /**
  66709. * Block used to implement the PBR metallic/roughness model
  66710. */
  66711. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66712. /**
  66713. * Gets or sets the light associated with this block
  66714. */
  66715. light: Nullable<Light>;
  66716. private _lightId;
  66717. private _scene;
  66718. private _environmentBRDFTexture;
  66719. private _environmentBrdfSamplerName;
  66720. private _vNormalWName;
  66721. private _invertNormalName;
  66722. /**
  66723. * Create a new ReflectionBlock
  66724. * @param name defines the block name
  66725. */
  66726. constructor(name: string);
  66727. /**
  66728. * Intensity of the direct lights e.g. the four lights available in your scene.
  66729. * This impacts both the direct diffuse and specular highlights.
  66730. */
  66731. directIntensity: number;
  66732. /**
  66733. * Intensity of the environment e.g. how much the environment will light the object
  66734. * either through harmonics for rough material or through the refelction for shiny ones.
  66735. */
  66736. environmentIntensity: number;
  66737. /**
  66738. * This is a special control allowing the reduction of the specular highlights coming from the
  66739. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66740. */
  66741. specularIntensity: number;
  66742. /**
  66743. * Defines the falloff type used in this material.
  66744. * It by default is Physical.
  66745. */
  66746. lightFalloff: number;
  66747. /**
  66748. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66749. */
  66750. useAlphaFromAlbedoTexture: boolean;
  66751. /**
  66752. * Specifies that alpha test should be used
  66753. */
  66754. useAlphaTest: boolean;
  66755. /**
  66756. * Defines the alpha limits in alpha test mode.
  66757. */
  66758. alphaTestCutoff: number;
  66759. /**
  66760. * Specifies that alpha blending should be used
  66761. */
  66762. useAlphaBlending: boolean;
  66763. /**
  66764. * Defines if the alpha value should be determined via the rgb values.
  66765. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66766. */
  66767. opacityRGB: boolean;
  66768. /**
  66769. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66770. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66771. */
  66772. useRadianceOverAlpha: boolean;
  66773. /**
  66774. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66775. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66776. */
  66777. useSpecularOverAlpha: boolean;
  66778. /**
  66779. * Enables specular anti aliasing in the PBR shader.
  66780. * It will both interacts on the Geometry for analytical and IBL lighting.
  66781. * It also prefilter the roughness map based on the bump values.
  66782. */
  66783. enableSpecularAntiAliasing: boolean;
  66784. /**
  66785. * Enables realtime filtering on the texture.
  66786. */
  66787. realTimeFiltering: boolean;
  66788. /**
  66789. * Quality switch for realtime filtering
  66790. */
  66791. realTimeFilteringQuality: number;
  66792. /**
  66793. * Defines if the material uses energy conservation.
  66794. */
  66795. useEnergyConservation: boolean;
  66796. /**
  66797. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66798. * too much the area relying on ambient texture to define their ambient occlusion.
  66799. */
  66800. useRadianceOcclusion: boolean;
  66801. /**
  66802. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66803. * makes the reflect vector face the model (under horizon).
  66804. */
  66805. useHorizonOcclusion: boolean;
  66806. /**
  66807. * If set to true, no lighting calculations will be applied.
  66808. */
  66809. unlit: boolean;
  66810. /**
  66811. * Force normal to face away from face.
  66812. */
  66813. forceNormalForward: boolean;
  66814. /**
  66815. * Defines the material debug mode.
  66816. * It helps seeing only some components of the material while troubleshooting.
  66817. */
  66818. debugMode: number;
  66819. /**
  66820. * Specify from where on screen the debug mode should start.
  66821. * The value goes from -1 (full screen) to 1 (not visible)
  66822. * It helps with side by side comparison against the final render
  66823. * This defaults to 0
  66824. */
  66825. debugLimit: number;
  66826. /**
  66827. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66828. * You can use the factor to better multiply the final value.
  66829. */
  66830. debugFactor: number;
  66831. /**
  66832. * Initialize the block and prepare the context for build
  66833. * @param state defines the state that will be used for the build
  66834. */
  66835. initialize(state: NodeMaterialBuildState): void;
  66836. /**
  66837. * Gets the current class name
  66838. * @returns the class name
  66839. */
  66840. getClassName(): string;
  66841. /**
  66842. * Gets the world position input component
  66843. */
  66844. get worldPosition(): NodeMaterialConnectionPoint;
  66845. /**
  66846. * Gets the world normal input component
  66847. */
  66848. get worldNormal(): NodeMaterialConnectionPoint;
  66849. /**
  66850. * Gets the perturbed normal input component
  66851. */
  66852. get perturbedNormal(): NodeMaterialConnectionPoint;
  66853. /**
  66854. * Gets the camera position input component
  66855. */
  66856. get cameraPosition(): NodeMaterialConnectionPoint;
  66857. /**
  66858. * Gets the base color input component
  66859. */
  66860. get baseColor(): NodeMaterialConnectionPoint;
  66861. /**
  66862. * Gets the opacity texture input component
  66863. */
  66864. get opacityTexture(): NodeMaterialConnectionPoint;
  66865. /**
  66866. * Gets the ambient color input component
  66867. */
  66868. get ambientColor(): NodeMaterialConnectionPoint;
  66869. /**
  66870. * Gets the reflectivity object parameters
  66871. */
  66872. get reflectivity(): NodeMaterialConnectionPoint;
  66873. /**
  66874. * Gets the ambient occlusion object parameters
  66875. */
  66876. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66877. /**
  66878. * Gets the reflection object parameters
  66879. */
  66880. get reflection(): NodeMaterialConnectionPoint;
  66881. /**
  66882. * Gets the sheen object parameters
  66883. */
  66884. get sheen(): NodeMaterialConnectionPoint;
  66885. /**
  66886. * Gets the clear coat object parameters
  66887. */
  66888. get clearcoat(): NodeMaterialConnectionPoint;
  66889. /**
  66890. * Gets the sub surface object parameters
  66891. */
  66892. get subsurface(): NodeMaterialConnectionPoint;
  66893. /**
  66894. * Gets the anisotropy object parameters
  66895. */
  66896. get anisotropy(): NodeMaterialConnectionPoint;
  66897. /**
  66898. * Gets the ambient output component
  66899. */
  66900. get ambient(): NodeMaterialConnectionPoint;
  66901. /**
  66902. * Gets the diffuse output component
  66903. */
  66904. get diffuse(): NodeMaterialConnectionPoint;
  66905. /**
  66906. * Gets the specular output component
  66907. */
  66908. get specular(): NodeMaterialConnectionPoint;
  66909. /**
  66910. * Gets the sheen output component
  66911. */
  66912. get sheenDir(): NodeMaterialConnectionPoint;
  66913. /**
  66914. * Gets the clear coat output component
  66915. */
  66916. get clearcoatDir(): NodeMaterialConnectionPoint;
  66917. /**
  66918. * Gets the indirect diffuse output component
  66919. */
  66920. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66921. /**
  66922. * Gets the indirect specular output component
  66923. */
  66924. get specularIndirect(): NodeMaterialConnectionPoint;
  66925. /**
  66926. * Gets the indirect sheen output component
  66927. */
  66928. get sheenIndirect(): NodeMaterialConnectionPoint;
  66929. /**
  66930. * Gets the indirect clear coat output component
  66931. */
  66932. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66933. /**
  66934. * Gets the refraction output component
  66935. */
  66936. get refraction(): NodeMaterialConnectionPoint;
  66937. /**
  66938. * Gets the global lighting output component
  66939. */
  66940. get lighting(): NodeMaterialConnectionPoint;
  66941. /**
  66942. * Gets the shadow output component
  66943. */
  66944. get shadow(): NodeMaterialConnectionPoint;
  66945. /**
  66946. * Gets the alpha output component
  66947. */
  66948. get alpha(): NodeMaterialConnectionPoint;
  66949. autoConfigure(material: NodeMaterial): void;
  66950. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66951. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66952. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66953. private _injectVertexCode;
  66954. /**
  66955. * Gets the code corresponding to the albedo/opacity module
  66956. * @returns the shader code
  66957. */
  66958. getAlbedoOpacityCode(): string;
  66959. protected _buildBlock(state: NodeMaterialBuildState): this;
  66960. protected _dumpPropertiesCode(): string;
  66961. serialize(): any;
  66962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66963. }
  66964. }
  66965. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  66966. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  66967. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  66968. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  66969. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  66970. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  66971. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66972. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  66973. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  66974. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  66975. }
  66976. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  66977. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  66978. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  66979. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  66980. }
  66981. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  66982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66985. /**
  66986. * Block used to compute value of one parameter modulo another
  66987. */
  66988. export class ModBlock extends NodeMaterialBlock {
  66989. /**
  66990. * Creates a new ModBlock
  66991. * @param name defines the block name
  66992. */
  66993. constructor(name: string);
  66994. /**
  66995. * Gets the current class name
  66996. * @returns the class name
  66997. */
  66998. getClassName(): string;
  66999. /**
  67000. * Gets the left operand input component
  67001. */
  67002. get left(): NodeMaterialConnectionPoint;
  67003. /**
  67004. * Gets the right operand input component
  67005. */
  67006. get right(): NodeMaterialConnectionPoint;
  67007. /**
  67008. * Gets the output component
  67009. */
  67010. get output(): NodeMaterialConnectionPoint;
  67011. protected _buildBlock(state: NodeMaterialBuildState): this;
  67012. }
  67013. }
  67014. declare module "babylonjs/Materials/Node/Blocks/index" {
  67015. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67016. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67017. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67018. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67019. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67020. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67021. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67022. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67023. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67024. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67025. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67026. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67027. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67028. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67029. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67030. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67031. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67032. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67033. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67034. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67035. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67036. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67037. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67038. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67039. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67040. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67041. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67042. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67043. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67044. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67045. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67046. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67047. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67048. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67049. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67050. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67051. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67052. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67053. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67054. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67055. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67056. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67057. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67058. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67059. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67060. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67061. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67062. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67063. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67064. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67065. }
  67066. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67067. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67068. }
  67069. declare module "babylonjs/Materials/Node/index" {
  67070. export * from "babylonjs/Materials/Node/Enums/index";
  67071. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67072. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67073. export * from "babylonjs/Materials/Node/nodeMaterial";
  67074. export * from "babylonjs/Materials/Node/Blocks/index";
  67075. export * from "babylonjs/Materials/Node/Optimizers/index";
  67076. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67077. }
  67078. declare module "babylonjs/Materials/index" {
  67079. export * from "babylonjs/Materials/Background/index";
  67080. export * from "babylonjs/Materials/colorCurves";
  67081. export * from "babylonjs/Materials/iEffectFallbacks";
  67082. export * from "babylonjs/Materials/effectFallbacks";
  67083. export * from "babylonjs/Materials/effect";
  67084. export * from "babylonjs/Materials/fresnelParameters";
  67085. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67086. export * from "babylonjs/Materials/material";
  67087. export * from "babylonjs/Materials/materialDefines";
  67088. export * from "babylonjs/Materials/materialHelper";
  67089. export * from "babylonjs/Materials/multiMaterial";
  67090. export * from "babylonjs/Materials/PBR/index";
  67091. export * from "babylonjs/Materials/pushMaterial";
  67092. export * from "babylonjs/Materials/shaderMaterial";
  67093. export * from "babylonjs/Materials/standardMaterial";
  67094. export * from "babylonjs/Materials/Textures/index";
  67095. export * from "babylonjs/Materials/uniformBuffer";
  67096. export * from "babylonjs/Materials/materialFlags";
  67097. export * from "babylonjs/Materials/Node/index";
  67098. export * from "babylonjs/Materials/effectRenderer";
  67099. export * from "babylonjs/Materials/shadowDepthWrapper";
  67100. }
  67101. declare module "babylonjs/Maths/index" {
  67102. export * from "babylonjs/Maths/math.scalar";
  67103. export * from "babylonjs/Maths/math";
  67104. export * from "babylonjs/Maths/sphericalPolynomial";
  67105. }
  67106. declare module "babylonjs/Misc/workerPool" {
  67107. import { IDisposable } from "babylonjs/scene";
  67108. /**
  67109. * Helper class to push actions to a pool of workers.
  67110. */
  67111. export class WorkerPool implements IDisposable {
  67112. private _workerInfos;
  67113. private _pendingActions;
  67114. /**
  67115. * Constructor
  67116. * @param workers Array of workers to use for actions
  67117. */
  67118. constructor(workers: Array<Worker>);
  67119. /**
  67120. * Terminates all workers and clears any pending actions.
  67121. */
  67122. dispose(): void;
  67123. /**
  67124. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67125. * pended until a worker has completed its action.
  67126. * @param action The action to perform. Call onComplete when the action is complete.
  67127. */
  67128. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67129. private _execute;
  67130. }
  67131. }
  67132. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67133. import { IDisposable } from "babylonjs/scene";
  67134. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67135. /**
  67136. * Configuration for Draco compression
  67137. */
  67138. export interface IDracoCompressionConfiguration {
  67139. /**
  67140. * Configuration for the decoder.
  67141. */
  67142. decoder: {
  67143. /**
  67144. * The url to the WebAssembly module.
  67145. */
  67146. wasmUrl?: string;
  67147. /**
  67148. * The url to the WebAssembly binary.
  67149. */
  67150. wasmBinaryUrl?: string;
  67151. /**
  67152. * The url to the fallback JavaScript module.
  67153. */
  67154. fallbackUrl?: string;
  67155. };
  67156. }
  67157. /**
  67158. * Draco compression (https://google.github.io/draco/)
  67159. *
  67160. * This class wraps the Draco module.
  67161. *
  67162. * **Encoder**
  67163. *
  67164. * The encoder is not currently implemented.
  67165. *
  67166. * **Decoder**
  67167. *
  67168. * 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.
  67169. *
  67170. * To update the configuration, use the following code:
  67171. * ```javascript
  67172. * DracoCompression.Configuration = {
  67173. * decoder: {
  67174. * wasmUrl: "<url to the WebAssembly library>",
  67175. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67176. * fallbackUrl: "<url to the fallback JavaScript library>",
  67177. * }
  67178. * };
  67179. * ```
  67180. *
  67181. * 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.
  67182. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67183. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67184. *
  67185. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67186. * ```javascript
  67187. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67188. * ```
  67189. *
  67190. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67191. */
  67192. export class DracoCompression implements IDisposable {
  67193. private _workerPoolPromise?;
  67194. private _decoderModulePromise?;
  67195. /**
  67196. * The configuration. Defaults to the following urls:
  67197. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67198. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67199. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67200. */
  67201. static Configuration: IDracoCompressionConfiguration;
  67202. /**
  67203. * Returns true if the decoder configuration is available.
  67204. */
  67205. static get DecoderAvailable(): boolean;
  67206. /**
  67207. * Default number of workers to create when creating the draco compression object.
  67208. */
  67209. static DefaultNumWorkers: number;
  67210. private static GetDefaultNumWorkers;
  67211. private static _Default;
  67212. /**
  67213. * Default instance for the draco compression object.
  67214. */
  67215. static get Default(): DracoCompression;
  67216. /**
  67217. * Constructor
  67218. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67219. */
  67220. constructor(numWorkers?: number);
  67221. /**
  67222. * Stop all async operations and release resources.
  67223. */
  67224. dispose(): void;
  67225. /**
  67226. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67227. * @returns a promise that resolves when ready
  67228. */
  67229. whenReadyAsync(): Promise<void>;
  67230. /**
  67231. * Decode Draco compressed mesh data to vertex data.
  67232. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67233. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67234. * @returns A promise that resolves with the decoded vertex data
  67235. */
  67236. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67237. [kind: string]: number;
  67238. }): Promise<VertexData>;
  67239. }
  67240. }
  67241. declare module "babylonjs/Meshes/Compression/index" {
  67242. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67243. }
  67244. declare module "babylonjs/Meshes/csg" {
  67245. import { Nullable } from "babylonjs/types";
  67246. import { Scene } from "babylonjs/scene";
  67247. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67248. import { Mesh } from "babylonjs/Meshes/mesh";
  67249. import { Material } from "babylonjs/Materials/material";
  67250. /**
  67251. * Class for building Constructive Solid Geometry
  67252. */
  67253. export class CSG {
  67254. private polygons;
  67255. /**
  67256. * The world matrix
  67257. */
  67258. matrix: Matrix;
  67259. /**
  67260. * Stores the position
  67261. */
  67262. position: Vector3;
  67263. /**
  67264. * Stores the rotation
  67265. */
  67266. rotation: Vector3;
  67267. /**
  67268. * Stores the rotation quaternion
  67269. */
  67270. rotationQuaternion: Nullable<Quaternion>;
  67271. /**
  67272. * Stores the scaling vector
  67273. */
  67274. scaling: Vector3;
  67275. /**
  67276. * Convert the Mesh to CSG
  67277. * @param mesh The Mesh to convert to CSG
  67278. * @returns A new CSG from the Mesh
  67279. */
  67280. static FromMesh(mesh: Mesh): CSG;
  67281. /**
  67282. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67283. * @param polygons Polygons used to construct a CSG solid
  67284. */
  67285. private static FromPolygons;
  67286. /**
  67287. * Clones, or makes a deep copy, of the CSG
  67288. * @returns A new CSG
  67289. */
  67290. clone(): CSG;
  67291. /**
  67292. * Unions this CSG with another CSG
  67293. * @param csg The CSG to union against this CSG
  67294. * @returns The unioned CSG
  67295. */
  67296. union(csg: CSG): CSG;
  67297. /**
  67298. * Unions this CSG with another CSG in place
  67299. * @param csg The CSG to union against this CSG
  67300. */
  67301. unionInPlace(csg: CSG): void;
  67302. /**
  67303. * Subtracts this CSG with another CSG
  67304. * @param csg The CSG to subtract against this CSG
  67305. * @returns A new CSG
  67306. */
  67307. subtract(csg: CSG): CSG;
  67308. /**
  67309. * Subtracts this CSG with another CSG in place
  67310. * @param csg The CSG to subtact against this CSG
  67311. */
  67312. subtractInPlace(csg: CSG): void;
  67313. /**
  67314. * Intersect this CSG with another CSG
  67315. * @param csg The CSG to intersect against this CSG
  67316. * @returns A new CSG
  67317. */
  67318. intersect(csg: CSG): CSG;
  67319. /**
  67320. * Intersects this CSG with another CSG in place
  67321. * @param csg The CSG to intersect against this CSG
  67322. */
  67323. intersectInPlace(csg: CSG): void;
  67324. /**
  67325. * Return a new CSG solid with solid and empty space switched. This solid is
  67326. * not modified.
  67327. * @returns A new CSG solid with solid and empty space switched
  67328. */
  67329. inverse(): CSG;
  67330. /**
  67331. * Inverses the CSG in place
  67332. */
  67333. inverseInPlace(): void;
  67334. /**
  67335. * This is used to keep meshes transformations so they can be restored
  67336. * when we build back a Babylon Mesh
  67337. * NB : All CSG operations are performed in world coordinates
  67338. * @param csg The CSG to copy the transform attributes from
  67339. * @returns This CSG
  67340. */
  67341. copyTransformAttributes(csg: CSG): CSG;
  67342. /**
  67343. * Build Raw mesh from CSG
  67344. * Coordinates here are in world space
  67345. * @param name The name of the mesh geometry
  67346. * @param scene The Scene
  67347. * @param keepSubMeshes Specifies if the submeshes should be kept
  67348. * @returns A new Mesh
  67349. */
  67350. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67351. /**
  67352. * Build Mesh from CSG taking material and transforms into account
  67353. * @param name The name of the Mesh
  67354. * @param material The material of the Mesh
  67355. * @param scene The Scene
  67356. * @param keepSubMeshes Specifies if submeshes should be kept
  67357. * @returns The new Mesh
  67358. */
  67359. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67360. }
  67361. }
  67362. declare module "babylonjs/Meshes/trailMesh" {
  67363. import { Mesh } from "babylonjs/Meshes/mesh";
  67364. import { Scene } from "babylonjs/scene";
  67365. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67366. /**
  67367. * Class used to create a trail following a mesh
  67368. */
  67369. export class TrailMesh extends Mesh {
  67370. private _generator;
  67371. private _autoStart;
  67372. private _running;
  67373. private _diameter;
  67374. private _length;
  67375. private _sectionPolygonPointsCount;
  67376. private _sectionVectors;
  67377. private _sectionNormalVectors;
  67378. private _beforeRenderObserver;
  67379. /**
  67380. * @constructor
  67381. * @param name The value used by scene.getMeshByName() to do a lookup.
  67382. * @param generator The mesh or transform node to generate a trail.
  67383. * @param scene The scene to add this mesh to.
  67384. * @param diameter Diameter of trailing mesh. Default is 1.
  67385. * @param length Length of trailing mesh. Default is 60.
  67386. * @param autoStart Automatically start trailing mesh. Default true.
  67387. */
  67388. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67389. /**
  67390. * "TrailMesh"
  67391. * @returns "TrailMesh"
  67392. */
  67393. getClassName(): string;
  67394. private _createMesh;
  67395. /**
  67396. * Start trailing mesh.
  67397. */
  67398. start(): void;
  67399. /**
  67400. * Stop trailing mesh.
  67401. */
  67402. stop(): void;
  67403. /**
  67404. * Update trailing mesh geometry.
  67405. */
  67406. update(): void;
  67407. /**
  67408. * Returns a new TrailMesh object.
  67409. * @param name is a string, the name given to the new mesh
  67410. * @param newGenerator use new generator object for cloned trail mesh
  67411. * @returns a new mesh
  67412. */
  67413. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67414. /**
  67415. * Serializes this trail mesh
  67416. * @param serializationObject object to write serialization to
  67417. */
  67418. serialize(serializationObject: any): void;
  67419. /**
  67420. * Parses a serialized trail mesh
  67421. * @param parsedMesh the serialized mesh
  67422. * @param scene the scene to create the trail mesh in
  67423. * @returns the created trail mesh
  67424. */
  67425. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67426. }
  67427. }
  67428. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67429. import { Nullable } from "babylonjs/types";
  67430. import { Scene } from "babylonjs/scene";
  67431. import { Vector4 } from "babylonjs/Maths/math.vector";
  67432. import { Color4 } from "babylonjs/Maths/math.color";
  67433. import { Mesh } from "babylonjs/Meshes/mesh";
  67434. /**
  67435. * Class containing static functions to help procedurally build meshes
  67436. */
  67437. export class TiledBoxBuilder {
  67438. /**
  67439. * Creates a box mesh
  67440. * 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)
  67441. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67442. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67443. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67445. * @param name defines the name of the mesh
  67446. * @param options defines the options used to create the mesh
  67447. * @param scene defines the hosting scene
  67448. * @returns the box mesh
  67449. */
  67450. static CreateTiledBox(name: string, options: {
  67451. pattern?: number;
  67452. width?: number;
  67453. height?: number;
  67454. depth?: number;
  67455. tileSize?: number;
  67456. tileWidth?: number;
  67457. tileHeight?: number;
  67458. alignHorizontal?: number;
  67459. alignVertical?: number;
  67460. faceUV?: Vector4[];
  67461. faceColors?: Color4[];
  67462. sideOrientation?: number;
  67463. updatable?: boolean;
  67464. }, scene?: Nullable<Scene>): Mesh;
  67465. }
  67466. }
  67467. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67468. import { Vector4 } from "babylonjs/Maths/math.vector";
  67469. import { Mesh } from "babylonjs/Meshes/mesh";
  67470. /**
  67471. * Class containing static functions to help procedurally build meshes
  67472. */
  67473. export class TorusKnotBuilder {
  67474. /**
  67475. * Creates a torus knot mesh
  67476. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67477. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67478. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67479. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67483. * @param name defines the name of the mesh
  67484. * @param options defines the options used to create the mesh
  67485. * @param scene defines the hosting scene
  67486. * @returns the torus knot mesh
  67487. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67488. */
  67489. static CreateTorusKnot(name: string, options: {
  67490. radius?: number;
  67491. tube?: number;
  67492. radialSegments?: number;
  67493. tubularSegments?: number;
  67494. p?: number;
  67495. q?: number;
  67496. updatable?: boolean;
  67497. sideOrientation?: number;
  67498. frontUVs?: Vector4;
  67499. backUVs?: Vector4;
  67500. }, scene: any): Mesh;
  67501. }
  67502. }
  67503. declare module "babylonjs/Meshes/polygonMesh" {
  67504. import { Scene } from "babylonjs/scene";
  67505. import { Vector2 } from "babylonjs/Maths/math.vector";
  67506. import { Mesh } from "babylonjs/Meshes/mesh";
  67507. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67508. import { Path2 } from "babylonjs/Maths/math.path";
  67509. /**
  67510. * Polygon
  67511. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67512. */
  67513. export class Polygon {
  67514. /**
  67515. * Creates a rectangle
  67516. * @param xmin bottom X coord
  67517. * @param ymin bottom Y coord
  67518. * @param xmax top X coord
  67519. * @param ymax top Y coord
  67520. * @returns points that make the resulting rectation
  67521. */
  67522. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67523. /**
  67524. * Creates a circle
  67525. * @param radius radius of circle
  67526. * @param cx scale in x
  67527. * @param cy scale in y
  67528. * @param numberOfSides number of sides that make up the circle
  67529. * @returns points that make the resulting circle
  67530. */
  67531. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67532. /**
  67533. * Creates a polygon from input string
  67534. * @param input Input polygon data
  67535. * @returns the parsed points
  67536. */
  67537. static Parse(input: string): Vector2[];
  67538. /**
  67539. * Starts building a polygon from x and y coordinates
  67540. * @param x x coordinate
  67541. * @param y y coordinate
  67542. * @returns the started path2
  67543. */
  67544. static StartingAt(x: number, y: number): Path2;
  67545. }
  67546. /**
  67547. * Builds a polygon
  67548. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67549. */
  67550. export class PolygonMeshBuilder {
  67551. private _points;
  67552. private _outlinepoints;
  67553. private _holes;
  67554. private _name;
  67555. private _scene;
  67556. private _epoints;
  67557. private _eholes;
  67558. private _addToepoint;
  67559. /**
  67560. * Babylon reference to the earcut plugin.
  67561. */
  67562. bjsEarcut: any;
  67563. /**
  67564. * Creates a PolygonMeshBuilder
  67565. * @param name name of the builder
  67566. * @param contours Path of the polygon
  67567. * @param scene scene to add to when creating the mesh
  67568. * @param earcutInjection can be used to inject your own earcut reference
  67569. */
  67570. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67571. /**
  67572. * Adds a whole within the polygon
  67573. * @param hole Array of points defining the hole
  67574. * @returns this
  67575. */
  67576. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67577. /**
  67578. * Creates the polygon
  67579. * @param updatable If the mesh should be updatable
  67580. * @param depth The depth of the mesh created
  67581. * @returns the created mesh
  67582. */
  67583. build(updatable?: boolean, depth?: number): Mesh;
  67584. /**
  67585. * Creates the polygon
  67586. * @param depth The depth of the mesh created
  67587. * @returns the created VertexData
  67588. */
  67589. buildVertexData(depth?: number): VertexData;
  67590. /**
  67591. * Adds a side to the polygon
  67592. * @param positions points that make the polygon
  67593. * @param normals normals of the polygon
  67594. * @param uvs uvs of the polygon
  67595. * @param indices indices of the polygon
  67596. * @param bounds bounds of the polygon
  67597. * @param points points of the polygon
  67598. * @param depth depth of the polygon
  67599. * @param flip flip of the polygon
  67600. */
  67601. private addSide;
  67602. }
  67603. }
  67604. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67605. import { Scene } from "babylonjs/scene";
  67606. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67607. import { Color4 } from "babylonjs/Maths/math.color";
  67608. import { Mesh } from "babylonjs/Meshes/mesh";
  67609. import { Nullable } from "babylonjs/types";
  67610. /**
  67611. * Class containing static functions to help procedurally build meshes
  67612. */
  67613. export class PolygonBuilder {
  67614. /**
  67615. * Creates a polygon mesh
  67616. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67617. * * 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
  67618. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67621. * * Remember you can only change the shape positions, not their number when updating a polygon
  67622. * @param name defines the name of the mesh
  67623. * @param options defines the options used to create the mesh
  67624. * @param scene defines the hosting scene
  67625. * @param earcutInjection can be used to inject your own earcut reference
  67626. * @returns the polygon mesh
  67627. */
  67628. static CreatePolygon(name: string, options: {
  67629. shape: Vector3[];
  67630. holes?: Vector3[][];
  67631. depth?: number;
  67632. faceUV?: Vector4[];
  67633. faceColors?: Color4[];
  67634. updatable?: boolean;
  67635. sideOrientation?: number;
  67636. frontUVs?: Vector4;
  67637. backUVs?: Vector4;
  67638. wrap?: boolean;
  67639. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67640. /**
  67641. * Creates an extruded polygon mesh, with depth in the Y direction.
  67642. * * 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)
  67643. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67644. * @param name defines the name of the mesh
  67645. * @param options defines the options used to create the mesh
  67646. * @param scene defines the hosting scene
  67647. * @param earcutInjection can be used to inject your own earcut reference
  67648. * @returns the polygon mesh
  67649. */
  67650. static ExtrudePolygon(name: string, options: {
  67651. shape: Vector3[];
  67652. holes?: Vector3[][];
  67653. depth?: number;
  67654. faceUV?: Vector4[];
  67655. faceColors?: Color4[];
  67656. updatable?: boolean;
  67657. sideOrientation?: number;
  67658. frontUVs?: Vector4;
  67659. backUVs?: Vector4;
  67660. wrap?: boolean;
  67661. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67662. }
  67663. }
  67664. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67665. import { Scene } from "babylonjs/scene";
  67666. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67667. import { Mesh } from "babylonjs/Meshes/mesh";
  67668. import { Nullable } from "babylonjs/types";
  67669. /**
  67670. * Class containing static functions to help procedurally build meshes
  67671. */
  67672. export class LatheBuilder {
  67673. /**
  67674. * Creates lathe mesh.
  67675. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67676. * * 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
  67677. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67678. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67679. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67680. * * 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
  67681. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67682. * * 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
  67683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67687. * @param name defines the name of the mesh
  67688. * @param options defines the options used to create the mesh
  67689. * @param scene defines the hosting scene
  67690. * @returns the lathe mesh
  67691. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67692. */
  67693. static CreateLathe(name: string, options: {
  67694. shape: Vector3[];
  67695. radius?: number;
  67696. tessellation?: number;
  67697. clip?: number;
  67698. arc?: number;
  67699. closed?: boolean;
  67700. updatable?: boolean;
  67701. sideOrientation?: number;
  67702. frontUVs?: Vector4;
  67703. backUVs?: Vector4;
  67704. cap?: number;
  67705. invertUV?: boolean;
  67706. }, scene?: Nullable<Scene>): Mesh;
  67707. }
  67708. }
  67709. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67710. import { Nullable } from "babylonjs/types";
  67711. import { Scene } from "babylonjs/scene";
  67712. import { Vector4 } from "babylonjs/Maths/math.vector";
  67713. import { Mesh } from "babylonjs/Meshes/mesh";
  67714. /**
  67715. * Class containing static functions to help procedurally build meshes
  67716. */
  67717. export class TiledPlaneBuilder {
  67718. /**
  67719. * Creates a tiled plane mesh
  67720. * * The parameter `pattern` will, depending on value, do nothing or
  67721. * * * flip (reflect about central vertical) alternate tiles across and up
  67722. * * * flip every tile on alternate rows
  67723. * * * rotate (180 degs) alternate tiles across and up
  67724. * * * rotate every tile on alternate rows
  67725. * * * flip and rotate alternate tiles across and up
  67726. * * * flip and rotate every tile on alternate rows
  67727. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67728. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67730. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67731. * * 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)
  67732. * * 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)
  67733. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67734. * @param name defines the name of the mesh
  67735. * @param options defines the options used to create the mesh
  67736. * @param scene defines the hosting scene
  67737. * @returns the box mesh
  67738. */
  67739. static CreateTiledPlane(name: string, options: {
  67740. pattern?: number;
  67741. tileSize?: number;
  67742. tileWidth?: number;
  67743. tileHeight?: number;
  67744. size?: number;
  67745. width?: number;
  67746. height?: number;
  67747. alignHorizontal?: number;
  67748. alignVertical?: number;
  67749. sideOrientation?: number;
  67750. frontUVs?: Vector4;
  67751. backUVs?: Vector4;
  67752. updatable?: boolean;
  67753. }, scene?: Nullable<Scene>): Mesh;
  67754. }
  67755. }
  67756. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67757. import { Nullable } from "babylonjs/types";
  67758. import { Scene } from "babylonjs/scene";
  67759. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67760. import { Mesh } from "babylonjs/Meshes/mesh";
  67761. /**
  67762. * Class containing static functions to help procedurally build meshes
  67763. */
  67764. export class TubeBuilder {
  67765. /**
  67766. * Creates a tube mesh.
  67767. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67768. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67769. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67770. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67771. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67772. * * 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)
  67773. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67774. * * 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
  67775. * * 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
  67776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67778. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67780. * @param name defines the name of the mesh
  67781. * @param options defines the options used to create the mesh
  67782. * @param scene defines the hosting scene
  67783. * @returns the tube mesh
  67784. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67785. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67786. */
  67787. static CreateTube(name: string, options: {
  67788. path: Vector3[];
  67789. radius?: number;
  67790. tessellation?: number;
  67791. radiusFunction?: {
  67792. (i: number, distance: number): number;
  67793. };
  67794. cap?: number;
  67795. arc?: number;
  67796. updatable?: boolean;
  67797. sideOrientation?: number;
  67798. frontUVs?: Vector4;
  67799. backUVs?: Vector4;
  67800. instance?: Mesh;
  67801. invertUV?: boolean;
  67802. }, scene?: Nullable<Scene>): Mesh;
  67803. }
  67804. }
  67805. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67806. import { Scene } from "babylonjs/scene";
  67807. import { Vector4 } from "babylonjs/Maths/math.vector";
  67808. import { Mesh } from "babylonjs/Meshes/mesh";
  67809. import { Nullable } from "babylonjs/types";
  67810. /**
  67811. * Class containing static functions to help procedurally build meshes
  67812. */
  67813. export class IcoSphereBuilder {
  67814. /**
  67815. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67816. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67817. * * 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`)
  67818. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67819. * * 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
  67820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67823. * @param name defines the name of the mesh
  67824. * @param options defines the options used to create the mesh
  67825. * @param scene defines the hosting scene
  67826. * @returns the icosahedron mesh
  67827. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67828. */
  67829. static CreateIcoSphere(name: string, options: {
  67830. radius?: number;
  67831. radiusX?: number;
  67832. radiusY?: number;
  67833. radiusZ?: number;
  67834. flat?: boolean;
  67835. subdivisions?: number;
  67836. sideOrientation?: number;
  67837. frontUVs?: Vector4;
  67838. backUVs?: Vector4;
  67839. updatable?: boolean;
  67840. }, scene?: Nullable<Scene>): Mesh;
  67841. }
  67842. }
  67843. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67844. import { Vector3 } from "babylonjs/Maths/math.vector";
  67845. import { Mesh } from "babylonjs/Meshes/mesh";
  67846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67847. /**
  67848. * Class containing static functions to help procedurally build meshes
  67849. */
  67850. export class DecalBuilder {
  67851. /**
  67852. * Creates a decal mesh.
  67853. * 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
  67854. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67855. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67856. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67857. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67858. * @param name defines the name of the mesh
  67859. * @param sourceMesh defines the mesh where the decal must be applied
  67860. * @param options defines the options used to create the mesh
  67861. * @param scene defines the hosting scene
  67862. * @returns the decal mesh
  67863. * @see https://doc.babylonjs.com/how_to/decals
  67864. */
  67865. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67866. position?: Vector3;
  67867. normal?: Vector3;
  67868. size?: Vector3;
  67869. angle?: number;
  67870. }): Mesh;
  67871. }
  67872. }
  67873. declare module "babylonjs/Meshes/meshBuilder" {
  67874. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  67875. import { Nullable } from "babylonjs/types";
  67876. import { Scene } from "babylonjs/scene";
  67877. import { Mesh } from "babylonjs/Meshes/mesh";
  67878. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  67879. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  67880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67881. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67882. import { Plane } from "babylonjs/Maths/math.plane";
  67883. /**
  67884. * Class containing static functions to help procedurally build meshes
  67885. */
  67886. export class MeshBuilder {
  67887. /**
  67888. * Creates a box mesh
  67889. * * The parameter `size` sets the size (float) of each box side (default 1)
  67890. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67891. * * 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)
  67892. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67896. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67897. * @param name defines the name of the mesh
  67898. * @param options defines the options used to create the mesh
  67899. * @param scene defines the hosting scene
  67900. * @returns the box mesh
  67901. */
  67902. static CreateBox(name: string, options: {
  67903. size?: number;
  67904. width?: number;
  67905. height?: number;
  67906. depth?: number;
  67907. faceUV?: Vector4[];
  67908. faceColors?: Color4[];
  67909. sideOrientation?: number;
  67910. frontUVs?: Vector4;
  67911. backUVs?: Vector4;
  67912. wrap?: boolean;
  67913. topBaseAt?: number;
  67914. bottomBaseAt?: number;
  67915. updatable?: boolean;
  67916. }, scene?: Nullable<Scene>): Mesh;
  67917. /**
  67918. * Creates a tiled box mesh
  67919. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67921. * @param name defines the name of the mesh
  67922. * @param options defines the options used to create the mesh
  67923. * @param scene defines the hosting scene
  67924. * @returns the tiled box mesh
  67925. */
  67926. static CreateTiledBox(name: string, options: {
  67927. pattern?: number;
  67928. size?: number;
  67929. width?: number;
  67930. height?: number;
  67931. depth: number;
  67932. tileSize?: number;
  67933. tileWidth?: number;
  67934. tileHeight?: number;
  67935. faceUV?: Vector4[];
  67936. faceColors?: Color4[];
  67937. alignHorizontal?: number;
  67938. alignVertical?: number;
  67939. sideOrientation?: number;
  67940. updatable?: boolean;
  67941. }, scene?: Nullable<Scene>): Mesh;
  67942. /**
  67943. * Creates a sphere mesh
  67944. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67945. * * 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`)
  67946. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67947. * * 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
  67948. * * 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)
  67949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67952. * @param name defines the name of the mesh
  67953. * @param options defines the options used to create the mesh
  67954. * @param scene defines the hosting scene
  67955. * @returns the sphere mesh
  67956. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67957. */
  67958. static CreateSphere(name: string, options: {
  67959. segments?: number;
  67960. diameter?: number;
  67961. diameterX?: number;
  67962. diameterY?: number;
  67963. diameterZ?: number;
  67964. arc?: number;
  67965. slice?: number;
  67966. sideOrientation?: number;
  67967. frontUVs?: Vector4;
  67968. backUVs?: Vector4;
  67969. updatable?: boolean;
  67970. }, scene?: Nullable<Scene>): Mesh;
  67971. /**
  67972. * Creates a plane polygonal mesh. By default, this is a disc
  67973. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67974. * * 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
  67975. * * 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
  67976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67979. * @param name defines the name of the mesh
  67980. * @param options defines the options used to create the mesh
  67981. * @param scene defines the hosting scene
  67982. * @returns the plane polygonal mesh
  67983. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67984. */
  67985. static CreateDisc(name: string, options: {
  67986. radius?: number;
  67987. tessellation?: number;
  67988. arc?: number;
  67989. updatable?: boolean;
  67990. sideOrientation?: number;
  67991. frontUVs?: Vector4;
  67992. backUVs?: Vector4;
  67993. }, scene?: Nullable<Scene>): Mesh;
  67994. /**
  67995. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67996. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67997. * * 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`)
  67998. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67999. * * 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
  68000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68003. * @param name defines the name of the mesh
  68004. * @param options defines the options used to create the mesh
  68005. * @param scene defines the hosting scene
  68006. * @returns the icosahedron mesh
  68007. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68008. */
  68009. static CreateIcoSphere(name: string, options: {
  68010. radius?: number;
  68011. radiusX?: number;
  68012. radiusY?: number;
  68013. radiusZ?: number;
  68014. flat?: boolean;
  68015. subdivisions?: number;
  68016. sideOrientation?: number;
  68017. frontUVs?: Vector4;
  68018. backUVs?: Vector4;
  68019. updatable?: boolean;
  68020. }, scene?: Nullable<Scene>): Mesh;
  68021. /**
  68022. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68023. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68024. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68025. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68026. * * 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
  68027. * * 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
  68028. * * 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
  68029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68031. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68032. * * 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
  68033. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68034. * * 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
  68035. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68037. * @param name defines the name of the mesh
  68038. * @param options defines the options used to create the mesh
  68039. * @param scene defines the hosting scene
  68040. * @returns the ribbon mesh
  68041. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68042. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68043. */
  68044. static CreateRibbon(name: string, options: {
  68045. pathArray: Vector3[][];
  68046. closeArray?: boolean;
  68047. closePath?: boolean;
  68048. offset?: number;
  68049. updatable?: boolean;
  68050. sideOrientation?: number;
  68051. frontUVs?: Vector4;
  68052. backUVs?: Vector4;
  68053. instance?: Mesh;
  68054. invertUV?: boolean;
  68055. uvs?: Vector2[];
  68056. colors?: Color4[];
  68057. }, scene?: Nullable<Scene>): Mesh;
  68058. /**
  68059. * Creates a cylinder or a cone mesh
  68060. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68061. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68062. * * 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.
  68063. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68064. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68065. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68066. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68067. * * 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).
  68068. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68069. * * 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).
  68070. * * 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
  68071. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68072. * * 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
  68073. * * 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.
  68074. * * If `enclose` is false, a ring surface is one element.
  68075. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68076. * * 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
  68077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68080. * @param name defines the name of the mesh
  68081. * @param options defines the options used to create the mesh
  68082. * @param scene defines the hosting scene
  68083. * @returns the cylinder mesh
  68084. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68085. */
  68086. static CreateCylinder(name: string, options: {
  68087. height?: number;
  68088. diameterTop?: number;
  68089. diameterBottom?: number;
  68090. diameter?: number;
  68091. tessellation?: number;
  68092. subdivisions?: number;
  68093. arc?: number;
  68094. faceColors?: Color4[];
  68095. faceUV?: Vector4[];
  68096. updatable?: boolean;
  68097. hasRings?: boolean;
  68098. enclose?: boolean;
  68099. cap?: number;
  68100. sideOrientation?: number;
  68101. frontUVs?: Vector4;
  68102. backUVs?: Vector4;
  68103. }, scene?: Nullable<Scene>): Mesh;
  68104. /**
  68105. * Creates a torus mesh
  68106. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68107. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68108. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68110. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68111. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68112. * @param name defines the name of the mesh
  68113. * @param options defines the options used to create the mesh
  68114. * @param scene defines the hosting scene
  68115. * @returns the torus mesh
  68116. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68117. */
  68118. static CreateTorus(name: string, options: {
  68119. diameter?: number;
  68120. thickness?: number;
  68121. tessellation?: number;
  68122. updatable?: boolean;
  68123. sideOrientation?: number;
  68124. frontUVs?: Vector4;
  68125. backUVs?: Vector4;
  68126. }, scene?: Nullable<Scene>): Mesh;
  68127. /**
  68128. * Creates a torus knot mesh
  68129. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68130. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68131. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68132. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68135. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68136. * @param name defines the name of the mesh
  68137. * @param options defines the options used to create the mesh
  68138. * @param scene defines the hosting scene
  68139. * @returns the torus knot mesh
  68140. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68141. */
  68142. static CreateTorusKnot(name: string, options: {
  68143. radius?: number;
  68144. tube?: number;
  68145. radialSegments?: number;
  68146. tubularSegments?: number;
  68147. p?: number;
  68148. q?: number;
  68149. updatable?: boolean;
  68150. sideOrientation?: number;
  68151. frontUVs?: Vector4;
  68152. backUVs?: Vector4;
  68153. }, scene?: Nullable<Scene>): Mesh;
  68154. /**
  68155. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68156. * * 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
  68157. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68158. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68159. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68160. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68161. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68162. * * 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
  68163. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68165. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68166. * @param name defines the name of the new line system
  68167. * @param options defines the options used to create the line system
  68168. * @param scene defines the hosting scene
  68169. * @returns a new line system mesh
  68170. */
  68171. static CreateLineSystem(name: string, options: {
  68172. lines: Vector3[][];
  68173. updatable?: boolean;
  68174. instance?: Nullable<LinesMesh>;
  68175. colors?: Nullable<Color4[][]>;
  68176. useVertexAlpha?: boolean;
  68177. }, scene: Nullable<Scene>): LinesMesh;
  68178. /**
  68179. * Creates a line mesh
  68180. * 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
  68181. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68182. * * The parameter `points` is an array successive Vector3
  68183. * * 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
  68184. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68185. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68186. * * When updating an instance, remember that only point positions can change, not the number of points
  68187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68189. * @param name defines the name of the new line system
  68190. * @param options defines the options used to create the line system
  68191. * @param scene defines the hosting scene
  68192. * @returns a new line mesh
  68193. */
  68194. static CreateLines(name: string, options: {
  68195. points: Vector3[];
  68196. updatable?: boolean;
  68197. instance?: Nullable<LinesMesh>;
  68198. colors?: Color4[];
  68199. useVertexAlpha?: boolean;
  68200. }, scene?: Nullable<Scene>): LinesMesh;
  68201. /**
  68202. * Creates a dashed line mesh
  68203. * * 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
  68204. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68205. * * The parameter `points` is an array successive Vector3
  68206. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68207. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68208. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68209. * * 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
  68210. * * When updating an instance, remember that only point positions can change, not the number of points
  68211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68212. * @param name defines the name of the mesh
  68213. * @param options defines the options used to create the mesh
  68214. * @param scene defines the hosting scene
  68215. * @returns the dashed line mesh
  68216. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68217. */
  68218. static CreateDashedLines(name: string, options: {
  68219. points: Vector3[];
  68220. dashSize?: number;
  68221. gapSize?: number;
  68222. dashNb?: number;
  68223. updatable?: boolean;
  68224. instance?: LinesMesh;
  68225. }, scene?: Nullable<Scene>): LinesMesh;
  68226. /**
  68227. * 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.
  68228. * * 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.
  68229. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68230. * * 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.
  68231. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68232. * * 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
  68233. * * 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
  68234. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68237. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68239. * @param name defines the name of the mesh
  68240. * @param options defines the options used to create the mesh
  68241. * @param scene defines the hosting scene
  68242. * @returns the extruded shape mesh
  68243. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68245. */
  68246. static ExtrudeShape(name: string, options: {
  68247. shape: Vector3[];
  68248. path: Vector3[];
  68249. scale?: number;
  68250. rotation?: number;
  68251. cap?: number;
  68252. updatable?: boolean;
  68253. sideOrientation?: number;
  68254. frontUVs?: Vector4;
  68255. backUVs?: Vector4;
  68256. instance?: Mesh;
  68257. invertUV?: boolean;
  68258. }, scene?: Nullable<Scene>): Mesh;
  68259. /**
  68260. * Creates an custom extruded shape mesh.
  68261. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68262. * * 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.
  68263. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68264. * * 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
  68265. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68266. * * 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
  68267. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68268. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68269. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68270. * * 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
  68271. * * 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
  68272. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68277. * @param name defines the name of the mesh
  68278. * @param options defines the options used to create the mesh
  68279. * @param scene defines the hosting scene
  68280. * @returns the custom extruded shape mesh
  68281. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68282. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68283. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68284. */
  68285. static ExtrudeShapeCustom(name: string, options: {
  68286. shape: Vector3[];
  68287. path: Vector3[];
  68288. scaleFunction?: any;
  68289. rotationFunction?: any;
  68290. ribbonCloseArray?: boolean;
  68291. ribbonClosePath?: boolean;
  68292. cap?: number;
  68293. updatable?: boolean;
  68294. sideOrientation?: number;
  68295. frontUVs?: Vector4;
  68296. backUVs?: Vector4;
  68297. instance?: Mesh;
  68298. invertUV?: boolean;
  68299. }, scene?: Nullable<Scene>): Mesh;
  68300. /**
  68301. * Creates lathe mesh.
  68302. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68303. * * 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
  68304. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68305. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68306. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68307. * * 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
  68308. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68309. * * 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
  68310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68311. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68312. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68314. * @param name defines the name of the mesh
  68315. * @param options defines the options used to create the mesh
  68316. * @param scene defines the hosting scene
  68317. * @returns the lathe mesh
  68318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68319. */
  68320. static CreateLathe(name: string, options: {
  68321. shape: Vector3[];
  68322. radius?: number;
  68323. tessellation?: number;
  68324. clip?: number;
  68325. arc?: number;
  68326. closed?: boolean;
  68327. updatable?: boolean;
  68328. sideOrientation?: number;
  68329. frontUVs?: Vector4;
  68330. backUVs?: Vector4;
  68331. cap?: number;
  68332. invertUV?: boolean;
  68333. }, scene?: Nullable<Scene>): Mesh;
  68334. /**
  68335. * Creates a tiled plane mesh
  68336. * * You can set a limited pattern arrangement with the tiles
  68337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68340. * @param name defines the name of the mesh
  68341. * @param options defines the options used to create the mesh
  68342. * @param scene defines the hosting scene
  68343. * @returns the plane mesh
  68344. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68345. */
  68346. static CreateTiledPlane(name: string, options: {
  68347. pattern?: number;
  68348. tileSize?: number;
  68349. tileWidth?: number;
  68350. tileHeight?: number;
  68351. size?: number;
  68352. width?: number;
  68353. height?: number;
  68354. alignHorizontal?: number;
  68355. alignVertical?: number;
  68356. sideOrientation?: number;
  68357. frontUVs?: Vector4;
  68358. backUVs?: Vector4;
  68359. updatable?: boolean;
  68360. }, scene?: Nullable<Scene>): Mesh;
  68361. /**
  68362. * Creates a plane mesh
  68363. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68364. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68365. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68369. * @param name defines the name of the mesh
  68370. * @param options defines the options used to create the mesh
  68371. * @param scene defines the hosting scene
  68372. * @returns the plane mesh
  68373. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68374. */
  68375. static CreatePlane(name: string, options: {
  68376. size?: number;
  68377. width?: number;
  68378. height?: number;
  68379. sideOrientation?: number;
  68380. frontUVs?: Vector4;
  68381. backUVs?: Vector4;
  68382. updatable?: boolean;
  68383. sourcePlane?: Plane;
  68384. }, scene?: Nullable<Scene>): Mesh;
  68385. /**
  68386. * Creates a ground mesh
  68387. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68388. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68390. * @param name defines the name of the mesh
  68391. * @param options defines the options used to create the mesh
  68392. * @param scene defines the hosting scene
  68393. * @returns the ground mesh
  68394. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68395. */
  68396. static CreateGround(name: string, options: {
  68397. width?: number;
  68398. height?: number;
  68399. subdivisions?: number;
  68400. subdivisionsX?: number;
  68401. subdivisionsY?: number;
  68402. updatable?: boolean;
  68403. }, scene?: Nullable<Scene>): Mesh;
  68404. /**
  68405. * Creates a tiled ground mesh
  68406. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68407. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68408. * * 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
  68409. * * 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
  68410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68411. * @param name defines the name of the mesh
  68412. * @param options defines the options used to create the mesh
  68413. * @param scene defines the hosting scene
  68414. * @returns the tiled ground mesh
  68415. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68416. */
  68417. static CreateTiledGround(name: string, options: {
  68418. xmin: number;
  68419. zmin: number;
  68420. xmax: number;
  68421. zmax: number;
  68422. subdivisions?: {
  68423. w: number;
  68424. h: number;
  68425. };
  68426. precision?: {
  68427. w: number;
  68428. h: number;
  68429. };
  68430. updatable?: boolean;
  68431. }, scene?: Nullable<Scene>): Mesh;
  68432. /**
  68433. * Creates a ground mesh from a height map
  68434. * * The parameter `url` sets the URL of the height map image resource.
  68435. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68436. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68437. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68438. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68439. * * 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.
  68440. * * 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).
  68441. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68443. * @param name defines the name of the mesh
  68444. * @param url defines the url to the height map
  68445. * @param options defines the options used to create the mesh
  68446. * @param scene defines the hosting scene
  68447. * @returns the ground mesh
  68448. * @see https://doc.babylonjs.com/babylon101/height_map
  68449. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68450. */
  68451. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68452. width?: number;
  68453. height?: number;
  68454. subdivisions?: number;
  68455. minHeight?: number;
  68456. maxHeight?: number;
  68457. colorFilter?: Color3;
  68458. alphaFilter?: number;
  68459. updatable?: boolean;
  68460. onReady?: (mesh: GroundMesh) => void;
  68461. }, scene?: Nullable<Scene>): GroundMesh;
  68462. /**
  68463. * Creates a polygon mesh
  68464. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68465. * * 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
  68466. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68469. * * Remember you can only change the shape positions, not their number when updating a polygon
  68470. * @param name defines the name of the mesh
  68471. * @param options defines the options used to create the mesh
  68472. * @param scene defines the hosting scene
  68473. * @param earcutInjection can be used to inject your own earcut reference
  68474. * @returns the polygon mesh
  68475. */
  68476. static CreatePolygon(name: string, options: {
  68477. shape: Vector3[];
  68478. holes?: Vector3[][];
  68479. depth?: number;
  68480. faceUV?: Vector4[];
  68481. faceColors?: Color4[];
  68482. updatable?: boolean;
  68483. sideOrientation?: number;
  68484. frontUVs?: Vector4;
  68485. backUVs?: Vector4;
  68486. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68487. /**
  68488. * Creates an extruded polygon mesh, with depth in the Y direction.
  68489. * * 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)
  68490. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68491. * @param name defines the name of the mesh
  68492. * @param options defines the options used to create the mesh
  68493. * @param scene defines the hosting scene
  68494. * @param earcutInjection can be used to inject your own earcut reference
  68495. * @returns the polygon mesh
  68496. */
  68497. static ExtrudePolygon(name: string, options: {
  68498. shape: Vector3[];
  68499. holes?: Vector3[][];
  68500. depth?: number;
  68501. faceUV?: Vector4[];
  68502. faceColors?: Color4[];
  68503. updatable?: boolean;
  68504. sideOrientation?: number;
  68505. frontUVs?: Vector4;
  68506. backUVs?: Vector4;
  68507. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68508. /**
  68509. * Creates a tube mesh.
  68510. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68511. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68512. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68513. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68514. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68515. * * 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)
  68516. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68517. * * 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
  68518. * * 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
  68519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68521. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68523. * @param name defines the name of the mesh
  68524. * @param options defines the options used to create the mesh
  68525. * @param scene defines the hosting scene
  68526. * @returns the tube mesh
  68527. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68528. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68529. */
  68530. static CreateTube(name: string, options: {
  68531. path: Vector3[];
  68532. radius?: number;
  68533. tessellation?: number;
  68534. radiusFunction?: {
  68535. (i: number, distance: number): number;
  68536. };
  68537. cap?: number;
  68538. arc?: number;
  68539. updatable?: boolean;
  68540. sideOrientation?: number;
  68541. frontUVs?: Vector4;
  68542. backUVs?: Vector4;
  68543. instance?: Mesh;
  68544. invertUV?: boolean;
  68545. }, scene?: Nullable<Scene>): Mesh;
  68546. /**
  68547. * Creates a polyhedron mesh
  68548. * * 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
  68549. * * The parameter `size` (positive float, default 1) sets the polygon size
  68550. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68551. * * 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`
  68552. * * 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
  68553. * * 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)`)
  68554. * * 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
  68555. * * 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
  68556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68559. * @param name defines the name of the mesh
  68560. * @param options defines the options used to create the mesh
  68561. * @param scene defines the hosting scene
  68562. * @returns the polyhedron mesh
  68563. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68564. */
  68565. static CreatePolyhedron(name: string, options: {
  68566. type?: number;
  68567. size?: number;
  68568. sizeX?: number;
  68569. sizeY?: number;
  68570. sizeZ?: number;
  68571. custom?: any;
  68572. faceUV?: Vector4[];
  68573. faceColors?: Color4[];
  68574. flat?: boolean;
  68575. updatable?: boolean;
  68576. sideOrientation?: number;
  68577. frontUVs?: Vector4;
  68578. backUVs?: Vector4;
  68579. }, scene?: Nullable<Scene>): Mesh;
  68580. /**
  68581. * Creates a decal mesh.
  68582. * 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
  68583. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68584. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68585. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68586. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68587. * @param name defines the name of the mesh
  68588. * @param sourceMesh defines the mesh where the decal must be applied
  68589. * @param options defines the options used to create the mesh
  68590. * @param scene defines the hosting scene
  68591. * @returns the decal mesh
  68592. * @see https://doc.babylonjs.com/how_to/decals
  68593. */
  68594. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68595. position?: Vector3;
  68596. normal?: Vector3;
  68597. size?: Vector3;
  68598. angle?: number;
  68599. }): Mesh;
  68600. }
  68601. }
  68602. declare module "babylonjs/Meshes/meshSimplification" {
  68603. import { Mesh } from "babylonjs/Meshes/mesh";
  68604. /**
  68605. * A simplifier interface for future simplification implementations
  68606. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68607. */
  68608. export interface ISimplifier {
  68609. /**
  68610. * Simplification of a given mesh according to the given settings.
  68611. * Since this requires computation, it is assumed that the function runs async.
  68612. * @param settings The settings of the simplification, including quality and distance
  68613. * @param successCallback A callback that will be called after the mesh was simplified.
  68614. * @param errorCallback in case of an error, this callback will be called. optional.
  68615. */
  68616. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68617. }
  68618. /**
  68619. * Expected simplification settings.
  68620. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68621. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68622. */
  68623. export interface ISimplificationSettings {
  68624. /**
  68625. * Gets or sets the expected quality
  68626. */
  68627. quality: number;
  68628. /**
  68629. * Gets or sets the distance when this optimized version should be used
  68630. */
  68631. distance: number;
  68632. /**
  68633. * Gets an already optimized mesh
  68634. */
  68635. optimizeMesh?: boolean;
  68636. }
  68637. /**
  68638. * Class used to specify simplification options
  68639. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68640. */
  68641. export class SimplificationSettings implements ISimplificationSettings {
  68642. /** expected quality */
  68643. quality: number;
  68644. /** distance when this optimized version should be used */
  68645. distance: number;
  68646. /** already optimized mesh */
  68647. optimizeMesh?: boolean | undefined;
  68648. /**
  68649. * Creates a SimplificationSettings
  68650. * @param quality expected quality
  68651. * @param distance distance when this optimized version should be used
  68652. * @param optimizeMesh already optimized mesh
  68653. */
  68654. constructor(
  68655. /** expected quality */
  68656. quality: number,
  68657. /** distance when this optimized version should be used */
  68658. distance: number,
  68659. /** already optimized mesh */
  68660. optimizeMesh?: boolean | undefined);
  68661. }
  68662. /**
  68663. * Interface used to define a simplification task
  68664. */
  68665. export interface ISimplificationTask {
  68666. /**
  68667. * Array of settings
  68668. */
  68669. settings: Array<ISimplificationSettings>;
  68670. /**
  68671. * Simplification type
  68672. */
  68673. simplificationType: SimplificationType;
  68674. /**
  68675. * Mesh to simplify
  68676. */
  68677. mesh: Mesh;
  68678. /**
  68679. * Callback called on success
  68680. */
  68681. successCallback?: () => void;
  68682. /**
  68683. * Defines if parallel processing can be used
  68684. */
  68685. parallelProcessing: boolean;
  68686. }
  68687. /**
  68688. * Queue used to order the simplification tasks
  68689. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68690. */
  68691. export class SimplificationQueue {
  68692. private _simplificationArray;
  68693. /**
  68694. * Gets a boolean indicating that the process is still running
  68695. */
  68696. running: boolean;
  68697. /**
  68698. * Creates a new queue
  68699. */
  68700. constructor();
  68701. /**
  68702. * Adds a new simplification task
  68703. * @param task defines a task to add
  68704. */
  68705. addTask(task: ISimplificationTask): void;
  68706. /**
  68707. * Execute next task
  68708. */
  68709. executeNext(): void;
  68710. /**
  68711. * Execute a simplification task
  68712. * @param task defines the task to run
  68713. */
  68714. runSimplification(task: ISimplificationTask): void;
  68715. private getSimplifier;
  68716. }
  68717. /**
  68718. * The implemented types of simplification
  68719. * At the moment only Quadratic Error Decimation is implemented
  68720. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68721. */
  68722. export enum SimplificationType {
  68723. /** Quadratic error decimation */
  68724. QUADRATIC = 0
  68725. }
  68726. /**
  68727. * An implementation of the Quadratic Error simplification algorithm.
  68728. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68729. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68730. * @author RaananW
  68731. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68732. */
  68733. export class QuadraticErrorSimplification implements ISimplifier {
  68734. private _mesh;
  68735. private triangles;
  68736. private vertices;
  68737. private references;
  68738. private _reconstructedMesh;
  68739. /** Gets or sets the number pf sync interations */
  68740. syncIterations: number;
  68741. /** Gets or sets the aggressiveness of the simplifier */
  68742. aggressiveness: number;
  68743. /** Gets or sets the number of allowed iterations for decimation */
  68744. decimationIterations: number;
  68745. /** Gets or sets the espilon to use for bounding box computation */
  68746. boundingBoxEpsilon: number;
  68747. /**
  68748. * Creates a new QuadraticErrorSimplification
  68749. * @param _mesh defines the target mesh
  68750. */
  68751. constructor(_mesh: Mesh);
  68752. /**
  68753. * Simplification of a given mesh according to the given settings.
  68754. * Since this requires computation, it is assumed that the function runs async.
  68755. * @param settings The settings of the simplification, including quality and distance
  68756. * @param successCallback A callback that will be called after the mesh was simplified.
  68757. */
  68758. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68759. private runDecimation;
  68760. private initWithMesh;
  68761. private init;
  68762. private reconstructMesh;
  68763. private initDecimatedMesh;
  68764. private isFlipped;
  68765. private updateTriangles;
  68766. private identifyBorder;
  68767. private updateMesh;
  68768. private vertexError;
  68769. private calculateError;
  68770. }
  68771. }
  68772. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68773. import { Scene } from "babylonjs/scene";
  68774. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68775. import { ISceneComponent } from "babylonjs/sceneComponent";
  68776. module "babylonjs/scene" {
  68777. interface Scene {
  68778. /** @hidden (Backing field) */
  68779. _simplificationQueue: SimplificationQueue;
  68780. /**
  68781. * Gets or sets the simplification queue attached to the scene
  68782. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68783. */
  68784. simplificationQueue: SimplificationQueue;
  68785. }
  68786. }
  68787. module "babylonjs/Meshes/mesh" {
  68788. interface Mesh {
  68789. /**
  68790. * Simplify the mesh according to the given array of settings.
  68791. * Function will return immediately and will simplify async
  68792. * @param settings a collection of simplification settings
  68793. * @param parallelProcessing should all levels calculate parallel or one after the other
  68794. * @param simplificationType the type of simplification to run
  68795. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68796. * @returns the current mesh
  68797. */
  68798. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68799. }
  68800. }
  68801. /**
  68802. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68803. * created in a scene
  68804. */
  68805. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68806. /**
  68807. * The component name helpfull to identify the component in the list of scene components.
  68808. */
  68809. readonly name: string;
  68810. /**
  68811. * The scene the component belongs to.
  68812. */
  68813. scene: Scene;
  68814. /**
  68815. * Creates a new instance of the component for the given scene
  68816. * @param scene Defines the scene to register the component in
  68817. */
  68818. constructor(scene: Scene);
  68819. /**
  68820. * Registers the component in a given scene
  68821. */
  68822. register(): void;
  68823. /**
  68824. * Rebuilds the elements related to this component in case of
  68825. * context lost for instance.
  68826. */
  68827. rebuild(): void;
  68828. /**
  68829. * Disposes the component and the associated ressources
  68830. */
  68831. dispose(): void;
  68832. private _beforeCameraUpdate;
  68833. }
  68834. }
  68835. declare module "babylonjs/Meshes/Builders/index" {
  68836. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68837. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68838. export * from "babylonjs/Meshes/Builders/discBuilder";
  68839. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68840. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68841. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68842. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68843. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68844. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68845. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68846. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68847. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68848. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68849. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68850. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68851. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68852. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68853. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68854. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68855. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68856. }
  68857. declare module "babylonjs/Meshes/thinInstanceMesh" {
  68858. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  68859. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  68860. import { Matrix } from "babylonjs/Maths/math.vector";
  68861. module "babylonjs/Meshes/mesh" {
  68862. interface Mesh {
  68863. /**
  68864. * Creates a new thin instance
  68865. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68866. * @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
  68867. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68868. */
  68869. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68870. /**
  68871. * Adds the transformation (matrix) of the current mesh as a thin instance
  68872. * @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
  68873. * @returns the thin instance index number
  68874. */
  68875. thinInstanceAddSelf(refresh: boolean): number;
  68876. /**
  68877. * Registers a custom attribute to be used with thin instances
  68878. * @param kind name of the attribute
  68879. * @param stride size in floats of the attribute
  68880. */
  68881. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68882. /**
  68883. * Sets the matrix of a thin instance
  68884. * @param index index of the thin instance
  68885. * @param matrix matrix to set
  68886. * @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
  68887. */
  68888. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68889. /**
  68890. * Sets the value of a custom attribute for a thin instance
  68891. * @param kind name of the attribute
  68892. * @param index index of the thin instance
  68893. * @param value value to set
  68894. * @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
  68895. */
  68896. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68897. /**
  68898. * 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.
  68899. */
  68900. thinInstanceCount: number;
  68901. /**
  68902. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68903. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68904. * @param buffer buffer to set
  68905. * @param stride size in floats of each value of the buffer
  68906. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68907. */
  68908. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68909. /**
  68910. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68911. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68912. */
  68913. thinInstanceBufferUpdated(kind: string): void;
  68914. /**
  68915. * Refreshes the bounding info, taking into account all the thin instances defined
  68916. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68917. */
  68918. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68919. /** @hidden */
  68920. _thinInstanceInitializeUserStorage(): void;
  68921. /** @hidden */
  68922. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68923. /** @hidden */
  68924. _userThinInstanceBuffersStorage: {
  68925. data: {
  68926. [key: string]: Float32Array;
  68927. };
  68928. sizes: {
  68929. [key: string]: number;
  68930. };
  68931. vertexBuffers: {
  68932. [key: string]: Nullable<VertexBuffer>;
  68933. };
  68934. strides: {
  68935. [key: string]: number;
  68936. };
  68937. };
  68938. }
  68939. }
  68940. }
  68941. declare module "babylonjs/Meshes/index" {
  68942. export * from "babylonjs/Meshes/abstractMesh";
  68943. export * from "babylonjs/Meshes/buffer";
  68944. export * from "babylonjs/Meshes/Compression/index";
  68945. export * from "babylonjs/Meshes/csg";
  68946. export * from "babylonjs/Meshes/geometry";
  68947. export * from "babylonjs/Meshes/groundMesh";
  68948. export * from "babylonjs/Meshes/trailMesh";
  68949. export * from "babylonjs/Meshes/instancedMesh";
  68950. export * from "babylonjs/Meshes/linesMesh";
  68951. export * from "babylonjs/Meshes/mesh";
  68952. export * from "babylonjs/Meshes/mesh.vertexData";
  68953. export * from "babylonjs/Meshes/meshBuilder";
  68954. export * from "babylonjs/Meshes/meshSimplification";
  68955. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  68956. export * from "babylonjs/Meshes/polygonMesh";
  68957. export * from "babylonjs/Meshes/subMesh";
  68958. export * from "babylonjs/Meshes/meshLODLevel";
  68959. export * from "babylonjs/Meshes/transformNode";
  68960. export * from "babylonjs/Meshes/Builders/index";
  68961. export * from "babylonjs/Meshes/dataBuffer";
  68962. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  68963. import "babylonjs/Meshes/thinInstanceMesh";
  68964. export * from "babylonjs/Meshes/thinInstanceMesh";
  68965. }
  68966. declare module "babylonjs/Morph/index" {
  68967. export * from "babylonjs/Morph/morphTarget";
  68968. export * from "babylonjs/Morph/morphTargetManager";
  68969. }
  68970. declare module "babylonjs/Navigation/INavigationEngine" {
  68971. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68972. import { Vector3 } from "babylonjs/Maths/math";
  68973. import { Mesh } from "babylonjs/Meshes/mesh";
  68974. import { Scene } from "babylonjs/scene";
  68975. /**
  68976. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68977. */
  68978. export interface INavigationEnginePlugin {
  68979. /**
  68980. * plugin name
  68981. */
  68982. name: string;
  68983. /**
  68984. * Creates a navigation mesh
  68985. * @param meshes array of all the geometry used to compute the navigatio mesh
  68986. * @param parameters bunch of parameters used to filter geometry
  68987. */
  68988. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68989. /**
  68990. * Create a navigation mesh debug mesh
  68991. * @param scene is where the mesh will be added
  68992. * @returns debug display mesh
  68993. */
  68994. createDebugNavMesh(scene: Scene): Mesh;
  68995. /**
  68996. * Get a navigation mesh constrained position, closest to the parameter position
  68997. * @param position world position
  68998. * @returns the closest point to position constrained by the navigation mesh
  68999. */
  69000. getClosestPoint(position: Vector3): Vector3;
  69001. /**
  69002. * Get a navigation mesh constrained position, closest to the parameter position
  69003. * @param position world position
  69004. * @param result output the closest point to position constrained by the navigation mesh
  69005. */
  69006. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69007. /**
  69008. * Get a navigation mesh constrained position, within a particular radius
  69009. * @param position world position
  69010. * @param maxRadius the maximum distance to the constrained world position
  69011. * @returns the closest point to position constrained by the navigation mesh
  69012. */
  69013. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69014. /**
  69015. * Get a navigation mesh constrained position, within a particular radius
  69016. * @param position world position
  69017. * @param maxRadius the maximum distance to the constrained world position
  69018. * @param result output the closest point to position constrained by the navigation mesh
  69019. */
  69020. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69021. /**
  69022. * Compute the final position from a segment made of destination-position
  69023. * @param position world position
  69024. * @param destination world position
  69025. * @returns the resulting point along the navmesh
  69026. */
  69027. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69028. /**
  69029. * Compute the final position from a segment made of destination-position
  69030. * @param position world position
  69031. * @param destination world position
  69032. * @param result output the resulting point along the navmesh
  69033. */
  69034. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69035. /**
  69036. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69037. * @param start world position
  69038. * @param end world position
  69039. * @returns array containing world position composing the path
  69040. */
  69041. computePath(start: Vector3, end: Vector3): Vector3[];
  69042. /**
  69043. * If this plugin is supported
  69044. * @returns true if plugin is supported
  69045. */
  69046. isSupported(): boolean;
  69047. /**
  69048. * Create a new Crowd so you can add agents
  69049. * @param maxAgents the maximum agent count in the crowd
  69050. * @param maxAgentRadius the maximum radius an agent can have
  69051. * @param scene to attach the crowd to
  69052. * @returns the crowd you can add agents to
  69053. */
  69054. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69055. /**
  69056. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69057. * The queries will try to find a solution within those bounds
  69058. * default is (1,1,1)
  69059. * @param extent x,y,z value that define the extent around the queries point of reference
  69060. */
  69061. setDefaultQueryExtent(extent: Vector3): void;
  69062. /**
  69063. * Get the Bounding box extent specified by setDefaultQueryExtent
  69064. * @returns the box extent values
  69065. */
  69066. getDefaultQueryExtent(): Vector3;
  69067. /**
  69068. * build the navmesh from a previously saved state using getNavmeshData
  69069. * @param data the Uint8Array returned by getNavmeshData
  69070. */
  69071. buildFromNavmeshData(data: Uint8Array): void;
  69072. /**
  69073. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69074. * @returns data the Uint8Array that can be saved and reused
  69075. */
  69076. getNavmeshData(): Uint8Array;
  69077. /**
  69078. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69079. * @param result output the box extent values
  69080. */
  69081. getDefaultQueryExtentToRef(result: Vector3): void;
  69082. /**
  69083. * Release all resources
  69084. */
  69085. dispose(): void;
  69086. }
  69087. /**
  69088. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69089. */
  69090. export interface ICrowd {
  69091. /**
  69092. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69093. * You can attach anything to that node. The node position is updated in the scene update tick.
  69094. * @param pos world position that will be constrained by the navigation mesh
  69095. * @param parameters agent parameters
  69096. * @param transform hooked to the agent that will be update by the scene
  69097. * @returns agent index
  69098. */
  69099. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69100. /**
  69101. * Returns the agent position in world space
  69102. * @param index agent index returned by addAgent
  69103. * @returns world space position
  69104. */
  69105. getAgentPosition(index: number): Vector3;
  69106. /**
  69107. * Gets the agent position result in world space
  69108. * @param index agent index returned by addAgent
  69109. * @param result output world space position
  69110. */
  69111. getAgentPositionToRef(index: number, result: Vector3): void;
  69112. /**
  69113. * Gets the agent velocity in world space
  69114. * @param index agent index returned by addAgent
  69115. * @returns world space velocity
  69116. */
  69117. getAgentVelocity(index: number): Vector3;
  69118. /**
  69119. * Gets the agent velocity result in world space
  69120. * @param index agent index returned by addAgent
  69121. * @param result output world space velocity
  69122. */
  69123. getAgentVelocityToRef(index: number, result: Vector3): void;
  69124. /**
  69125. * remove a particular agent previously created
  69126. * @param index agent index returned by addAgent
  69127. */
  69128. removeAgent(index: number): void;
  69129. /**
  69130. * get the list of all agents attached to this crowd
  69131. * @returns list of agent indices
  69132. */
  69133. getAgents(): number[];
  69134. /**
  69135. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69136. * @param deltaTime in seconds
  69137. */
  69138. update(deltaTime: number): void;
  69139. /**
  69140. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69141. * @param index agent index returned by addAgent
  69142. * @param destination targeted world position
  69143. */
  69144. agentGoto(index: number, destination: Vector3): void;
  69145. /**
  69146. * Teleport the agent to a new position
  69147. * @param index agent index returned by addAgent
  69148. * @param destination targeted world position
  69149. */
  69150. agentTeleport(index: number, destination: Vector3): void;
  69151. /**
  69152. * Update agent parameters
  69153. * @param index agent index returned by addAgent
  69154. * @param parameters agent parameters
  69155. */
  69156. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69157. /**
  69158. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69159. * The queries will try to find a solution within those bounds
  69160. * default is (1,1,1)
  69161. * @param extent x,y,z value that define the extent around the queries point of reference
  69162. */
  69163. setDefaultQueryExtent(extent: Vector3): void;
  69164. /**
  69165. * Get the Bounding box extent specified by setDefaultQueryExtent
  69166. * @returns the box extent values
  69167. */
  69168. getDefaultQueryExtent(): Vector3;
  69169. /**
  69170. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69171. * @param result output the box extent values
  69172. */
  69173. getDefaultQueryExtentToRef(result: Vector3): void;
  69174. /**
  69175. * Release all resources
  69176. */
  69177. dispose(): void;
  69178. }
  69179. /**
  69180. * Configures an agent
  69181. */
  69182. export interface IAgentParameters {
  69183. /**
  69184. * Agent radius. [Limit: >= 0]
  69185. */
  69186. radius: number;
  69187. /**
  69188. * Agent height. [Limit: > 0]
  69189. */
  69190. height: number;
  69191. /**
  69192. * Maximum allowed acceleration. [Limit: >= 0]
  69193. */
  69194. maxAcceleration: number;
  69195. /**
  69196. * Maximum allowed speed. [Limit: >= 0]
  69197. */
  69198. maxSpeed: number;
  69199. /**
  69200. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69201. */
  69202. collisionQueryRange: number;
  69203. /**
  69204. * The path visibility optimization range. [Limit: > 0]
  69205. */
  69206. pathOptimizationRange: number;
  69207. /**
  69208. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69209. */
  69210. separationWeight: number;
  69211. }
  69212. /**
  69213. * Configures the navigation mesh creation
  69214. */
  69215. export interface INavMeshParameters {
  69216. /**
  69217. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69218. */
  69219. cs: number;
  69220. /**
  69221. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69222. */
  69223. ch: number;
  69224. /**
  69225. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69226. */
  69227. walkableSlopeAngle: number;
  69228. /**
  69229. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69230. * be considered walkable. [Limit: >= 3] [Units: vx]
  69231. */
  69232. walkableHeight: number;
  69233. /**
  69234. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69235. */
  69236. walkableClimb: number;
  69237. /**
  69238. * The distance to erode/shrink the walkable area of the heightfield away from
  69239. * obstructions. [Limit: >=0] [Units: vx]
  69240. */
  69241. walkableRadius: number;
  69242. /**
  69243. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69244. */
  69245. maxEdgeLen: number;
  69246. /**
  69247. * The maximum distance a simplfied contour's border edges should deviate
  69248. * the original raw contour. [Limit: >=0] [Units: vx]
  69249. */
  69250. maxSimplificationError: number;
  69251. /**
  69252. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69253. */
  69254. minRegionArea: number;
  69255. /**
  69256. * Any regions with a span count smaller than this value will, if possible,
  69257. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69258. */
  69259. mergeRegionArea: number;
  69260. /**
  69261. * The maximum number of vertices allowed for polygons generated during the
  69262. * contour to polygon conversion process. [Limit: >= 3]
  69263. */
  69264. maxVertsPerPoly: number;
  69265. /**
  69266. * Sets the sampling distance to use when generating the detail mesh.
  69267. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69268. */
  69269. detailSampleDist: number;
  69270. /**
  69271. * The maximum distance the detail mesh surface should deviate from heightfield
  69272. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69273. */
  69274. detailSampleMaxError: number;
  69275. }
  69276. }
  69277. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69278. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69279. import { Mesh } from "babylonjs/Meshes/mesh";
  69280. import { Scene } from "babylonjs/scene";
  69281. import { Vector3 } from "babylonjs/Maths/math";
  69282. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69283. /**
  69284. * RecastJS navigation plugin
  69285. */
  69286. export class RecastJSPlugin implements INavigationEnginePlugin {
  69287. /**
  69288. * Reference to the Recast library
  69289. */
  69290. bjsRECAST: any;
  69291. /**
  69292. * plugin name
  69293. */
  69294. name: string;
  69295. /**
  69296. * the first navmesh created. We might extend this to support multiple navmeshes
  69297. */
  69298. navMesh: any;
  69299. /**
  69300. * Initializes the recastJS plugin
  69301. * @param recastInjection can be used to inject your own recast reference
  69302. */
  69303. constructor(recastInjection?: any);
  69304. /**
  69305. * Creates a navigation mesh
  69306. * @param meshes array of all the geometry used to compute the navigatio mesh
  69307. * @param parameters bunch of parameters used to filter geometry
  69308. */
  69309. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69310. /**
  69311. * Create a navigation mesh debug mesh
  69312. * @param scene is where the mesh will be added
  69313. * @returns debug display mesh
  69314. */
  69315. createDebugNavMesh(scene: Scene): Mesh;
  69316. /**
  69317. * Get a navigation mesh constrained position, closest to the parameter position
  69318. * @param position world position
  69319. * @returns the closest point to position constrained by the navigation mesh
  69320. */
  69321. getClosestPoint(position: Vector3): Vector3;
  69322. /**
  69323. * Get a navigation mesh constrained position, closest to the parameter position
  69324. * @param position world position
  69325. * @param result output the closest point to position constrained by the navigation mesh
  69326. */
  69327. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69328. /**
  69329. * Get a navigation mesh constrained position, within a particular radius
  69330. * @param position world position
  69331. * @param maxRadius the maximum distance to the constrained world position
  69332. * @returns the closest point to position constrained by the navigation mesh
  69333. */
  69334. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69335. /**
  69336. * Get a navigation mesh constrained position, within a particular radius
  69337. * @param position world position
  69338. * @param maxRadius the maximum distance to the constrained world position
  69339. * @param result output the closest point to position constrained by the navigation mesh
  69340. */
  69341. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69342. /**
  69343. * Compute the final position from a segment made of destination-position
  69344. * @param position world position
  69345. * @param destination world position
  69346. * @returns the resulting point along the navmesh
  69347. */
  69348. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69349. /**
  69350. * Compute the final position from a segment made of destination-position
  69351. * @param position world position
  69352. * @param destination world position
  69353. * @param result output the resulting point along the navmesh
  69354. */
  69355. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69356. /**
  69357. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69358. * @param start world position
  69359. * @param end world position
  69360. * @returns array containing world position composing the path
  69361. */
  69362. computePath(start: Vector3, end: Vector3): Vector3[];
  69363. /**
  69364. * Create a new Crowd so you can add agents
  69365. * @param maxAgents the maximum agent count in the crowd
  69366. * @param maxAgentRadius the maximum radius an agent can have
  69367. * @param scene to attach the crowd to
  69368. * @returns the crowd you can add agents to
  69369. */
  69370. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69371. /**
  69372. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69373. * The queries will try to find a solution within those bounds
  69374. * default is (1,1,1)
  69375. * @param extent x,y,z value that define the extent around the queries point of reference
  69376. */
  69377. setDefaultQueryExtent(extent: Vector3): void;
  69378. /**
  69379. * Get the Bounding box extent specified by setDefaultQueryExtent
  69380. * @returns the box extent values
  69381. */
  69382. getDefaultQueryExtent(): Vector3;
  69383. /**
  69384. * build the navmesh from a previously saved state using getNavmeshData
  69385. * @param data the Uint8Array returned by getNavmeshData
  69386. */
  69387. buildFromNavmeshData(data: Uint8Array): void;
  69388. /**
  69389. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69390. * @returns data the Uint8Array that can be saved and reused
  69391. */
  69392. getNavmeshData(): Uint8Array;
  69393. /**
  69394. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69395. * @param result output the box extent values
  69396. */
  69397. getDefaultQueryExtentToRef(result: Vector3): void;
  69398. /**
  69399. * Disposes
  69400. */
  69401. dispose(): void;
  69402. /**
  69403. * If this plugin is supported
  69404. * @returns true if plugin is supported
  69405. */
  69406. isSupported(): boolean;
  69407. }
  69408. /**
  69409. * Recast detour crowd implementation
  69410. */
  69411. export class RecastJSCrowd implements ICrowd {
  69412. /**
  69413. * Recast/detour plugin
  69414. */
  69415. bjsRECASTPlugin: RecastJSPlugin;
  69416. /**
  69417. * Link to the detour crowd
  69418. */
  69419. recastCrowd: any;
  69420. /**
  69421. * One transform per agent
  69422. */
  69423. transforms: TransformNode[];
  69424. /**
  69425. * All agents created
  69426. */
  69427. agents: number[];
  69428. /**
  69429. * Link to the scene is kept to unregister the crowd from the scene
  69430. */
  69431. private _scene;
  69432. /**
  69433. * Observer for crowd updates
  69434. */
  69435. private _onBeforeAnimationsObserver;
  69436. /**
  69437. * Constructor
  69438. * @param plugin recastJS plugin
  69439. * @param maxAgents the maximum agent count in the crowd
  69440. * @param maxAgentRadius the maximum radius an agent can have
  69441. * @param scene to attach the crowd to
  69442. * @returns the crowd you can add agents to
  69443. */
  69444. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69445. /**
  69446. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69447. * You can attach anything to that node. The node position is updated in the scene update tick.
  69448. * @param pos world position that will be constrained by the navigation mesh
  69449. * @param parameters agent parameters
  69450. * @param transform hooked to the agent that will be update by the scene
  69451. * @returns agent index
  69452. */
  69453. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69454. /**
  69455. * Returns the agent position in world space
  69456. * @param index agent index returned by addAgent
  69457. * @returns world space position
  69458. */
  69459. getAgentPosition(index: number): Vector3;
  69460. /**
  69461. * Returns the agent position result in world space
  69462. * @param index agent index returned by addAgent
  69463. * @param result output world space position
  69464. */
  69465. getAgentPositionToRef(index: number, result: Vector3): void;
  69466. /**
  69467. * Returns the agent velocity in world space
  69468. * @param index agent index returned by addAgent
  69469. * @returns world space velocity
  69470. */
  69471. getAgentVelocity(index: number): Vector3;
  69472. /**
  69473. * Returns the agent velocity result in world space
  69474. * @param index agent index returned by addAgent
  69475. * @param result output world space velocity
  69476. */
  69477. getAgentVelocityToRef(index: number, result: Vector3): void;
  69478. /**
  69479. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69480. * @param index agent index returned by addAgent
  69481. * @param destination targeted world position
  69482. */
  69483. agentGoto(index: number, destination: Vector3): void;
  69484. /**
  69485. * Teleport the agent to a new position
  69486. * @param index agent index returned by addAgent
  69487. * @param destination targeted world position
  69488. */
  69489. agentTeleport(index: number, destination: Vector3): void;
  69490. /**
  69491. * Update agent parameters
  69492. * @param index agent index returned by addAgent
  69493. * @param parameters agent parameters
  69494. */
  69495. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69496. /**
  69497. * remove a particular agent previously created
  69498. * @param index agent index returned by addAgent
  69499. */
  69500. removeAgent(index: number): void;
  69501. /**
  69502. * get the list of all agents attached to this crowd
  69503. * @returns list of agent indices
  69504. */
  69505. getAgents(): number[];
  69506. /**
  69507. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69508. * @param deltaTime in seconds
  69509. */
  69510. update(deltaTime: number): void;
  69511. /**
  69512. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69513. * The queries will try to find a solution within those bounds
  69514. * default is (1,1,1)
  69515. * @param extent x,y,z value that define the extent around the queries point of reference
  69516. */
  69517. setDefaultQueryExtent(extent: Vector3): void;
  69518. /**
  69519. * Get the Bounding box extent specified by setDefaultQueryExtent
  69520. * @returns the box extent values
  69521. */
  69522. getDefaultQueryExtent(): Vector3;
  69523. /**
  69524. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69525. * @param result output the box extent values
  69526. */
  69527. getDefaultQueryExtentToRef(result: Vector3): void;
  69528. /**
  69529. * Release all resources
  69530. */
  69531. dispose(): void;
  69532. }
  69533. }
  69534. declare module "babylonjs/Navigation/Plugins/index" {
  69535. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69536. }
  69537. declare module "babylonjs/Navigation/index" {
  69538. export * from "babylonjs/Navigation/INavigationEngine";
  69539. export * from "babylonjs/Navigation/Plugins/index";
  69540. }
  69541. declare module "babylonjs/Offline/database" {
  69542. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69543. /**
  69544. * Class used to enable access to IndexedDB
  69545. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69546. */
  69547. export class Database implements IOfflineProvider {
  69548. private _callbackManifestChecked;
  69549. private _currentSceneUrl;
  69550. private _db;
  69551. private _enableSceneOffline;
  69552. private _enableTexturesOffline;
  69553. private _manifestVersionFound;
  69554. private _mustUpdateRessources;
  69555. private _hasReachedQuota;
  69556. private _isSupported;
  69557. private _idbFactory;
  69558. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69559. private static IsUASupportingBlobStorage;
  69560. /**
  69561. * Gets a boolean indicating if Database storate is enabled (off by default)
  69562. */
  69563. static IDBStorageEnabled: boolean;
  69564. /**
  69565. * Gets a boolean indicating if scene must be saved in the database
  69566. */
  69567. get enableSceneOffline(): boolean;
  69568. /**
  69569. * Gets a boolean indicating if textures must be saved in the database
  69570. */
  69571. get enableTexturesOffline(): boolean;
  69572. /**
  69573. * Creates a new Database
  69574. * @param urlToScene defines the url to load the scene
  69575. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69576. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69577. */
  69578. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69579. private static _ParseURL;
  69580. private static _ReturnFullUrlLocation;
  69581. private _checkManifestFile;
  69582. /**
  69583. * Open the database and make it available
  69584. * @param successCallback defines the callback to call on success
  69585. * @param errorCallback defines the callback to call on error
  69586. */
  69587. open(successCallback: () => void, errorCallback: () => void): void;
  69588. /**
  69589. * Loads an image from the database
  69590. * @param url defines the url to load from
  69591. * @param image defines the target DOM image
  69592. */
  69593. loadImage(url: string, image: HTMLImageElement): void;
  69594. private _loadImageFromDBAsync;
  69595. private _saveImageIntoDBAsync;
  69596. private _checkVersionFromDB;
  69597. private _loadVersionFromDBAsync;
  69598. private _saveVersionIntoDBAsync;
  69599. /**
  69600. * Loads a file from database
  69601. * @param url defines the URL to load from
  69602. * @param sceneLoaded defines a callback to call on success
  69603. * @param progressCallBack defines a callback to call when progress changed
  69604. * @param errorCallback defines a callback to call on error
  69605. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69606. */
  69607. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69608. private _loadFileAsync;
  69609. private _saveFileAsync;
  69610. /**
  69611. * Validates if xhr data is correct
  69612. * @param xhr defines the request to validate
  69613. * @param dataType defines the expected data type
  69614. * @returns true if data is correct
  69615. */
  69616. private static _ValidateXHRData;
  69617. }
  69618. }
  69619. declare module "babylonjs/Offline/index" {
  69620. export * from "babylonjs/Offline/database";
  69621. export * from "babylonjs/Offline/IOfflineProvider";
  69622. }
  69623. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69624. /** @hidden */
  69625. export var gpuUpdateParticlesPixelShader: {
  69626. name: string;
  69627. shader: string;
  69628. };
  69629. }
  69630. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69631. /** @hidden */
  69632. export var gpuUpdateParticlesVertexShader: {
  69633. name: string;
  69634. shader: string;
  69635. };
  69636. }
  69637. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69638. /** @hidden */
  69639. export var clipPlaneFragmentDeclaration2: {
  69640. name: string;
  69641. shader: string;
  69642. };
  69643. }
  69644. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69645. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69646. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69647. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69648. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69649. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69650. /** @hidden */
  69651. export var gpuRenderParticlesPixelShader: {
  69652. name: string;
  69653. shader: string;
  69654. };
  69655. }
  69656. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69657. /** @hidden */
  69658. export var clipPlaneVertexDeclaration2: {
  69659. name: string;
  69660. shader: string;
  69661. };
  69662. }
  69663. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69664. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69665. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69666. /** @hidden */
  69667. export var gpuRenderParticlesVertexShader: {
  69668. name: string;
  69669. shader: string;
  69670. };
  69671. }
  69672. declare module "babylonjs/Particles/gpuParticleSystem" {
  69673. import { Nullable } from "babylonjs/types";
  69674. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69675. import { Observable } from "babylonjs/Misc/observable";
  69676. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69677. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69678. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69679. import { Scene, IDisposable } from "babylonjs/scene";
  69680. import { Effect } from "babylonjs/Materials/effect";
  69681. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69682. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69683. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69684. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69685. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69686. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69687. /**
  69688. * This represents a GPU particle system in Babylon
  69689. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69690. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69691. */
  69692. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69693. /**
  69694. * The layer mask we are rendering the particles through.
  69695. */
  69696. layerMask: number;
  69697. private _capacity;
  69698. private _activeCount;
  69699. private _currentActiveCount;
  69700. private _accumulatedCount;
  69701. private _renderEffect;
  69702. private _updateEffect;
  69703. private _buffer0;
  69704. private _buffer1;
  69705. private _spriteBuffer;
  69706. private _updateVAO;
  69707. private _renderVAO;
  69708. private _targetIndex;
  69709. private _sourceBuffer;
  69710. private _targetBuffer;
  69711. private _engine;
  69712. private _currentRenderId;
  69713. private _started;
  69714. private _stopped;
  69715. private _timeDelta;
  69716. private _randomTexture;
  69717. private _randomTexture2;
  69718. private _attributesStrideSize;
  69719. private _updateEffectOptions;
  69720. private _randomTextureSize;
  69721. private _actualFrame;
  69722. private _customEffect;
  69723. private readonly _rawTextureWidth;
  69724. /**
  69725. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69726. */
  69727. static get IsSupported(): boolean;
  69728. /**
  69729. * An event triggered when the system is disposed.
  69730. */
  69731. onDisposeObservable: Observable<IParticleSystem>;
  69732. /**
  69733. * Gets the maximum number of particles active at the same time.
  69734. * @returns The max number of active particles.
  69735. */
  69736. getCapacity(): number;
  69737. /**
  69738. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69739. * to override the particles.
  69740. */
  69741. forceDepthWrite: boolean;
  69742. /**
  69743. * Gets or set the number of active particles
  69744. */
  69745. get activeParticleCount(): number;
  69746. set activeParticleCount(value: number);
  69747. private _preWarmDone;
  69748. /**
  69749. * Specifies if the particles are updated in emitter local space or world space.
  69750. */
  69751. isLocal: boolean;
  69752. /**
  69753. * Is this system ready to be used/rendered
  69754. * @return true if the system is ready
  69755. */
  69756. isReady(): boolean;
  69757. /**
  69758. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69759. * @returns True if it has been started, otherwise false.
  69760. */
  69761. isStarted(): boolean;
  69762. /**
  69763. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69764. * @returns True if it has been stopped, otherwise false.
  69765. */
  69766. isStopped(): boolean;
  69767. /**
  69768. * Gets a boolean indicating that the system is stopping
  69769. * @returns true if the system is currently stopping
  69770. */
  69771. isStopping(): boolean;
  69772. /**
  69773. * Gets the number of particles active at the same time.
  69774. * @returns The number of active particles.
  69775. */
  69776. getActiveCount(): number;
  69777. /**
  69778. * Starts the particle system and begins to emit
  69779. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69780. */
  69781. start(delay?: number): void;
  69782. /**
  69783. * Stops the particle system.
  69784. */
  69785. stop(): void;
  69786. /**
  69787. * Remove all active particles
  69788. */
  69789. reset(): void;
  69790. /**
  69791. * Returns the string "GPUParticleSystem"
  69792. * @returns a string containing the class name
  69793. */
  69794. getClassName(): string;
  69795. /**
  69796. * Gets the custom effect used to render the particles
  69797. * @param blendMode Blend mode for which the effect should be retrieved
  69798. * @returns The effect
  69799. */
  69800. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69801. /**
  69802. * Sets the custom effect used to render the particles
  69803. * @param effect The effect to set
  69804. * @param blendMode Blend mode for which the effect should be set
  69805. */
  69806. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69807. /** @hidden */
  69808. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69809. /**
  69810. * Observable that will be called just before the particles are drawn
  69811. */
  69812. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69813. /**
  69814. * Gets the name of the particle vertex shader
  69815. */
  69816. get vertexShaderName(): string;
  69817. private _colorGradientsTexture;
  69818. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69819. /**
  69820. * Adds a new color gradient
  69821. * @param gradient defines the gradient to use (between 0 and 1)
  69822. * @param color1 defines the color to affect to the specified gradient
  69823. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69824. * @returns the current particle system
  69825. */
  69826. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69827. private _refreshColorGradient;
  69828. /** Force the system to rebuild all gradients that need to be resync */
  69829. forceRefreshGradients(): void;
  69830. /**
  69831. * Remove a specific color gradient
  69832. * @param gradient defines the gradient to remove
  69833. * @returns the current particle system
  69834. */
  69835. removeColorGradient(gradient: number): GPUParticleSystem;
  69836. private _angularSpeedGradientsTexture;
  69837. private _sizeGradientsTexture;
  69838. private _velocityGradientsTexture;
  69839. private _limitVelocityGradientsTexture;
  69840. private _dragGradientsTexture;
  69841. private _addFactorGradient;
  69842. /**
  69843. * Adds a new size gradient
  69844. * @param gradient defines the gradient to use (between 0 and 1)
  69845. * @param factor defines the size factor to affect to the specified gradient
  69846. * @returns the current particle system
  69847. */
  69848. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69849. /**
  69850. * Remove a specific size gradient
  69851. * @param gradient defines the gradient to remove
  69852. * @returns the current particle system
  69853. */
  69854. removeSizeGradient(gradient: number): GPUParticleSystem;
  69855. private _refreshFactorGradient;
  69856. /**
  69857. * Adds a new angular speed gradient
  69858. * @param gradient defines the gradient to use (between 0 and 1)
  69859. * @param factor defines the angular speed to affect to the specified gradient
  69860. * @returns the current particle system
  69861. */
  69862. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69863. /**
  69864. * Remove a specific angular speed gradient
  69865. * @param gradient defines the gradient to remove
  69866. * @returns the current particle system
  69867. */
  69868. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69869. /**
  69870. * Adds a new velocity gradient
  69871. * @param gradient defines the gradient to use (between 0 and 1)
  69872. * @param factor defines the velocity to affect to the specified gradient
  69873. * @returns the current particle system
  69874. */
  69875. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69876. /**
  69877. * Remove a specific velocity gradient
  69878. * @param gradient defines the gradient to remove
  69879. * @returns the current particle system
  69880. */
  69881. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69882. /**
  69883. * Adds a new limit velocity gradient
  69884. * @param gradient defines the gradient to use (between 0 and 1)
  69885. * @param factor defines the limit velocity value to affect to the specified gradient
  69886. * @returns the current particle system
  69887. */
  69888. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69889. /**
  69890. * Remove a specific limit velocity gradient
  69891. * @param gradient defines the gradient to remove
  69892. * @returns the current particle system
  69893. */
  69894. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69895. /**
  69896. * Adds a new drag gradient
  69897. * @param gradient defines the gradient to use (between 0 and 1)
  69898. * @param factor defines the drag value to affect to the specified gradient
  69899. * @returns the current particle system
  69900. */
  69901. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69902. /**
  69903. * Remove a specific drag gradient
  69904. * @param gradient defines the gradient to remove
  69905. * @returns the current particle system
  69906. */
  69907. removeDragGradient(gradient: number): GPUParticleSystem;
  69908. /**
  69909. * Not supported by GPUParticleSystem
  69910. * @param gradient defines the gradient to use (between 0 and 1)
  69911. * @param factor defines the emit rate value to affect to the specified gradient
  69912. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69913. * @returns the current particle system
  69914. */
  69915. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69916. /**
  69917. * Not supported by GPUParticleSystem
  69918. * @param gradient defines the gradient to remove
  69919. * @returns the current particle system
  69920. */
  69921. removeEmitRateGradient(gradient: number): IParticleSystem;
  69922. /**
  69923. * Not supported by GPUParticleSystem
  69924. * @param gradient defines the gradient to use (between 0 and 1)
  69925. * @param factor defines the start size value to affect to the specified gradient
  69926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69927. * @returns the current particle system
  69928. */
  69929. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69930. /**
  69931. * Not supported by GPUParticleSystem
  69932. * @param gradient defines the gradient to remove
  69933. * @returns the current particle system
  69934. */
  69935. removeStartSizeGradient(gradient: number): IParticleSystem;
  69936. /**
  69937. * Not supported by GPUParticleSystem
  69938. * @param gradient defines the gradient to use (between 0 and 1)
  69939. * @param min defines the color remap minimal range
  69940. * @param max defines the color remap maximal range
  69941. * @returns the current particle system
  69942. */
  69943. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69944. /**
  69945. * Not supported by GPUParticleSystem
  69946. * @param gradient defines the gradient to remove
  69947. * @returns the current particle system
  69948. */
  69949. removeColorRemapGradient(): IParticleSystem;
  69950. /**
  69951. * Not supported by GPUParticleSystem
  69952. * @param gradient defines the gradient to use (between 0 and 1)
  69953. * @param min defines the alpha remap minimal range
  69954. * @param max defines the alpha remap maximal range
  69955. * @returns the current particle system
  69956. */
  69957. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69958. /**
  69959. * Not supported by GPUParticleSystem
  69960. * @param gradient defines the gradient to remove
  69961. * @returns the current particle system
  69962. */
  69963. removeAlphaRemapGradient(): IParticleSystem;
  69964. /**
  69965. * Not supported by GPUParticleSystem
  69966. * @param gradient defines the gradient to use (between 0 and 1)
  69967. * @param color defines the color to affect to the specified gradient
  69968. * @returns the current particle system
  69969. */
  69970. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69971. /**
  69972. * Not supported by GPUParticleSystem
  69973. * @param gradient defines the gradient to remove
  69974. * @returns the current particle system
  69975. */
  69976. removeRampGradient(): IParticleSystem;
  69977. /**
  69978. * Not supported by GPUParticleSystem
  69979. * @returns the list of ramp gradients
  69980. */
  69981. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69982. /**
  69983. * Not supported by GPUParticleSystem
  69984. * Gets or sets a boolean indicating that ramp gradients must be used
  69985. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69986. */
  69987. get useRampGradients(): boolean;
  69988. set useRampGradients(value: boolean);
  69989. /**
  69990. * Not supported by GPUParticleSystem
  69991. * @param gradient defines the gradient to use (between 0 and 1)
  69992. * @param factor defines the life time factor to affect to the specified gradient
  69993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69994. * @returns the current particle system
  69995. */
  69996. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69997. /**
  69998. * Not supported by GPUParticleSystem
  69999. * @param gradient defines the gradient to remove
  70000. * @returns the current particle system
  70001. */
  70002. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70003. /**
  70004. * Instantiates a GPU particle system.
  70005. * 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.
  70006. * @param name The name of the particle system
  70007. * @param options The options used to create the system
  70008. * @param scene The scene the particle system belongs to
  70009. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70010. * @param customEffect a custom effect used to change the way particles are rendered by default
  70011. */
  70012. constructor(name: string, options: Partial<{
  70013. capacity: number;
  70014. randomTextureSize: number;
  70015. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70016. protected _reset(): void;
  70017. private _createUpdateVAO;
  70018. private _createRenderVAO;
  70019. private _initialize;
  70020. /** @hidden */
  70021. _recreateUpdateEffect(): void;
  70022. private _getEffect;
  70023. /**
  70024. * Fill the defines array according to the current settings of the particle system
  70025. * @param defines Array to be updated
  70026. * @param blendMode blend mode to take into account when updating the array
  70027. */
  70028. fillDefines(defines: Array<string>, blendMode?: number): void;
  70029. /**
  70030. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70031. * @param uniforms Uniforms array to fill
  70032. * @param attributes Attributes array to fill
  70033. * @param samplers Samplers array to fill
  70034. */
  70035. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70036. /** @hidden */
  70037. _recreateRenderEffect(): Effect;
  70038. /**
  70039. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70040. * @param preWarm defines if we are in the pre-warmimg phase
  70041. */
  70042. animate(preWarm?: boolean): void;
  70043. private _createFactorGradientTexture;
  70044. private _createSizeGradientTexture;
  70045. private _createAngularSpeedGradientTexture;
  70046. private _createVelocityGradientTexture;
  70047. private _createLimitVelocityGradientTexture;
  70048. private _createDragGradientTexture;
  70049. private _createColorGradientTexture;
  70050. /**
  70051. * Renders the particle system in its current state
  70052. * @param preWarm defines if the system should only update the particles but not render them
  70053. * @returns the current number of particles
  70054. */
  70055. render(preWarm?: boolean): number;
  70056. /**
  70057. * Rebuilds the particle system
  70058. */
  70059. rebuild(): void;
  70060. private _releaseBuffers;
  70061. private _releaseVAOs;
  70062. /**
  70063. * Disposes the particle system and free the associated resources
  70064. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70065. */
  70066. dispose(disposeTexture?: boolean): void;
  70067. /**
  70068. * Clones the particle system.
  70069. * @param name The name of the cloned object
  70070. * @param newEmitter The new emitter to use
  70071. * @returns the cloned particle system
  70072. */
  70073. clone(name: string, newEmitter: any): GPUParticleSystem;
  70074. /**
  70075. * Serializes the particle system to a JSON object
  70076. * @param serializeTexture defines if the texture must be serialized as well
  70077. * @returns the JSON object
  70078. */
  70079. serialize(serializeTexture?: boolean): any;
  70080. /**
  70081. * Parses a JSON object to create a GPU particle system.
  70082. * @param parsedParticleSystem The JSON object to parse
  70083. * @param scene The scene to create the particle system in
  70084. * @param rootUrl The root url to use to load external dependencies like texture
  70085. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70086. * @returns the parsed GPU particle system
  70087. */
  70088. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70089. }
  70090. }
  70091. declare module "babylonjs/Particles/particleSystemSet" {
  70092. import { Nullable } from "babylonjs/types";
  70093. import { Color3 } from "babylonjs/Maths/math.color";
  70094. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70096. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70097. import { Scene, IDisposable } from "babylonjs/scene";
  70098. /**
  70099. * Represents a set of particle systems working together to create a specific effect
  70100. */
  70101. export class ParticleSystemSet implements IDisposable {
  70102. /**
  70103. * Gets or sets base Assets URL
  70104. */
  70105. static BaseAssetsUrl: string;
  70106. private _emitterCreationOptions;
  70107. private _emitterNode;
  70108. /**
  70109. * Gets the particle system list
  70110. */
  70111. systems: IParticleSystem[];
  70112. /**
  70113. * Gets the emitter node used with this set
  70114. */
  70115. get emitterNode(): Nullable<TransformNode>;
  70116. /**
  70117. * Creates a new emitter mesh as a sphere
  70118. * @param options defines the options used to create the sphere
  70119. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70120. * @param scene defines the hosting scene
  70121. */
  70122. setEmitterAsSphere(options: {
  70123. diameter: number;
  70124. segments: number;
  70125. color: Color3;
  70126. }, renderingGroupId: number, scene: Scene): void;
  70127. /**
  70128. * Starts all particle systems of the set
  70129. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70130. */
  70131. start(emitter?: AbstractMesh): void;
  70132. /**
  70133. * Release all associated resources
  70134. */
  70135. dispose(): void;
  70136. /**
  70137. * Serialize the set into a JSON compatible object
  70138. * @param serializeTexture defines if the texture must be serialized as well
  70139. * @returns a JSON compatible representation of the set
  70140. */
  70141. serialize(serializeTexture?: boolean): any;
  70142. /**
  70143. * Parse a new ParticleSystemSet from a serialized source
  70144. * @param data defines a JSON compatible representation of the set
  70145. * @param scene defines the hosting scene
  70146. * @param gpu defines if we want GPU particles or CPU particles
  70147. * @returns a new ParticleSystemSet
  70148. */
  70149. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70150. }
  70151. }
  70152. declare module "babylonjs/Particles/particleHelper" {
  70153. import { Nullable } from "babylonjs/types";
  70154. import { Scene } from "babylonjs/scene";
  70155. import { Vector3 } from "babylonjs/Maths/math.vector";
  70156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70157. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70158. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70159. /**
  70160. * This class is made for on one-liner static method to help creating particle system set.
  70161. */
  70162. export class ParticleHelper {
  70163. /**
  70164. * Gets or sets base Assets URL
  70165. */
  70166. static BaseAssetsUrl: string;
  70167. /** Define the Url to load snippets */
  70168. static SnippetUrl: string;
  70169. /**
  70170. * Create a default particle system that you can tweak
  70171. * @param emitter defines the emitter to use
  70172. * @param capacity defines the system capacity (default is 500 particles)
  70173. * @param scene defines the hosting scene
  70174. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70175. * @returns the new Particle system
  70176. */
  70177. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70178. /**
  70179. * This is the main static method (one-liner) of this helper to create different particle systems
  70180. * @param type This string represents the type to the particle system to create
  70181. * @param scene The scene where the particle system should live
  70182. * @param gpu If the system will use gpu
  70183. * @returns the ParticleSystemSet created
  70184. */
  70185. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70186. /**
  70187. * Static function used to export a particle system to a ParticleSystemSet variable.
  70188. * Please note that the emitter shape is not exported
  70189. * @param systems defines the particle systems to export
  70190. * @returns the created particle system set
  70191. */
  70192. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70193. /**
  70194. * Creates a particle system from a snippet saved in a remote file
  70195. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70196. * @param url defines the url to load from
  70197. * @param scene defines the hosting scene
  70198. * @param gpu If the system will use gpu
  70199. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70200. * @returns a promise that will resolve to the new particle system
  70201. */
  70202. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70203. /**
  70204. * Creates a particle system from a snippet saved by the particle system editor
  70205. * @param snippetId defines the snippet to load
  70206. * @param scene defines the hosting scene
  70207. * @param gpu If the system will use gpu
  70208. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70209. * @returns a promise that will resolve to the new particle system
  70210. */
  70211. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70212. }
  70213. }
  70214. declare module "babylonjs/Particles/particleSystemComponent" {
  70215. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70216. import { Effect } from "babylonjs/Materials/effect";
  70217. import "babylonjs/Shaders/particles.vertex";
  70218. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70219. module "babylonjs/Engines/engine" {
  70220. interface Engine {
  70221. /**
  70222. * Create an effect to use with particle systems.
  70223. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70224. * the particle system for which you want to create a custom effect in the last parameter
  70225. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70226. * @param uniformsNames defines a list of attribute names
  70227. * @param samplers defines an array of string used to represent textures
  70228. * @param defines defines the string containing the defines to use to compile the shaders
  70229. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70230. * @param onCompiled defines a function to call when the effect creation is successful
  70231. * @param onError defines a function to call when the effect creation has failed
  70232. * @param particleSystem the particle system you want to create the effect for
  70233. * @returns the new Effect
  70234. */
  70235. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70236. }
  70237. }
  70238. module "babylonjs/Meshes/mesh" {
  70239. interface Mesh {
  70240. /**
  70241. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70242. * @returns an array of IParticleSystem
  70243. */
  70244. getEmittedParticleSystems(): IParticleSystem[];
  70245. /**
  70246. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70247. * @returns an array of IParticleSystem
  70248. */
  70249. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70250. }
  70251. }
  70252. }
  70253. declare module "babylonjs/Particles/pointsCloudSystem" {
  70254. import { Color4 } from "babylonjs/Maths/math";
  70255. import { Mesh } from "babylonjs/Meshes/mesh";
  70256. import { Scene, IDisposable } from "babylonjs/scene";
  70257. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70258. /** Defines the 4 color options */
  70259. export enum PointColor {
  70260. /** color value */
  70261. Color = 2,
  70262. /** uv value */
  70263. UV = 1,
  70264. /** random value */
  70265. Random = 0,
  70266. /** stated value */
  70267. Stated = 3
  70268. }
  70269. /**
  70270. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70271. * 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.
  70272. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70273. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70274. *
  70275. * Full documentation here : TO BE ENTERED
  70276. */
  70277. export class PointsCloudSystem implements IDisposable {
  70278. /**
  70279. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70280. * Example : var p = SPS.particles[i];
  70281. */
  70282. particles: CloudPoint[];
  70283. /**
  70284. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70285. */
  70286. nbParticles: number;
  70287. /**
  70288. * This a counter for your own usage. It's not set by any SPS functions.
  70289. */
  70290. counter: number;
  70291. /**
  70292. * The PCS name. This name is also given to the underlying mesh.
  70293. */
  70294. name: string;
  70295. /**
  70296. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70297. */
  70298. mesh: Mesh;
  70299. /**
  70300. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70301. * Please read :
  70302. */
  70303. vars: any;
  70304. /**
  70305. * @hidden
  70306. */
  70307. _size: number;
  70308. private _scene;
  70309. private _promises;
  70310. private _positions;
  70311. private _indices;
  70312. private _normals;
  70313. private _colors;
  70314. private _uvs;
  70315. private _indices32;
  70316. private _positions32;
  70317. private _colors32;
  70318. private _uvs32;
  70319. private _updatable;
  70320. private _isVisibilityBoxLocked;
  70321. private _alwaysVisible;
  70322. private _groups;
  70323. private _groupCounter;
  70324. private _computeParticleColor;
  70325. private _computeParticleTexture;
  70326. private _computeParticleRotation;
  70327. private _computeBoundingBox;
  70328. private _isReady;
  70329. /**
  70330. * Creates a PCS (Points Cloud System) object
  70331. * @param name (String) is the PCS name, this will be the underlying mesh name
  70332. * @param pointSize (number) is the size for each point
  70333. * @param scene (Scene) is the scene in which the PCS is added
  70334. * @param options defines the options of the PCS e.g.
  70335. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70336. */
  70337. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70338. updatable?: boolean;
  70339. });
  70340. /**
  70341. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70342. * If no points were added to the PCS, the returned mesh is just a single point.
  70343. * @returns a promise for the created mesh
  70344. */
  70345. buildMeshAsync(): Promise<Mesh>;
  70346. /**
  70347. * @hidden
  70348. */
  70349. private _buildMesh;
  70350. private _addParticle;
  70351. private _randomUnitVector;
  70352. private _getColorIndicesForCoord;
  70353. private _setPointsColorOrUV;
  70354. private _colorFromTexture;
  70355. private _calculateDensity;
  70356. /**
  70357. * Adds points to the PCS in random positions within a unit sphere
  70358. * @param nb (positive integer) the number of particles to be created from this model
  70359. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70360. * @returns the number of groups in the system
  70361. */
  70362. addPoints(nb: number, pointFunction?: any): number;
  70363. /**
  70364. * Adds points to the PCS from the surface of the model shape
  70365. * @param mesh is any Mesh object that will be used as a surface model for the points
  70366. * @param nb (positive integer) the number of particles to be created from this model
  70367. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70368. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70369. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70370. * @returns the number of groups in the system
  70371. */
  70372. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70373. /**
  70374. * Adds points to the PCS inside the model shape
  70375. * @param mesh is any Mesh object that will be used as a surface model for the points
  70376. * @param nb (positive integer) the number of particles to be created from this model
  70377. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70378. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70379. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70380. * @returns the number of groups in the system
  70381. */
  70382. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70383. /**
  70384. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70385. * This method calls `updateParticle()` for each particle of the SPS.
  70386. * For an animated SPS, it is usually called within the render loop.
  70387. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70388. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70389. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70390. * @returns the PCS.
  70391. */
  70392. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70393. /**
  70394. * Disposes the PCS.
  70395. */
  70396. dispose(): void;
  70397. /**
  70398. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70399. * doc :
  70400. * @returns the PCS.
  70401. */
  70402. refreshVisibleSize(): PointsCloudSystem;
  70403. /**
  70404. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70405. * @param size the size (float) of the visibility box
  70406. * note : this doesn't lock the PCS mesh bounding box.
  70407. * doc :
  70408. */
  70409. setVisibilityBox(size: number): void;
  70410. /**
  70411. * Gets whether the PCS is always visible or not
  70412. * doc :
  70413. */
  70414. get isAlwaysVisible(): boolean;
  70415. /**
  70416. * Sets the PCS as always visible or not
  70417. * doc :
  70418. */
  70419. set isAlwaysVisible(val: boolean);
  70420. /**
  70421. * Tells to `setParticles()` to compute the particle rotations or not
  70422. * Default value : false. The PCS is faster when it's set to false
  70423. * Note : particle rotations are only applied to parent particles
  70424. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70425. */
  70426. set computeParticleRotation(val: boolean);
  70427. /**
  70428. * Tells to `setParticles()` to compute the particle colors or not.
  70429. * Default value : true. The PCS is faster when it's set to false.
  70430. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70431. */
  70432. set computeParticleColor(val: boolean);
  70433. set computeParticleTexture(val: boolean);
  70434. /**
  70435. * Gets if `setParticles()` computes the particle colors or not.
  70436. * Default value : false. The PCS is faster when it's set to false.
  70437. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70438. */
  70439. get computeParticleColor(): boolean;
  70440. /**
  70441. * Gets if `setParticles()` computes the particle textures or not.
  70442. * Default value : false. The PCS is faster when it's set to false.
  70443. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70444. */
  70445. get computeParticleTexture(): boolean;
  70446. /**
  70447. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70448. */
  70449. set computeBoundingBox(val: boolean);
  70450. /**
  70451. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70452. */
  70453. get computeBoundingBox(): boolean;
  70454. /**
  70455. * This function does nothing. It may be overwritten to set all the particle first values.
  70456. * The PCS doesn't call this function, you may have to call it by your own.
  70457. * doc :
  70458. */
  70459. initParticles(): void;
  70460. /**
  70461. * This function does nothing. It may be overwritten to recycle a particle
  70462. * The PCS doesn't call this function, you can to call it
  70463. * doc :
  70464. * @param particle The particle to recycle
  70465. * @returns the recycled particle
  70466. */
  70467. recycleParticle(particle: CloudPoint): CloudPoint;
  70468. /**
  70469. * Updates a particle : this function should be overwritten by the user.
  70470. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70471. * doc :
  70472. * @example : just set a particle position or velocity and recycle conditions
  70473. * @param particle The particle to update
  70474. * @returns the updated particle
  70475. */
  70476. updateParticle(particle: CloudPoint): CloudPoint;
  70477. /**
  70478. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70479. * This does nothing and may be overwritten by the user.
  70480. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70481. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70482. * @param update the boolean update value actually passed to setParticles()
  70483. */
  70484. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70485. /**
  70486. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70487. * This will be passed three parameters.
  70488. * This does nothing and may be overwritten by the user.
  70489. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70490. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70491. * @param update the boolean update value actually passed to setParticles()
  70492. */
  70493. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70494. }
  70495. }
  70496. declare module "babylonjs/Particles/cloudPoint" {
  70497. import { Nullable } from "babylonjs/types";
  70498. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70499. import { Mesh } from "babylonjs/Meshes/mesh";
  70500. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70501. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70502. /**
  70503. * Represents one particle of a points cloud system.
  70504. */
  70505. export class CloudPoint {
  70506. /**
  70507. * particle global index
  70508. */
  70509. idx: number;
  70510. /**
  70511. * The color of the particle
  70512. */
  70513. color: Nullable<Color4>;
  70514. /**
  70515. * The world space position of the particle.
  70516. */
  70517. position: Vector3;
  70518. /**
  70519. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70520. */
  70521. rotation: Vector3;
  70522. /**
  70523. * The world space rotation quaternion of the particle.
  70524. */
  70525. rotationQuaternion: Nullable<Quaternion>;
  70526. /**
  70527. * The uv of the particle.
  70528. */
  70529. uv: Nullable<Vector2>;
  70530. /**
  70531. * The current speed of the particle.
  70532. */
  70533. velocity: Vector3;
  70534. /**
  70535. * The pivot point in the particle local space.
  70536. */
  70537. pivot: Vector3;
  70538. /**
  70539. * Must the particle be translated from its pivot point in its local space ?
  70540. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70541. * Default : false
  70542. */
  70543. translateFromPivot: boolean;
  70544. /**
  70545. * Index of this particle in the global "positions" array (Internal use)
  70546. * @hidden
  70547. */
  70548. _pos: number;
  70549. /**
  70550. * @hidden Index of this particle in the global "indices" array (Internal use)
  70551. */
  70552. _ind: number;
  70553. /**
  70554. * Group this particle belongs to
  70555. */
  70556. _group: PointsGroup;
  70557. /**
  70558. * Group id of this particle
  70559. */
  70560. groupId: number;
  70561. /**
  70562. * Index of the particle in its group id (Internal use)
  70563. */
  70564. idxInGroup: number;
  70565. /**
  70566. * @hidden Particle BoundingInfo object (Internal use)
  70567. */
  70568. _boundingInfo: BoundingInfo;
  70569. /**
  70570. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70571. */
  70572. _pcs: PointsCloudSystem;
  70573. /**
  70574. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70575. */
  70576. _stillInvisible: boolean;
  70577. /**
  70578. * @hidden Last computed particle rotation matrix
  70579. */
  70580. _rotationMatrix: number[];
  70581. /**
  70582. * Parent particle Id, if any.
  70583. * Default null.
  70584. */
  70585. parentId: Nullable<number>;
  70586. /**
  70587. * @hidden Internal global position in the PCS.
  70588. */
  70589. _globalPosition: Vector3;
  70590. /**
  70591. * Creates a Point Cloud object.
  70592. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70593. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70594. * @param group (PointsGroup) is the group the particle belongs to
  70595. * @param groupId (integer) is the group identifier in the PCS.
  70596. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70597. * @param pcs defines the PCS it is associated to
  70598. */
  70599. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70600. /**
  70601. * get point size
  70602. */
  70603. get size(): Vector3;
  70604. /**
  70605. * Set point size
  70606. */
  70607. set size(scale: Vector3);
  70608. /**
  70609. * Legacy support, changed quaternion to rotationQuaternion
  70610. */
  70611. get quaternion(): Nullable<Quaternion>;
  70612. /**
  70613. * Legacy support, changed quaternion to rotationQuaternion
  70614. */
  70615. set quaternion(q: Nullable<Quaternion>);
  70616. /**
  70617. * Returns a boolean. True if the particle intersects a mesh, else false
  70618. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70619. * @param target is the object (point or mesh) what the intersection is computed against
  70620. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70621. * @returns true if it intersects
  70622. */
  70623. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70624. /**
  70625. * get the rotation matrix of the particle
  70626. * @hidden
  70627. */
  70628. getRotationMatrix(m: Matrix): void;
  70629. }
  70630. /**
  70631. * Represents a group of points in a points cloud system
  70632. * * PCS internal tool, don't use it manually.
  70633. */
  70634. export class PointsGroup {
  70635. /**
  70636. * The group id
  70637. * @hidden
  70638. */
  70639. groupID: number;
  70640. /**
  70641. * image data for group (internal use)
  70642. * @hidden
  70643. */
  70644. _groupImageData: Nullable<ArrayBufferView>;
  70645. /**
  70646. * Image Width (internal use)
  70647. * @hidden
  70648. */
  70649. _groupImgWidth: number;
  70650. /**
  70651. * Image Height (internal use)
  70652. * @hidden
  70653. */
  70654. _groupImgHeight: number;
  70655. /**
  70656. * Custom position function (internal use)
  70657. * @hidden
  70658. */
  70659. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70660. /**
  70661. * density per facet for surface points
  70662. * @hidden
  70663. */
  70664. _groupDensity: number[];
  70665. /**
  70666. * Only when points are colored by texture carries pointer to texture list array
  70667. * @hidden
  70668. */
  70669. _textureNb: number;
  70670. /**
  70671. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70672. * PCS internal tool, don't use it manually.
  70673. * @hidden
  70674. */
  70675. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70676. }
  70677. }
  70678. declare module "babylonjs/Particles/index" {
  70679. export * from "babylonjs/Particles/baseParticleSystem";
  70680. export * from "babylonjs/Particles/EmitterTypes/index";
  70681. export * from "babylonjs/Particles/gpuParticleSystem";
  70682. export * from "babylonjs/Particles/IParticleSystem";
  70683. export * from "babylonjs/Particles/particle";
  70684. export * from "babylonjs/Particles/particleHelper";
  70685. export * from "babylonjs/Particles/particleSystem";
  70686. import "babylonjs/Particles/particleSystemComponent";
  70687. export * from "babylonjs/Particles/particleSystemComponent";
  70688. export * from "babylonjs/Particles/particleSystemSet";
  70689. export * from "babylonjs/Particles/solidParticle";
  70690. export * from "babylonjs/Particles/solidParticleSystem";
  70691. export * from "babylonjs/Particles/cloudPoint";
  70692. export * from "babylonjs/Particles/pointsCloudSystem";
  70693. export * from "babylonjs/Particles/subEmitter";
  70694. }
  70695. declare module "babylonjs/Physics/physicsEngineComponent" {
  70696. import { Nullable } from "babylonjs/types";
  70697. import { Observable, Observer } from "babylonjs/Misc/observable";
  70698. import { Vector3 } from "babylonjs/Maths/math.vector";
  70699. import { Mesh } from "babylonjs/Meshes/mesh";
  70700. import { ISceneComponent } from "babylonjs/sceneComponent";
  70701. import { Scene } from "babylonjs/scene";
  70702. import { Node } from "babylonjs/node";
  70703. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70704. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70705. module "babylonjs/scene" {
  70706. interface Scene {
  70707. /** @hidden (Backing field) */
  70708. _physicsEngine: Nullable<IPhysicsEngine>;
  70709. /** @hidden */
  70710. _physicsTimeAccumulator: number;
  70711. /**
  70712. * Gets the current physics engine
  70713. * @returns a IPhysicsEngine or null if none attached
  70714. */
  70715. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70716. /**
  70717. * Enables physics to the current scene
  70718. * @param gravity defines the scene's gravity for the physics engine
  70719. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70720. * @return a boolean indicating if the physics engine was initialized
  70721. */
  70722. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70723. /**
  70724. * Disables and disposes the physics engine associated with the scene
  70725. */
  70726. disablePhysicsEngine(): void;
  70727. /**
  70728. * Gets a boolean indicating if there is an active physics engine
  70729. * @returns a boolean indicating if there is an active physics engine
  70730. */
  70731. isPhysicsEnabled(): boolean;
  70732. /**
  70733. * Deletes a physics compound impostor
  70734. * @param compound defines the compound to delete
  70735. */
  70736. deleteCompoundImpostor(compound: any): void;
  70737. /**
  70738. * An event triggered when physic simulation is about to be run
  70739. */
  70740. onBeforePhysicsObservable: Observable<Scene>;
  70741. /**
  70742. * An event triggered when physic simulation has been done
  70743. */
  70744. onAfterPhysicsObservable: Observable<Scene>;
  70745. }
  70746. }
  70747. module "babylonjs/Meshes/abstractMesh" {
  70748. interface AbstractMesh {
  70749. /** @hidden */
  70750. _physicsImpostor: Nullable<PhysicsImpostor>;
  70751. /**
  70752. * Gets or sets impostor used for physic simulation
  70753. * @see http://doc.babylonjs.com/features/physics_engine
  70754. */
  70755. physicsImpostor: Nullable<PhysicsImpostor>;
  70756. /**
  70757. * Gets the current physics impostor
  70758. * @see http://doc.babylonjs.com/features/physics_engine
  70759. * @returns a physics impostor or null
  70760. */
  70761. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70762. /** Apply a physic impulse to the mesh
  70763. * @param force defines the force to apply
  70764. * @param contactPoint defines where to apply the force
  70765. * @returns the current mesh
  70766. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  70767. */
  70768. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70769. /**
  70770. * Creates a physic joint between two meshes
  70771. * @param otherMesh defines the other mesh to use
  70772. * @param pivot1 defines the pivot to use on this mesh
  70773. * @param pivot2 defines the pivot to use on the other mesh
  70774. * @param options defines additional options (can be plugin dependent)
  70775. * @returns the current mesh
  70776. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70777. */
  70778. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70779. /** @hidden */
  70780. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70781. }
  70782. }
  70783. /**
  70784. * Defines the physics engine scene component responsible to manage a physics engine
  70785. */
  70786. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70787. /**
  70788. * The component name helpful to identify the component in the list of scene components.
  70789. */
  70790. readonly name: string;
  70791. /**
  70792. * The scene the component belongs to.
  70793. */
  70794. scene: Scene;
  70795. /**
  70796. * Creates a new instance of the component for the given scene
  70797. * @param scene Defines the scene to register the component in
  70798. */
  70799. constructor(scene: Scene);
  70800. /**
  70801. * Registers the component in a given scene
  70802. */
  70803. register(): void;
  70804. /**
  70805. * Rebuilds the elements related to this component in case of
  70806. * context lost for instance.
  70807. */
  70808. rebuild(): void;
  70809. /**
  70810. * Disposes the component and the associated ressources
  70811. */
  70812. dispose(): void;
  70813. }
  70814. }
  70815. declare module "babylonjs/Physics/physicsHelper" {
  70816. import { Nullable } from "babylonjs/types";
  70817. import { Vector3 } from "babylonjs/Maths/math.vector";
  70818. import { Mesh } from "babylonjs/Meshes/mesh";
  70819. import { Scene } from "babylonjs/scene";
  70820. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70821. /**
  70822. * A helper for physics simulations
  70823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70824. */
  70825. export class PhysicsHelper {
  70826. private _scene;
  70827. private _physicsEngine;
  70828. /**
  70829. * Initializes the Physics helper
  70830. * @param scene Babylon.js scene
  70831. */
  70832. constructor(scene: Scene);
  70833. /**
  70834. * Applies a radial explosion impulse
  70835. * @param origin the origin of the explosion
  70836. * @param radiusOrEventOptions the radius or the options of radial explosion
  70837. * @param strength the explosion strength
  70838. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70839. * @returns A physics radial explosion event, or null
  70840. */
  70841. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70842. /**
  70843. * Applies a radial explosion force
  70844. * @param origin the origin of the explosion
  70845. * @param radiusOrEventOptions the radius or the options of radial explosion
  70846. * @param strength the explosion strength
  70847. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70848. * @returns A physics radial explosion event, or null
  70849. */
  70850. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70851. /**
  70852. * Creates a gravitational field
  70853. * @param origin the origin of the explosion
  70854. * @param radiusOrEventOptions the radius or the options of radial explosion
  70855. * @param strength the explosion strength
  70856. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70857. * @returns A physics gravitational field event, or null
  70858. */
  70859. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70860. /**
  70861. * Creates a physics updraft event
  70862. * @param origin the origin of the updraft
  70863. * @param radiusOrEventOptions the radius or the options of the updraft
  70864. * @param strength the strength of the updraft
  70865. * @param height the height of the updraft
  70866. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70867. * @returns A physics updraft event, or null
  70868. */
  70869. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70870. /**
  70871. * Creates a physics vortex event
  70872. * @param origin the of the vortex
  70873. * @param radiusOrEventOptions the radius or the options of the vortex
  70874. * @param strength the strength of the vortex
  70875. * @param height the height of the vortex
  70876. * @returns a Physics vortex event, or null
  70877. * A physics vortex event or null
  70878. */
  70879. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70880. }
  70881. /**
  70882. * Represents a physics radial explosion event
  70883. */
  70884. class PhysicsRadialExplosionEvent {
  70885. private _scene;
  70886. private _options;
  70887. private _sphere;
  70888. private _dataFetched;
  70889. /**
  70890. * Initializes a radial explosioin event
  70891. * @param _scene BabylonJS scene
  70892. * @param _options The options for the vortex event
  70893. */
  70894. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70895. /**
  70896. * Returns the data related to the radial explosion event (sphere).
  70897. * @returns The radial explosion event data
  70898. */
  70899. getData(): PhysicsRadialExplosionEventData;
  70900. /**
  70901. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70902. * @param impostor A physics imposter
  70903. * @param origin the origin of the explosion
  70904. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70905. */
  70906. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70907. /**
  70908. * Triggers affecterd impostors callbacks
  70909. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70910. */
  70911. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70912. /**
  70913. * Disposes the sphere.
  70914. * @param force Specifies if the sphere should be disposed by force
  70915. */
  70916. dispose(force?: boolean): void;
  70917. /*** Helpers ***/
  70918. private _prepareSphere;
  70919. private _intersectsWithSphere;
  70920. }
  70921. /**
  70922. * Represents a gravitational field event
  70923. */
  70924. class PhysicsGravitationalFieldEvent {
  70925. private _physicsHelper;
  70926. private _scene;
  70927. private _origin;
  70928. private _options;
  70929. private _tickCallback;
  70930. private _sphere;
  70931. private _dataFetched;
  70932. /**
  70933. * Initializes the physics gravitational field event
  70934. * @param _physicsHelper A physics helper
  70935. * @param _scene BabylonJS scene
  70936. * @param _origin The origin position of the gravitational field event
  70937. * @param _options The options for the vortex event
  70938. */
  70939. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70940. /**
  70941. * Returns the data related to the gravitational field event (sphere).
  70942. * @returns A gravitational field event
  70943. */
  70944. getData(): PhysicsGravitationalFieldEventData;
  70945. /**
  70946. * Enables the gravitational field.
  70947. */
  70948. enable(): void;
  70949. /**
  70950. * Disables the gravitational field.
  70951. */
  70952. disable(): void;
  70953. /**
  70954. * Disposes the sphere.
  70955. * @param force The force to dispose from the gravitational field event
  70956. */
  70957. dispose(force?: boolean): void;
  70958. private _tick;
  70959. }
  70960. /**
  70961. * Represents a physics updraft event
  70962. */
  70963. class PhysicsUpdraftEvent {
  70964. private _scene;
  70965. private _origin;
  70966. private _options;
  70967. private _physicsEngine;
  70968. private _originTop;
  70969. private _originDirection;
  70970. private _tickCallback;
  70971. private _cylinder;
  70972. private _cylinderPosition;
  70973. private _dataFetched;
  70974. /**
  70975. * Initializes the physics updraft event
  70976. * @param _scene BabylonJS scene
  70977. * @param _origin The origin position of the updraft
  70978. * @param _options The options for the updraft event
  70979. */
  70980. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70981. /**
  70982. * Returns the data related to the updraft event (cylinder).
  70983. * @returns A physics updraft event
  70984. */
  70985. getData(): PhysicsUpdraftEventData;
  70986. /**
  70987. * Enables the updraft.
  70988. */
  70989. enable(): void;
  70990. /**
  70991. * Disables the updraft.
  70992. */
  70993. disable(): void;
  70994. /**
  70995. * Disposes the cylinder.
  70996. * @param force Specifies if the updraft should be disposed by force
  70997. */
  70998. dispose(force?: boolean): void;
  70999. private getImpostorHitData;
  71000. private _tick;
  71001. /*** Helpers ***/
  71002. private _prepareCylinder;
  71003. private _intersectsWithCylinder;
  71004. }
  71005. /**
  71006. * Represents a physics vortex event
  71007. */
  71008. class PhysicsVortexEvent {
  71009. private _scene;
  71010. private _origin;
  71011. private _options;
  71012. private _physicsEngine;
  71013. private _originTop;
  71014. private _tickCallback;
  71015. private _cylinder;
  71016. private _cylinderPosition;
  71017. private _dataFetched;
  71018. /**
  71019. * Initializes the physics vortex event
  71020. * @param _scene The BabylonJS scene
  71021. * @param _origin The origin position of the vortex
  71022. * @param _options The options for the vortex event
  71023. */
  71024. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71025. /**
  71026. * Returns the data related to the vortex event (cylinder).
  71027. * @returns The physics vortex event data
  71028. */
  71029. getData(): PhysicsVortexEventData;
  71030. /**
  71031. * Enables the vortex.
  71032. */
  71033. enable(): void;
  71034. /**
  71035. * Disables the cortex.
  71036. */
  71037. disable(): void;
  71038. /**
  71039. * Disposes the sphere.
  71040. * @param force
  71041. */
  71042. dispose(force?: boolean): void;
  71043. private getImpostorHitData;
  71044. private _tick;
  71045. /*** Helpers ***/
  71046. private _prepareCylinder;
  71047. private _intersectsWithCylinder;
  71048. }
  71049. /**
  71050. * Options fot the radial explosion event
  71051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71052. */
  71053. export class PhysicsRadialExplosionEventOptions {
  71054. /**
  71055. * The radius of the sphere for the radial explosion.
  71056. */
  71057. radius: number;
  71058. /**
  71059. * The strenth of the explosion.
  71060. */
  71061. strength: number;
  71062. /**
  71063. * The strenght of the force in correspondence to the distance of the affected object
  71064. */
  71065. falloff: PhysicsRadialImpulseFalloff;
  71066. /**
  71067. * Sphere options for the radial explosion.
  71068. */
  71069. sphere: {
  71070. segments: number;
  71071. diameter: number;
  71072. };
  71073. /**
  71074. * Sphere options for the radial explosion.
  71075. */
  71076. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71077. }
  71078. /**
  71079. * Options fot the updraft event
  71080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71081. */
  71082. export class PhysicsUpdraftEventOptions {
  71083. /**
  71084. * The radius of the cylinder for the vortex
  71085. */
  71086. radius: number;
  71087. /**
  71088. * The strenth of the updraft.
  71089. */
  71090. strength: number;
  71091. /**
  71092. * The height of the cylinder for the updraft.
  71093. */
  71094. height: number;
  71095. /**
  71096. * The mode for the the updraft.
  71097. */
  71098. updraftMode: PhysicsUpdraftMode;
  71099. }
  71100. /**
  71101. * Options fot the vortex event
  71102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71103. */
  71104. export class PhysicsVortexEventOptions {
  71105. /**
  71106. * The radius of the cylinder for the vortex
  71107. */
  71108. radius: number;
  71109. /**
  71110. * The strenth of the vortex.
  71111. */
  71112. strength: number;
  71113. /**
  71114. * The height of the cylinder for the vortex.
  71115. */
  71116. height: number;
  71117. /**
  71118. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71119. */
  71120. centripetalForceThreshold: number;
  71121. /**
  71122. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71123. */
  71124. centripetalForceMultiplier: number;
  71125. /**
  71126. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71127. */
  71128. centrifugalForceMultiplier: number;
  71129. /**
  71130. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71131. */
  71132. updraftForceMultiplier: number;
  71133. }
  71134. /**
  71135. * The strenght of the force in correspondence to the distance of the affected object
  71136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71137. */
  71138. export enum PhysicsRadialImpulseFalloff {
  71139. /** Defines that impulse is constant in strength across it's whole radius */
  71140. Constant = 0,
  71141. /** Defines that impulse gets weaker if it's further from the origin */
  71142. Linear = 1
  71143. }
  71144. /**
  71145. * The strength of the force in correspondence to the distance of the affected object
  71146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71147. */
  71148. export enum PhysicsUpdraftMode {
  71149. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71150. Center = 0,
  71151. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71152. Perpendicular = 1
  71153. }
  71154. /**
  71155. * Interface for a physics hit data
  71156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71157. */
  71158. export interface PhysicsHitData {
  71159. /**
  71160. * The force applied at the contact point
  71161. */
  71162. force: Vector3;
  71163. /**
  71164. * The contact point
  71165. */
  71166. contactPoint: Vector3;
  71167. /**
  71168. * The distance from the origin to the contact point
  71169. */
  71170. distanceFromOrigin: number;
  71171. }
  71172. /**
  71173. * Interface for radial explosion event data
  71174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71175. */
  71176. export interface PhysicsRadialExplosionEventData {
  71177. /**
  71178. * A sphere used for the radial explosion event
  71179. */
  71180. sphere: Mesh;
  71181. }
  71182. /**
  71183. * Interface for gravitational field event data
  71184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71185. */
  71186. export interface PhysicsGravitationalFieldEventData {
  71187. /**
  71188. * A sphere mesh used for the gravitational field event
  71189. */
  71190. sphere: Mesh;
  71191. }
  71192. /**
  71193. * Interface for updraft event data
  71194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71195. */
  71196. export interface PhysicsUpdraftEventData {
  71197. /**
  71198. * A cylinder used for the updraft event
  71199. */
  71200. cylinder: Mesh;
  71201. }
  71202. /**
  71203. * Interface for vortex event data
  71204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71205. */
  71206. export interface PhysicsVortexEventData {
  71207. /**
  71208. * A cylinder used for the vortex event
  71209. */
  71210. cylinder: Mesh;
  71211. }
  71212. /**
  71213. * Interface for an affected physics impostor
  71214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71215. */
  71216. export interface PhysicsAffectedImpostorWithData {
  71217. /**
  71218. * The impostor affected by the effect
  71219. */
  71220. impostor: PhysicsImpostor;
  71221. /**
  71222. * The data about the hit/horce from the explosion
  71223. */
  71224. hitData: PhysicsHitData;
  71225. }
  71226. }
  71227. declare module "babylonjs/Physics/Plugins/index" {
  71228. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71229. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71230. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71231. }
  71232. declare module "babylonjs/Physics/index" {
  71233. export * from "babylonjs/Physics/IPhysicsEngine";
  71234. export * from "babylonjs/Physics/physicsEngine";
  71235. export * from "babylonjs/Physics/physicsEngineComponent";
  71236. export * from "babylonjs/Physics/physicsHelper";
  71237. export * from "babylonjs/Physics/physicsImpostor";
  71238. export * from "babylonjs/Physics/physicsJoint";
  71239. export * from "babylonjs/Physics/Plugins/index";
  71240. }
  71241. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71242. /** @hidden */
  71243. export var blackAndWhitePixelShader: {
  71244. name: string;
  71245. shader: string;
  71246. };
  71247. }
  71248. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71249. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71250. import { Camera } from "babylonjs/Cameras/camera";
  71251. import { Engine } from "babylonjs/Engines/engine";
  71252. import "babylonjs/Shaders/blackAndWhite.fragment";
  71253. /**
  71254. * Post process used to render in black and white
  71255. */
  71256. export class BlackAndWhitePostProcess extends PostProcess {
  71257. /**
  71258. * Linear about to convert he result to black and white (default: 1)
  71259. */
  71260. degree: number;
  71261. /**
  71262. * Creates a black and white post process
  71263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71264. * @param name The name of the effect.
  71265. * @param options The required width/height ratio to downsize to before computing the render pass.
  71266. * @param camera The camera to apply the render pass to.
  71267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71268. * @param engine The engine which the post process will be applied. (default: current engine)
  71269. * @param reusable If the post process can be reused on the same frame. (default: false)
  71270. */
  71271. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71272. }
  71273. }
  71274. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71275. import { Nullable } from "babylonjs/types";
  71276. import { Camera } from "babylonjs/Cameras/camera";
  71277. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71278. import { Engine } from "babylonjs/Engines/engine";
  71279. /**
  71280. * This represents a set of one or more post processes in Babylon.
  71281. * A post process can be used to apply a shader to a texture after it is rendered.
  71282. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71283. */
  71284. export class PostProcessRenderEffect {
  71285. private _postProcesses;
  71286. private _getPostProcesses;
  71287. private _singleInstance;
  71288. private _cameras;
  71289. private _indicesForCamera;
  71290. /**
  71291. * Name of the effect
  71292. * @hidden
  71293. */
  71294. _name: string;
  71295. /**
  71296. * Instantiates a post process render effect.
  71297. * A post process can be used to apply a shader to a texture after it is rendered.
  71298. * @param engine The engine the effect is tied to
  71299. * @param name The name of the effect
  71300. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71301. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71302. */
  71303. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71304. /**
  71305. * Checks if all the post processes in the effect are supported.
  71306. */
  71307. get isSupported(): boolean;
  71308. /**
  71309. * Updates the current state of the effect
  71310. * @hidden
  71311. */
  71312. _update(): void;
  71313. /**
  71314. * Attaches the effect on cameras
  71315. * @param cameras The camera to attach to.
  71316. * @hidden
  71317. */
  71318. _attachCameras(cameras: Camera): void;
  71319. /**
  71320. * Attaches the effect on cameras
  71321. * @param cameras The camera to attach to.
  71322. * @hidden
  71323. */
  71324. _attachCameras(cameras: Camera[]): void;
  71325. /**
  71326. * Detaches the effect on cameras
  71327. * @param cameras The camera to detatch from.
  71328. * @hidden
  71329. */
  71330. _detachCameras(cameras: Camera): void;
  71331. /**
  71332. * Detatches the effect on cameras
  71333. * @param cameras The camera to detatch from.
  71334. * @hidden
  71335. */
  71336. _detachCameras(cameras: Camera[]): void;
  71337. /**
  71338. * Enables the effect on given cameras
  71339. * @param cameras The camera to enable.
  71340. * @hidden
  71341. */
  71342. _enable(cameras: Camera): void;
  71343. /**
  71344. * Enables the effect on given cameras
  71345. * @param cameras The camera to enable.
  71346. * @hidden
  71347. */
  71348. _enable(cameras: Nullable<Camera[]>): void;
  71349. /**
  71350. * Disables the effect on the given cameras
  71351. * @param cameras The camera to disable.
  71352. * @hidden
  71353. */
  71354. _disable(cameras: Camera): void;
  71355. /**
  71356. * Disables the effect on the given cameras
  71357. * @param cameras The camera to disable.
  71358. * @hidden
  71359. */
  71360. _disable(cameras: Nullable<Camera[]>): void;
  71361. /**
  71362. * Gets a list of the post processes contained in the effect.
  71363. * @param camera The camera to get the post processes on.
  71364. * @returns The list of the post processes in the effect.
  71365. */
  71366. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71367. }
  71368. }
  71369. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71370. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71371. /** @hidden */
  71372. export var extractHighlightsPixelShader: {
  71373. name: string;
  71374. shader: string;
  71375. };
  71376. }
  71377. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71378. import { Nullable } from "babylonjs/types";
  71379. import { Camera } from "babylonjs/Cameras/camera";
  71380. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71381. import { Engine } from "babylonjs/Engines/engine";
  71382. import "babylonjs/Shaders/extractHighlights.fragment";
  71383. /**
  71384. * 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.
  71385. */
  71386. export class ExtractHighlightsPostProcess extends PostProcess {
  71387. /**
  71388. * The luminance threshold, pixels below this value will be set to black.
  71389. */
  71390. threshold: number;
  71391. /** @hidden */
  71392. _exposure: number;
  71393. /**
  71394. * Post process which has the input texture to be used when performing highlight extraction
  71395. * @hidden
  71396. */
  71397. _inputPostProcess: Nullable<PostProcess>;
  71398. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71399. }
  71400. }
  71401. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71402. /** @hidden */
  71403. export var bloomMergePixelShader: {
  71404. name: string;
  71405. shader: string;
  71406. };
  71407. }
  71408. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71409. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71410. import { Nullable } from "babylonjs/types";
  71411. import { Engine } from "babylonjs/Engines/engine";
  71412. import { Camera } from "babylonjs/Cameras/camera";
  71413. import "babylonjs/Shaders/bloomMerge.fragment";
  71414. /**
  71415. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71416. */
  71417. export class BloomMergePostProcess extends PostProcess {
  71418. /** Weight of the bloom to be added to the original input. */
  71419. weight: number;
  71420. /**
  71421. * Creates a new instance of @see BloomMergePostProcess
  71422. * @param name The name of the effect.
  71423. * @param originalFromInput Post process which's input will be used for the merge.
  71424. * @param blurred Blurred highlights post process which's output will be used.
  71425. * @param weight Weight of the bloom to be added to the original input.
  71426. * @param options The required width/height ratio to downsize to before computing the render pass.
  71427. * @param camera The camera to apply the render pass to.
  71428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71429. * @param engine The engine which the post process will be applied. (default: current engine)
  71430. * @param reusable If the post process can be reused on the same frame. (default: false)
  71431. * @param textureType Type of textures used when performing the post process. (default: 0)
  71432. * @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)
  71433. */
  71434. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71435. /** Weight of the bloom to be added to the original input. */
  71436. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71437. }
  71438. }
  71439. declare module "babylonjs/PostProcesses/bloomEffect" {
  71440. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71441. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71442. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71443. import { Camera } from "babylonjs/Cameras/camera";
  71444. import { Scene } from "babylonjs/scene";
  71445. /**
  71446. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71447. */
  71448. export class BloomEffect extends PostProcessRenderEffect {
  71449. private bloomScale;
  71450. /**
  71451. * @hidden Internal
  71452. */
  71453. _effects: Array<PostProcess>;
  71454. /**
  71455. * @hidden Internal
  71456. */
  71457. _downscale: ExtractHighlightsPostProcess;
  71458. private _blurX;
  71459. private _blurY;
  71460. private _merge;
  71461. /**
  71462. * The luminance threshold to find bright areas of the image to bloom.
  71463. */
  71464. get threshold(): number;
  71465. set threshold(value: number);
  71466. /**
  71467. * The strength of the bloom.
  71468. */
  71469. get weight(): number;
  71470. set weight(value: number);
  71471. /**
  71472. * Specifies the size of the bloom blur kernel, relative to the final output size
  71473. */
  71474. get kernel(): number;
  71475. set kernel(value: number);
  71476. /**
  71477. * Creates a new instance of @see BloomEffect
  71478. * @param scene The scene the effect belongs to.
  71479. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71480. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71481. * @param bloomWeight The the strength of bloom.
  71482. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71483. * @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)
  71484. */
  71485. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71486. /**
  71487. * Disposes each of the internal effects for a given camera.
  71488. * @param camera The camera to dispose the effect on.
  71489. */
  71490. disposeEffects(camera: Camera): void;
  71491. /**
  71492. * @hidden Internal
  71493. */
  71494. _updateEffects(): void;
  71495. /**
  71496. * Internal
  71497. * @returns if all the contained post processes are ready.
  71498. * @hidden
  71499. */
  71500. _isReady(): boolean;
  71501. }
  71502. }
  71503. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71504. /** @hidden */
  71505. export var chromaticAberrationPixelShader: {
  71506. name: string;
  71507. shader: string;
  71508. };
  71509. }
  71510. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71511. import { Vector2 } from "babylonjs/Maths/math.vector";
  71512. import { Nullable } from "babylonjs/types";
  71513. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71514. import { Camera } from "babylonjs/Cameras/camera";
  71515. import { Engine } from "babylonjs/Engines/engine";
  71516. import "babylonjs/Shaders/chromaticAberration.fragment";
  71517. /**
  71518. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71519. */
  71520. export class ChromaticAberrationPostProcess extends PostProcess {
  71521. /**
  71522. * The amount of seperation of rgb channels (default: 30)
  71523. */
  71524. aberrationAmount: number;
  71525. /**
  71526. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71527. */
  71528. radialIntensity: number;
  71529. /**
  71530. * 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))
  71531. */
  71532. direction: Vector2;
  71533. /**
  71534. * 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))
  71535. */
  71536. centerPosition: Vector2;
  71537. /**
  71538. * Creates a new instance ChromaticAberrationPostProcess
  71539. * @param name The name of the effect.
  71540. * @param screenWidth The width of the screen to apply the effect on.
  71541. * @param screenHeight The height of the screen to apply the effect on.
  71542. * @param options The required width/height ratio to downsize to before computing the render pass.
  71543. * @param camera The camera to apply the render pass to.
  71544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71545. * @param engine The engine which the post process will be applied. (default: current engine)
  71546. * @param reusable If the post process can be reused on the same frame. (default: false)
  71547. * @param textureType Type of textures used when performing the post process. (default: 0)
  71548. * @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)
  71549. */
  71550. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71551. }
  71552. }
  71553. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71554. /** @hidden */
  71555. export var circleOfConfusionPixelShader: {
  71556. name: string;
  71557. shader: string;
  71558. };
  71559. }
  71560. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71561. import { Nullable } from "babylonjs/types";
  71562. import { Engine } from "babylonjs/Engines/engine";
  71563. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71564. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71565. import { Camera } from "babylonjs/Cameras/camera";
  71566. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71567. /**
  71568. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71569. */
  71570. export class CircleOfConfusionPostProcess extends PostProcess {
  71571. /**
  71572. * 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.
  71573. */
  71574. lensSize: number;
  71575. /**
  71576. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71577. */
  71578. fStop: number;
  71579. /**
  71580. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71581. */
  71582. focusDistance: number;
  71583. /**
  71584. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71585. */
  71586. focalLength: number;
  71587. private _depthTexture;
  71588. /**
  71589. * Creates a new instance CircleOfConfusionPostProcess
  71590. * @param name The name of the effect.
  71591. * @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.
  71592. * @param options The required width/height ratio to downsize to before computing the render pass.
  71593. * @param camera The camera to apply the render pass to.
  71594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71595. * @param engine The engine which the post process will be applied. (default: current engine)
  71596. * @param reusable If the post process can be reused on the same frame. (default: false)
  71597. * @param textureType Type of textures used when performing the post process. (default: 0)
  71598. * @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)
  71599. */
  71600. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71601. /**
  71602. * 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.
  71603. */
  71604. set depthTexture(value: RenderTargetTexture);
  71605. }
  71606. }
  71607. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71608. /** @hidden */
  71609. export var colorCorrectionPixelShader: {
  71610. name: string;
  71611. shader: string;
  71612. };
  71613. }
  71614. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71615. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71616. import { Engine } from "babylonjs/Engines/engine";
  71617. import { Camera } from "babylonjs/Cameras/camera";
  71618. import "babylonjs/Shaders/colorCorrection.fragment";
  71619. /**
  71620. *
  71621. * This post-process allows the modification of rendered colors by using
  71622. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71623. *
  71624. * The object needs to be provided an url to a texture containing the color
  71625. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71626. * Use an image editing software to tweak the LUT to match your needs.
  71627. *
  71628. * For an example of a color LUT, see here:
  71629. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71630. * For explanations on color grading, see here:
  71631. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71632. *
  71633. */
  71634. export class ColorCorrectionPostProcess extends PostProcess {
  71635. private _colorTableTexture;
  71636. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71637. }
  71638. }
  71639. declare module "babylonjs/Shaders/convolution.fragment" {
  71640. /** @hidden */
  71641. export var convolutionPixelShader: {
  71642. name: string;
  71643. shader: string;
  71644. };
  71645. }
  71646. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71647. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71648. import { Nullable } from "babylonjs/types";
  71649. import { Camera } from "babylonjs/Cameras/camera";
  71650. import { Engine } from "babylonjs/Engines/engine";
  71651. import "babylonjs/Shaders/convolution.fragment";
  71652. /**
  71653. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71654. * input texture to perform effects such as edge detection or sharpening
  71655. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71656. */
  71657. export class ConvolutionPostProcess extends PostProcess {
  71658. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71659. kernel: number[];
  71660. /**
  71661. * Creates a new instance ConvolutionPostProcess
  71662. * @param name The name of the effect.
  71663. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71664. * @param options The required width/height ratio to downsize to before computing the render pass.
  71665. * @param camera The camera to apply the render pass to.
  71666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71667. * @param engine The engine which the post process will be applied. (default: current engine)
  71668. * @param reusable If the post process can be reused on the same frame. (default: false)
  71669. * @param textureType Type of textures used when performing the post process. (default: 0)
  71670. */
  71671. constructor(name: string,
  71672. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71673. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71674. /**
  71675. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71676. */
  71677. static EdgeDetect0Kernel: number[];
  71678. /**
  71679. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71680. */
  71681. static EdgeDetect1Kernel: number[];
  71682. /**
  71683. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71684. */
  71685. static EdgeDetect2Kernel: number[];
  71686. /**
  71687. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71688. */
  71689. static SharpenKernel: number[];
  71690. /**
  71691. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71692. */
  71693. static EmbossKernel: number[];
  71694. /**
  71695. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71696. */
  71697. static GaussianKernel: number[];
  71698. }
  71699. }
  71700. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71701. import { Nullable } from "babylonjs/types";
  71702. import { Vector2 } from "babylonjs/Maths/math.vector";
  71703. import { Camera } from "babylonjs/Cameras/camera";
  71704. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71705. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71706. import { Engine } from "babylonjs/Engines/engine";
  71707. import { Scene } from "babylonjs/scene";
  71708. /**
  71709. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71710. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71711. * based on samples that have a large difference in distance than the center pixel.
  71712. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71713. */
  71714. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71715. direction: Vector2;
  71716. /**
  71717. * Creates a new instance CircleOfConfusionPostProcess
  71718. * @param name The name of the effect.
  71719. * @param scene The scene the effect belongs to.
  71720. * @param direction The direction the blur should be applied.
  71721. * @param kernel The size of the kernel used to blur.
  71722. * @param options The required width/height ratio to downsize to before computing the render pass.
  71723. * @param camera The camera to apply the render pass to.
  71724. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71725. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71727. * @param engine The engine which the post process will be applied. (default: current engine)
  71728. * @param reusable If the post process can be reused on the same frame. (default: false)
  71729. * @param textureType Type of textures used when performing the post process. (default: 0)
  71730. * @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)
  71731. */
  71732. 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);
  71733. }
  71734. }
  71735. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71736. /** @hidden */
  71737. export var depthOfFieldMergePixelShader: {
  71738. name: string;
  71739. shader: string;
  71740. };
  71741. }
  71742. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71743. import { Nullable } from "babylonjs/types";
  71744. import { Camera } from "babylonjs/Cameras/camera";
  71745. import { Effect } from "babylonjs/Materials/effect";
  71746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71747. import { Engine } from "babylonjs/Engines/engine";
  71748. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71749. /**
  71750. * Options to be set when merging outputs from the default pipeline.
  71751. */
  71752. export class DepthOfFieldMergePostProcessOptions {
  71753. /**
  71754. * The original image to merge on top of
  71755. */
  71756. originalFromInput: PostProcess;
  71757. /**
  71758. * Parameters to perform the merge of the depth of field effect
  71759. */
  71760. depthOfField?: {
  71761. circleOfConfusion: PostProcess;
  71762. blurSteps: Array<PostProcess>;
  71763. };
  71764. /**
  71765. * Parameters to perform the merge of bloom effect
  71766. */
  71767. bloom?: {
  71768. blurred: PostProcess;
  71769. weight: number;
  71770. };
  71771. }
  71772. /**
  71773. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71774. */
  71775. export class DepthOfFieldMergePostProcess extends PostProcess {
  71776. private blurSteps;
  71777. /**
  71778. * Creates a new instance of DepthOfFieldMergePostProcess
  71779. * @param name The name of the effect.
  71780. * @param originalFromInput Post process which's input will be used for the merge.
  71781. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71782. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71783. * @param options The required width/height ratio to downsize to before computing the render pass.
  71784. * @param camera The camera to apply the render pass to.
  71785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71786. * @param engine The engine which the post process will be applied. (default: current engine)
  71787. * @param reusable If the post process can be reused on the same frame. (default: false)
  71788. * @param textureType Type of textures used when performing the post process. (default: 0)
  71789. * @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)
  71790. */
  71791. 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);
  71792. /**
  71793. * Updates the effect with the current post process compile time values and recompiles the shader.
  71794. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71795. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71796. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71797. * @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
  71798. * @param onCompiled Called when the shader has been compiled.
  71799. * @param onError Called if there is an error when compiling a shader.
  71800. */
  71801. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71802. }
  71803. }
  71804. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71805. import { Nullable } from "babylonjs/types";
  71806. import { Camera } from "babylonjs/Cameras/camera";
  71807. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71808. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71809. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71810. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71811. import { Scene } from "babylonjs/scene";
  71812. /**
  71813. * Specifies the level of max blur that should be applied when using the depth of field effect
  71814. */
  71815. export enum DepthOfFieldEffectBlurLevel {
  71816. /**
  71817. * Subtle blur
  71818. */
  71819. Low = 0,
  71820. /**
  71821. * Medium blur
  71822. */
  71823. Medium = 1,
  71824. /**
  71825. * Large blur
  71826. */
  71827. High = 2
  71828. }
  71829. /**
  71830. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71831. */
  71832. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71833. private _circleOfConfusion;
  71834. /**
  71835. * @hidden Internal, blurs from high to low
  71836. */
  71837. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71838. private _depthOfFieldBlurY;
  71839. private _dofMerge;
  71840. /**
  71841. * @hidden Internal post processes in depth of field effect
  71842. */
  71843. _effects: Array<PostProcess>;
  71844. /**
  71845. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71846. */
  71847. set focalLength(value: number);
  71848. get focalLength(): number;
  71849. /**
  71850. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71851. */
  71852. set fStop(value: number);
  71853. get fStop(): number;
  71854. /**
  71855. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71856. */
  71857. set focusDistance(value: number);
  71858. get focusDistance(): number;
  71859. /**
  71860. * 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.
  71861. */
  71862. set lensSize(value: number);
  71863. get lensSize(): number;
  71864. /**
  71865. * Creates a new instance DepthOfFieldEffect
  71866. * @param scene The scene the effect belongs to.
  71867. * @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.
  71868. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71869. * @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)
  71870. */
  71871. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71872. /**
  71873. * Get the current class name of the current effet
  71874. * @returns "DepthOfFieldEffect"
  71875. */
  71876. getClassName(): string;
  71877. /**
  71878. * 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.
  71879. */
  71880. set depthTexture(value: RenderTargetTexture);
  71881. /**
  71882. * Disposes each of the internal effects for a given camera.
  71883. * @param camera The camera to dispose the effect on.
  71884. */
  71885. disposeEffects(camera: Camera): void;
  71886. /**
  71887. * @hidden Internal
  71888. */
  71889. _updateEffects(): void;
  71890. /**
  71891. * Internal
  71892. * @returns if all the contained post processes are ready.
  71893. * @hidden
  71894. */
  71895. _isReady(): boolean;
  71896. }
  71897. }
  71898. declare module "babylonjs/Shaders/displayPass.fragment" {
  71899. /** @hidden */
  71900. export var displayPassPixelShader: {
  71901. name: string;
  71902. shader: string;
  71903. };
  71904. }
  71905. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  71906. import { Nullable } from "babylonjs/types";
  71907. import { Camera } from "babylonjs/Cameras/camera";
  71908. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71909. import { Engine } from "babylonjs/Engines/engine";
  71910. import "babylonjs/Shaders/displayPass.fragment";
  71911. /**
  71912. * DisplayPassPostProcess which produces an output the same as it's input
  71913. */
  71914. export class DisplayPassPostProcess extends PostProcess {
  71915. /**
  71916. * Creates the DisplayPassPostProcess
  71917. * @param name The name of the effect.
  71918. * @param options The required width/height ratio to downsize to before computing the render pass.
  71919. * @param camera The camera to apply the render pass to.
  71920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71921. * @param engine The engine which the post process will be applied. (default: current engine)
  71922. * @param reusable If the post process can be reused on the same frame. (default: false)
  71923. */
  71924. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71925. }
  71926. }
  71927. declare module "babylonjs/Shaders/filter.fragment" {
  71928. /** @hidden */
  71929. export var filterPixelShader: {
  71930. name: string;
  71931. shader: string;
  71932. };
  71933. }
  71934. declare module "babylonjs/PostProcesses/filterPostProcess" {
  71935. import { Nullable } from "babylonjs/types";
  71936. import { Matrix } from "babylonjs/Maths/math.vector";
  71937. import { Camera } from "babylonjs/Cameras/camera";
  71938. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71939. import { Engine } from "babylonjs/Engines/engine";
  71940. import "babylonjs/Shaders/filter.fragment";
  71941. /**
  71942. * Applies a kernel filter to the image
  71943. */
  71944. export class FilterPostProcess extends PostProcess {
  71945. /** The matrix to be applied to the image */
  71946. kernelMatrix: Matrix;
  71947. /**
  71948. *
  71949. * @param name The name of the effect.
  71950. * @param kernelMatrix The matrix to be applied to the image
  71951. * @param options The required width/height ratio to downsize to before computing the render pass.
  71952. * @param camera The camera to apply the render pass to.
  71953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71954. * @param engine The engine which the post process will be applied. (default: current engine)
  71955. * @param reusable If the post process can be reused on the same frame. (default: false)
  71956. */
  71957. constructor(name: string,
  71958. /** The matrix to be applied to the image */
  71959. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71960. }
  71961. }
  71962. declare module "babylonjs/Shaders/fxaa.fragment" {
  71963. /** @hidden */
  71964. export var fxaaPixelShader: {
  71965. name: string;
  71966. shader: string;
  71967. };
  71968. }
  71969. declare module "babylonjs/Shaders/fxaa.vertex" {
  71970. /** @hidden */
  71971. export var fxaaVertexShader: {
  71972. name: string;
  71973. shader: string;
  71974. };
  71975. }
  71976. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  71977. import { Nullable } from "babylonjs/types";
  71978. import { Camera } from "babylonjs/Cameras/camera";
  71979. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71980. import { Engine } from "babylonjs/Engines/engine";
  71981. import "babylonjs/Shaders/fxaa.fragment";
  71982. import "babylonjs/Shaders/fxaa.vertex";
  71983. /**
  71984. * Fxaa post process
  71985. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71986. */
  71987. export class FxaaPostProcess extends PostProcess {
  71988. /** @hidden */
  71989. texelWidth: number;
  71990. /** @hidden */
  71991. texelHeight: number;
  71992. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71993. private _getDefines;
  71994. }
  71995. }
  71996. declare module "babylonjs/Shaders/grain.fragment" {
  71997. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71998. /** @hidden */
  71999. export var grainPixelShader: {
  72000. name: string;
  72001. shader: string;
  72002. };
  72003. }
  72004. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72005. import { Nullable } from "babylonjs/types";
  72006. import { Camera } from "babylonjs/Cameras/camera";
  72007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72008. import { Engine } from "babylonjs/Engines/engine";
  72009. import "babylonjs/Shaders/grain.fragment";
  72010. /**
  72011. * The GrainPostProcess adds noise to the image at mid luminance levels
  72012. */
  72013. export class GrainPostProcess extends PostProcess {
  72014. /**
  72015. * The intensity of the grain added (default: 30)
  72016. */
  72017. intensity: number;
  72018. /**
  72019. * If the grain should be randomized on every frame
  72020. */
  72021. animated: boolean;
  72022. /**
  72023. * Creates a new instance of @see GrainPostProcess
  72024. * @param name The name of the effect.
  72025. * @param options The required width/height ratio to downsize to before computing the render pass.
  72026. * @param camera The camera to apply the render pass to.
  72027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72028. * @param engine The engine which the post process will be applied. (default: current engine)
  72029. * @param reusable If the post process can be reused on the same frame. (default: false)
  72030. * @param textureType Type of textures used when performing the post process. (default: 0)
  72031. * @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)
  72032. */
  72033. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72034. }
  72035. }
  72036. declare module "babylonjs/Shaders/highlights.fragment" {
  72037. /** @hidden */
  72038. export var highlightsPixelShader: {
  72039. name: string;
  72040. shader: string;
  72041. };
  72042. }
  72043. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72044. import { Nullable } from "babylonjs/types";
  72045. import { Camera } from "babylonjs/Cameras/camera";
  72046. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72047. import { Engine } from "babylonjs/Engines/engine";
  72048. import "babylonjs/Shaders/highlights.fragment";
  72049. /**
  72050. * Extracts highlights from the image
  72051. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72052. */
  72053. export class HighlightsPostProcess extends PostProcess {
  72054. /**
  72055. * Extracts highlights from the image
  72056. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72057. * @param name The name of the effect.
  72058. * @param options The required width/height ratio to downsize to before computing the render pass.
  72059. * @param camera The camera to apply the render pass to.
  72060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72061. * @param engine The engine which the post process will be applied. (default: current engine)
  72062. * @param reusable If the post process can be reused on the same frame. (default: false)
  72063. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72064. */
  72065. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72066. }
  72067. }
  72068. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72069. /** @hidden */
  72070. export var mrtFragmentDeclaration: {
  72071. name: string;
  72072. shader: string;
  72073. };
  72074. }
  72075. declare module "babylonjs/Shaders/geometry.fragment" {
  72076. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72077. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72078. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72079. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72080. /** @hidden */
  72081. export var geometryPixelShader: {
  72082. name: string;
  72083. shader: string;
  72084. };
  72085. }
  72086. declare module "babylonjs/Shaders/geometry.vertex" {
  72087. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72088. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72089. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72090. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72091. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72092. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72093. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72094. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72095. /** @hidden */
  72096. export var geometryVertexShader: {
  72097. name: string;
  72098. shader: string;
  72099. };
  72100. }
  72101. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72102. import { Matrix } from "babylonjs/Maths/math.vector";
  72103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72104. import { Mesh } from "babylonjs/Meshes/mesh";
  72105. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72106. import { Effect } from "babylonjs/Materials/effect";
  72107. import { Scene } from "babylonjs/scene";
  72108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72109. import "babylonjs/Shaders/geometry.fragment";
  72110. import "babylonjs/Shaders/geometry.vertex";
  72111. /** @hidden */
  72112. interface ISavedTransformationMatrix {
  72113. world: Matrix;
  72114. viewProjection: Matrix;
  72115. }
  72116. /**
  72117. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72118. */
  72119. export class GeometryBufferRenderer {
  72120. /**
  72121. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72122. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72123. */
  72124. static readonly POSITION_TEXTURE_TYPE: number;
  72125. /**
  72126. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72127. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72128. */
  72129. static readonly VELOCITY_TEXTURE_TYPE: number;
  72130. /**
  72131. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72132. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72133. */
  72134. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72135. /**
  72136. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72137. * in order to compute objects velocities when enableVelocity is set to "true"
  72138. * @hidden
  72139. */
  72140. _previousTransformationMatrices: {
  72141. [index: number]: ISavedTransformationMatrix;
  72142. };
  72143. /**
  72144. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72145. * in order to compute objects velocities when enableVelocity is set to "true"
  72146. * @hidden
  72147. */
  72148. _previousBonesTransformationMatrices: {
  72149. [index: number]: Float32Array;
  72150. };
  72151. /**
  72152. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72153. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72154. */
  72155. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72156. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72157. renderTransparentMeshes: boolean;
  72158. private _scene;
  72159. private _multiRenderTarget;
  72160. private _ratio;
  72161. private _enablePosition;
  72162. private _enableVelocity;
  72163. private _enableReflectivity;
  72164. private _positionIndex;
  72165. private _velocityIndex;
  72166. private _reflectivityIndex;
  72167. protected _effect: Effect;
  72168. protected _cachedDefines: string;
  72169. /**
  72170. * Set the render list (meshes to be rendered) used in the G buffer.
  72171. */
  72172. set renderList(meshes: Mesh[]);
  72173. /**
  72174. * Gets wether or not G buffer are supported by the running hardware.
  72175. * This requires draw buffer supports
  72176. */
  72177. get isSupported(): boolean;
  72178. /**
  72179. * Returns the index of the given texture type in the G-Buffer textures array
  72180. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72181. * @returns the index of the given texture type in the G-Buffer textures array
  72182. */
  72183. getTextureIndex(textureType: number): number;
  72184. /**
  72185. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72186. */
  72187. get enablePosition(): boolean;
  72188. /**
  72189. * Sets whether or not objects positions are enabled for the G buffer.
  72190. */
  72191. set enablePosition(enable: boolean);
  72192. /**
  72193. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72194. */
  72195. get enableVelocity(): boolean;
  72196. /**
  72197. * Sets wether or not objects velocities are enabled for the G buffer.
  72198. */
  72199. set enableVelocity(enable: boolean);
  72200. /**
  72201. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72202. */
  72203. get enableReflectivity(): boolean;
  72204. /**
  72205. * Sets wether or not objects roughness are enabled for the G buffer.
  72206. */
  72207. set enableReflectivity(enable: boolean);
  72208. /**
  72209. * Gets the scene associated with the buffer.
  72210. */
  72211. get scene(): Scene;
  72212. /**
  72213. * Gets the ratio used by the buffer during its creation.
  72214. * How big is the buffer related to the main canvas.
  72215. */
  72216. get ratio(): number;
  72217. /** @hidden */
  72218. static _SceneComponentInitialization: (scene: Scene) => void;
  72219. /**
  72220. * Creates a new G Buffer for the scene
  72221. * @param scene The scene the buffer belongs to
  72222. * @param ratio How big is the buffer related to the main canvas.
  72223. */
  72224. constructor(scene: Scene, ratio?: number);
  72225. /**
  72226. * Checks wether everything is ready to render a submesh to the G buffer.
  72227. * @param subMesh the submesh to check readiness for
  72228. * @param useInstances is the mesh drawn using instance or not
  72229. * @returns true if ready otherwise false
  72230. */
  72231. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72232. /**
  72233. * Gets the current underlying G Buffer.
  72234. * @returns the buffer
  72235. */
  72236. getGBuffer(): MultiRenderTarget;
  72237. /**
  72238. * Gets the number of samples used to render the buffer (anti aliasing).
  72239. */
  72240. get samples(): number;
  72241. /**
  72242. * Sets the number of samples used to render the buffer (anti aliasing).
  72243. */
  72244. set samples(value: number);
  72245. /**
  72246. * Disposes the renderer and frees up associated resources.
  72247. */
  72248. dispose(): void;
  72249. protected _createRenderTargets(): void;
  72250. private _copyBonesTransformationMatrices;
  72251. }
  72252. }
  72253. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72254. import { Nullable } from "babylonjs/types";
  72255. import { Scene } from "babylonjs/scene";
  72256. import { ISceneComponent } from "babylonjs/sceneComponent";
  72257. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72258. module "babylonjs/scene" {
  72259. interface Scene {
  72260. /** @hidden (Backing field) */
  72261. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72262. /**
  72263. * Gets or Sets the current geometry buffer associated to the scene.
  72264. */
  72265. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72266. /**
  72267. * Enables a GeometryBufferRender and associates it with the scene
  72268. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72269. * @returns the GeometryBufferRenderer
  72270. */
  72271. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72272. /**
  72273. * Disables the GeometryBufferRender associated with the scene
  72274. */
  72275. disableGeometryBufferRenderer(): void;
  72276. }
  72277. }
  72278. /**
  72279. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72280. * in several rendering techniques.
  72281. */
  72282. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72283. /**
  72284. * The component name helpful to identify the component in the list of scene components.
  72285. */
  72286. readonly name: string;
  72287. /**
  72288. * The scene the component belongs to.
  72289. */
  72290. scene: Scene;
  72291. /**
  72292. * Creates a new instance of the component for the given scene
  72293. * @param scene Defines the scene to register the component in
  72294. */
  72295. constructor(scene: Scene);
  72296. /**
  72297. * Registers the component in a given scene
  72298. */
  72299. register(): void;
  72300. /**
  72301. * Rebuilds the elements related to this component in case of
  72302. * context lost for instance.
  72303. */
  72304. rebuild(): void;
  72305. /**
  72306. * Disposes the component and the associated ressources
  72307. */
  72308. dispose(): void;
  72309. private _gatherRenderTargets;
  72310. }
  72311. }
  72312. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72313. /** @hidden */
  72314. export var motionBlurPixelShader: {
  72315. name: string;
  72316. shader: string;
  72317. };
  72318. }
  72319. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72320. import { Nullable } from "babylonjs/types";
  72321. import { Camera } from "babylonjs/Cameras/camera";
  72322. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72323. import { Scene } from "babylonjs/scene";
  72324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72325. import "babylonjs/Animations/animatable";
  72326. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72327. import "babylonjs/Shaders/motionBlur.fragment";
  72328. import { Engine } from "babylonjs/Engines/engine";
  72329. /**
  72330. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72331. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72332. * As an example, all you have to do is to create the post-process:
  72333. * var mb = new BABYLON.MotionBlurPostProcess(
  72334. * 'mb', // The name of the effect.
  72335. * scene, // The scene containing the objects to blur according to their velocity.
  72336. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72337. * camera // The camera to apply the render pass to.
  72338. * );
  72339. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72340. */
  72341. export class MotionBlurPostProcess extends PostProcess {
  72342. /**
  72343. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72344. */
  72345. motionStrength: number;
  72346. /**
  72347. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72348. */
  72349. get motionBlurSamples(): number;
  72350. /**
  72351. * Sets the number of iterations to be used for motion blur quality
  72352. */
  72353. set motionBlurSamples(samples: number);
  72354. private _motionBlurSamples;
  72355. private _geometryBufferRenderer;
  72356. /**
  72357. * Creates a new instance MotionBlurPostProcess
  72358. * @param name The name of the effect.
  72359. * @param scene The scene containing the objects to blur according to their velocity.
  72360. * @param options The required width/height ratio to downsize to before computing the render pass.
  72361. * @param camera The camera to apply the render pass to.
  72362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72363. * @param engine The engine which the post process will be applied. (default: current engine)
  72364. * @param reusable If the post process can be reused on the same frame. (default: false)
  72365. * @param textureType Type of textures used when performing the post process. (default: 0)
  72366. * @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)
  72367. */
  72368. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72369. /**
  72370. * Excludes the given skinned mesh from computing bones velocities.
  72371. * 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.
  72372. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72373. */
  72374. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72375. /**
  72376. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72377. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72378. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72379. */
  72380. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72381. /**
  72382. * Disposes the post process.
  72383. * @param camera The camera to dispose the post process on.
  72384. */
  72385. dispose(camera?: Camera): void;
  72386. }
  72387. }
  72388. declare module "babylonjs/Shaders/refraction.fragment" {
  72389. /** @hidden */
  72390. export var refractionPixelShader: {
  72391. name: string;
  72392. shader: string;
  72393. };
  72394. }
  72395. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72396. import { Color3 } from "babylonjs/Maths/math.color";
  72397. import { Camera } from "babylonjs/Cameras/camera";
  72398. import { Texture } from "babylonjs/Materials/Textures/texture";
  72399. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72400. import { Engine } from "babylonjs/Engines/engine";
  72401. import "babylonjs/Shaders/refraction.fragment";
  72402. /**
  72403. * Post process which applies a refractin texture
  72404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72405. */
  72406. export class RefractionPostProcess extends PostProcess {
  72407. /** the base color of the refraction (used to taint the rendering) */
  72408. color: Color3;
  72409. /** simulated refraction depth */
  72410. depth: number;
  72411. /** the coefficient of the base color (0 to remove base color tainting) */
  72412. colorLevel: number;
  72413. private _refTexture;
  72414. private _ownRefractionTexture;
  72415. /**
  72416. * Gets or sets the refraction texture
  72417. * Please note that you are responsible for disposing the texture if you set it manually
  72418. */
  72419. get refractionTexture(): Texture;
  72420. set refractionTexture(value: Texture);
  72421. /**
  72422. * Initializes the RefractionPostProcess
  72423. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72424. * @param name The name of the effect.
  72425. * @param refractionTextureUrl Url of the refraction texture to use
  72426. * @param color the base color of the refraction (used to taint the rendering)
  72427. * @param depth simulated refraction depth
  72428. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72429. * @param camera The camera to apply the render pass to.
  72430. * @param options The required width/height ratio to downsize to before computing the render pass.
  72431. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72432. * @param engine The engine which the post process will be applied. (default: current engine)
  72433. * @param reusable If the post process can be reused on the same frame. (default: false)
  72434. */
  72435. constructor(name: string, refractionTextureUrl: string,
  72436. /** the base color of the refraction (used to taint the rendering) */
  72437. color: Color3,
  72438. /** simulated refraction depth */
  72439. depth: number,
  72440. /** the coefficient of the base color (0 to remove base color tainting) */
  72441. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72442. /**
  72443. * Disposes of the post process
  72444. * @param camera Camera to dispose post process on
  72445. */
  72446. dispose(camera: Camera): void;
  72447. }
  72448. }
  72449. declare module "babylonjs/Shaders/sharpen.fragment" {
  72450. /** @hidden */
  72451. export var sharpenPixelShader: {
  72452. name: string;
  72453. shader: string;
  72454. };
  72455. }
  72456. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72457. import { Nullable } from "babylonjs/types";
  72458. import { Camera } from "babylonjs/Cameras/camera";
  72459. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72460. import "babylonjs/Shaders/sharpen.fragment";
  72461. import { Engine } from "babylonjs/Engines/engine";
  72462. /**
  72463. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72464. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72465. */
  72466. export class SharpenPostProcess extends PostProcess {
  72467. /**
  72468. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72469. */
  72470. colorAmount: number;
  72471. /**
  72472. * How much sharpness should be applied (default: 0.3)
  72473. */
  72474. edgeAmount: number;
  72475. /**
  72476. * Creates a new instance ConvolutionPostProcess
  72477. * @param name The name of the effect.
  72478. * @param options The required width/height ratio to downsize to before computing the render pass.
  72479. * @param camera The camera to apply the render pass to.
  72480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72481. * @param engine The engine which the post process will be applied. (default: current engine)
  72482. * @param reusable If the post process can be reused on the same frame. (default: false)
  72483. * @param textureType Type of textures used when performing the post process. (default: 0)
  72484. * @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)
  72485. */
  72486. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72487. }
  72488. }
  72489. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72490. import { Nullable } from "babylonjs/types";
  72491. import { Camera } from "babylonjs/Cameras/camera";
  72492. import { Engine } from "babylonjs/Engines/engine";
  72493. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72494. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72495. /**
  72496. * PostProcessRenderPipeline
  72497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72498. */
  72499. export class PostProcessRenderPipeline {
  72500. private engine;
  72501. private _renderEffects;
  72502. private _renderEffectsForIsolatedPass;
  72503. /**
  72504. * List of inspectable custom properties (used by the Inspector)
  72505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72506. */
  72507. inspectableCustomProperties: IInspectable[];
  72508. /**
  72509. * @hidden
  72510. */
  72511. protected _cameras: Camera[];
  72512. /** @hidden */
  72513. _name: string;
  72514. /**
  72515. * Gets pipeline name
  72516. */
  72517. get name(): string;
  72518. /** Gets the list of attached cameras */
  72519. get cameras(): Camera[];
  72520. /**
  72521. * Initializes a PostProcessRenderPipeline
  72522. * @param engine engine to add the pipeline to
  72523. * @param name name of the pipeline
  72524. */
  72525. constructor(engine: Engine, name: string);
  72526. /**
  72527. * Gets the class name
  72528. * @returns "PostProcessRenderPipeline"
  72529. */
  72530. getClassName(): string;
  72531. /**
  72532. * If all the render effects in the pipeline are supported
  72533. */
  72534. get isSupported(): boolean;
  72535. /**
  72536. * Adds an effect to the pipeline
  72537. * @param renderEffect the effect to add
  72538. */
  72539. addEffect(renderEffect: PostProcessRenderEffect): void;
  72540. /** @hidden */
  72541. _rebuild(): void;
  72542. /** @hidden */
  72543. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72544. /** @hidden */
  72545. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72546. /** @hidden */
  72547. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72548. /** @hidden */
  72549. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72550. /** @hidden */
  72551. _attachCameras(cameras: Camera, unique: boolean): void;
  72552. /** @hidden */
  72553. _attachCameras(cameras: Camera[], unique: boolean): void;
  72554. /** @hidden */
  72555. _detachCameras(cameras: Camera): void;
  72556. /** @hidden */
  72557. _detachCameras(cameras: Nullable<Camera[]>): void;
  72558. /** @hidden */
  72559. _update(): void;
  72560. /** @hidden */
  72561. _reset(): void;
  72562. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72563. /**
  72564. * Disposes of the pipeline
  72565. */
  72566. dispose(): void;
  72567. }
  72568. }
  72569. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72570. import { Camera } from "babylonjs/Cameras/camera";
  72571. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72572. /**
  72573. * PostProcessRenderPipelineManager class
  72574. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72575. */
  72576. export class PostProcessRenderPipelineManager {
  72577. private _renderPipelines;
  72578. /**
  72579. * Initializes a PostProcessRenderPipelineManager
  72580. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72581. */
  72582. constructor();
  72583. /**
  72584. * Gets the list of supported render pipelines
  72585. */
  72586. get supportedPipelines(): PostProcessRenderPipeline[];
  72587. /**
  72588. * Adds a pipeline to the manager
  72589. * @param renderPipeline The pipeline to add
  72590. */
  72591. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72592. /**
  72593. * Attaches a camera to the pipeline
  72594. * @param renderPipelineName The name of the pipeline to attach to
  72595. * @param cameras the camera to attach
  72596. * @param unique if the camera can be attached multiple times to the pipeline
  72597. */
  72598. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72599. /**
  72600. * Detaches a camera from the pipeline
  72601. * @param renderPipelineName The name of the pipeline to detach from
  72602. * @param cameras the camera to detach
  72603. */
  72604. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72605. /**
  72606. * Enables an effect by name on a pipeline
  72607. * @param renderPipelineName the name of the pipeline to enable the effect in
  72608. * @param renderEffectName the name of the effect to enable
  72609. * @param cameras the cameras that the effect should be enabled on
  72610. */
  72611. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72612. /**
  72613. * Disables an effect by name on a pipeline
  72614. * @param renderPipelineName the name of the pipeline to disable the effect in
  72615. * @param renderEffectName the name of the effect to disable
  72616. * @param cameras the cameras that the effect should be disabled on
  72617. */
  72618. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72619. /**
  72620. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72621. */
  72622. update(): void;
  72623. /** @hidden */
  72624. _rebuild(): void;
  72625. /**
  72626. * Disposes of the manager and pipelines
  72627. */
  72628. dispose(): void;
  72629. }
  72630. }
  72631. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72632. import { ISceneComponent } from "babylonjs/sceneComponent";
  72633. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72634. import { Scene } from "babylonjs/scene";
  72635. module "babylonjs/scene" {
  72636. interface Scene {
  72637. /** @hidden (Backing field) */
  72638. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72639. /**
  72640. * Gets the postprocess render pipeline manager
  72641. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72642. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72643. */
  72644. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72645. }
  72646. }
  72647. /**
  72648. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72649. */
  72650. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72651. /**
  72652. * The component name helpfull to identify the component in the list of scene components.
  72653. */
  72654. readonly name: string;
  72655. /**
  72656. * The scene the component belongs to.
  72657. */
  72658. scene: Scene;
  72659. /**
  72660. * Creates a new instance of the component for the given scene
  72661. * @param scene Defines the scene to register the component in
  72662. */
  72663. constructor(scene: Scene);
  72664. /**
  72665. * Registers the component in a given scene
  72666. */
  72667. register(): void;
  72668. /**
  72669. * Rebuilds the elements related to this component in case of
  72670. * context lost for instance.
  72671. */
  72672. rebuild(): void;
  72673. /**
  72674. * Disposes the component and the associated ressources
  72675. */
  72676. dispose(): void;
  72677. private _gatherRenderTargets;
  72678. }
  72679. }
  72680. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72681. import { Nullable } from "babylonjs/types";
  72682. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72683. import { Camera } from "babylonjs/Cameras/camera";
  72684. import { IDisposable } from "babylonjs/scene";
  72685. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72686. import { Scene } from "babylonjs/scene";
  72687. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72688. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72689. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72690. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72691. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72692. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72693. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72694. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72695. import { Animation } from "babylonjs/Animations/animation";
  72696. /**
  72697. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72698. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72699. */
  72700. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72701. private _scene;
  72702. private _camerasToBeAttached;
  72703. /**
  72704. * ID of the sharpen post process,
  72705. */
  72706. private readonly SharpenPostProcessId;
  72707. /**
  72708. * @ignore
  72709. * ID of the image processing post process;
  72710. */
  72711. readonly ImageProcessingPostProcessId: string;
  72712. /**
  72713. * @ignore
  72714. * ID of the Fast Approximate Anti-Aliasing post process;
  72715. */
  72716. readonly FxaaPostProcessId: string;
  72717. /**
  72718. * ID of the chromatic aberration post process,
  72719. */
  72720. private readonly ChromaticAberrationPostProcessId;
  72721. /**
  72722. * ID of the grain post process
  72723. */
  72724. private readonly GrainPostProcessId;
  72725. /**
  72726. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72727. */
  72728. sharpen: SharpenPostProcess;
  72729. private _sharpenEffect;
  72730. private bloom;
  72731. /**
  72732. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72733. */
  72734. depthOfField: DepthOfFieldEffect;
  72735. /**
  72736. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72737. */
  72738. fxaa: FxaaPostProcess;
  72739. /**
  72740. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72741. */
  72742. imageProcessing: ImageProcessingPostProcess;
  72743. /**
  72744. * Chromatic aberration post process which will shift rgb colors in the image
  72745. */
  72746. chromaticAberration: ChromaticAberrationPostProcess;
  72747. private _chromaticAberrationEffect;
  72748. /**
  72749. * Grain post process which add noise to the image
  72750. */
  72751. grain: GrainPostProcess;
  72752. private _grainEffect;
  72753. /**
  72754. * Glow post process which adds a glow to emissive areas of the image
  72755. */
  72756. private _glowLayer;
  72757. /**
  72758. * Animations which can be used to tweak settings over a period of time
  72759. */
  72760. animations: Animation[];
  72761. private _imageProcessingConfigurationObserver;
  72762. private _sharpenEnabled;
  72763. private _bloomEnabled;
  72764. private _depthOfFieldEnabled;
  72765. private _depthOfFieldBlurLevel;
  72766. private _fxaaEnabled;
  72767. private _imageProcessingEnabled;
  72768. private _defaultPipelineTextureType;
  72769. private _bloomScale;
  72770. private _chromaticAberrationEnabled;
  72771. private _grainEnabled;
  72772. private _buildAllowed;
  72773. /**
  72774. * Gets active scene
  72775. */
  72776. get scene(): Scene;
  72777. /**
  72778. * Enable or disable the sharpen process from the pipeline
  72779. */
  72780. set sharpenEnabled(enabled: boolean);
  72781. get sharpenEnabled(): boolean;
  72782. private _resizeObserver;
  72783. private _hardwareScaleLevel;
  72784. private _bloomKernel;
  72785. /**
  72786. * Specifies the size of the bloom blur kernel, relative to the final output size
  72787. */
  72788. get bloomKernel(): number;
  72789. set bloomKernel(value: number);
  72790. /**
  72791. * Specifies the weight of the bloom in the final rendering
  72792. */
  72793. private _bloomWeight;
  72794. /**
  72795. * Specifies the luma threshold for the area that will be blurred by the bloom
  72796. */
  72797. private _bloomThreshold;
  72798. private _hdr;
  72799. /**
  72800. * The strength of the bloom.
  72801. */
  72802. set bloomWeight(value: number);
  72803. get bloomWeight(): number;
  72804. /**
  72805. * The strength of the bloom.
  72806. */
  72807. set bloomThreshold(value: number);
  72808. get bloomThreshold(): number;
  72809. /**
  72810. * The scale of the bloom, lower value will provide better performance.
  72811. */
  72812. set bloomScale(value: number);
  72813. get bloomScale(): number;
  72814. /**
  72815. * Enable or disable the bloom from the pipeline
  72816. */
  72817. set bloomEnabled(enabled: boolean);
  72818. get bloomEnabled(): boolean;
  72819. private _rebuildBloom;
  72820. /**
  72821. * If the depth of field is enabled.
  72822. */
  72823. get depthOfFieldEnabled(): boolean;
  72824. set depthOfFieldEnabled(enabled: boolean);
  72825. /**
  72826. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72827. */
  72828. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72829. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72830. /**
  72831. * If the anti aliasing is enabled.
  72832. */
  72833. set fxaaEnabled(enabled: boolean);
  72834. get fxaaEnabled(): boolean;
  72835. private _samples;
  72836. /**
  72837. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72838. */
  72839. set samples(sampleCount: number);
  72840. get samples(): number;
  72841. /**
  72842. * If image processing is enabled.
  72843. */
  72844. set imageProcessingEnabled(enabled: boolean);
  72845. get imageProcessingEnabled(): boolean;
  72846. /**
  72847. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72848. */
  72849. set glowLayerEnabled(enabled: boolean);
  72850. get glowLayerEnabled(): boolean;
  72851. /**
  72852. * Gets the glow layer (or null if not defined)
  72853. */
  72854. get glowLayer(): Nullable<GlowLayer>;
  72855. /**
  72856. * Enable or disable the chromaticAberration process from the pipeline
  72857. */
  72858. set chromaticAberrationEnabled(enabled: boolean);
  72859. get chromaticAberrationEnabled(): boolean;
  72860. /**
  72861. * Enable or disable the grain process from the pipeline
  72862. */
  72863. set grainEnabled(enabled: boolean);
  72864. get grainEnabled(): boolean;
  72865. /**
  72866. * @constructor
  72867. * @param name - The rendering pipeline name (default: "")
  72868. * @param hdr - If high dynamic range textures should be used (default: true)
  72869. * @param scene - The scene linked to this pipeline (default: the last created scene)
  72870. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  72871. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  72872. */
  72873. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  72874. /**
  72875. * Get the class name
  72876. * @returns "DefaultRenderingPipeline"
  72877. */
  72878. getClassName(): string;
  72879. /**
  72880. * Force the compilation of the entire pipeline.
  72881. */
  72882. prepare(): void;
  72883. private _hasCleared;
  72884. private _prevPostProcess;
  72885. private _prevPrevPostProcess;
  72886. private _setAutoClearAndTextureSharing;
  72887. private _depthOfFieldSceneObserver;
  72888. private _buildPipeline;
  72889. private _disposePostProcesses;
  72890. /**
  72891. * Adds a camera to the pipeline
  72892. * @param camera the camera to be added
  72893. */
  72894. addCamera(camera: Camera): void;
  72895. /**
  72896. * Removes a camera from the pipeline
  72897. * @param camera the camera to remove
  72898. */
  72899. removeCamera(camera: Camera): void;
  72900. /**
  72901. * Dispose of the pipeline and stop all post processes
  72902. */
  72903. dispose(): void;
  72904. /**
  72905. * Serialize the rendering pipeline (Used when exporting)
  72906. * @returns the serialized object
  72907. */
  72908. serialize(): any;
  72909. /**
  72910. * Parse the serialized pipeline
  72911. * @param source Source pipeline.
  72912. * @param scene The scene to load the pipeline to.
  72913. * @param rootUrl The URL of the serialized pipeline.
  72914. * @returns An instantiated pipeline from the serialized object.
  72915. */
  72916. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  72917. }
  72918. }
  72919. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  72920. /** @hidden */
  72921. export var lensHighlightsPixelShader: {
  72922. name: string;
  72923. shader: string;
  72924. };
  72925. }
  72926. declare module "babylonjs/Shaders/depthOfField.fragment" {
  72927. /** @hidden */
  72928. export var depthOfFieldPixelShader: {
  72929. name: string;
  72930. shader: string;
  72931. };
  72932. }
  72933. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  72934. import { Camera } from "babylonjs/Cameras/camera";
  72935. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72936. import { Scene } from "babylonjs/scene";
  72937. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72938. import "babylonjs/Shaders/chromaticAberration.fragment";
  72939. import "babylonjs/Shaders/lensHighlights.fragment";
  72940. import "babylonjs/Shaders/depthOfField.fragment";
  72941. /**
  72942. * BABYLON.JS Chromatic Aberration GLSL Shader
  72943. * Author: Olivier Guyot
  72944. * Separates very slightly R, G and B colors on the edges of the screen
  72945. * Inspired by Francois Tarlier & Martins Upitis
  72946. */
  72947. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72948. /**
  72949. * @ignore
  72950. * The chromatic aberration PostProcess id in the pipeline
  72951. */
  72952. LensChromaticAberrationEffect: string;
  72953. /**
  72954. * @ignore
  72955. * The highlights enhancing PostProcess id in the pipeline
  72956. */
  72957. HighlightsEnhancingEffect: string;
  72958. /**
  72959. * @ignore
  72960. * The depth-of-field PostProcess id in the pipeline
  72961. */
  72962. LensDepthOfFieldEffect: string;
  72963. private _scene;
  72964. private _depthTexture;
  72965. private _grainTexture;
  72966. private _chromaticAberrationPostProcess;
  72967. private _highlightsPostProcess;
  72968. private _depthOfFieldPostProcess;
  72969. private _edgeBlur;
  72970. private _grainAmount;
  72971. private _chromaticAberration;
  72972. private _distortion;
  72973. private _highlightsGain;
  72974. private _highlightsThreshold;
  72975. private _dofDistance;
  72976. private _dofAperture;
  72977. private _dofDarken;
  72978. private _dofPentagon;
  72979. private _blurNoise;
  72980. /**
  72981. * @constructor
  72982. *
  72983. * Effect parameters are as follow:
  72984. * {
  72985. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72986. * edge_blur: number; // from 0 to x (1 for realism)
  72987. * distortion: number; // from 0 to x (1 for realism)
  72988. * grain_amount: number; // from 0 to 1
  72989. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72990. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72991. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72992. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72993. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72994. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72995. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72996. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72997. * }
  72998. * Note: if an effect parameter is unset, effect is disabled
  72999. *
  73000. * @param name The rendering pipeline name
  73001. * @param parameters - An object containing all parameters (see above)
  73002. * @param scene The scene linked to this pipeline
  73003. * @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)
  73004. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73005. */
  73006. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73007. /**
  73008. * Get the class name
  73009. * @returns "LensRenderingPipeline"
  73010. */
  73011. getClassName(): string;
  73012. /**
  73013. * Gets associated scene
  73014. */
  73015. get scene(): Scene;
  73016. /**
  73017. * Gets or sets the edge blur
  73018. */
  73019. get edgeBlur(): number;
  73020. set edgeBlur(value: number);
  73021. /**
  73022. * Gets or sets the grain amount
  73023. */
  73024. get grainAmount(): number;
  73025. set grainAmount(value: number);
  73026. /**
  73027. * Gets or sets the chromatic aberration amount
  73028. */
  73029. get chromaticAberration(): number;
  73030. set chromaticAberration(value: number);
  73031. /**
  73032. * Gets or sets the depth of field aperture
  73033. */
  73034. get dofAperture(): number;
  73035. set dofAperture(value: number);
  73036. /**
  73037. * Gets or sets the edge distortion
  73038. */
  73039. get edgeDistortion(): number;
  73040. set edgeDistortion(value: number);
  73041. /**
  73042. * Gets or sets the depth of field distortion
  73043. */
  73044. get dofDistortion(): number;
  73045. set dofDistortion(value: number);
  73046. /**
  73047. * Gets or sets the darken out of focus amount
  73048. */
  73049. get darkenOutOfFocus(): number;
  73050. set darkenOutOfFocus(value: number);
  73051. /**
  73052. * Gets or sets a boolean indicating if blur noise is enabled
  73053. */
  73054. get blurNoise(): boolean;
  73055. set blurNoise(value: boolean);
  73056. /**
  73057. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73058. */
  73059. get pentagonBokeh(): boolean;
  73060. set pentagonBokeh(value: boolean);
  73061. /**
  73062. * Gets or sets the highlight grain amount
  73063. */
  73064. get highlightsGain(): number;
  73065. set highlightsGain(value: number);
  73066. /**
  73067. * Gets or sets the highlight threshold
  73068. */
  73069. get highlightsThreshold(): number;
  73070. set highlightsThreshold(value: number);
  73071. /**
  73072. * Sets the amount of blur at the edges
  73073. * @param amount blur amount
  73074. */
  73075. setEdgeBlur(amount: number): void;
  73076. /**
  73077. * Sets edge blur to 0
  73078. */
  73079. disableEdgeBlur(): void;
  73080. /**
  73081. * Sets the amout of grain
  73082. * @param amount Amount of grain
  73083. */
  73084. setGrainAmount(amount: number): void;
  73085. /**
  73086. * Set grain amount to 0
  73087. */
  73088. disableGrain(): void;
  73089. /**
  73090. * Sets the chromatic aberration amount
  73091. * @param amount amount of chromatic aberration
  73092. */
  73093. setChromaticAberration(amount: number): void;
  73094. /**
  73095. * Sets chromatic aberration amount to 0
  73096. */
  73097. disableChromaticAberration(): void;
  73098. /**
  73099. * Sets the EdgeDistortion amount
  73100. * @param amount amount of EdgeDistortion
  73101. */
  73102. setEdgeDistortion(amount: number): void;
  73103. /**
  73104. * Sets edge distortion to 0
  73105. */
  73106. disableEdgeDistortion(): void;
  73107. /**
  73108. * Sets the FocusDistance amount
  73109. * @param amount amount of FocusDistance
  73110. */
  73111. setFocusDistance(amount: number): void;
  73112. /**
  73113. * Disables depth of field
  73114. */
  73115. disableDepthOfField(): void;
  73116. /**
  73117. * Sets the Aperture amount
  73118. * @param amount amount of Aperture
  73119. */
  73120. setAperture(amount: number): void;
  73121. /**
  73122. * Sets the DarkenOutOfFocus amount
  73123. * @param amount amount of DarkenOutOfFocus
  73124. */
  73125. setDarkenOutOfFocus(amount: number): void;
  73126. private _pentagonBokehIsEnabled;
  73127. /**
  73128. * Creates a pentagon bokeh effect
  73129. */
  73130. enablePentagonBokeh(): void;
  73131. /**
  73132. * Disables the pentagon bokeh effect
  73133. */
  73134. disablePentagonBokeh(): void;
  73135. /**
  73136. * Enables noise blur
  73137. */
  73138. enableNoiseBlur(): void;
  73139. /**
  73140. * Disables noise blur
  73141. */
  73142. disableNoiseBlur(): void;
  73143. /**
  73144. * Sets the HighlightsGain amount
  73145. * @param amount amount of HighlightsGain
  73146. */
  73147. setHighlightsGain(amount: number): void;
  73148. /**
  73149. * Sets the HighlightsThreshold amount
  73150. * @param amount amount of HighlightsThreshold
  73151. */
  73152. setHighlightsThreshold(amount: number): void;
  73153. /**
  73154. * Disables highlights
  73155. */
  73156. disableHighlights(): void;
  73157. /**
  73158. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73159. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73160. */
  73161. dispose(disableDepthRender?: boolean): void;
  73162. private _createChromaticAberrationPostProcess;
  73163. private _createHighlightsPostProcess;
  73164. private _createDepthOfFieldPostProcess;
  73165. private _createGrainTexture;
  73166. }
  73167. }
  73168. declare module "babylonjs/Shaders/ssao2.fragment" {
  73169. /** @hidden */
  73170. export var ssao2PixelShader: {
  73171. name: string;
  73172. shader: string;
  73173. };
  73174. }
  73175. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73176. /** @hidden */
  73177. export var ssaoCombinePixelShader: {
  73178. name: string;
  73179. shader: string;
  73180. };
  73181. }
  73182. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73183. import { Camera } from "babylonjs/Cameras/camera";
  73184. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73185. import { Scene } from "babylonjs/scene";
  73186. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73187. import "babylonjs/Shaders/ssao2.fragment";
  73188. import "babylonjs/Shaders/ssaoCombine.fragment";
  73189. /**
  73190. * Render pipeline to produce ssao effect
  73191. */
  73192. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73193. /**
  73194. * @ignore
  73195. * The PassPostProcess id in the pipeline that contains the original scene color
  73196. */
  73197. SSAOOriginalSceneColorEffect: string;
  73198. /**
  73199. * @ignore
  73200. * The SSAO PostProcess id in the pipeline
  73201. */
  73202. SSAORenderEffect: string;
  73203. /**
  73204. * @ignore
  73205. * The horizontal blur PostProcess id in the pipeline
  73206. */
  73207. SSAOBlurHRenderEffect: string;
  73208. /**
  73209. * @ignore
  73210. * The vertical blur PostProcess id in the pipeline
  73211. */
  73212. SSAOBlurVRenderEffect: string;
  73213. /**
  73214. * @ignore
  73215. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73216. */
  73217. SSAOCombineRenderEffect: string;
  73218. /**
  73219. * The output strength of the SSAO post-process. Default value is 1.0.
  73220. */
  73221. totalStrength: number;
  73222. /**
  73223. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73224. */
  73225. maxZ: number;
  73226. /**
  73227. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73228. */
  73229. minZAspect: number;
  73230. private _samples;
  73231. /**
  73232. * Number of samples used for the SSAO calculations. Default value is 8
  73233. */
  73234. set samples(n: number);
  73235. get samples(): number;
  73236. private _textureSamples;
  73237. /**
  73238. * Number of samples to use for antialiasing
  73239. */
  73240. set textureSamples(n: number);
  73241. get textureSamples(): number;
  73242. /**
  73243. * Ratio object used for SSAO ratio and blur ratio
  73244. */
  73245. private _ratio;
  73246. /**
  73247. * Dynamically generated sphere sampler.
  73248. */
  73249. private _sampleSphere;
  73250. /**
  73251. * Blur filter offsets
  73252. */
  73253. private _samplerOffsets;
  73254. private _expensiveBlur;
  73255. /**
  73256. * If bilateral blur should be used
  73257. */
  73258. set expensiveBlur(b: boolean);
  73259. get expensiveBlur(): boolean;
  73260. /**
  73261. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73262. */
  73263. radius: number;
  73264. /**
  73265. * The base color of the SSAO post-process
  73266. * The final result is "base + ssao" between [0, 1]
  73267. */
  73268. base: number;
  73269. /**
  73270. * Support test.
  73271. */
  73272. static get IsSupported(): boolean;
  73273. private _scene;
  73274. private _depthTexture;
  73275. private _normalTexture;
  73276. private _randomTexture;
  73277. private _originalColorPostProcess;
  73278. private _ssaoPostProcess;
  73279. private _blurHPostProcess;
  73280. private _blurVPostProcess;
  73281. private _ssaoCombinePostProcess;
  73282. /**
  73283. * Gets active scene
  73284. */
  73285. get scene(): Scene;
  73286. /**
  73287. * @constructor
  73288. * @param name The rendering pipeline name
  73289. * @param scene The scene linked to this pipeline
  73290. * @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 }
  73291. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73292. */
  73293. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73294. /**
  73295. * Get the class name
  73296. * @returns "SSAO2RenderingPipeline"
  73297. */
  73298. getClassName(): string;
  73299. /**
  73300. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73301. */
  73302. dispose(disableGeometryBufferRenderer?: boolean): void;
  73303. private _createBlurPostProcess;
  73304. /** @hidden */
  73305. _rebuild(): void;
  73306. private _bits;
  73307. private _radicalInverse_VdC;
  73308. private _hammersley;
  73309. private _hemisphereSample_uniform;
  73310. private _generateHemisphere;
  73311. private _createSSAOPostProcess;
  73312. private _createSSAOCombinePostProcess;
  73313. private _createRandomTexture;
  73314. /**
  73315. * Serialize the rendering pipeline (Used when exporting)
  73316. * @returns the serialized object
  73317. */
  73318. serialize(): any;
  73319. /**
  73320. * Parse the serialized pipeline
  73321. * @param source Source pipeline.
  73322. * @param scene The scene to load the pipeline to.
  73323. * @param rootUrl The URL of the serialized pipeline.
  73324. * @returns An instantiated pipeline from the serialized object.
  73325. */
  73326. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73327. }
  73328. }
  73329. declare module "babylonjs/Shaders/ssao.fragment" {
  73330. /** @hidden */
  73331. export var ssaoPixelShader: {
  73332. name: string;
  73333. shader: string;
  73334. };
  73335. }
  73336. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73337. import { Camera } from "babylonjs/Cameras/camera";
  73338. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73339. import { Scene } from "babylonjs/scene";
  73340. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73341. import "babylonjs/Shaders/ssao.fragment";
  73342. import "babylonjs/Shaders/ssaoCombine.fragment";
  73343. /**
  73344. * Render pipeline to produce ssao effect
  73345. */
  73346. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73347. /**
  73348. * @ignore
  73349. * The PassPostProcess id in the pipeline that contains the original scene color
  73350. */
  73351. SSAOOriginalSceneColorEffect: string;
  73352. /**
  73353. * @ignore
  73354. * The SSAO PostProcess id in the pipeline
  73355. */
  73356. SSAORenderEffect: string;
  73357. /**
  73358. * @ignore
  73359. * The horizontal blur PostProcess id in the pipeline
  73360. */
  73361. SSAOBlurHRenderEffect: string;
  73362. /**
  73363. * @ignore
  73364. * The vertical blur PostProcess id in the pipeline
  73365. */
  73366. SSAOBlurVRenderEffect: string;
  73367. /**
  73368. * @ignore
  73369. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73370. */
  73371. SSAOCombineRenderEffect: string;
  73372. /**
  73373. * The output strength of the SSAO post-process. Default value is 1.0.
  73374. */
  73375. totalStrength: number;
  73376. /**
  73377. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73378. */
  73379. radius: number;
  73380. /**
  73381. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73382. * Must not be equal to fallOff and superior to fallOff.
  73383. * Default value is 0.0075
  73384. */
  73385. area: number;
  73386. /**
  73387. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73388. * Must not be equal to area and inferior to area.
  73389. * Default value is 0.000001
  73390. */
  73391. fallOff: number;
  73392. /**
  73393. * The base color of the SSAO post-process
  73394. * The final result is "base + ssao" between [0, 1]
  73395. */
  73396. base: number;
  73397. private _scene;
  73398. private _depthTexture;
  73399. private _randomTexture;
  73400. private _originalColorPostProcess;
  73401. private _ssaoPostProcess;
  73402. private _blurHPostProcess;
  73403. private _blurVPostProcess;
  73404. private _ssaoCombinePostProcess;
  73405. private _firstUpdate;
  73406. /**
  73407. * Gets active scene
  73408. */
  73409. get scene(): Scene;
  73410. /**
  73411. * @constructor
  73412. * @param name - The rendering pipeline name
  73413. * @param scene - The scene linked to this pipeline
  73414. * @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 }
  73415. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73416. */
  73417. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73418. /**
  73419. * Get the class name
  73420. * @returns "SSAORenderingPipeline"
  73421. */
  73422. getClassName(): string;
  73423. /**
  73424. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73425. */
  73426. dispose(disableDepthRender?: boolean): void;
  73427. private _createBlurPostProcess;
  73428. /** @hidden */
  73429. _rebuild(): void;
  73430. private _createSSAOPostProcess;
  73431. private _createSSAOCombinePostProcess;
  73432. private _createRandomTexture;
  73433. }
  73434. }
  73435. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73436. /** @hidden */
  73437. export var screenSpaceReflectionPixelShader: {
  73438. name: string;
  73439. shader: string;
  73440. };
  73441. }
  73442. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73443. import { Nullable } from "babylonjs/types";
  73444. import { Camera } from "babylonjs/Cameras/camera";
  73445. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73446. import { Scene } from "babylonjs/scene";
  73447. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73448. import { Engine } from "babylonjs/Engines/engine";
  73449. /**
  73450. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73451. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73452. */
  73453. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73454. /**
  73455. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73456. */
  73457. threshold: number;
  73458. /**
  73459. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73460. */
  73461. strength: number;
  73462. /**
  73463. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73464. */
  73465. reflectionSpecularFalloffExponent: number;
  73466. /**
  73467. * 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]
  73468. */
  73469. step: number;
  73470. /**
  73471. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73472. */
  73473. roughnessFactor: number;
  73474. private _geometryBufferRenderer;
  73475. private _enableSmoothReflections;
  73476. private _reflectionSamples;
  73477. private _smoothSteps;
  73478. /**
  73479. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73480. * @param name The name of the effect.
  73481. * @param scene The scene containing the objects to calculate reflections.
  73482. * @param options The required width/height ratio to downsize to before computing the render pass.
  73483. * @param camera The camera to apply the render pass to.
  73484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73485. * @param engine The engine which the post process will be applied. (default: current engine)
  73486. * @param reusable If the post process can be reused on the same frame. (default: false)
  73487. * @param textureType Type of textures used when performing the post process. (default: 0)
  73488. * @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)
  73489. */
  73490. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73491. /**
  73492. * Gets wether or not smoothing reflections is enabled.
  73493. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73494. */
  73495. get enableSmoothReflections(): boolean;
  73496. /**
  73497. * Sets wether or not smoothing reflections is enabled.
  73498. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73499. */
  73500. set enableSmoothReflections(enabled: boolean);
  73501. /**
  73502. * Gets the number of samples taken while computing reflections. More samples count is high,
  73503. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73504. */
  73505. get reflectionSamples(): number;
  73506. /**
  73507. * Sets the number of samples taken while computing reflections. More samples count is high,
  73508. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73509. */
  73510. set reflectionSamples(samples: number);
  73511. /**
  73512. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73513. * more the post-process will require GPU power and can generate a drop in FPS.
  73514. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73515. */
  73516. get smoothSteps(): number;
  73517. set smoothSteps(steps: number);
  73518. private _updateEffectDefines;
  73519. }
  73520. }
  73521. declare module "babylonjs/Shaders/standard.fragment" {
  73522. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73523. /** @hidden */
  73524. export var standardPixelShader: {
  73525. name: string;
  73526. shader: string;
  73527. };
  73528. }
  73529. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73530. import { Nullable } from "babylonjs/types";
  73531. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73532. import { Camera } from "babylonjs/Cameras/camera";
  73533. import { Texture } from "babylonjs/Materials/Textures/texture";
  73534. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73535. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73536. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73537. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73538. import { IDisposable } from "babylonjs/scene";
  73539. import { SpotLight } from "babylonjs/Lights/spotLight";
  73540. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73541. import { Scene } from "babylonjs/scene";
  73542. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73543. import { Animation } from "babylonjs/Animations/animation";
  73544. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73545. import "babylonjs/Shaders/standard.fragment";
  73546. /**
  73547. * Standard rendering pipeline
  73548. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73549. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73550. */
  73551. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73552. /**
  73553. * Public members
  73554. */
  73555. /**
  73556. * Post-process which contains the original scene color before the pipeline applies all the effects
  73557. */
  73558. originalPostProcess: Nullable<PostProcess>;
  73559. /**
  73560. * Post-process used to down scale an image x4
  73561. */
  73562. downSampleX4PostProcess: Nullable<PostProcess>;
  73563. /**
  73564. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73565. */
  73566. brightPassPostProcess: Nullable<PostProcess>;
  73567. /**
  73568. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73569. */
  73570. blurHPostProcesses: PostProcess[];
  73571. /**
  73572. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73573. */
  73574. blurVPostProcesses: PostProcess[];
  73575. /**
  73576. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73577. */
  73578. textureAdderPostProcess: Nullable<PostProcess>;
  73579. /**
  73580. * Post-process used to create volumetric lighting effect
  73581. */
  73582. volumetricLightPostProcess: Nullable<PostProcess>;
  73583. /**
  73584. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73585. */
  73586. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73587. /**
  73588. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73589. */
  73590. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73591. /**
  73592. * Post-process used to merge the volumetric light effect and the real scene color
  73593. */
  73594. volumetricLightMergePostProces: Nullable<PostProcess>;
  73595. /**
  73596. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73597. */
  73598. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73599. /**
  73600. * Base post-process used to calculate the average luminance of the final image for HDR
  73601. */
  73602. luminancePostProcess: Nullable<PostProcess>;
  73603. /**
  73604. * Post-processes used to create down sample post-processes in order to get
  73605. * the average luminance of the final image for HDR
  73606. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73607. */
  73608. luminanceDownSamplePostProcesses: PostProcess[];
  73609. /**
  73610. * Post-process used to create a HDR effect (light adaptation)
  73611. */
  73612. hdrPostProcess: Nullable<PostProcess>;
  73613. /**
  73614. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73615. */
  73616. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73617. /**
  73618. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73619. */
  73620. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73621. /**
  73622. * Post-process used to merge the final HDR post-process and the real scene color
  73623. */
  73624. hdrFinalPostProcess: Nullable<PostProcess>;
  73625. /**
  73626. * Post-process used to create a lens flare effect
  73627. */
  73628. lensFlarePostProcess: Nullable<PostProcess>;
  73629. /**
  73630. * Post-process that merges the result of the lens flare post-process and the real scene color
  73631. */
  73632. lensFlareComposePostProcess: Nullable<PostProcess>;
  73633. /**
  73634. * Post-process used to create a motion blur effect
  73635. */
  73636. motionBlurPostProcess: Nullable<PostProcess>;
  73637. /**
  73638. * Post-process used to create a depth of field effect
  73639. */
  73640. depthOfFieldPostProcess: Nullable<PostProcess>;
  73641. /**
  73642. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73643. */
  73644. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73645. /**
  73646. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73647. */
  73648. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73649. /**
  73650. * Represents the brightness threshold in order to configure the illuminated surfaces
  73651. */
  73652. brightThreshold: number;
  73653. /**
  73654. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73655. */
  73656. blurWidth: number;
  73657. /**
  73658. * Sets if the blur for highlighted surfaces must be only horizontal
  73659. */
  73660. horizontalBlur: boolean;
  73661. /**
  73662. * Gets the overall exposure used by the pipeline
  73663. */
  73664. get exposure(): number;
  73665. /**
  73666. * Sets the overall exposure used by the pipeline
  73667. */
  73668. set exposure(value: number);
  73669. /**
  73670. * Texture used typically to simulate "dirty" on camera lens
  73671. */
  73672. lensTexture: Nullable<Texture>;
  73673. /**
  73674. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73675. */
  73676. volumetricLightCoefficient: number;
  73677. /**
  73678. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73679. */
  73680. volumetricLightPower: number;
  73681. /**
  73682. * Used the set the blur intensity to smooth the volumetric lights
  73683. */
  73684. volumetricLightBlurScale: number;
  73685. /**
  73686. * Light (spot or directional) used to generate the volumetric lights rays
  73687. * The source light must have a shadow generate so the pipeline can get its
  73688. * depth map
  73689. */
  73690. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73691. /**
  73692. * For eye adaptation, represents the minimum luminance the eye can see
  73693. */
  73694. hdrMinimumLuminance: number;
  73695. /**
  73696. * For eye adaptation, represents the decrease luminance speed
  73697. */
  73698. hdrDecreaseRate: number;
  73699. /**
  73700. * For eye adaptation, represents the increase luminance speed
  73701. */
  73702. hdrIncreaseRate: number;
  73703. /**
  73704. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73705. */
  73706. get hdrAutoExposure(): boolean;
  73707. /**
  73708. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73709. */
  73710. set hdrAutoExposure(value: boolean);
  73711. /**
  73712. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73713. */
  73714. lensColorTexture: Nullable<Texture>;
  73715. /**
  73716. * The overall strengh for the lens flare effect
  73717. */
  73718. lensFlareStrength: number;
  73719. /**
  73720. * Dispersion coefficient for lens flare ghosts
  73721. */
  73722. lensFlareGhostDispersal: number;
  73723. /**
  73724. * Main lens flare halo width
  73725. */
  73726. lensFlareHaloWidth: number;
  73727. /**
  73728. * Based on the lens distortion effect, defines how much the lens flare result
  73729. * is distorted
  73730. */
  73731. lensFlareDistortionStrength: number;
  73732. /**
  73733. * Configures the blur intensity used for for lens flare (halo)
  73734. */
  73735. lensFlareBlurWidth: number;
  73736. /**
  73737. * Lens star texture must be used to simulate rays on the flares and is available
  73738. * in the documentation
  73739. */
  73740. lensStarTexture: Nullable<Texture>;
  73741. /**
  73742. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73743. * flare effect by taking account of the dirt texture
  73744. */
  73745. lensFlareDirtTexture: Nullable<Texture>;
  73746. /**
  73747. * Represents the focal length for the depth of field effect
  73748. */
  73749. depthOfFieldDistance: number;
  73750. /**
  73751. * Represents the blur intensity for the blurred part of the depth of field effect
  73752. */
  73753. depthOfFieldBlurWidth: number;
  73754. /**
  73755. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73756. */
  73757. get motionStrength(): number;
  73758. /**
  73759. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73760. */
  73761. set motionStrength(strength: number);
  73762. /**
  73763. * Gets wether or not the motion blur post-process is object based or screen based.
  73764. */
  73765. get objectBasedMotionBlur(): boolean;
  73766. /**
  73767. * Sets wether or not the motion blur post-process should be object based or screen based
  73768. */
  73769. set objectBasedMotionBlur(value: boolean);
  73770. /**
  73771. * List of animations for the pipeline (IAnimatable implementation)
  73772. */
  73773. animations: Animation[];
  73774. /**
  73775. * Private members
  73776. */
  73777. private _scene;
  73778. private _currentDepthOfFieldSource;
  73779. private _basePostProcess;
  73780. private _fixedExposure;
  73781. private _currentExposure;
  73782. private _hdrAutoExposure;
  73783. private _hdrCurrentLuminance;
  73784. private _motionStrength;
  73785. private _isObjectBasedMotionBlur;
  73786. private _floatTextureType;
  73787. private _camerasToBeAttached;
  73788. private _ratio;
  73789. private _bloomEnabled;
  73790. private _depthOfFieldEnabled;
  73791. private _vlsEnabled;
  73792. private _lensFlareEnabled;
  73793. private _hdrEnabled;
  73794. private _motionBlurEnabled;
  73795. private _fxaaEnabled;
  73796. private _screenSpaceReflectionsEnabled;
  73797. private _motionBlurSamples;
  73798. private _volumetricLightStepsCount;
  73799. private _samples;
  73800. /**
  73801. * @ignore
  73802. * Specifies if the bloom pipeline is enabled
  73803. */
  73804. get BloomEnabled(): boolean;
  73805. set BloomEnabled(enabled: boolean);
  73806. /**
  73807. * @ignore
  73808. * Specifies if the depth of field pipeline is enabed
  73809. */
  73810. get DepthOfFieldEnabled(): boolean;
  73811. set DepthOfFieldEnabled(enabled: boolean);
  73812. /**
  73813. * @ignore
  73814. * Specifies if the lens flare pipeline is enabed
  73815. */
  73816. get LensFlareEnabled(): boolean;
  73817. set LensFlareEnabled(enabled: boolean);
  73818. /**
  73819. * @ignore
  73820. * Specifies if the HDR pipeline is enabled
  73821. */
  73822. get HDREnabled(): boolean;
  73823. set HDREnabled(enabled: boolean);
  73824. /**
  73825. * @ignore
  73826. * Specifies if the volumetric lights scattering effect is enabled
  73827. */
  73828. get VLSEnabled(): boolean;
  73829. set VLSEnabled(enabled: boolean);
  73830. /**
  73831. * @ignore
  73832. * Specifies if the motion blur effect is enabled
  73833. */
  73834. get MotionBlurEnabled(): boolean;
  73835. set MotionBlurEnabled(enabled: boolean);
  73836. /**
  73837. * Specifies if anti-aliasing is enabled
  73838. */
  73839. get fxaaEnabled(): boolean;
  73840. set fxaaEnabled(enabled: boolean);
  73841. /**
  73842. * Specifies if screen space reflections are enabled.
  73843. */
  73844. get screenSpaceReflectionsEnabled(): boolean;
  73845. set screenSpaceReflectionsEnabled(enabled: boolean);
  73846. /**
  73847. * Specifies the number of steps used to calculate the volumetric lights
  73848. * Typically in interval [50, 200]
  73849. */
  73850. get volumetricLightStepsCount(): number;
  73851. set volumetricLightStepsCount(count: number);
  73852. /**
  73853. * Specifies the number of samples used for the motion blur effect
  73854. * Typically in interval [16, 64]
  73855. */
  73856. get motionBlurSamples(): number;
  73857. set motionBlurSamples(samples: number);
  73858. /**
  73859. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73860. */
  73861. get samples(): number;
  73862. set samples(sampleCount: number);
  73863. /**
  73864. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73865. * @constructor
  73866. * @param name The rendering pipeline name
  73867. * @param scene The scene linked to this pipeline
  73868. * @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)
  73869. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  73870. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73871. */
  73872. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  73873. private _buildPipeline;
  73874. private _createDownSampleX4PostProcess;
  73875. private _createBrightPassPostProcess;
  73876. private _createBlurPostProcesses;
  73877. private _createTextureAdderPostProcess;
  73878. private _createVolumetricLightPostProcess;
  73879. private _createLuminancePostProcesses;
  73880. private _createHdrPostProcess;
  73881. private _createLensFlarePostProcess;
  73882. private _createDepthOfFieldPostProcess;
  73883. private _createMotionBlurPostProcess;
  73884. private _getDepthTexture;
  73885. private _disposePostProcesses;
  73886. /**
  73887. * Dispose of the pipeline and stop all post processes
  73888. */
  73889. dispose(): void;
  73890. /**
  73891. * Serialize the rendering pipeline (Used when exporting)
  73892. * @returns the serialized object
  73893. */
  73894. serialize(): any;
  73895. /**
  73896. * Parse the serialized pipeline
  73897. * @param source Source pipeline.
  73898. * @param scene The scene to load the pipeline to.
  73899. * @param rootUrl The URL of the serialized pipeline.
  73900. * @returns An instantiated pipeline from the serialized object.
  73901. */
  73902. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  73903. /**
  73904. * Luminance steps
  73905. */
  73906. static LuminanceSteps: number;
  73907. }
  73908. }
  73909. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  73910. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  73911. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  73912. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  73913. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  73914. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  73915. }
  73916. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  73917. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  73918. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73919. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73920. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73921. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73922. }
  73923. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  73924. /** @hidden */
  73925. export var stereoscopicInterlacePixelShader: {
  73926. name: string;
  73927. shader: string;
  73928. };
  73929. }
  73930. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  73931. import { Camera } from "babylonjs/Cameras/camera";
  73932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73933. import { Engine } from "babylonjs/Engines/engine";
  73934. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  73935. /**
  73936. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73937. */
  73938. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73939. private _stepSize;
  73940. private _passedProcess;
  73941. /**
  73942. * Initializes a StereoscopicInterlacePostProcessI
  73943. * @param name The name of the effect.
  73944. * @param rigCameras The rig cameras to be appled to the post process
  73945. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73946. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73948. * @param engine The engine which the post process will be applied. (default: current engine)
  73949. * @param reusable If the post process can be reused on the same frame. (default: false)
  73950. */
  73951. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73952. }
  73953. /**
  73954. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73955. */
  73956. export class StereoscopicInterlacePostProcess extends PostProcess {
  73957. private _stepSize;
  73958. private _passedProcess;
  73959. /**
  73960. * Initializes a StereoscopicInterlacePostProcess
  73961. * @param name The name of the effect.
  73962. * @param rigCameras The rig cameras to be appled to the post process
  73963. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73965. * @param engine The engine which the post process will be applied. (default: current engine)
  73966. * @param reusable If the post process can be reused on the same frame. (default: false)
  73967. */
  73968. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73969. }
  73970. }
  73971. declare module "babylonjs/Shaders/tonemap.fragment" {
  73972. /** @hidden */
  73973. export var tonemapPixelShader: {
  73974. name: string;
  73975. shader: string;
  73976. };
  73977. }
  73978. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  73979. import { Camera } from "babylonjs/Cameras/camera";
  73980. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73981. import "babylonjs/Shaders/tonemap.fragment";
  73982. import { Engine } from "babylonjs/Engines/engine";
  73983. /** Defines operator used for tonemapping */
  73984. export enum TonemappingOperator {
  73985. /** Hable */
  73986. Hable = 0,
  73987. /** Reinhard */
  73988. Reinhard = 1,
  73989. /** HejiDawson */
  73990. HejiDawson = 2,
  73991. /** Photographic */
  73992. Photographic = 3
  73993. }
  73994. /**
  73995. * Defines a post process to apply tone mapping
  73996. */
  73997. export class TonemapPostProcess extends PostProcess {
  73998. private _operator;
  73999. /** Defines the required exposure adjustement */
  74000. exposureAdjustment: number;
  74001. /**
  74002. * Creates a new TonemapPostProcess
  74003. * @param name defines the name of the postprocess
  74004. * @param _operator defines the operator to use
  74005. * @param exposureAdjustment defines the required exposure adjustement
  74006. * @param camera defines the camera to use (can be null)
  74007. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74008. * @param engine defines the hosting engine (can be ignore if camera is set)
  74009. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74010. */
  74011. constructor(name: string, _operator: TonemappingOperator,
  74012. /** Defines the required exposure adjustement */
  74013. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74014. }
  74015. }
  74016. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74017. /** @hidden */
  74018. export var volumetricLightScatteringPixelShader: {
  74019. name: string;
  74020. shader: string;
  74021. };
  74022. }
  74023. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74024. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74025. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74026. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74027. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74028. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74029. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74030. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74031. /** @hidden */
  74032. export var volumetricLightScatteringPassVertexShader: {
  74033. name: string;
  74034. shader: string;
  74035. };
  74036. }
  74037. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74038. /** @hidden */
  74039. export var volumetricLightScatteringPassPixelShader: {
  74040. name: string;
  74041. shader: string;
  74042. };
  74043. }
  74044. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74045. import { Vector3 } from "babylonjs/Maths/math.vector";
  74046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74047. import { Mesh } from "babylonjs/Meshes/mesh";
  74048. import { Camera } from "babylonjs/Cameras/camera";
  74049. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74050. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74051. import { Scene } from "babylonjs/scene";
  74052. import "babylonjs/Meshes/Builders/planeBuilder";
  74053. import "babylonjs/Shaders/depth.vertex";
  74054. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74055. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74056. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74057. import { Engine } from "babylonjs/Engines/engine";
  74058. /**
  74059. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74060. */
  74061. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74062. private _volumetricLightScatteringPass;
  74063. private _volumetricLightScatteringRTT;
  74064. private _viewPort;
  74065. private _screenCoordinates;
  74066. private _cachedDefines;
  74067. /**
  74068. * If not undefined, the mesh position is computed from the attached node position
  74069. */
  74070. attachedNode: {
  74071. position: Vector3;
  74072. };
  74073. /**
  74074. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74075. */
  74076. customMeshPosition: Vector3;
  74077. /**
  74078. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74079. */
  74080. useCustomMeshPosition: boolean;
  74081. /**
  74082. * If the post-process should inverse the light scattering direction
  74083. */
  74084. invert: boolean;
  74085. /**
  74086. * The internal mesh used by the post-process
  74087. */
  74088. mesh: Mesh;
  74089. /**
  74090. * @hidden
  74091. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74092. */
  74093. get useDiffuseColor(): boolean;
  74094. set useDiffuseColor(useDiffuseColor: boolean);
  74095. /**
  74096. * Array containing the excluded meshes not rendered in the internal pass
  74097. */
  74098. excludedMeshes: AbstractMesh[];
  74099. /**
  74100. * Controls the overall intensity of the post-process
  74101. */
  74102. exposure: number;
  74103. /**
  74104. * Dissipates each sample's contribution in range [0, 1]
  74105. */
  74106. decay: number;
  74107. /**
  74108. * Controls the overall intensity of each sample
  74109. */
  74110. weight: number;
  74111. /**
  74112. * Controls the density of each sample
  74113. */
  74114. density: number;
  74115. /**
  74116. * @constructor
  74117. * @param name The post-process name
  74118. * @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)
  74119. * @param camera The camera that the post-process will be attached to
  74120. * @param mesh The mesh used to create the light scattering
  74121. * @param samples The post-process quality, default 100
  74122. * @param samplingModeThe post-process filtering mode
  74123. * @param engine The babylon engine
  74124. * @param reusable If the post-process is reusable
  74125. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74126. */
  74127. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74128. /**
  74129. * Returns the string "VolumetricLightScatteringPostProcess"
  74130. * @returns "VolumetricLightScatteringPostProcess"
  74131. */
  74132. getClassName(): string;
  74133. private _isReady;
  74134. /**
  74135. * Sets the new light position for light scattering effect
  74136. * @param position The new custom light position
  74137. */
  74138. setCustomMeshPosition(position: Vector3): void;
  74139. /**
  74140. * Returns the light position for light scattering effect
  74141. * @return Vector3 The custom light position
  74142. */
  74143. getCustomMeshPosition(): Vector3;
  74144. /**
  74145. * Disposes the internal assets and detaches the post-process from the camera
  74146. */
  74147. dispose(camera: Camera): void;
  74148. /**
  74149. * Returns the render target texture used by the post-process
  74150. * @return the render target texture used by the post-process
  74151. */
  74152. getPass(): RenderTargetTexture;
  74153. private _meshExcluded;
  74154. private _createPass;
  74155. private _updateMeshScreenCoordinates;
  74156. /**
  74157. * Creates a default mesh for the Volumeric Light Scattering post-process
  74158. * @param name The mesh name
  74159. * @param scene The scene where to create the mesh
  74160. * @return the default mesh
  74161. */
  74162. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74163. }
  74164. }
  74165. declare module "babylonjs/PostProcesses/index" {
  74166. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74167. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74168. export * from "babylonjs/PostProcesses/bloomEffect";
  74169. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74170. export * from "babylonjs/PostProcesses/blurPostProcess";
  74171. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74172. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74173. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74174. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74175. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74176. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74177. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74178. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74179. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74180. export * from "babylonjs/PostProcesses/filterPostProcess";
  74181. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74182. export * from "babylonjs/PostProcesses/grainPostProcess";
  74183. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74184. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74185. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74186. export * from "babylonjs/PostProcesses/passPostProcess";
  74187. export * from "babylonjs/PostProcesses/postProcess";
  74188. export * from "babylonjs/PostProcesses/postProcessManager";
  74189. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74190. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74191. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74192. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74193. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74194. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74195. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74196. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74197. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74198. }
  74199. declare module "babylonjs/Probes/index" {
  74200. export * from "babylonjs/Probes/reflectionProbe";
  74201. }
  74202. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74203. import { Scene } from "babylonjs/scene";
  74204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74205. import { SmartArray } from "babylonjs/Misc/smartArray";
  74206. import { ISceneComponent } from "babylonjs/sceneComponent";
  74207. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74208. import "babylonjs/Meshes/Builders/boxBuilder";
  74209. import "babylonjs/Shaders/color.fragment";
  74210. import "babylonjs/Shaders/color.vertex";
  74211. import { Color3 } from "babylonjs/Maths/math.color";
  74212. import { Observable } from "babylonjs/Misc/observable";
  74213. module "babylonjs/scene" {
  74214. interface Scene {
  74215. /** @hidden (Backing field) */
  74216. _boundingBoxRenderer: BoundingBoxRenderer;
  74217. /** @hidden (Backing field) */
  74218. _forceShowBoundingBoxes: boolean;
  74219. /**
  74220. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74221. */
  74222. forceShowBoundingBoxes: boolean;
  74223. /**
  74224. * Gets the bounding box renderer associated with the scene
  74225. * @returns a BoundingBoxRenderer
  74226. */
  74227. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74228. }
  74229. }
  74230. module "babylonjs/Meshes/abstractMesh" {
  74231. interface AbstractMesh {
  74232. /** @hidden (Backing field) */
  74233. _showBoundingBox: boolean;
  74234. /**
  74235. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74236. */
  74237. showBoundingBox: boolean;
  74238. }
  74239. }
  74240. /**
  74241. * Component responsible of rendering the bounding box of the meshes in a scene.
  74242. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74243. */
  74244. export class BoundingBoxRenderer implements ISceneComponent {
  74245. /**
  74246. * The component name helpfull to identify the component in the list of scene components.
  74247. */
  74248. readonly name: string;
  74249. /**
  74250. * The scene the component belongs to.
  74251. */
  74252. scene: Scene;
  74253. /**
  74254. * Color of the bounding box lines placed in front of an object
  74255. */
  74256. frontColor: Color3;
  74257. /**
  74258. * Color of the bounding box lines placed behind an object
  74259. */
  74260. backColor: Color3;
  74261. /**
  74262. * Defines if the renderer should show the back lines or not
  74263. */
  74264. showBackLines: boolean;
  74265. /**
  74266. * Observable raised before rendering a bounding box
  74267. */
  74268. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74269. /**
  74270. * Observable raised after rendering a bounding box
  74271. */
  74272. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74273. /**
  74274. * @hidden
  74275. */
  74276. renderList: SmartArray<BoundingBox>;
  74277. private _colorShader;
  74278. private _vertexBuffers;
  74279. private _indexBuffer;
  74280. private _fillIndexBuffer;
  74281. private _fillIndexData;
  74282. /**
  74283. * Instantiates a new bounding box renderer in a scene.
  74284. * @param scene the scene the renderer renders in
  74285. */
  74286. constructor(scene: Scene);
  74287. /**
  74288. * Registers the component in a given scene
  74289. */
  74290. register(): void;
  74291. private _evaluateSubMesh;
  74292. private _activeMesh;
  74293. private _prepareRessources;
  74294. private _createIndexBuffer;
  74295. /**
  74296. * Rebuilds the elements related to this component in case of
  74297. * context lost for instance.
  74298. */
  74299. rebuild(): void;
  74300. /**
  74301. * @hidden
  74302. */
  74303. reset(): void;
  74304. /**
  74305. * Render the bounding boxes of a specific rendering group
  74306. * @param renderingGroupId defines the rendering group to render
  74307. */
  74308. render(renderingGroupId: number): void;
  74309. /**
  74310. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74311. * @param mesh Define the mesh to render the occlusion bounding box for
  74312. */
  74313. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74314. /**
  74315. * Dispose and release the resources attached to this renderer.
  74316. */
  74317. dispose(): void;
  74318. }
  74319. }
  74320. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74321. import { Nullable } from "babylonjs/types";
  74322. import { Scene } from "babylonjs/scene";
  74323. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74324. import { Camera } from "babylonjs/Cameras/camera";
  74325. import { ISceneComponent } from "babylonjs/sceneComponent";
  74326. module "babylonjs/scene" {
  74327. interface Scene {
  74328. /** @hidden (Backing field) */
  74329. _depthRenderer: {
  74330. [id: string]: DepthRenderer;
  74331. };
  74332. /**
  74333. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74334. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74335. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74336. * @returns the created depth renderer
  74337. */
  74338. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74339. /**
  74340. * Disables a depth renderer for a given camera
  74341. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74342. */
  74343. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74344. }
  74345. }
  74346. /**
  74347. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74348. * in several rendering techniques.
  74349. */
  74350. export class DepthRendererSceneComponent implements ISceneComponent {
  74351. /**
  74352. * The component name helpfull to identify the component in the list of scene components.
  74353. */
  74354. readonly name: string;
  74355. /**
  74356. * The scene the component belongs to.
  74357. */
  74358. scene: Scene;
  74359. /**
  74360. * Creates a new instance of the component for the given scene
  74361. * @param scene Defines the scene to register the component in
  74362. */
  74363. constructor(scene: Scene);
  74364. /**
  74365. * Registers the component in a given scene
  74366. */
  74367. register(): void;
  74368. /**
  74369. * Rebuilds the elements related to this component in case of
  74370. * context lost for instance.
  74371. */
  74372. rebuild(): void;
  74373. /**
  74374. * Disposes the component and the associated ressources
  74375. */
  74376. dispose(): void;
  74377. private _gatherRenderTargets;
  74378. private _gatherActiveCameraRenderTargets;
  74379. }
  74380. }
  74381. declare module "babylonjs/Shaders/outline.fragment" {
  74382. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74383. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  74384. /** @hidden */
  74385. export var outlinePixelShader: {
  74386. name: string;
  74387. shader: string;
  74388. };
  74389. }
  74390. declare module "babylonjs/Shaders/outline.vertex" {
  74391. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74392. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74394. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74395. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74396. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74397. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74398. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74399. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  74400. /** @hidden */
  74401. export var outlineVertexShader: {
  74402. name: string;
  74403. shader: string;
  74404. };
  74405. }
  74406. declare module "babylonjs/Rendering/outlineRenderer" {
  74407. import { SubMesh } from "babylonjs/Meshes/subMesh";
  74408. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  74409. import { Scene } from "babylonjs/scene";
  74410. import { ISceneComponent } from "babylonjs/sceneComponent";
  74411. import "babylonjs/Shaders/outline.fragment";
  74412. import "babylonjs/Shaders/outline.vertex";
  74413. module "babylonjs/scene" {
  74414. interface Scene {
  74415. /** @hidden */
  74416. _outlineRenderer: OutlineRenderer;
  74417. /**
  74418. * Gets the outline renderer associated with the scene
  74419. * @returns a OutlineRenderer
  74420. */
  74421. getOutlineRenderer(): OutlineRenderer;
  74422. }
  74423. }
  74424. module "babylonjs/Meshes/abstractMesh" {
  74425. interface AbstractMesh {
  74426. /** @hidden (Backing field) */
  74427. _renderOutline: boolean;
  74428. /**
  74429. * Gets or sets a boolean indicating if the outline must be rendered as well
  74430. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74431. */
  74432. renderOutline: boolean;
  74433. /** @hidden (Backing field) */
  74434. _renderOverlay: boolean;
  74435. /**
  74436. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74437. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74438. */
  74439. renderOverlay: boolean;
  74440. }
  74441. }
  74442. /**
  74443. * This class is responsible to draw bothe outline/overlay of meshes.
  74444. * It should not be used directly but through the available method on mesh.
  74445. */
  74446. export class OutlineRenderer implements ISceneComponent {
  74447. /**
  74448. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74449. */
  74450. private static _StencilReference;
  74451. /**
  74452. * The name of the component. Each component must have a unique name.
  74453. */
  74454. name: string;
  74455. /**
  74456. * The scene the component belongs to.
  74457. */
  74458. scene: Scene;
  74459. /**
  74460. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74461. */
  74462. zOffset: number;
  74463. private _engine;
  74464. private _effect;
  74465. private _cachedDefines;
  74466. private _savedDepthWrite;
  74467. /**
  74468. * Instantiates a new outline renderer. (There could be only one per scene).
  74469. * @param scene Defines the scene it belongs to
  74470. */
  74471. constructor(scene: Scene);
  74472. /**
  74473. * Register the component to one instance of a scene.
  74474. */
  74475. register(): void;
  74476. /**
  74477. * Rebuilds the elements related to this component in case of
  74478. * context lost for instance.
  74479. */
  74480. rebuild(): void;
  74481. /**
  74482. * Disposes the component and the associated ressources.
  74483. */
  74484. dispose(): void;
  74485. /**
  74486. * Renders the outline in the canvas.
  74487. * @param subMesh Defines the sumesh to render
  74488. * @param batch Defines the batch of meshes in case of instances
  74489. * @param useOverlay Defines if the rendering is for the overlay or the outline
  74490. */
  74491. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  74492. /**
  74493. * Returns whether or not the outline renderer is ready for a given submesh.
  74494. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  74495. * @param subMesh Defines the submesh to check readyness for
  74496. * @param useInstances Defines wheter wee are trying to render instances or not
  74497. * @returns true if ready otherwise false
  74498. */
  74499. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74500. private _beforeRenderingMesh;
  74501. private _afterRenderingMesh;
  74502. }
  74503. }
  74504. declare module "babylonjs/Rendering/index" {
  74505. export * from "babylonjs/Rendering/boundingBoxRenderer";
  74506. export * from "babylonjs/Rendering/depthRenderer";
  74507. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  74508. export * from "babylonjs/Rendering/edgesRenderer";
  74509. export * from "babylonjs/Rendering/geometryBufferRenderer";
  74510. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74511. export * from "babylonjs/Rendering/outlineRenderer";
  74512. export * from "babylonjs/Rendering/renderingGroup";
  74513. export * from "babylonjs/Rendering/renderingManager";
  74514. export * from "babylonjs/Rendering/utilityLayerRenderer";
  74515. }
  74516. declare module "babylonjs/Sprites/ISprites" {
  74517. /**
  74518. * Defines the basic options interface of a Sprite Frame Source Size.
  74519. */
  74520. export interface ISpriteJSONSpriteSourceSize {
  74521. /**
  74522. * number of the original width of the Frame
  74523. */
  74524. w: number;
  74525. /**
  74526. * number of the original height of the Frame
  74527. */
  74528. h: number;
  74529. }
  74530. /**
  74531. * Defines the basic options interface of a Sprite Frame Data.
  74532. */
  74533. export interface ISpriteJSONSpriteFrameData {
  74534. /**
  74535. * number of the x offset of the Frame
  74536. */
  74537. x: number;
  74538. /**
  74539. * number of the y offset of the Frame
  74540. */
  74541. y: number;
  74542. /**
  74543. * number of the width of the Frame
  74544. */
  74545. w: number;
  74546. /**
  74547. * number of the height of the Frame
  74548. */
  74549. h: number;
  74550. }
  74551. /**
  74552. * Defines the basic options interface of a JSON Sprite.
  74553. */
  74554. export interface ISpriteJSONSprite {
  74555. /**
  74556. * string name of the Frame
  74557. */
  74558. filename: string;
  74559. /**
  74560. * ISpriteJSONSpriteFrame basic object of the frame data
  74561. */
  74562. frame: ISpriteJSONSpriteFrameData;
  74563. /**
  74564. * boolean to flag is the frame was rotated.
  74565. */
  74566. rotated: boolean;
  74567. /**
  74568. * boolean to flag is the frame was trimmed.
  74569. */
  74570. trimmed: boolean;
  74571. /**
  74572. * ISpriteJSONSpriteFrame basic object of the source data
  74573. */
  74574. spriteSourceSize: ISpriteJSONSpriteFrameData;
  74575. /**
  74576. * ISpriteJSONSpriteFrame basic object of the source data
  74577. */
  74578. sourceSize: ISpriteJSONSpriteSourceSize;
  74579. }
  74580. /**
  74581. * Defines the basic options interface of a JSON atlas.
  74582. */
  74583. export interface ISpriteJSONAtlas {
  74584. /**
  74585. * Array of objects that contain the frame data.
  74586. */
  74587. frames: Array<ISpriteJSONSprite>;
  74588. /**
  74589. * object basic object containing the sprite meta data.
  74590. */
  74591. meta?: object;
  74592. }
  74593. }
  74594. declare module "babylonjs/Shaders/spriteMap.fragment" {
  74595. /** @hidden */
  74596. export var spriteMapPixelShader: {
  74597. name: string;
  74598. shader: string;
  74599. };
  74600. }
  74601. declare module "babylonjs/Shaders/spriteMap.vertex" {
  74602. /** @hidden */
  74603. export var spriteMapVertexShader: {
  74604. name: string;
  74605. shader: string;
  74606. };
  74607. }
  74608. declare module "babylonjs/Sprites/spriteMap" {
  74609. import { IDisposable, Scene } from "babylonjs/scene";
  74610. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  74611. import { Texture } from "babylonjs/Materials/Textures/texture";
  74612. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  74613. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  74614. import "babylonjs/Meshes/Builders/planeBuilder";
  74615. import "babylonjs/Shaders/spriteMap.fragment";
  74616. import "babylonjs/Shaders/spriteMap.vertex";
  74617. /**
  74618. * Defines the basic options interface of a SpriteMap
  74619. */
  74620. export interface ISpriteMapOptions {
  74621. /**
  74622. * Vector2 of the number of cells in the grid.
  74623. */
  74624. stageSize?: Vector2;
  74625. /**
  74626. * Vector2 of the size of the output plane in World Units.
  74627. */
  74628. outputSize?: Vector2;
  74629. /**
  74630. * Vector3 of the position of the output plane in World Units.
  74631. */
  74632. outputPosition?: Vector3;
  74633. /**
  74634. * Vector3 of the rotation of the output plane.
  74635. */
  74636. outputRotation?: Vector3;
  74637. /**
  74638. * number of layers that the system will reserve in resources.
  74639. */
  74640. layerCount?: number;
  74641. /**
  74642. * number of max animation frames a single cell will reserve in resources.
  74643. */
  74644. maxAnimationFrames?: number;
  74645. /**
  74646. * number cell index of the base tile when the system compiles.
  74647. */
  74648. baseTile?: number;
  74649. /**
  74650. * boolean flip the sprite after its been repositioned by the framing data.
  74651. */
  74652. flipU?: boolean;
  74653. /**
  74654. * Vector3 scalar of the global RGB values of the SpriteMap.
  74655. */
  74656. colorMultiply?: Vector3;
  74657. }
  74658. /**
  74659. * Defines the IDisposable interface in order to be cleanable from resources.
  74660. */
  74661. export interface ISpriteMap extends IDisposable {
  74662. /**
  74663. * String name of the SpriteMap.
  74664. */
  74665. name: string;
  74666. /**
  74667. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  74668. */
  74669. atlasJSON: ISpriteJSONAtlas;
  74670. /**
  74671. * Texture of the SpriteMap.
  74672. */
  74673. spriteSheet: Texture;
  74674. /**
  74675. * The parameters to initialize the SpriteMap with.
  74676. */
  74677. options: ISpriteMapOptions;
  74678. }
  74679. /**
  74680. * Class used to manage a grid restricted sprite deployment on an Output plane.
  74681. */
  74682. export class SpriteMap implements ISpriteMap {
  74683. /** The Name of the spriteMap */
  74684. name: string;
  74685. /** The JSON file with the frame and meta data */
  74686. atlasJSON: ISpriteJSONAtlas;
  74687. /** The systems Sprite Sheet Texture */
  74688. spriteSheet: Texture;
  74689. /** Arguments passed with the Constructor */
  74690. options: ISpriteMapOptions;
  74691. /** Public Sprite Storage array, parsed from atlasJSON */
  74692. sprites: Array<ISpriteJSONSprite>;
  74693. /** Returns the Number of Sprites in the System */
  74694. get spriteCount(): number;
  74695. /** Returns the Position of Output Plane*/
  74696. get position(): Vector3;
  74697. /** Returns the Position of Output Plane*/
  74698. set position(v: Vector3);
  74699. /** Returns the Rotation of Output Plane*/
  74700. get rotation(): Vector3;
  74701. /** Returns the Rotation of Output Plane*/
  74702. set rotation(v: Vector3);
  74703. /** Sets the AnimationMap*/
  74704. get animationMap(): RawTexture;
  74705. /** Sets the AnimationMap*/
  74706. set animationMap(v: RawTexture);
  74707. /** Scene that the SpriteMap was created in */
  74708. private _scene;
  74709. /** Texture Buffer of Float32 that holds tile frame data*/
  74710. private _frameMap;
  74711. /** Texture Buffers of Float32 that holds tileMap data*/
  74712. private _tileMaps;
  74713. /** Texture Buffer of Float32 that holds Animation Data*/
  74714. private _animationMap;
  74715. /** Custom ShaderMaterial Central to the System*/
  74716. private _material;
  74717. /** Custom ShaderMaterial Central to the System*/
  74718. private _output;
  74719. /** Systems Time Ticker*/
  74720. private _time;
  74721. /**
  74722. * Creates a new SpriteMap
  74723. * @param name defines the SpriteMaps Name
  74724. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  74725. * @param spriteSheet is the Texture that the Sprites are on.
  74726. * @param options a basic deployment configuration
  74727. * @param scene The Scene that the map is deployed on
  74728. */
  74729. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74730. /**
  74731. * Returns tileID location
  74732. * @returns Vector2 the cell position ID
  74733. */
  74734. getTileID(): Vector2;
  74735. /**
  74736. * Gets the UV location of the mouse over the SpriteMap.
  74737. * @returns Vector2 the UV position of the mouse interaction
  74738. */
  74739. getMousePosition(): Vector2;
  74740. /**
  74741. * Creates the "frame" texture Buffer
  74742. * -------------------------------------
  74743. * Structure of frames
  74744. * "filename": "Falling-Water-2.png",
  74745. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74746. * "rotated": true,
  74747. * "trimmed": true,
  74748. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74749. * "sourceSize": {"w":32,"h":32}
  74750. * @returns RawTexture of the frameMap
  74751. */
  74752. private _createFrameBuffer;
  74753. /**
  74754. * Creates the tileMap texture Buffer
  74755. * @param buffer normally and array of numbers, or a false to generate from scratch
  74756. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74757. * @returns RawTexture of the tileMap
  74758. */
  74759. private _createTileBuffer;
  74760. /**
  74761. * Modifies the data of the tileMaps
  74762. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74763. * @param pos is the iVector2 Coordinates of the Tile
  74764. * @param tile The SpriteIndex of the new Tile
  74765. */
  74766. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74767. /**
  74768. * Creates the animationMap texture Buffer
  74769. * @param buffer normally and array of numbers, or a false to generate from scratch
  74770. * @returns RawTexture of the animationMap
  74771. */
  74772. private _createTileAnimationBuffer;
  74773. /**
  74774. * Modifies the data of the animationMap
  74775. * @param cellID is the Index of the Sprite
  74776. * @param _frame is the target Animation frame
  74777. * @param toCell is the Target Index of the next frame of the animation
  74778. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74779. * @param speed is a global scalar of the time variable on the map.
  74780. */
  74781. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74782. /**
  74783. * Exports the .tilemaps file
  74784. */
  74785. saveTileMaps(): void;
  74786. /**
  74787. * Imports the .tilemaps file
  74788. * @param url of the .tilemaps file
  74789. */
  74790. loadTileMaps(url: string): void;
  74791. /**
  74792. * Release associated resources
  74793. */
  74794. dispose(): void;
  74795. }
  74796. }
  74797. declare module "babylonjs/Sprites/spritePackedManager" {
  74798. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74799. import { Scene } from "babylonjs/scene";
  74800. /**
  74801. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74802. * @see http://doc.babylonjs.com/babylon101/sprites
  74803. */
  74804. export class SpritePackedManager extends SpriteManager {
  74805. /** defines the packed manager's name */
  74806. name: string;
  74807. /**
  74808. * Creates a new sprite manager from a packed sprite sheet
  74809. * @param name defines the manager's name
  74810. * @param imgUrl defines the sprite sheet url
  74811. * @param capacity defines the maximum allowed number of sprites
  74812. * @param scene defines the hosting scene
  74813. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74814. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74815. * @param samplingMode defines the smapling mode to use with spritesheet
  74816. * @param fromPacked set to true; do not alter
  74817. */
  74818. constructor(
  74819. /** defines the packed manager's name */
  74820. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74821. }
  74822. }
  74823. declare module "babylonjs/Sprites/index" {
  74824. export * from "babylonjs/Sprites/sprite";
  74825. export * from "babylonjs/Sprites/ISprites";
  74826. export * from "babylonjs/Sprites/spriteManager";
  74827. export * from "babylonjs/Sprites/spriteMap";
  74828. export * from "babylonjs/Sprites/spritePackedManager";
  74829. export * from "babylonjs/Sprites/spriteSceneComponent";
  74830. }
  74831. declare module "babylonjs/States/index" {
  74832. export * from "babylonjs/States/alphaCullingState";
  74833. export * from "babylonjs/States/depthCullingState";
  74834. export * from "babylonjs/States/stencilState";
  74835. }
  74836. declare module "babylonjs/Misc/assetsManager" {
  74837. import { Scene } from "babylonjs/scene";
  74838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74839. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74840. import { Skeleton } from "babylonjs/Bones/skeleton";
  74841. import { Observable } from "babylonjs/Misc/observable";
  74842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74843. import { Texture } from "babylonjs/Materials/Textures/texture";
  74844. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74845. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74846. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74847. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74848. /**
  74849. * Defines the list of states available for a task inside a AssetsManager
  74850. */
  74851. export enum AssetTaskState {
  74852. /**
  74853. * Initialization
  74854. */
  74855. INIT = 0,
  74856. /**
  74857. * Running
  74858. */
  74859. RUNNING = 1,
  74860. /**
  74861. * Done
  74862. */
  74863. DONE = 2,
  74864. /**
  74865. * Error
  74866. */
  74867. ERROR = 3
  74868. }
  74869. /**
  74870. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74871. */
  74872. export abstract class AbstractAssetTask {
  74873. /**
  74874. * Task name
  74875. */ name: string;
  74876. /**
  74877. * Callback called when the task is successful
  74878. */
  74879. onSuccess: (task: any) => void;
  74880. /**
  74881. * Callback called when the task is not successful
  74882. */
  74883. onError: (task: any, message?: string, exception?: any) => void;
  74884. /**
  74885. * Creates a new AssetsManager
  74886. * @param name defines the name of the task
  74887. */
  74888. constructor(
  74889. /**
  74890. * Task name
  74891. */ name: string);
  74892. private _isCompleted;
  74893. private _taskState;
  74894. private _errorObject;
  74895. /**
  74896. * Get if the task is completed
  74897. */
  74898. get isCompleted(): boolean;
  74899. /**
  74900. * Gets the current state of the task
  74901. */
  74902. get taskState(): AssetTaskState;
  74903. /**
  74904. * Gets the current error object (if task is in error)
  74905. */
  74906. get errorObject(): {
  74907. message?: string;
  74908. exception?: any;
  74909. };
  74910. /**
  74911. * Internal only
  74912. * @hidden
  74913. */
  74914. _setErrorObject(message?: string, exception?: any): void;
  74915. /**
  74916. * Execute the current task
  74917. * @param scene defines the scene where you want your assets to be loaded
  74918. * @param onSuccess is a callback called when the task is successfully executed
  74919. * @param onError is a callback called if an error occurs
  74920. */
  74921. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74922. /**
  74923. * Execute the current task
  74924. * @param scene defines the scene where you want your assets to be loaded
  74925. * @param onSuccess is a callback called when the task is successfully executed
  74926. * @param onError is a callback called if an error occurs
  74927. */
  74928. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74929. /**
  74930. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74931. * This can be used with failed tasks that have the reason for failure fixed.
  74932. */
  74933. reset(): void;
  74934. private onErrorCallback;
  74935. private onDoneCallback;
  74936. }
  74937. /**
  74938. * Define the interface used by progress events raised during assets loading
  74939. */
  74940. export interface IAssetsProgressEvent {
  74941. /**
  74942. * Defines the number of remaining tasks to process
  74943. */
  74944. remainingCount: number;
  74945. /**
  74946. * Defines the total number of tasks
  74947. */
  74948. totalCount: number;
  74949. /**
  74950. * Defines the task that was just processed
  74951. */
  74952. task: AbstractAssetTask;
  74953. }
  74954. /**
  74955. * Class used to share progress information about assets loading
  74956. */
  74957. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74958. /**
  74959. * Defines the number of remaining tasks to process
  74960. */
  74961. remainingCount: number;
  74962. /**
  74963. * Defines the total number of tasks
  74964. */
  74965. totalCount: number;
  74966. /**
  74967. * Defines the task that was just processed
  74968. */
  74969. task: AbstractAssetTask;
  74970. /**
  74971. * Creates a AssetsProgressEvent
  74972. * @param remainingCount defines the number of remaining tasks to process
  74973. * @param totalCount defines the total number of tasks
  74974. * @param task defines the task that was just processed
  74975. */
  74976. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74977. }
  74978. /**
  74979. * Define a task used by AssetsManager to load meshes
  74980. */
  74981. export class MeshAssetTask extends AbstractAssetTask {
  74982. /**
  74983. * Defines the name of the task
  74984. */
  74985. name: string;
  74986. /**
  74987. * Defines the list of mesh's names you want to load
  74988. */
  74989. meshesNames: any;
  74990. /**
  74991. * Defines the root url to use as a base to load your meshes and associated resources
  74992. */
  74993. rootUrl: string;
  74994. /**
  74995. * Defines the filename or File of the scene to load from
  74996. */
  74997. sceneFilename: string | File;
  74998. /**
  74999. * Gets the list of loaded meshes
  75000. */
  75001. loadedMeshes: Array<AbstractMesh>;
  75002. /**
  75003. * Gets the list of loaded particle systems
  75004. */
  75005. loadedParticleSystems: Array<IParticleSystem>;
  75006. /**
  75007. * Gets the list of loaded skeletons
  75008. */
  75009. loadedSkeletons: Array<Skeleton>;
  75010. /**
  75011. * Gets the list of loaded animation groups
  75012. */
  75013. loadedAnimationGroups: Array<AnimationGroup>;
  75014. /**
  75015. * Callback called when the task is successful
  75016. */
  75017. onSuccess: (task: MeshAssetTask) => void;
  75018. /**
  75019. * Callback called when the task is successful
  75020. */
  75021. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75022. /**
  75023. * Creates a new MeshAssetTask
  75024. * @param name defines the name of the task
  75025. * @param meshesNames defines the list of mesh's names you want to load
  75026. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75027. * @param sceneFilename defines the filename or File of the scene to load from
  75028. */
  75029. constructor(
  75030. /**
  75031. * Defines the name of the task
  75032. */
  75033. name: string,
  75034. /**
  75035. * Defines the list of mesh's names you want to load
  75036. */
  75037. meshesNames: any,
  75038. /**
  75039. * Defines the root url to use as a base to load your meshes and associated resources
  75040. */
  75041. rootUrl: string,
  75042. /**
  75043. * Defines the filename or File of the scene to load from
  75044. */
  75045. sceneFilename: string | File);
  75046. /**
  75047. * Execute the current task
  75048. * @param scene defines the scene where you want your assets to be loaded
  75049. * @param onSuccess is a callback called when the task is successfully executed
  75050. * @param onError is a callback called if an error occurs
  75051. */
  75052. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75053. }
  75054. /**
  75055. * Define a task used by AssetsManager to load text content
  75056. */
  75057. export class TextFileAssetTask extends AbstractAssetTask {
  75058. /**
  75059. * Defines the name of the task
  75060. */
  75061. name: string;
  75062. /**
  75063. * Defines the location of the file to load
  75064. */
  75065. url: string;
  75066. /**
  75067. * Gets the loaded text string
  75068. */
  75069. text: string;
  75070. /**
  75071. * Callback called when the task is successful
  75072. */
  75073. onSuccess: (task: TextFileAssetTask) => void;
  75074. /**
  75075. * Callback called when the task is successful
  75076. */
  75077. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75078. /**
  75079. * Creates a new TextFileAssetTask object
  75080. * @param name defines the name of the task
  75081. * @param url defines the location of the file to load
  75082. */
  75083. constructor(
  75084. /**
  75085. * Defines the name of the task
  75086. */
  75087. name: string,
  75088. /**
  75089. * Defines the location of the file to load
  75090. */
  75091. url: string);
  75092. /**
  75093. * Execute the current task
  75094. * @param scene defines the scene where you want your assets to be loaded
  75095. * @param onSuccess is a callback called when the task is successfully executed
  75096. * @param onError is a callback called if an error occurs
  75097. */
  75098. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75099. }
  75100. /**
  75101. * Define a task used by AssetsManager to load binary data
  75102. */
  75103. export class BinaryFileAssetTask extends AbstractAssetTask {
  75104. /**
  75105. * Defines the name of the task
  75106. */
  75107. name: string;
  75108. /**
  75109. * Defines the location of the file to load
  75110. */
  75111. url: string;
  75112. /**
  75113. * Gets the lodaded data (as an array buffer)
  75114. */
  75115. data: ArrayBuffer;
  75116. /**
  75117. * Callback called when the task is successful
  75118. */
  75119. onSuccess: (task: BinaryFileAssetTask) => void;
  75120. /**
  75121. * Callback called when the task is successful
  75122. */
  75123. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75124. /**
  75125. * Creates a new BinaryFileAssetTask object
  75126. * @param name defines the name of the new task
  75127. * @param url defines the location of the file to load
  75128. */
  75129. constructor(
  75130. /**
  75131. * Defines the name of the task
  75132. */
  75133. name: string,
  75134. /**
  75135. * Defines the location of the file to load
  75136. */
  75137. url: string);
  75138. /**
  75139. * Execute the current task
  75140. * @param scene defines the scene where you want your assets to be loaded
  75141. * @param onSuccess is a callback called when the task is successfully executed
  75142. * @param onError is a callback called if an error occurs
  75143. */
  75144. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75145. }
  75146. /**
  75147. * Define a task used by AssetsManager to load images
  75148. */
  75149. export class ImageAssetTask extends AbstractAssetTask {
  75150. /**
  75151. * Defines the name of the task
  75152. */
  75153. name: string;
  75154. /**
  75155. * Defines the location of the image to load
  75156. */
  75157. url: string;
  75158. /**
  75159. * Gets the loaded images
  75160. */
  75161. image: HTMLImageElement;
  75162. /**
  75163. * Callback called when the task is successful
  75164. */
  75165. onSuccess: (task: ImageAssetTask) => void;
  75166. /**
  75167. * Callback called when the task is successful
  75168. */
  75169. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75170. /**
  75171. * Creates a new ImageAssetTask
  75172. * @param name defines the name of the task
  75173. * @param url defines the location of the image to load
  75174. */
  75175. constructor(
  75176. /**
  75177. * Defines the name of the task
  75178. */
  75179. name: string,
  75180. /**
  75181. * Defines the location of the image to load
  75182. */
  75183. url: string);
  75184. /**
  75185. * Execute the current task
  75186. * @param scene defines the scene where you want your assets to be loaded
  75187. * @param onSuccess is a callback called when the task is successfully executed
  75188. * @param onError is a callback called if an error occurs
  75189. */
  75190. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75191. }
  75192. /**
  75193. * Defines the interface used by texture loading tasks
  75194. */
  75195. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75196. /**
  75197. * Gets the loaded texture
  75198. */
  75199. texture: TEX;
  75200. }
  75201. /**
  75202. * Define a task used by AssetsManager to load 2D textures
  75203. */
  75204. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75205. /**
  75206. * Defines the name of the task
  75207. */
  75208. name: string;
  75209. /**
  75210. * Defines the location of the file to load
  75211. */
  75212. url: string;
  75213. /**
  75214. * Defines if mipmap should not be generated (default is false)
  75215. */
  75216. noMipmap?: boolean | undefined;
  75217. /**
  75218. * Defines if texture must be inverted on Y axis (default is true)
  75219. */
  75220. invertY: boolean;
  75221. /**
  75222. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75223. */
  75224. samplingMode: number;
  75225. /**
  75226. * Gets the loaded texture
  75227. */
  75228. texture: Texture;
  75229. /**
  75230. * Callback called when the task is successful
  75231. */
  75232. onSuccess: (task: TextureAssetTask) => void;
  75233. /**
  75234. * Callback called when the task is successful
  75235. */
  75236. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75237. /**
  75238. * Creates a new TextureAssetTask object
  75239. * @param name defines the name of the task
  75240. * @param url defines the location of the file to load
  75241. * @param noMipmap defines if mipmap should not be generated (default is false)
  75242. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75243. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75244. */
  75245. constructor(
  75246. /**
  75247. * Defines the name of the task
  75248. */
  75249. name: string,
  75250. /**
  75251. * Defines the location of the file to load
  75252. */
  75253. url: string,
  75254. /**
  75255. * Defines if mipmap should not be generated (default is false)
  75256. */
  75257. noMipmap?: boolean | undefined,
  75258. /**
  75259. * Defines if texture must be inverted on Y axis (default is true)
  75260. */
  75261. invertY?: boolean,
  75262. /**
  75263. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75264. */
  75265. samplingMode?: number);
  75266. /**
  75267. * Execute the current task
  75268. * @param scene defines the scene where you want your assets to be loaded
  75269. * @param onSuccess is a callback called when the task is successfully executed
  75270. * @param onError is a callback called if an error occurs
  75271. */
  75272. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75273. }
  75274. /**
  75275. * Define a task used by AssetsManager to load cube textures
  75276. */
  75277. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75278. /**
  75279. * Defines the name of the task
  75280. */
  75281. name: string;
  75282. /**
  75283. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75284. */
  75285. url: string;
  75286. /**
  75287. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75288. */
  75289. extensions?: string[] | undefined;
  75290. /**
  75291. * Defines if mipmaps should not be generated (default is false)
  75292. */
  75293. noMipmap?: boolean | undefined;
  75294. /**
  75295. * Defines the explicit list of files (undefined by default)
  75296. */
  75297. files?: string[] | undefined;
  75298. /**
  75299. * Gets the loaded texture
  75300. */
  75301. texture: CubeTexture;
  75302. /**
  75303. * Callback called when the task is successful
  75304. */
  75305. onSuccess: (task: CubeTextureAssetTask) => void;
  75306. /**
  75307. * Callback called when the task is successful
  75308. */
  75309. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75310. /**
  75311. * Creates a new CubeTextureAssetTask
  75312. * @param name defines the name of the task
  75313. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75314. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75315. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75316. * @param files defines the explicit list of files (undefined by default)
  75317. */
  75318. constructor(
  75319. /**
  75320. * Defines the name of the task
  75321. */
  75322. name: string,
  75323. /**
  75324. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75325. */
  75326. url: string,
  75327. /**
  75328. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75329. */
  75330. extensions?: string[] | undefined,
  75331. /**
  75332. * Defines if mipmaps should not be generated (default is false)
  75333. */
  75334. noMipmap?: boolean | undefined,
  75335. /**
  75336. * Defines the explicit list of files (undefined by default)
  75337. */
  75338. files?: string[] | undefined);
  75339. /**
  75340. * Execute the current task
  75341. * @param scene defines the scene where you want your assets to be loaded
  75342. * @param onSuccess is a callback called when the task is successfully executed
  75343. * @param onError is a callback called if an error occurs
  75344. */
  75345. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75346. }
  75347. /**
  75348. * Define a task used by AssetsManager to load HDR cube textures
  75349. */
  75350. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  75351. /**
  75352. * Defines the name of the task
  75353. */
  75354. name: string;
  75355. /**
  75356. * Defines the location of the file to load
  75357. */
  75358. url: string;
  75359. /**
  75360. * Defines the desired size (the more it increases the longer the generation will be)
  75361. */
  75362. size: number;
  75363. /**
  75364. * Defines if mipmaps should not be generated (default is false)
  75365. */
  75366. noMipmap: boolean;
  75367. /**
  75368. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75369. */
  75370. generateHarmonics: boolean;
  75371. /**
  75372. * 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)
  75373. */
  75374. gammaSpace: boolean;
  75375. /**
  75376. * Internal Use Only
  75377. */
  75378. reserved: boolean;
  75379. /**
  75380. * Gets the loaded texture
  75381. */
  75382. texture: HDRCubeTexture;
  75383. /**
  75384. * Callback called when the task is successful
  75385. */
  75386. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  75387. /**
  75388. * Callback called when the task is successful
  75389. */
  75390. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  75391. /**
  75392. * Creates a new HDRCubeTextureAssetTask object
  75393. * @param name defines the name of the task
  75394. * @param url defines the location of the file to load
  75395. * @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.
  75396. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75397. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75398. * @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)
  75399. * @param reserved Internal use only
  75400. */
  75401. constructor(
  75402. /**
  75403. * Defines the name of the task
  75404. */
  75405. name: string,
  75406. /**
  75407. * Defines the location of the file to load
  75408. */
  75409. url: string,
  75410. /**
  75411. * Defines the desired size (the more it increases the longer the generation will be)
  75412. */
  75413. size: number,
  75414. /**
  75415. * Defines if mipmaps should not be generated (default is false)
  75416. */
  75417. noMipmap?: boolean,
  75418. /**
  75419. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75420. */
  75421. generateHarmonics?: boolean,
  75422. /**
  75423. * 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)
  75424. */
  75425. gammaSpace?: boolean,
  75426. /**
  75427. * Internal Use Only
  75428. */
  75429. reserved?: boolean);
  75430. /**
  75431. * Execute the current task
  75432. * @param scene defines the scene where you want your assets to be loaded
  75433. * @param onSuccess is a callback called when the task is successfully executed
  75434. * @param onError is a callback called if an error occurs
  75435. */
  75436. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75437. }
  75438. /**
  75439. * Define a task used by AssetsManager to load Equirectangular cube textures
  75440. */
  75441. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75442. /**
  75443. * Defines the name of the task
  75444. */
  75445. name: string;
  75446. /**
  75447. * Defines the location of the file to load
  75448. */
  75449. url: string;
  75450. /**
  75451. * Defines the desired size (the more it increases the longer the generation will be)
  75452. */
  75453. size: number;
  75454. /**
  75455. * Defines if mipmaps should not be generated (default is false)
  75456. */
  75457. noMipmap: boolean;
  75458. /**
  75459. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75460. * but the standard material would require them in Gamma space) (default is true)
  75461. */
  75462. gammaSpace: boolean;
  75463. /**
  75464. * Gets the loaded texture
  75465. */
  75466. texture: EquiRectangularCubeTexture;
  75467. /**
  75468. * Callback called when the task is successful
  75469. */
  75470. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75471. /**
  75472. * Callback called when the task is successful
  75473. */
  75474. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  75475. /**
  75476. * Creates a new EquiRectangularCubeTextureAssetTask object
  75477. * @param name defines the name of the task
  75478. * @param url defines the location of the file to load
  75479. * @param size defines the desired size (the more it increases the longer the generation will be)
  75480. * If the size is omitted this implies you are using a preprocessed cubemap.
  75481. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75482. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  75483. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  75484. * (default is true)
  75485. */
  75486. constructor(
  75487. /**
  75488. * Defines the name of the task
  75489. */
  75490. name: string,
  75491. /**
  75492. * Defines the location of the file to load
  75493. */
  75494. url: string,
  75495. /**
  75496. * Defines the desired size (the more it increases the longer the generation will be)
  75497. */
  75498. size: number,
  75499. /**
  75500. * Defines if mipmaps should not be generated (default is false)
  75501. */
  75502. noMipmap?: boolean,
  75503. /**
  75504. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75505. * but the standard material would require them in Gamma space) (default is true)
  75506. */
  75507. gammaSpace?: boolean);
  75508. /**
  75509. * Execute the current task
  75510. * @param scene defines the scene where you want your assets to be loaded
  75511. * @param onSuccess is a callback called when the task is successfully executed
  75512. * @param onError is a callback called if an error occurs
  75513. */
  75514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75515. }
  75516. /**
  75517. * This class can be used to easily import assets into a scene
  75518. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  75519. */
  75520. export class AssetsManager {
  75521. private _scene;
  75522. private _isLoading;
  75523. protected _tasks: AbstractAssetTask[];
  75524. protected _waitingTasksCount: number;
  75525. protected _totalTasksCount: number;
  75526. /**
  75527. * Callback called when all tasks are processed
  75528. */
  75529. onFinish: (tasks: AbstractAssetTask[]) => void;
  75530. /**
  75531. * Callback called when a task is successful
  75532. */
  75533. onTaskSuccess: (task: AbstractAssetTask) => void;
  75534. /**
  75535. * Callback called when a task had an error
  75536. */
  75537. onTaskError: (task: AbstractAssetTask) => void;
  75538. /**
  75539. * Callback called when a task is done (whatever the result is)
  75540. */
  75541. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  75542. /**
  75543. * Observable called when all tasks are processed
  75544. */
  75545. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  75546. /**
  75547. * Observable called when a task had an error
  75548. */
  75549. onTaskErrorObservable: Observable<AbstractAssetTask>;
  75550. /**
  75551. * Observable called when all tasks were executed
  75552. */
  75553. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  75554. /**
  75555. * Observable called when a task is done (whatever the result is)
  75556. */
  75557. onProgressObservable: Observable<IAssetsProgressEvent>;
  75558. /**
  75559. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  75560. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  75561. */
  75562. useDefaultLoadingScreen: boolean;
  75563. /**
  75564. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  75565. * when all assets have been downloaded.
  75566. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  75567. */
  75568. autoHideLoadingUI: boolean;
  75569. /**
  75570. * Creates a new AssetsManager
  75571. * @param scene defines the scene to work on
  75572. */
  75573. constructor(scene: Scene);
  75574. /**
  75575. * Add a MeshAssetTask to the list of active tasks
  75576. * @param taskName defines the name of the new task
  75577. * @param meshesNames defines the name of meshes to load
  75578. * @param rootUrl defines the root url to use to locate files
  75579. * @param sceneFilename defines the filename of the scene file
  75580. * @returns a new MeshAssetTask object
  75581. */
  75582. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  75583. /**
  75584. * Add a TextFileAssetTask to the list of active tasks
  75585. * @param taskName defines the name of the new task
  75586. * @param url defines the url of the file to load
  75587. * @returns a new TextFileAssetTask object
  75588. */
  75589. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  75590. /**
  75591. * Add a BinaryFileAssetTask to the list of active tasks
  75592. * @param taskName defines the name of the new task
  75593. * @param url defines the url of the file to load
  75594. * @returns a new BinaryFileAssetTask object
  75595. */
  75596. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  75597. /**
  75598. * Add a ImageAssetTask to the list of active tasks
  75599. * @param taskName defines the name of the new task
  75600. * @param url defines the url of the file to load
  75601. * @returns a new ImageAssetTask object
  75602. */
  75603. addImageTask(taskName: string, url: string): ImageAssetTask;
  75604. /**
  75605. * Add a TextureAssetTask to the list of active tasks
  75606. * @param taskName defines the name of the new task
  75607. * @param url defines the url of the file to load
  75608. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75609. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  75610. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  75611. * @returns a new TextureAssetTask object
  75612. */
  75613. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  75614. /**
  75615. * Add a CubeTextureAssetTask to the list of active tasks
  75616. * @param taskName defines the name of the new task
  75617. * @param url defines the url of the file to load
  75618. * @param extensions defines the extension to use to load the cube map (can be null)
  75619. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75620. * @param files defines the list of files to load (can be null)
  75621. * @returns a new CubeTextureAssetTask object
  75622. */
  75623. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  75624. /**
  75625. *
  75626. * Add a HDRCubeTextureAssetTask to the list of active tasks
  75627. * @param taskName defines the name of the new task
  75628. * @param url defines the url of the file to load
  75629. * @param size defines the size you want for the cubemap (can be null)
  75630. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75631. * @param generateHarmonics defines if you want to automatically generate (true by default)
  75632. * @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)
  75633. * @param reserved Internal use only
  75634. * @returns a new HDRCubeTextureAssetTask object
  75635. */
  75636. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  75637. /**
  75638. *
  75639. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  75640. * @param taskName defines the name of the new task
  75641. * @param url defines the url of the file to load
  75642. * @param size defines the size you want for the cubemap (can be null)
  75643. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75644. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  75645. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  75646. * @returns a new EquiRectangularCubeTextureAssetTask object
  75647. */
  75648. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  75649. /**
  75650. * Remove a task from the assets manager.
  75651. * @param task the task to remove
  75652. */
  75653. removeTask(task: AbstractAssetTask): void;
  75654. private _decreaseWaitingTasksCount;
  75655. private _runTask;
  75656. /**
  75657. * Reset the AssetsManager and remove all tasks
  75658. * @return the current instance of the AssetsManager
  75659. */
  75660. reset(): AssetsManager;
  75661. /**
  75662. * Start the loading process
  75663. * @return the current instance of the AssetsManager
  75664. */
  75665. load(): AssetsManager;
  75666. /**
  75667. * Start the loading process as an async operation
  75668. * @return a promise returning the list of failed tasks
  75669. */
  75670. loadAsync(): Promise<void>;
  75671. }
  75672. }
  75673. declare module "babylonjs/Misc/deferred" {
  75674. /**
  75675. * Wrapper class for promise with external resolve and reject.
  75676. */
  75677. export class Deferred<T> {
  75678. /**
  75679. * The promise associated with this deferred object.
  75680. */
  75681. readonly promise: Promise<T>;
  75682. private _resolve;
  75683. private _reject;
  75684. /**
  75685. * The resolve method of the promise associated with this deferred object.
  75686. */
  75687. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75688. /**
  75689. * The reject method of the promise associated with this deferred object.
  75690. */
  75691. get reject(): (reason?: any) => void;
  75692. /**
  75693. * Constructor for this deferred object.
  75694. */
  75695. constructor();
  75696. }
  75697. }
  75698. declare module "babylonjs/Misc/meshExploder" {
  75699. import { Mesh } from "babylonjs/Meshes/mesh";
  75700. /**
  75701. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75702. */
  75703. export class MeshExploder {
  75704. private _centerMesh;
  75705. private _meshes;
  75706. private _meshesOrigins;
  75707. private _toCenterVectors;
  75708. private _scaledDirection;
  75709. private _newPosition;
  75710. private _centerPosition;
  75711. /**
  75712. * Explodes meshes from a center mesh.
  75713. * @param meshes The meshes to explode.
  75714. * @param centerMesh The mesh to be center of explosion.
  75715. */
  75716. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75717. private _setCenterMesh;
  75718. /**
  75719. * Get class name
  75720. * @returns "MeshExploder"
  75721. */
  75722. getClassName(): string;
  75723. /**
  75724. * "Exploded meshes"
  75725. * @returns Array of meshes with the centerMesh at index 0.
  75726. */
  75727. getMeshes(): Array<Mesh>;
  75728. /**
  75729. * Explodes meshes giving a specific direction
  75730. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75731. */
  75732. explode(direction?: number): void;
  75733. }
  75734. }
  75735. declare module "babylonjs/Misc/filesInput" {
  75736. import { Engine } from "babylonjs/Engines/engine";
  75737. import { Scene } from "babylonjs/scene";
  75738. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  75739. /**
  75740. * Class used to help managing file picking and drag'n'drop
  75741. */
  75742. export class FilesInput {
  75743. /**
  75744. * List of files ready to be loaded
  75745. */
  75746. static get FilesToLoad(): {
  75747. [key: string]: File;
  75748. };
  75749. /**
  75750. * Callback called when a file is processed
  75751. */
  75752. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  75753. private _engine;
  75754. private _currentScene;
  75755. private _sceneLoadedCallback;
  75756. private _progressCallback;
  75757. private _additionalRenderLoopLogicCallback;
  75758. private _textureLoadingCallback;
  75759. private _startingProcessingFilesCallback;
  75760. private _onReloadCallback;
  75761. private _errorCallback;
  75762. private _elementToMonitor;
  75763. private _sceneFileToLoad;
  75764. private _filesToLoad;
  75765. /**
  75766. * Creates a new FilesInput
  75767. * @param engine defines the rendering engine
  75768. * @param scene defines the hosting scene
  75769. * @param sceneLoadedCallback callback called when scene is loaded
  75770. * @param progressCallback callback called to track progress
  75771. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75772. * @param textureLoadingCallback callback called when a texture is loading
  75773. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75774. * @param onReloadCallback callback called when a reload is requested
  75775. * @param errorCallback callback call if an error occurs
  75776. */
  75777. 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);
  75778. private _dragEnterHandler;
  75779. private _dragOverHandler;
  75780. private _dropHandler;
  75781. /**
  75782. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75783. * @param elementToMonitor defines the DOM element to track
  75784. */
  75785. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75786. /**
  75787. * Release all associated resources
  75788. */
  75789. dispose(): void;
  75790. private renderFunction;
  75791. private drag;
  75792. private drop;
  75793. private _traverseFolder;
  75794. private _processFiles;
  75795. /**
  75796. * Load files from a drop event
  75797. * @param event defines the drop event to use as source
  75798. */
  75799. loadFiles(event: any): void;
  75800. private _processReload;
  75801. /**
  75802. * Reload the current scene from the loaded files
  75803. */
  75804. reload(): void;
  75805. }
  75806. }
  75807. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75808. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75809. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75810. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75811. }
  75812. declare module "babylonjs/Misc/sceneOptimizer" {
  75813. import { Scene, IDisposable } from "babylonjs/scene";
  75814. import { Observable } from "babylonjs/Misc/observable";
  75815. /**
  75816. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75817. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75818. */
  75819. export class SceneOptimization {
  75820. /**
  75821. * Defines the priority of this optimization (0 by default which means first in the list)
  75822. */
  75823. priority: number;
  75824. /**
  75825. * Gets a string describing the action executed by the current optimization
  75826. * @returns description string
  75827. */
  75828. getDescription(): string;
  75829. /**
  75830. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75831. * @param scene defines the current scene where to apply this optimization
  75832. * @param optimizer defines the current optimizer
  75833. * @returns true if everything that can be done was applied
  75834. */
  75835. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75836. /**
  75837. * Creates the SceneOptimization object
  75838. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75839. * @param desc defines the description associated with the optimization
  75840. */
  75841. constructor(
  75842. /**
  75843. * Defines the priority of this optimization (0 by default which means first in the list)
  75844. */
  75845. priority?: number);
  75846. }
  75847. /**
  75848. * Defines an optimization used to reduce the size of render target textures
  75849. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75850. */
  75851. export class TextureOptimization extends SceneOptimization {
  75852. /**
  75853. * Defines the priority of this optimization (0 by default which means first in the list)
  75854. */
  75855. priority: number;
  75856. /**
  75857. * 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
  75858. */
  75859. maximumSize: number;
  75860. /**
  75861. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75862. */
  75863. step: number;
  75864. /**
  75865. * Gets a string describing the action executed by the current optimization
  75866. * @returns description string
  75867. */
  75868. getDescription(): string;
  75869. /**
  75870. * Creates the TextureOptimization object
  75871. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75872. * @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
  75873. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75874. */
  75875. constructor(
  75876. /**
  75877. * Defines the priority of this optimization (0 by default which means first in the list)
  75878. */
  75879. priority?: number,
  75880. /**
  75881. * 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
  75882. */
  75883. maximumSize?: number,
  75884. /**
  75885. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75886. */
  75887. step?: number);
  75888. /**
  75889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75890. * @param scene defines the current scene where to apply this optimization
  75891. * @param optimizer defines the current optimizer
  75892. * @returns true if everything that can be done was applied
  75893. */
  75894. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75895. }
  75896. /**
  75897. * Defines an optimization used to increase or decrease the rendering resolution
  75898. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75899. */
  75900. export class HardwareScalingOptimization extends SceneOptimization {
  75901. /**
  75902. * Defines the priority of this optimization (0 by default which means first in the list)
  75903. */
  75904. priority: number;
  75905. /**
  75906. * Defines the maximum scale to use (2 by default)
  75907. */
  75908. maximumScale: number;
  75909. /**
  75910. * Defines the step to use between two passes (0.5 by default)
  75911. */
  75912. step: number;
  75913. private _currentScale;
  75914. private _directionOffset;
  75915. /**
  75916. * Gets a string describing the action executed by the current optimization
  75917. * @return description string
  75918. */
  75919. getDescription(): string;
  75920. /**
  75921. * Creates the HardwareScalingOptimization object
  75922. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75923. * @param maximumScale defines the maximum scale to use (2 by default)
  75924. * @param step defines the step to use between two passes (0.5 by default)
  75925. */
  75926. constructor(
  75927. /**
  75928. * Defines the priority of this optimization (0 by default which means first in the list)
  75929. */
  75930. priority?: number,
  75931. /**
  75932. * Defines the maximum scale to use (2 by default)
  75933. */
  75934. maximumScale?: number,
  75935. /**
  75936. * Defines the step to use between two passes (0.5 by default)
  75937. */
  75938. step?: number);
  75939. /**
  75940. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75941. * @param scene defines the current scene where to apply this optimization
  75942. * @param optimizer defines the current optimizer
  75943. * @returns true if everything that can be done was applied
  75944. */
  75945. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75946. }
  75947. /**
  75948. * Defines an optimization used to remove shadows
  75949. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75950. */
  75951. export class ShadowsOptimization extends SceneOptimization {
  75952. /**
  75953. * Gets a string describing the action executed by the current optimization
  75954. * @return description string
  75955. */
  75956. getDescription(): string;
  75957. /**
  75958. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75959. * @param scene defines the current scene where to apply this optimization
  75960. * @param optimizer defines the current optimizer
  75961. * @returns true if everything that can be done was applied
  75962. */
  75963. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75964. }
  75965. /**
  75966. * Defines an optimization used to turn post-processes off
  75967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75968. */
  75969. export class PostProcessesOptimization extends SceneOptimization {
  75970. /**
  75971. * Gets a string describing the action executed by the current optimization
  75972. * @return description string
  75973. */
  75974. getDescription(): string;
  75975. /**
  75976. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75977. * @param scene defines the current scene where to apply this optimization
  75978. * @param optimizer defines the current optimizer
  75979. * @returns true if everything that can be done was applied
  75980. */
  75981. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75982. }
  75983. /**
  75984. * Defines an optimization used to turn lens flares off
  75985. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75986. */
  75987. export class LensFlaresOptimization extends SceneOptimization {
  75988. /**
  75989. * Gets a string describing the action executed by the current optimization
  75990. * @return description string
  75991. */
  75992. getDescription(): string;
  75993. /**
  75994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75995. * @param scene defines the current scene where to apply this optimization
  75996. * @param optimizer defines the current optimizer
  75997. * @returns true if everything that can be done was applied
  75998. */
  75999. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76000. }
  76001. /**
  76002. * Defines an optimization based on user defined callback.
  76003. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76004. */
  76005. export class CustomOptimization extends SceneOptimization {
  76006. /**
  76007. * Callback called to apply the custom optimization.
  76008. */
  76009. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76010. /**
  76011. * Callback called to get custom description
  76012. */
  76013. onGetDescription: () => string;
  76014. /**
  76015. * Gets a string describing the action executed by the current optimization
  76016. * @returns description string
  76017. */
  76018. getDescription(): string;
  76019. /**
  76020. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76021. * @param scene defines the current scene where to apply this optimization
  76022. * @param optimizer defines the current optimizer
  76023. * @returns true if everything that can be done was applied
  76024. */
  76025. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76026. }
  76027. /**
  76028. * Defines an optimization used to turn particles off
  76029. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76030. */
  76031. export class ParticlesOptimization extends SceneOptimization {
  76032. /**
  76033. * Gets a string describing the action executed by the current optimization
  76034. * @return description string
  76035. */
  76036. getDescription(): string;
  76037. /**
  76038. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76039. * @param scene defines the current scene where to apply this optimization
  76040. * @param optimizer defines the current optimizer
  76041. * @returns true if everything that can be done was applied
  76042. */
  76043. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76044. }
  76045. /**
  76046. * Defines an optimization used to turn render targets off
  76047. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76048. */
  76049. export class RenderTargetsOptimization extends SceneOptimization {
  76050. /**
  76051. * Gets a string describing the action executed by the current optimization
  76052. * @return description string
  76053. */
  76054. getDescription(): string;
  76055. /**
  76056. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76057. * @param scene defines the current scene where to apply this optimization
  76058. * @param optimizer defines the current optimizer
  76059. * @returns true if everything that can be done was applied
  76060. */
  76061. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76062. }
  76063. /**
  76064. * Defines an optimization used to merge meshes with compatible materials
  76065. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76066. */
  76067. export class MergeMeshesOptimization extends SceneOptimization {
  76068. private static _UpdateSelectionTree;
  76069. /**
  76070. * Gets or sets a boolean which defines if optimization octree has to be updated
  76071. */
  76072. static get UpdateSelectionTree(): boolean;
  76073. /**
  76074. * Gets or sets a boolean which defines if optimization octree has to be updated
  76075. */
  76076. static set UpdateSelectionTree(value: boolean);
  76077. /**
  76078. * Gets a string describing the action executed by the current optimization
  76079. * @return description string
  76080. */
  76081. getDescription(): string;
  76082. private _canBeMerged;
  76083. /**
  76084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76085. * @param scene defines the current scene where to apply this optimization
  76086. * @param optimizer defines the current optimizer
  76087. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76088. * @returns true if everything that can be done was applied
  76089. */
  76090. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76091. }
  76092. /**
  76093. * Defines a list of options used by SceneOptimizer
  76094. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76095. */
  76096. export class SceneOptimizerOptions {
  76097. /**
  76098. * Defines the target frame rate to reach (60 by default)
  76099. */
  76100. targetFrameRate: number;
  76101. /**
  76102. * Defines the interval between two checkes (2000ms by default)
  76103. */
  76104. trackerDuration: number;
  76105. /**
  76106. * Gets the list of optimizations to apply
  76107. */
  76108. optimizations: SceneOptimization[];
  76109. /**
  76110. * Creates a new list of options used by SceneOptimizer
  76111. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76112. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76113. */
  76114. constructor(
  76115. /**
  76116. * Defines the target frame rate to reach (60 by default)
  76117. */
  76118. targetFrameRate?: number,
  76119. /**
  76120. * Defines the interval between two checkes (2000ms by default)
  76121. */
  76122. trackerDuration?: number);
  76123. /**
  76124. * Add a new optimization
  76125. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76126. * @returns the current SceneOptimizerOptions
  76127. */
  76128. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76129. /**
  76130. * Add a new custom optimization
  76131. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76132. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76133. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76134. * @returns the current SceneOptimizerOptions
  76135. */
  76136. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76137. /**
  76138. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76139. * @param targetFrameRate defines the target frame rate (60 by default)
  76140. * @returns a SceneOptimizerOptions object
  76141. */
  76142. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76143. /**
  76144. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76145. * @param targetFrameRate defines the target frame rate (60 by default)
  76146. * @returns a SceneOptimizerOptions object
  76147. */
  76148. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76149. /**
  76150. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76151. * @param targetFrameRate defines the target frame rate (60 by default)
  76152. * @returns a SceneOptimizerOptions object
  76153. */
  76154. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76155. }
  76156. /**
  76157. * Class used to run optimizations in order to reach a target frame rate
  76158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76159. */
  76160. export class SceneOptimizer implements IDisposable {
  76161. private _isRunning;
  76162. private _options;
  76163. private _scene;
  76164. private _currentPriorityLevel;
  76165. private _targetFrameRate;
  76166. private _trackerDuration;
  76167. private _currentFrameRate;
  76168. private _sceneDisposeObserver;
  76169. private _improvementMode;
  76170. /**
  76171. * Defines an observable called when the optimizer reaches the target frame rate
  76172. */
  76173. onSuccessObservable: Observable<SceneOptimizer>;
  76174. /**
  76175. * Defines an observable called when the optimizer enables an optimization
  76176. */
  76177. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76178. /**
  76179. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76180. */
  76181. onFailureObservable: Observable<SceneOptimizer>;
  76182. /**
  76183. * Gets a boolean indicating if the optimizer is in improvement mode
  76184. */
  76185. get isInImprovementMode(): boolean;
  76186. /**
  76187. * Gets the current priority level (0 at start)
  76188. */
  76189. get currentPriorityLevel(): number;
  76190. /**
  76191. * Gets the current frame rate checked by the SceneOptimizer
  76192. */
  76193. get currentFrameRate(): number;
  76194. /**
  76195. * Gets or sets the current target frame rate (60 by default)
  76196. */
  76197. get targetFrameRate(): number;
  76198. /**
  76199. * Gets or sets the current target frame rate (60 by default)
  76200. */
  76201. set targetFrameRate(value: number);
  76202. /**
  76203. * Gets or sets the current interval between two checks (every 2000ms by default)
  76204. */
  76205. get trackerDuration(): number;
  76206. /**
  76207. * Gets or sets the current interval between two checks (every 2000ms by default)
  76208. */
  76209. set trackerDuration(value: number);
  76210. /**
  76211. * Gets the list of active optimizations
  76212. */
  76213. get optimizations(): SceneOptimization[];
  76214. /**
  76215. * Creates a new SceneOptimizer
  76216. * @param scene defines the scene to work on
  76217. * @param options defines the options to use with the SceneOptimizer
  76218. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76219. * @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)
  76220. */
  76221. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76222. /**
  76223. * Stops the current optimizer
  76224. */
  76225. stop(): void;
  76226. /**
  76227. * Reset the optimizer to initial step (current priority level = 0)
  76228. */
  76229. reset(): void;
  76230. /**
  76231. * Start the optimizer. By default it will try to reach a specific framerate
  76232. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76233. */
  76234. start(): void;
  76235. private _checkCurrentState;
  76236. /**
  76237. * Release all resources
  76238. */
  76239. dispose(): void;
  76240. /**
  76241. * Helper function to create a SceneOptimizer with one single line of code
  76242. * @param scene defines the scene to work on
  76243. * @param options defines the options to use with the SceneOptimizer
  76244. * @param onSuccess defines a callback to call on success
  76245. * @param onFailure defines a callback to call on failure
  76246. * @returns the new SceneOptimizer object
  76247. */
  76248. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76249. }
  76250. }
  76251. declare module "babylonjs/Misc/sceneSerializer" {
  76252. import { Scene } from "babylonjs/scene";
  76253. /**
  76254. * Class used to serialize a scene into a string
  76255. */
  76256. export class SceneSerializer {
  76257. /**
  76258. * Clear cache used by a previous serialization
  76259. */
  76260. static ClearCache(): void;
  76261. /**
  76262. * Serialize a scene into a JSON compatible object
  76263. * @param scene defines the scene to serialize
  76264. * @returns a JSON compatible object
  76265. */
  76266. static Serialize(scene: Scene): any;
  76267. /**
  76268. * Serialize a mesh into a JSON compatible object
  76269. * @param toSerialize defines the mesh to serialize
  76270. * @param withParents defines if parents must be serialized as well
  76271. * @param withChildren defines if children must be serialized as well
  76272. * @returns a JSON compatible object
  76273. */
  76274. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76275. }
  76276. }
  76277. declare module "babylonjs/Misc/textureTools" {
  76278. import { Texture } from "babylonjs/Materials/Textures/texture";
  76279. /**
  76280. * Class used to host texture specific utilities
  76281. */
  76282. export class TextureTools {
  76283. /**
  76284. * Uses the GPU to create a copy texture rescaled at a given size
  76285. * @param texture Texture to copy from
  76286. * @param width defines the desired width
  76287. * @param height defines the desired height
  76288. * @param useBilinearMode defines if bilinear mode has to be used
  76289. * @return the generated texture
  76290. */
  76291. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76292. }
  76293. }
  76294. declare module "babylonjs/Misc/videoRecorder" {
  76295. import { Nullable } from "babylonjs/types";
  76296. import { Engine } from "babylonjs/Engines/engine";
  76297. /**
  76298. * This represents the different options available for the video capture.
  76299. */
  76300. export interface VideoRecorderOptions {
  76301. /** Defines the mime type of the video. */
  76302. mimeType: string;
  76303. /** Defines the FPS the video should be recorded at. */
  76304. fps: number;
  76305. /** Defines the chunk size for the recording data. */
  76306. recordChunckSize: number;
  76307. /** The audio tracks to attach to the recording. */
  76308. audioTracks?: MediaStreamTrack[];
  76309. }
  76310. /**
  76311. * This can help with recording videos from BabylonJS.
  76312. * This is based on the available WebRTC functionalities of the browser.
  76313. *
  76314. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  76315. */
  76316. export class VideoRecorder {
  76317. private static readonly _defaultOptions;
  76318. /**
  76319. * Returns whether or not the VideoRecorder is available in your browser.
  76320. * @param engine Defines the Babylon Engine.
  76321. * @returns true if supported otherwise false.
  76322. */
  76323. static IsSupported(engine: Engine): boolean;
  76324. private readonly _options;
  76325. private _canvas;
  76326. private _mediaRecorder;
  76327. private _recordedChunks;
  76328. private _fileName;
  76329. private _resolve;
  76330. private _reject;
  76331. /**
  76332. * True when a recording is already in progress.
  76333. */
  76334. get isRecording(): boolean;
  76335. /**
  76336. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76337. * @param engine Defines the BabylonJS Engine you wish to record.
  76338. * @param options Defines options that can be used to customize the capture.
  76339. */
  76340. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76341. /**
  76342. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76343. */
  76344. stopRecording(): void;
  76345. /**
  76346. * Starts recording the canvas for a max duration specified in parameters.
  76347. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  76348. * If null no automatic download will start and you can rely on the promise to get the data back.
  76349. * @param maxDuration Defines the maximum recording time in seconds.
  76350. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  76351. * @return A promise callback at the end of the recording with the video data in Blob.
  76352. */
  76353. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  76354. /**
  76355. * Releases internal resources used during the recording.
  76356. */
  76357. dispose(): void;
  76358. private _handleDataAvailable;
  76359. private _handleError;
  76360. private _handleStop;
  76361. }
  76362. }
  76363. declare module "babylonjs/Misc/screenshotTools" {
  76364. import { Camera } from "babylonjs/Cameras/camera";
  76365. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  76366. import { Engine } from "babylonjs/Engines/engine";
  76367. /**
  76368. * Class containing a set of static utilities functions for screenshots
  76369. */
  76370. export class ScreenshotTools {
  76371. /**
  76372. * Captures a screenshot of the current rendering
  76373. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76374. * @param engine defines the rendering engine
  76375. * @param camera defines the source camera
  76376. * @param size This parameter can be set to a single number or to an object with the
  76377. * following (optional) properties: precision, width, height. If a single number is passed,
  76378. * it will be used for both width and height. If an object is passed, the screenshot size
  76379. * will be derived from the parameters. The precision property is a multiplier allowing
  76380. * rendering at a higher or lower resolution
  76381. * @param successCallback defines the callback receives a single parameter which contains the
  76382. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76383. * src parameter of an <img> to display it
  76384. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76385. * Check your browser for supported MIME types
  76386. */
  76387. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  76388. /**
  76389. * Captures a screenshot of the current rendering
  76390. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76391. * @param engine defines the rendering engine
  76392. * @param camera defines the source camera
  76393. * @param size This parameter can be set to a single number or to an object with the
  76394. * following (optional) properties: precision, width, height. If a single number is passed,
  76395. * it will be used for both width and height. If an object is passed, the screenshot size
  76396. * will be derived from the parameters. The precision property is a multiplier allowing
  76397. * rendering at a higher or lower resolution
  76398. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76399. * Check your browser for supported MIME types
  76400. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76401. * to the src parameter of an <img> to display it
  76402. */
  76403. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  76404. /**
  76405. * Generates an image screenshot from the specified camera.
  76406. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76407. * @param engine The engine to use for rendering
  76408. * @param camera The camera to use for rendering
  76409. * @param size This parameter can be set to a single number or to an object with the
  76410. * following (optional) properties: precision, width, height. If a single number is passed,
  76411. * it will be used for both width and height. If an object is passed, the screenshot size
  76412. * will be derived from the parameters. The precision property is a multiplier allowing
  76413. * rendering at a higher or lower resolution
  76414. * @param successCallback The callback receives a single parameter which contains the
  76415. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76416. * src parameter of an <img> to display it
  76417. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76418. * Check your browser for supported MIME types
  76419. * @param samples Texture samples (default: 1)
  76420. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76421. * @param fileName A name for for the downloaded file.
  76422. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76423. */
  76424. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76425. /**
  76426. * Generates an image screenshot from the specified camera.
  76427. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76428. * @param engine The engine to use for rendering
  76429. * @param camera The camera to use for rendering
  76430. * @param size This parameter can be set to a single number or to an object with the
  76431. * following (optional) properties: precision, width, height. If a single number is passed,
  76432. * it will be used for both width and height. If an object is passed, the screenshot size
  76433. * will be derived from the parameters. The precision property is a multiplier allowing
  76434. * rendering at a higher or lower resolution
  76435. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76436. * Check your browser for supported MIME types
  76437. * @param samples Texture samples (default: 1)
  76438. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76439. * @param fileName A name for for the downloaded file.
  76440. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76441. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76442. * to the src parameter of an <img> to display it
  76443. */
  76444. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76445. /**
  76446. * Gets height and width for screenshot size
  76447. * @private
  76448. */
  76449. private static _getScreenshotSize;
  76450. }
  76451. }
  76452. declare module "babylonjs/Misc/dataReader" {
  76453. /**
  76454. * Interface for a data buffer
  76455. */
  76456. export interface IDataBuffer {
  76457. /**
  76458. * Reads bytes from the data buffer.
  76459. * @param byteOffset The byte offset to read
  76460. * @param byteLength The byte length to read
  76461. * @returns A promise that resolves when the bytes are read
  76462. */
  76463. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76464. /**
  76465. * The byte length of the buffer.
  76466. */
  76467. readonly byteLength: number;
  76468. }
  76469. /**
  76470. * Utility class for reading from a data buffer
  76471. */
  76472. export class DataReader {
  76473. /**
  76474. * The data buffer associated with this data reader.
  76475. */
  76476. readonly buffer: IDataBuffer;
  76477. /**
  76478. * The current byte offset from the beginning of the data buffer.
  76479. */
  76480. byteOffset: number;
  76481. private _dataView;
  76482. private _dataByteOffset;
  76483. /**
  76484. * Constructor
  76485. * @param buffer The buffer to read
  76486. */
  76487. constructor(buffer: IDataBuffer);
  76488. /**
  76489. * Loads the given byte length.
  76490. * @param byteLength The byte length to load
  76491. * @returns A promise that resolves when the load is complete
  76492. */
  76493. loadAsync(byteLength: number): Promise<void>;
  76494. /**
  76495. * Read a unsigned 32-bit integer from the currently loaded data range.
  76496. * @returns The 32-bit integer read
  76497. */
  76498. readUint32(): number;
  76499. /**
  76500. * Read a byte array from the currently loaded data range.
  76501. * @param byteLength The byte length to read
  76502. * @returns The byte array read
  76503. */
  76504. readUint8Array(byteLength: number): Uint8Array;
  76505. /**
  76506. * Read a string from the currently loaded data range.
  76507. * @param byteLength The byte length to read
  76508. * @returns The string read
  76509. */
  76510. readString(byteLength: number): string;
  76511. /**
  76512. * Skips the given byte length the currently loaded data range.
  76513. * @param byteLength The byte length to skip
  76514. */
  76515. skipBytes(byteLength: number): void;
  76516. }
  76517. }
  76518. declare module "babylonjs/Misc/dataStorage" {
  76519. /**
  76520. * Class for storing data to local storage if available or in-memory storage otherwise
  76521. */
  76522. export class DataStorage {
  76523. private static _Storage;
  76524. private static _GetStorage;
  76525. /**
  76526. * Reads a string from the data storage
  76527. * @param key The key to read
  76528. * @param defaultValue The value if the key doesn't exist
  76529. * @returns The string value
  76530. */
  76531. static ReadString(key: string, defaultValue: string): string;
  76532. /**
  76533. * Writes a string to the data storage
  76534. * @param key The key to write
  76535. * @param value The value to write
  76536. */
  76537. static WriteString(key: string, value: string): void;
  76538. /**
  76539. * Reads a boolean from the data storage
  76540. * @param key The key to read
  76541. * @param defaultValue The value if the key doesn't exist
  76542. * @returns The boolean value
  76543. */
  76544. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  76545. /**
  76546. * Writes a boolean to the data storage
  76547. * @param key The key to write
  76548. * @param value The value to write
  76549. */
  76550. static WriteBoolean(key: string, value: boolean): void;
  76551. /**
  76552. * Reads a number from the data storage
  76553. * @param key The key to read
  76554. * @param defaultValue The value if the key doesn't exist
  76555. * @returns The number value
  76556. */
  76557. static ReadNumber(key: string, defaultValue: number): number;
  76558. /**
  76559. * Writes a number to the data storage
  76560. * @param key The key to write
  76561. * @param value The value to write
  76562. */
  76563. static WriteNumber(key: string, value: number): void;
  76564. }
  76565. }
  76566. declare module "babylonjs/Misc/index" {
  76567. export * from "babylonjs/Misc/andOrNotEvaluator";
  76568. export * from "babylonjs/Misc/assetsManager";
  76569. export * from "babylonjs/Misc/basis";
  76570. export * from "babylonjs/Misc/dds";
  76571. export * from "babylonjs/Misc/decorators";
  76572. export * from "babylonjs/Misc/deferred";
  76573. export * from "babylonjs/Misc/environmentTextureTools";
  76574. export * from "babylonjs/Misc/meshExploder";
  76575. export * from "babylonjs/Misc/filesInput";
  76576. export * from "babylonjs/Misc/HighDynamicRange/index";
  76577. export * from "babylonjs/Misc/khronosTextureContainer";
  76578. export * from "babylonjs/Misc/observable";
  76579. export * from "babylonjs/Misc/performanceMonitor";
  76580. export * from "babylonjs/Misc/promise";
  76581. export * from "babylonjs/Misc/sceneOptimizer";
  76582. export * from "babylonjs/Misc/sceneSerializer";
  76583. export * from "babylonjs/Misc/smartArray";
  76584. export * from "babylonjs/Misc/stringDictionary";
  76585. export * from "babylonjs/Misc/tags";
  76586. export * from "babylonjs/Misc/textureTools";
  76587. export * from "babylonjs/Misc/tga";
  76588. export * from "babylonjs/Misc/tools";
  76589. export * from "babylonjs/Misc/videoRecorder";
  76590. export * from "babylonjs/Misc/virtualJoystick";
  76591. export * from "babylonjs/Misc/workerPool";
  76592. export * from "babylonjs/Misc/logger";
  76593. export * from "babylonjs/Misc/typeStore";
  76594. export * from "babylonjs/Misc/filesInputStore";
  76595. export * from "babylonjs/Misc/deepCopier";
  76596. export * from "babylonjs/Misc/pivotTools";
  76597. export * from "babylonjs/Misc/precisionDate";
  76598. export * from "babylonjs/Misc/screenshotTools";
  76599. export * from "babylonjs/Misc/typeStore";
  76600. export * from "babylonjs/Misc/webRequest";
  76601. export * from "babylonjs/Misc/iInspectable";
  76602. export * from "babylonjs/Misc/brdfTextureTools";
  76603. export * from "babylonjs/Misc/rgbdTextureTools";
  76604. export * from "babylonjs/Misc/gradients";
  76605. export * from "babylonjs/Misc/perfCounter";
  76606. export * from "babylonjs/Misc/fileRequest";
  76607. export * from "babylonjs/Misc/customAnimationFrameRequester";
  76608. export * from "babylonjs/Misc/retryStrategy";
  76609. export * from "babylonjs/Misc/interfaces/screenshotSize";
  76610. export * from "babylonjs/Misc/canvasGenerator";
  76611. export * from "babylonjs/Misc/fileTools";
  76612. export * from "babylonjs/Misc/stringTools";
  76613. export * from "babylonjs/Misc/dataReader";
  76614. export * from "babylonjs/Misc/minMaxReducer";
  76615. export * from "babylonjs/Misc/depthReducer";
  76616. export * from "babylonjs/Misc/dataStorage";
  76617. }
  76618. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  76619. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  76620. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76621. import { Observable } from "babylonjs/Misc/observable";
  76622. import { Matrix } from "babylonjs/Maths/math.vector";
  76623. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76624. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76625. /**
  76626. * An interface for all Hit test features
  76627. */
  76628. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76629. /**
  76630. * Triggered when new babylon (transformed) hit test results are available
  76631. */
  76632. onHitTestResultObservable: Observable<T[]>;
  76633. }
  76634. /**
  76635. * Options used for hit testing
  76636. */
  76637. export interface IWebXRLegacyHitTestOptions {
  76638. /**
  76639. * Only test when user interacted with the scene. Default - hit test every frame
  76640. */
  76641. testOnPointerDownOnly?: boolean;
  76642. /**
  76643. * The node to use to transform the local results to world coordinates
  76644. */
  76645. worldParentNode?: TransformNode;
  76646. }
  76647. /**
  76648. * Interface defining the babylon result of raycasting/hit-test
  76649. */
  76650. export interface IWebXRLegacyHitResult {
  76651. /**
  76652. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76653. */
  76654. transformationMatrix: Matrix;
  76655. /**
  76656. * The native hit test result
  76657. */
  76658. xrHitResult: XRHitResult | XRHitTestResult;
  76659. }
  76660. /**
  76661. * The currently-working hit-test module.
  76662. * Hit test (or Ray-casting) is used to interact with the real world.
  76663. * For further information read here - https://github.com/immersive-web/hit-test
  76664. */
  76665. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76666. /**
  76667. * options to use when constructing this feature
  76668. */
  76669. readonly options: IWebXRLegacyHitTestOptions;
  76670. private _direction;
  76671. private _mat;
  76672. private _onSelectEnabled;
  76673. private _origin;
  76674. /**
  76675. * The module's name
  76676. */
  76677. static readonly Name: string;
  76678. /**
  76679. * The (Babylon) version of this module.
  76680. * This is an integer representing the implementation version.
  76681. * This number does not correspond to the WebXR specs version
  76682. */
  76683. static readonly Version: number;
  76684. /**
  76685. * Populated with the last native XR Hit Results
  76686. */
  76687. lastNativeXRHitResults: XRHitResult[];
  76688. /**
  76689. * Triggered when new babylon (transformed) hit test results are available
  76690. */
  76691. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76692. /**
  76693. * Creates a new instance of the (legacy version) hit test feature
  76694. * @param _xrSessionManager an instance of WebXRSessionManager
  76695. * @param options options to use when constructing this feature
  76696. */
  76697. constructor(_xrSessionManager: WebXRSessionManager,
  76698. /**
  76699. * options to use when constructing this feature
  76700. */
  76701. options?: IWebXRLegacyHitTestOptions);
  76702. /**
  76703. * execute a hit test with an XR Ray
  76704. *
  76705. * @param xrSession a native xrSession that will execute this hit test
  76706. * @param xrRay the ray (position and direction) to use for ray-casting
  76707. * @param referenceSpace native XR reference space to use for the hit-test
  76708. * @param filter filter function that will filter the results
  76709. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76710. */
  76711. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76712. /**
  76713. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76714. * @param event the (select) event to use to select with
  76715. * @param referenceSpace the reference space to use for this hit test
  76716. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76717. */
  76718. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76719. /**
  76720. * attach this feature
  76721. * Will usually be called by the features manager
  76722. *
  76723. * @returns true if successful.
  76724. */
  76725. attach(): boolean;
  76726. /**
  76727. * detach this feature.
  76728. * Will usually be called by the features manager
  76729. *
  76730. * @returns true if successful.
  76731. */
  76732. detach(): boolean;
  76733. /**
  76734. * Dispose this feature and all of the resources attached
  76735. */
  76736. dispose(): void;
  76737. protected _onXRFrame(frame: XRFrame): void;
  76738. private _onHitTestResults;
  76739. private _onSelect;
  76740. }
  76741. }
  76742. declare module "babylonjs/XR/features/WebXRHitTest" {
  76743. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76744. import { Observable } from "babylonjs/Misc/observable";
  76745. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76746. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76747. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76748. /**
  76749. * Options used for hit testing (version 2)
  76750. */
  76751. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76752. /**
  76753. * Do not create a permanent hit test. Will usually be used when only
  76754. * transient inputs are needed.
  76755. */
  76756. disablePermanentHitTest?: boolean;
  76757. /**
  76758. * Enable transient (for example touch-based) hit test inspections
  76759. */
  76760. enableTransientHitTest?: boolean;
  76761. /**
  76762. * Offset ray for the permanent hit test
  76763. */
  76764. offsetRay?: Vector3;
  76765. /**
  76766. * Offset ray for the transient hit test
  76767. */
  76768. transientOffsetRay?: Vector3;
  76769. /**
  76770. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76771. */
  76772. useReferenceSpace?: boolean;
  76773. }
  76774. /**
  76775. * Interface defining the babylon result of hit-test
  76776. */
  76777. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76778. /**
  76779. * The input source that generated this hit test (if transient)
  76780. */
  76781. inputSource?: XRInputSource;
  76782. /**
  76783. * Is this a transient hit test
  76784. */
  76785. isTransient?: boolean;
  76786. /**
  76787. * Position of the hit test result
  76788. */
  76789. position: Vector3;
  76790. /**
  76791. * Rotation of the hit test result
  76792. */
  76793. rotationQuaternion: Quaternion;
  76794. /**
  76795. * The native hit test result
  76796. */
  76797. xrHitResult: XRHitTestResult;
  76798. }
  76799. /**
  76800. * The currently-working hit-test module.
  76801. * Hit test (or Ray-casting) is used to interact with the real world.
  76802. * For further information read here - https://github.com/immersive-web/hit-test
  76803. *
  76804. * Tested on chrome (mobile) 80.
  76805. */
  76806. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76807. /**
  76808. * options to use when constructing this feature
  76809. */
  76810. readonly options: IWebXRHitTestOptions;
  76811. private _tmpMat;
  76812. private _tmpPos;
  76813. private _tmpQuat;
  76814. private _transientXrHitTestSource;
  76815. private _xrHitTestSource;
  76816. private initHitTestSource;
  76817. /**
  76818. * The module's name
  76819. */
  76820. static readonly Name: string;
  76821. /**
  76822. * The (Babylon) version of this module.
  76823. * This is an integer representing the implementation version.
  76824. * This number does not correspond to the WebXR specs version
  76825. */
  76826. static readonly Version: number;
  76827. /**
  76828. * When set to true, each hit test will have its own position/rotation objects
  76829. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76830. * the developers will clone them or copy them as they see fit.
  76831. */
  76832. autoCloneTransformation: boolean;
  76833. /**
  76834. * Triggered when new babylon (transformed) hit test results are available
  76835. */
  76836. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76837. /**
  76838. * Use this to temporarily pause hit test checks.
  76839. */
  76840. paused: boolean;
  76841. /**
  76842. * Creates a new instance of the hit test feature
  76843. * @param _xrSessionManager an instance of WebXRSessionManager
  76844. * @param options options to use when constructing this feature
  76845. */
  76846. constructor(_xrSessionManager: WebXRSessionManager,
  76847. /**
  76848. * options to use when constructing this feature
  76849. */
  76850. options?: IWebXRHitTestOptions);
  76851. /**
  76852. * attach this feature
  76853. * Will usually be called by the features manager
  76854. *
  76855. * @returns true if successful.
  76856. */
  76857. attach(): boolean;
  76858. /**
  76859. * detach this feature.
  76860. * Will usually be called by the features manager
  76861. *
  76862. * @returns true if successful.
  76863. */
  76864. detach(): boolean;
  76865. /**
  76866. * Dispose this feature and all of the resources attached
  76867. */
  76868. dispose(): void;
  76869. protected _onXRFrame(frame: XRFrame): void;
  76870. private _processWebXRHitTestResult;
  76871. }
  76872. }
  76873. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  76874. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76875. import { Observable } from "babylonjs/Misc/observable";
  76876. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76878. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76879. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  76880. /**
  76881. * Configuration options of the anchor system
  76882. */
  76883. export interface IWebXRAnchorSystemOptions {
  76884. /**
  76885. * a node that will be used to convert local to world coordinates
  76886. */
  76887. worldParentNode?: TransformNode;
  76888. /**
  76889. * If set to true a reference of the created anchors will be kept until the next session starts
  76890. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76891. */
  76892. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76893. }
  76894. /**
  76895. * A babylon container for an XR Anchor
  76896. */
  76897. export interface IWebXRAnchor {
  76898. /**
  76899. * A babylon-assigned ID for this anchor
  76900. */
  76901. id: number;
  76902. /**
  76903. * Transformation matrix to apply to an object attached to this anchor
  76904. */
  76905. transformationMatrix: Matrix;
  76906. /**
  76907. * The native anchor object
  76908. */
  76909. xrAnchor: XRAnchor;
  76910. /**
  76911. * if defined, this object will be constantly updated by the anchor's position and rotation
  76912. */
  76913. attachedNode?: TransformNode;
  76914. }
  76915. /**
  76916. * An implementation of the anchor system for WebXR.
  76917. * For further information see https://github.com/immersive-web/anchors/
  76918. */
  76919. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76920. private _options;
  76921. private _lastFrameDetected;
  76922. private _trackedAnchors;
  76923. private _referenceSpaceForFrameAnchors;
  76924. private _futureAnchors;
  76925. /**
  76926. * The module's name
  76927. */
  76928. static readonly Name: string;
  76929. /**
  76930. * The (Babylon) version of this module.
  76931. * This is an integer representing the implementation version.
  76932. * This number does not correspond to the WebXR specs version
  76933. */
  76934. static readonly Version: number;
  76935. /**
  76936. * Observers registered here will be executed when a new anchor was added to the session
  76937. */
  76938. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76939. /**
  76940. * Observers registered here will be executed when an anchor was removed from the session
  76941. */
  76942. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76943. /**
  76944. * Observers registered here will be executed when an existing anchor updates
  76945. * This can execute N times every frame
  76946. */
  76947. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76948. /**
  76949. * Set the reference space to use for anchor creation, when not using a hit test.
  76950. * Will default to the session's reference space if not defined
  76951. */
  76952. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76953. /**
  76954. * constructs a new anchor system
  76955. * @param _xrSessionManager an instance of WebXRSessionManager
  76956. * @param _options configuration object for this feature
  76957. */
  76958. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76959. private _tmpVector;
  76960. private _tmpQuaternion;
  76961. private _populateTmpTransformation;
  76962. /**
  76963. * Create a new anchor point using a hit test result at a specific point in the scene
  76964. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76965. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76966. *
  76967. * @param hitTestResult The hit test result to use for this anchor creation
  76968. * @param position an optional position offset for this anchor
  76969. * @param rotationQuaternion an optional rotation offset for this anchor
  76970. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76971. */
  76972. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  76973. /**
  76974. * Add a new anchor at a specific position and rotation
  76975. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76976. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76977. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76978. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76979. *
  76980. * @param position the position in which to add an anchor
  76981. * @param rotationQuaternion an optional rotation for the anchor transformation
  76982. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76983. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76984. */
  76985. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  76986. /**
  76987. * detach this feature.
  76988. * Will usually be called by the features manager
  76989. *
  76990. * @returns true if successful.
  76991. */
  76992. detach(): boolean;
  76993. /**
  76994. * Dispose this feature and all of the resources attached
  76995. */
  76996. dispose(): void;
  76997. protected _onXRFrame(frame: XRFrame): void;
  76998. /**
  76999. * avoiding using Array.find for global support.
  77000. * @param xrAnchor the plane to find in the array
  77001. */
  77002. private _findIndexInAnchorArray;
  77003. private _updateAnchorWithXRFrame;
  77004. private _createAnchorAtTransformation;
  77005. }
  77006. }
  77007. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77008. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77009. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77010. import { Observable } from "babylonjs/Misc/observable";
  77011. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77012. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77013. /**
  77014. * Options used in the plane detector module
  77015. */
  77016. export interface IWebXRPlaneDetectorOptions {
  77017. /**
  77018. * The node to use to transform the local results to world coordinates
  77019. */
  77020. worldParentNode?: TransformNode;
  77021. /**
  77022. * If set to true a reference of the created planes will be kept until the next session starts
  77023. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77024. */
  77025. doNotRemovePlanesOnSessionEnded?: boolean;
  77026. }
  77027. /**
  77028. * A babylon interface for a WebXR plane.
  77029. * A Plane is actually a polygon, built from N points in space
  77030. *
  77031. * Supported in chrome 79, not supported in canary 81 ATM
  77032. */
  77033. export interface IWebXRPlane {
  77034. /**
  77035. * a babylon-assigned ID for this polygon
  77036. */
  77037. id: number;
  77038. /**
  77039. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77040. */
  77041. polygonDefinition: Array<Vector3>;
  77042. /**
  77043. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77044. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77045. */
  77046. transformationMatrix: Matrix;
  77047. /**
  77048. * the native xr-plane object
  77049. */
  77050. xrPlane: XRPlane;
  77051. }
  77052. /**
  77053. * The plane detector is used to detect planes in the real world when in AR
  77054. * For more information see https://github.com/immersive-web/real-world-geometry/
  77055. */
  77056. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77057. private _options;
  77058. private _detectedPlanes;
  77059. private _enabled;
  77060. private _lastFrameDetected;
  77061. /**
  77062. * The module's name
  77063. */
  77064. static readonly Name: string;
  77065. /**
  77066. * The (Babylon) version of this module.
  77067. * This is an integer representing the implementation version.
  77068. * This number does not correspond to the WebXR specs version
  77069. */
  77070. static readonly Version: number;
  77071. /**
  77072. * Observers registered here will be executed when a new plane was added to the session
  77073. */
  77074. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77075. /**
  77076. * Observers registered here will be executed when a plane is no longer detected in the session
  77077. */
  77078. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77079. /**
  77080. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77081. * This can execute N times every frame
  77082. */
  77083. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77084. /**
  77085. * construct a new Plane Detector
  77086. * @param _xrSessionManager an instance of xr Session manager
  77087. * @param _options configuration to use when constructing this feature
  77088. */
  77089. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77090. /**
  77091. * detach this feature.
  77092. * Will usually be called by the features manager
  77093. *
  77094. * @returns true if successful.
  77095. */
  77096. detach(): boolean;
  77097. /**
  77098. * Dispose this feature and all of the resources attached
  77099. */
  77100. dispose(): void;
  77101. protected _onXRFrame(frame: XRFrame): void;
  77102. private _init;
  77103. private _updatePlaneWithXRPlane;
  77104. /**
  77105. * avoiding using Array.find for global support.
  77106. * @param xrPlane the plane to find in the array
  77107. */
  77108. private findIndexInPlaneArray;
  77109. }
  77110. }
  77111. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77112. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77114. import { Observable } from "babylonjs/Misc/observable";
  77115. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77116. /**
  77117. * Options interface for the background remover plugin
  77118. */
  77119. export interface IWebXRBackgroundRemoverOptions {
  77120. /**
  77121. * Further background meshes to disable when entering AR
  77122. */
  77123. backgroundMeshes?: AbstractMesh[];
  77124. /**
  77125. * flags to configure the removal of the environment helper.
  77126. * If not set, the entire background will be removed. If set, flags should be set as well.
  77127. */
  77128. environmentHelperRemovalFlags?: {
  77129. /**
  77130. * Should the skybox be removed (default false)
  77131. */
  77132. skyBox?: boolean;
  77133. /**
  77134. * Should the ground be removed (default false)
  77135. */
  77136. ground?: boolean;
  77137. };
  77138. /**
  77139. * don't disable the environment helper
  77140. */
  77141. ignoreEnvironmentHelper?: boolean;
  77142. }
  77143. /**
  77144. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77145. */
  77146. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77147. /**
  77148. * read-only options to be used in this module
  77149. */
  77150. readonly options: IWebXRBackgroundRemoverOptions;
  77151. /**
  77152. * The module's name
  77153. */
  77154. static readonly Name: string;
  77155. /**
  77156. * The (Babylon) version of this module.
  77157. * This is an integer representing the implementation version.
  77158. * This number does not correspond to the WebXR specs version
  77159. */
  77160. static readonly Version: number;
  77161. /**
  77162. * registered observers will be triggered when the background state changes
  77163. */
  77164. onBackgroundStateChangedObservable: Observable<boolean>;
  77165. /**
  77166. * constructs a new background remover module
  77167. * @param _xrSessionManager the session manager for this module
  77168. * @param options read-only options to be used in this module
  77169. */
  77170. constructor(_xrSessionManager: WebXRSessionManager,
  77171. /**
  77172. * read-only options to be used in this module
  77173. */
  77174. options?: IWebXRBackgroundRemoverOptions);
  77175. /**
  77176. * attach this feature
  77177. * Will usually be called by the features manager
  77178. *
  77179. * @returns true if successful.
  77180. */
  77181. attach(): boolean;
  77182. /**
  77183. * detach this feature.
  77184. * Will usually be called by the features manager
  77185. *
  77186. * @returns true if successful.
  77187. */
  77188. detach(): boolean;
  77189. /**
  77190. * Dispose this feature and all of the resources attached
  77191. */
  77192. dispose(): void;
  77193. protected _onXRFrame(_xrFrame: XRFrame): void;
  77194. private _setBackgroundState;
  77195. }
  77196. }
  77197. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77198. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77199. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77200. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77201. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77202. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77203. import { Nullable } from "babylonjs/types";
  77204. /**
  77205. * Options for the controller physics feature
  77206. */
  77207. export class IWebXRControllerPhysicsOptions {
  77208. /**
  77209. * Should the headset get its own impostor
  77210. */
  77211. enableHeadsetImpostor?: boolean;
  77212. /**
  77213. * Optional parameters for the headset impostor
  77214. */
  77215. headsetImpostorParams?: {
  77216. /**
  77217. * The type of impostor to create. Default is sphere
  77218. */
  77219. impostorType: number;
  77220. /**
  77221. * the size of the impostor. Defaults to 10cm
  77222. */
  77223. impostorSize?: number | {
  77224. width: number;
  77225. height: number;
  77226. depth: number;
  77227. };
  77228. /**
  77229. * Friction definitions
  77230. */
  77231. friction?: number;
  77232. /**
  77233. * Restitution
  77234. */
  77235. restitution?: number;
  77236. };
  77237. /**
  77238. * The physics properties of the future impostors
  77239. */
  77240. physicsProperties?: {
  77241. /**
  77242. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77243. * Note that this requires a physics engine that supports mesh impostors!
  77244. */
  77245. useControllerMesh?: boolean;
  77246. /**
  77247. * The type of impostor to create. Default is sphere
  77248. */
  77249. impostorType?: number;
  77250. /**
  77251. * the size of the impostor. Defaults to 10cm
  77252. */
  77253. impostorSize?: number | {
  77254. width: number;
  77255. height: number;
  77256. depth: number;
  77257. };
  77258. /**
  77259. * Friction definitions
  77260. */
  77261. friction?: number;
  77262. /**
  77263. * Restitution
  77264. */
  77265. restitution?: number;
  77266. };
  77267. /**
  77268. * the xr input to use with this pointer selection
  77269. */
  77270. xrInput: WebXRInput;
  77271. }
  77272. /**
  77273. * Add physics impostor to your webxr controllers,
  77274. * including naive calculation of their linear and angular velocity
  77275. */
  77276. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77277. private readonly _options;
  77278. private _attachController;
  77279. private _controllers;
  77280. private _debugMode;
  77281. private _delta;
  77282. private _headsetImpostor?;
  77283. private _headsetMesh?;
  77284. private _lastTimestamp;
  77285. private _tmpQuaternion;
  77286. private _tmpVector;
  77287. /**
  77288. * The module's name
  77289. */
  77290. static readonly Name: string;
  77291. /**
  77292. * The (Babylon) version of this module.
  77293. * This is an integer representing the implementation version.
  77294. * This number does not correspond to the webxr specs version
  77295. */
  77296. static readonly Version: number;
  77297. /**
  77298. * Construct a new Controller Physics Feature
  77299. * @param _xrSessionManager the corresponding xr session manager
  77300. * @param _options options to create this feature with
  77301. */
  77302. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77303. /**
  77304. * @hidden
  77305. * enable debugging - will show console outputs and the impostor mesh
  77306. */
  77307. _enablePhysicsDebug(): void;
  77308. /**
  77309. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77310. * @param xrController the controller to add
  77311. */
  77312. addController(xrController: WebXRInputSource): void;
  77313. /**
  77314. * attach this feature
  77315. * Will usually be called by the features manager
  77316. *
  77317. * @returns true if successful.
  77318. */
  77319. attach(): boolean;
  77320. /**
  77321. * detach this feature.
  77322. * Will usually be called by the features manager
  77323. *
  77324. * @returns true if successful.
  77325. */
  77326. detach(): boolean;
  77327. /**
  77328. * Get the headset impostor, if enabled
  77329. * @returns the impostor
  77330. */
  77331. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77332. /**
  77333. * Get the physics impostor of a specific controller.
  77334. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77335. * @param controller the controller or the controller id of which to get the impostor
  77336. * @returns the impostor or null
  77337. */
  77338. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77339. /**
  77340. * Update the physics properties provided in the constructor
  77341. * @param newProperties the new properties object
  77342. */
  77343. setPhysicsProperties(newProperties: {
  77344. impostorType?: number;
  77345. impostorSize?: number | {
  77346. width: number;
  77347. height: number;
  77348. depth: number;
  77349. };
  77350. friction?: number;
  77351. restitution?: number;
  77352. }): void;
  77353. protected _onXRFrame(_xrFrame: any): void;
  77354. private _detachController;
  77355. }
  77356. }
  77357. declare module "babylonjs/XR/features/index" {
  77358. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  77359. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  77360. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  77361. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  77362. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  77363. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  77364. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  77365. export * from "babylonjs/XR/features/WebXRHitTest";
  77366. }
  77367. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  77368. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77370. import { Scene } from "babylonjs/scene";
  77371. /**
  77372. * The motion controller class for all microsoft mixed reality controllers
  77373. */
  77374. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77375. protected readonly _mapping: {
  77376. defaultButton: {
  77377. valueNodeName: string;
  77378. unpressedNodeName: string;
  77379. pressedNodeName: string;
  77380. };
  77381. defaultAxis: {
  77382. valueNodeName: string;
  77383. minNodeName: string;
  77384. maxNodeName: string;
  77385. };
  77386. buttons: {
  77387. "xr-standard-trigger": {
  77388. rootNodeName: string;
  77389. componentProperty: string;
  77390. states: string[];
  77391. };
  77392. "xr-standard-squeeze": {
  77393. rootNodeName: string;
  77394. componentProperty: string;
  77395. states: string[];
  77396. };
  77397. "xr-standard-touchpad": {
  77398. rootNodeName: string;
  77399. labelAnchorNodeName: string;
  77400. touchPointNodeName: string;
  77401. };
  77402. "xr-standard-thumbstick": {
  77403. rootNodeName: string;
  77404. componentProperty: string;
  77405. states: string[];
  77406. };
  77407. };
  77408. axes: {
  77409. "xr-standard-touchpad": {
  77410. "x-axis": {
  77411. rootNodeName: string;
  77412. };
  77413. "y-axis": {
  77414. rootNodeName: string;
  77415. };
  77416. };
  77417. "xr-standard-thumbstick": {
  77418. "x-axis": {
  77419. rootNodeName: string;
  77420. };
  77421. "y-axis": {
  77422. rootNodeName: string;
  77423. };
  77424. };
  77425. };
  77426. };
  77427. /**
  77428. * The base url used to load the left and right controller models
  77429. */
  77430. static MODEL_BASE_URL: string;
  77431. /**
  77432. * The name of the left controller model file
  77433. */
  77434. static MODEL_LEFT_FILENAME: string;
  77435. /**
  77436. * The name of the right controller model file
  77437. */
  77438. static MODEL_RIGHT_FILENAME: string;
  77439. profileId: string;
  77440. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77441. protected _getFilenameAndPath(): {
  77442. filename: string;
  77443. path: string;
  77444. };
  77445. protected _getModelLoadingConstraints(): boolean;
  77446. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77447. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77448. protected _updateModel(): void;
  77449. }
  77450. }
  77451. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77452. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77454. import { Scene } from "babylonjs/scene";
  77455. /**
  77456. * The motion controller class for oculus touch (quest, rift).
  77457. * This class supports legacy mapping as well the standard xr mapping
  77458. */
  77459. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77460. private _forceLegacyControllers;
  77461. private _modelRootNode;
  77462. /**
  77463. * The base url used to load the left and right controller models
  77464. */
  77465. static MODEL_BASE_URL: string;
  77466. /**
  77467. * The name of the left controller model file
  77468. */
  77469. static MODEL_LEFT_FILENAME: string;
  77470. /**
  77471. * The name of the right controller model file
  77472. */
  77473. static MODEL_RIGHT_FILENAME: string;
  77474. /**
  77475. * Base Url for the Quest controller model.
  77476. */
  77477. static QUEST_MODEL_BASE_URL: string;
  77478. profileId: string;
  77479. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77480. protected _getFilenameAndPath(): {
  77481. filename: string;
  77482. path: string;
  77483. };
  77484. protected _getModelLoadingConstraints(): boolean;
  77485. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77486. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77487. protected _updateModel(): void;
  77488. /**
  77489. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77490. * between the touch and touch 2.
  77491. */
  77492. private _isQuest;
  77493. }
  77494. }
  77495. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  77496. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77497. import { Scene } from "babylonjs/scene";
  77498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77499. /**
  77500. * The motion controller class for the standard HTC-Vive controllers
  77501. */
  77502. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77503. private _modelRootNode;
  77504. /**
  77505. * The base url used to load the left and right controller models
  77506. */
  77507. static MODEL_BASE_URL: string;
  77508. /**
  77509. * File name for the controller model.
  77510. */
  77511. static MODEL_FILENAME: string;
  77512. profileId: string;
  77513. /**
  77514. * Create a new Vive motion controller object
  77515. * @param scene the scene to use to create this controller
  77516. * @param gamepadObject the corresponding gamepad object
  77517. * @param handedness the handedness of the controller
  77518. */
  77519. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77520. protected _getFilenameAndPath(): {
  77521. filename: string;
  77522. path: string;
  77523. };
  77524. protected _getModelLoadingConstraints(): boolean;
  77525. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77526. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77527. protected _updateModel(): void;
  77528. }
  77529. }
  77530. declare module "babylonjs/XR/motionController/index" {
  77531. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77532. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  77533. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  77534. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  77535. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  77536. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  77537. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  77538. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  77539. }
  77540. declare module "babylonjs/XR/index" {
  77541. export * from "babylonjs/XR/webXRCamera";
  77542. export * from "babylonjs/XR/webXREnterExitUI";
  77543. export * from "babylonjs/XR/webXRExperienceHelper";
  77544. export * from "babylonjs/XR/webXRInput";
  77545. export * from "babylonjs/XR/webXRInputSource";
  77546. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  77547. export * from "babylonjs/XR/webXRTypes";
  77548. export * from "babylonjs/XR/webXRSessionManager";
  77549. export * from "babylonjs/XR/webXRDefaultExperience";
  77550. export * from "babylonjs/XR/webXRFeaturesManager";
  77551. export * from "babylonjs/XR/features/index";
  77552. export * from "babylonjs/XR/motionController/index";
  77553. }
  77554. declare module "babylonjs/index" {
  77555. export * from "babylonjs/abstractScene";
  77556. export * from "babylonjs/Actions/index";
  77557. export * from "babylonjs/Animations/index";
  77558. export * from "babylonjs/assetContainer";
  77559. export * from "babylonjs/Audio/index";
  77560. export * from "babylonjs/Behaviors/index";
  77561. export * from "babylonjs/Bones/index";
  77562. export * from "babylonjs/Cameras/index";
  77563. export * from "babylonjs/Collisions/index";
  77564. export * from "babylonjs/Culling/index";
  77565. export * from "babylonjs/Debug/index";
  77566. export * from "babylonjs/DeviceInput/index";
  77567. export * from "babylonjs/Engines/index";
  77568. export * from "babylonjs/Events/index";
  77569. export * from "babylonjs/Gamepads/index";
  77570. export * from "babylonjs/Gizmos/index";
  77571. export * from "babylonjs/Helpers/index";
  77572. export * from "babylonjs/Instrumentation/index";
  77573. export * from "babylonjs/Layers/index";
  77574. export * from "babylonjs/LensFlares/index";
  77575. export * from "babylonjs/Lights/index";
  77576. export * from "babylonjs/Loading/index";
  77577. export * from "babylonjs/Materials/index";
  77578. export * from "babylonjs/Maths/index";
  77579. export * from "babylonjs/Meshes/index";
  77580. export * from "babylonjs/Morph/index";
  77581. export * from "babylonjs/Navigation/index";
  77582. export * from "babylonjs/node";
  77583. export * from "babylonjs/Offline/index";
  77584. export * from "babylonjs/Particles/index";
  77585. export * from "babylonjs/Physics/index";
  77586. export * from "babylonjs/PostProcesses/index";
  77587. export * from "babylonjs/Probes/index";
  77588. export * from "babylonjs/Rendering/index";
  77589. export * from "babylonjs/scene";
  77590. export * from "babylonjs/sceneComponent";
  77591. export * from "babylonjs/Sprites/index";
  77592. export * from "babylonjs/States/index";
  77593. export * from "babylonjs/Misc/index";
  77594. export * from "babylonjs/XR/index";
  77595. export * from "babylonjs/types";
  77596. }
  77597. declare module "babylonjs/Animations/pathCursor" {
  77598. import { Vector3 } from "babylonjs/Maths/math.vector";
  77599. import { Path2 } from "babylonjs/Maths/math.path";
  77600. /**
  77601. * A cursor which tracks a point on a path
  77602. */
  77603. export class PathCursor {
  77604. private path;
  77605. /**
  77606. * Stores path cursor callbacks for when an onchange event is triggered
  77607. */
  77608. private _onchange;
  77609. /**
  77610. * The value of the path cursor
  77611. */
  77612. value: number;
  77613. /**
  77614. * The animation array of the path cursor
  77615. */
  77616. animations: Animation[];
  77617. /**
  77618. * Initializes the path cursor
  77619. * @param path The path to track
  77620. */
  77621. constructor(path: Path2);
  77622. /**
  77623. * Gets the cursor point on the path
  77624. * @returns A point on the path cursor at the cursor location
  77625. */
  77626. getPoint(): Vector3;
  77627. /**
  77628. * Moves the cursor ahead by the step amount
  77629. * @param step The amount to move the cursor forward
  77630. * @returns This path cursor
  77631. */
  77632. moveAhead(step?: number): PathCursor;
  77633. /**
  77634. * Moves the cursor behind by the step amount
  77635. * @param step The amount to move the cursor back
  77636. * @returns This path cursor
  77637. */
  77638. moveBack(step?: number): PathCursor;
  77639. /**
  77640. * Moves the cursor by the step amount
  77641. * If the step amount is greater than one, an exception is thrown
  77642. * @param step The amount to move the cursor
  77643. * @returns This path cursor
  77644. */
  77645. move(step: number): PathCursor;
  77646. /**
  77647. * Ensures that the value is limited between zero and one
  77648. * @returns This path cursor
  77649. */
  77650. private ensureLimits;
  77651. /**
  77652. * Runs onchange callbacks on change (used by the animation engine)
  77653. * @returns This path cursor
  77654. */
  77655. private raiseOnChange;
  77656. /**
  77657. * Executes a function on change
  77658. * @param f A path cursor onchange callback
  77659. * @returns This path cursor
  77660. */
  77661. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77662. }
  77663. }
  77664. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  77665. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  77666. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  77667. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  77668. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  77669. }
  77670. declare module "babylonjs/Engines/Processors/Expressions/index" {
  77671. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  77672. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  77673. }
  77674. declare module "babylonjs/Engines/Processors/index" {
  77675. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  77676. export * from "babylonjs/Engines/Processors/Expressions/index";
  77677. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  77678. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  77679. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  77680. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  77681. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  77682. export * from "babylonjs/Engines/Processors/shaderProcessor";
  77683. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  77684. }
  77685. declare module "babylonjs/Legacy/legacy" {
  77686. import * as Babylon from "babylonjs/index";
  77687. export * from "babylonjs/index";
  77688. }
  77689. declare module "babylonjs/Shaders/blur.fragment" {
  77690. /** @hidden */
  77691. export var blurPixelShader: {
  77692. name: string;
  77693. shader: string;
  77694. };
  77695. }
  77696. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  77697. /** @hidden */
  77698. export var pointCloudVertexDeclaration: {
  77699. name: string;
  77700. shader: string;
  77701. };
  77702. }
  77703. declare module "babylonjs" {
  77704. export * from "babylonjs/Legacy/legacy";
  77705. }
  77706. declare module BABYLON {
  77707. /** Alias type for value that can be null */
  77708. export type Nullable<T> = T | null;
  77709. /**
  77710. * Alias type for number that are floats
  77711. * @ignorenaming
  77712. */
  77713. export type float = number;
  77714. /**
  77715. * Alias type for number that are doubles.
  77716. * @ignorenaming
  77717. */
  77718. export type double = number;
  77719. /**
  77720. * Alias type for number that are integer
  77721. * @ignorenaming
  77722. */
  77723. export type int = number;
  77724. /** Alias type for number array or Float32Array */
  77725. export type FloatArray = number[] | Float32Array;
  77726. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  77727. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  77728. /**
  77729. * Alias for types that can be used by a Buffer or VertexBuffer.
  77730. */
  77731. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  77732. /**
  77733. * Alias type for primitive types
  77734. * @ignorenaming
  77735. */
  77736. type Primitive = undefined | null | boolean | string | number | Function;
  77737. /**
  77738. * Type modifier to make all the properties of an object Readonly
  77739. */
  77740. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  77741. /**
  77742. * Type modifier to make all the properties of an object Readonly recursively
  77743. */
  77744. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  77745. /**
  77746. * Type modifier to make object properties readonly.
  77747. */
  77748. export type DeepImmutableObject<T> = {
  77749. readonly [K in keyof T]: DeepImmutable<T[K]>;
  77750. };
  77751. /** @hidden */
  77752. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  77753. }
  77754. }
  77755. declare module BABYLON {
  77756. /**
  77757. * A class serves as a medium between the observable and its observers
  77758. */
  77759. export class EventState {
  77760. /**
  77761. * Create a new EventState
  77762. * @param mask defines the mask associated with this state
  77763. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77764. * @param target defines the original target of the state
  77765. * @param currentTarget defines the current target of the state
  77766. */
  77767. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  77768. /**
  77769. * Initialize the current event state
  77770. * @param mask defines the mask associated with this state
  77771. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77772. * @param target defines the original target of the state
  77773. * @param currentTarget defines the current target of the state
  77774. * @returns the current event state
  77775. */
  77776. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77777. /**
  77778. * An Observer can set this property to true to prevent subsequent observers of being notified
  77779. */
  77780. skipNextObservers: boolean;
  77781. /**
  77782. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77783. */
  77784. mask: number;
  77785. /**
  77786. * The object that originally notified the event
  77787. */
  77788. target?: any;
  77789. /**
  77790. * The current object in the bubbling phase
  77791. */
  77792. currentTarget?: any;
  77793. /**
  77794. * This will be populated with the return value of the last function that was executed.
  77795. * If it is the first function in the callback chain it will be the event data.
  77796. */
  77797. lastReturnValue?: any;
  77798. }
  77799. /**
  77800. * Represent an Observer registered to a given Observable object.
  77801. */
  77802. export class Observer<T> {
  77803. /**
  77804. * Defines the callback to call when the observer is notified
  77805. */
  77806. callback: (eventData: T, eventState: EventState) => void;
  77807. /**
  77808. * Defines the mask of the observer (used to filter notifications)
  77809. */
  77810. mask: number;
  77811. /**
  77812. * Defines the current scope used to restore the JS context
  77813. */
  77814. scope: any;
  77815. /** @hidden */
  77816. _willBeUnregistered: boolean;
  77817. /**
  77818. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77819. */
  77820. unregisterOnNextCall: boolean;
  77821. /**
  77822. * Creates a new observer
  77823. * @param callback defines the callback to call when the observer is notified
  77824. * @param mask defines the mask of the observer (used to filter notifications)
  77825. * @param scope defines the current scope used to restore the JS context
  77826. */
  77827. constructor(
  77828. /**
  77829. * Defines the callback to call when the observer is notified
  77830. */
  77831. callback: (eventData: T, eventState: EventState) => void,
  77832. /**
  77833. * Defines the mask of the observer (used to filter notifications)
  77834. */
  77835. mask: number,
  77836. /**
  77837. * Defines the current scope used to restore the JS context
  77838. */
  77839. scope?: any);
  77840. }
  77841. /**
  77842. * Represent a list of observers registered to multiple Observables object.
  77843. */
  77844. export class MultiObserver<T> {
  77845. private _observers;
  77846. private _observables;
  77847. /**
  77848. * Release associated resources
  77849. */
  77850. dispose(): void;
  77851. /**
  77852. * Raise a callback when one of the observable will notify
  77853. * @param observables defines a list of observables to watch
  77854. * @param callback defines the callback to call on notification
  77855. * @param mask defines the mask used to filter notifications
  77856. * @param scope defines the current scope used to restore the JS context
  77857. * @returns the new MultiObserver
  77858. */
  77859. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  77860. }
  77861. /**
  77862. * The Observable class is a simple implementation of the Observable pattern.
  77863. *
  77864. * 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.
  77865. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  77866. * 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).
  77867. * 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.
  77868. */
  77869. export class Observable<T> {
  77870. private _observers;
  77871. private _eventState;
  77872. private _onObserverAdded;
  77873. /**
  77874. * Gets the list of observers
  77875. */
  77876. get observers(): Array<Observer<T>>;
  77877. /**
  77878. * Creates a new observable
  77879. * @param onObserverAdded defines a callback to call when a new observer is added
  77880. */
  77881. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  77882. /**
  77883. * Create a new Observer with the specified callback
  77884. * @param callback the callback that will be executed for that Observer
  77885. * @param mask the mask used to filter observers
  77886. * @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.
  77887. * @param scope optional scope for the callback to be called from
  77888. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  77889. * @returns the new observer created for the callback
  77890. */
  77891. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  77892. /**
  77893. * Create a new Observer with the specified callback and unregisters after the next notification
  77894. * @param callback the callback that will be executed for that Observer
  77895. * @returns the new observer created for the callback
  77896. */
  77897. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  77898. /**
  77899. * Remove an Observer from the Observable object
  77900. * @param observer the instance of the Observer to remove
  77901. * @returns false if it doesn't belong to this Observable
  77902. */
  77903. remove(observer: Nullable<Observer<T>>): boolean;
  77904. /**
  77905. * Remove a callback from the Observable object
  77906. * @param callback the callback to remove
  77907. * @param scope optional scope. If used only the callbacks with this scope will be removed
  77908. * @returns false if it doesn't belong to this Observable
  77909. */
  77910. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  77911. private _deferUnregister;
  77912. private _remove;
  77913. /**
  77914. * Moves the observable to the top of the observer list making it get called first when notified
  77915. * @param observer the observer to move
  77916. */
  77917. makeObserverTopPriority(observer: Observer<T>): void;
  77918. /**
  77919. * Moves the observable to the bottom of the observer list making it get called last when notified
  77920. * @param observer the observer to move
  77921. */
  77922. makeObserverBottomPriority(observer: Observer<T>): void;
  77923. /**
  77924. * Notify all Observers by calling their respective callback with the given data
  77925. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  77926. * @param eventData defines the data to send to all observers
  77927. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  77928. * @param target defines the original target of the state
  77929. * @param currentTarget defines the current target of the state
  77930. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  77931. */
  77932. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  77933. /**
  77934. * Calling this will execute each callback, expecting it to be a promise or return a value.
  77935. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  77936. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  77937. * and it is crucial that all callbacks will be executed.
  77938. * The order of the callbacks is kept, callbacks are not executed parallel.
  77939. *
  77940. * @param eventData The data to be sent to each callback
  77941. * @param mask is used to filter observers defaults to -1
  77942. * @param target defines the callback target (see EventState)
  77943. * @param currentTarget defines he current object in the bubbling phase
  77944. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  77945. */
  77946. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  77947. /**
  77948. * Notify a specific observer
  77949. * @param observer defines the observer to notify
  77950. * @param eventData defines the data to be sent to each callback
  77951. * @param mask is used to filter observers defaults to -1
  77952. */
  77953. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  77954. /**
  77955. * Gets a boolean indicating if the observable has at least one observer
  77956. * @returns true is the Observable has at least one Observer registered
  77957. */
  77958. hasObservers(): boolean;
  77959. /**
  77960. * Clear the list of observers
  77961. */
  77962. clear(): void;
  77963. /**
  77964. * Clone the current observable
  77965. * @returns a new observable
  77966. */
  77967. clone(): Observable<T>;
  77968. /**
  77969. * Does this observable handles observer registered with a given mask
  77970. * @param mask defines the mask to be tested
  77971. * @return whether or not one observer registered with the given mask is handeled
  77972. **/
  77973. hasSpecificMask(mask?: number): boolean;
  77974. }
  77975. }
  77976. declare module BABYLON {
  77977. /**
  77978. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  77979. * Babylon.js
  77980. */
  77981. export class DomManagement {
  77982. /**
  77983. * Checks if the window object exists
  77984. * @returns true if the window object exists
  77985. */
  77986. static IsWindowObjectExist(): boolean;
  77987. /**
  77988. * Checks if the navigator object exists
  77989. * @returns true if the navigator object exists
  77990. */
  77991. static IsNavigatorAvailable(): boolean;
  77992. /**
  77993. * Check if the document object exists
  77994. * @returns true if the document object exists
  77995. */
  77996. static IsDocumentAvailable(): boolean;
  77997. /**
  77998. * Extracts text content from a DOM element hierarchy
  77999. * @param element defines the root element
  78000. * @returns a string
  78001. */
  78002. static GetDOMTextContent(element: HTMLElement): string;
  78003. }
  78004. }
  78005. declare module BABYLON {
  78006. /**
  78007. * Logger used througouht the application to allow configuration of
  78008. * the log level required for the messages.
  78009. */
  78010. export class Logger {
  78011. /**
  78012. * No log
  78013. */
  78014. static readonly NoneLogLevel: number;
  78015. /**
  78016. * Only message logs
  78017. */
  78018. static readonly MessageLogLevel: number;
  78019. /**
  78020. * Only warning logs
  78021. */
  78022. static readonly WarningLogLevel: number;
  78023. /**
  78024. * Only error logs
  78025. */
  78026. static readonly ErrorLogLevel: number;
  78027. /**
  78028. * All logs
  78029. */
  78030. static readonly AllLogLevel: number;
  78031. private static _LogCache;
  78032. /**
  78033. * Gets a value indicating the number of loading errors
  78034. * @ignorenaming
  78035. */
  78036. static errorsCount: number;
  78037. /**
  78038. * Callback called when a new log is added
  78039. */
  78040. static OnNewCacheEntry: (entry: string) => void;
  78041. private static _AddLogEntry;
  78042. private static _FormatMessage;
  78043. private static _LogDisabled;
  78044. private static _LogEnabled;
  78045. private static _WarnDisabled;
  78046. private static _WarnEnabled;
  78047. private static _ErrorDisabled;
  78048. private static _ErrorEnabled;
  78049. /**
  78050. * Log a message to the console
  78051. */
  78052. static Log: (message: string) => void;
  78053. /**
  78054. * Write a warning message to the console
  78055. */
  78056. static Warn: (message: string) => void;
  78057. /**
  78058. * Write an error message to the console
  78059. */
  78060. static Error: (message: string) => void;
  78061. /**
  78062. * Gets current log cache (list of logs)
  78063. */
  78064. static get LogCache(): string;
  78065. /**
  78066. * Clears the log cache
  78067. */
  78068. static ClearLogCache(): void;
  78069. /**
  78070. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78071. */
  78072. static set LogLevels(level: number);
  78073. }
  78074. }
  78075. declare module BABYLON {
  78076. /** @hidden */
  78077. export class _TypeStore {
  78078. /** @hidden */
  78079. static RegisteredTypes: {
  78080. [key: string]: Object;
  78081. };
  78082. /** @hidden */
  78083. static GetClass(fqdn: string): any;
  78084. }
  78085. }
  78086. declare module BABYLON {
  78087. /**
  78088. * Helper to manipulate strings
  78089. */
  78090. export class StringTools {
  78091. /**
  78092. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78093. * @param str Source string
  78094. * @param suffix Suffix to search for in the source string
  78095. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78096. */
  78097. static EndsWith(str: string, suffix: string): boolean;
  78098. /**
  78099. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78100. * @param str Source string
  78101. * @param suffix Suffix to search for in the source string
  78102. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78103. */
  78104. static StartsWith(str: string, suffix: string): boolean;
  78105. /**
  78106. * Decodes a buffer into a string
  78107. * @param buffer The buffer to decode
  78108. * @returns The decoded string
  78109. */
  78110. static Decode(buffer: Uint8Array | Uint16Array): string;
  78111. /**
  78112. * Encode a buffer to a base64 string
  78113. * @param buffer defines the buffer to encode
  78114. * @returns the encoded string
  78115. */
  78116. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78117. /**
  78118. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78119. * @param num the number to convert and pad
  78120. * @param length the expected length of the string
  78121. * @returns the padded string
  78122. */
  78123. static PadNumber(num: number, length: number): string;
  78124. }
  78125. }
  78126. declare module BABYLON {
  78127. /**
  78128. * Class containing a set of static utilities functions for deep copy.
  78129. */
  78130. export class DeepCopier {
  78131. /**
  78132. * Tries to copy an object by duplicating every property
  78133. * @param source defines the source object
  78134. * @param destination defines the target object
  78135. * @param doNotCopyList defines a list of properties to avoid
  78136. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78137. */
  78138. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78139. }
  78140. }
  78141. declare module BABYLON {
  78142. /**
  78143. * Class containing a set of static utilities functions for precision date
  78144. */
  78145. export class PrecisionDate {
  78146. /**
  78147. * Gets either window.performance.now() if supported or Date.now() else
  78148. */
  78149. static get Now(): number;
  78150. }
  78151. }
  78152. declare module BABYLON {
  78153. /** @hidden */
  78154. export class _DevTools {
  78155. static WarnImport(name: string): string;
  78156. }
  78157. }
  78158. declare module BABYLON {
  78159. /**
  78160. * Interface used to define the mechanism to get data from the network
  78161. */
  78162. export interface IWebRequest {
  78163. /**
  78164. * Returns client's response url
  78165. */
  78166. responseURL: string;
  78167. /**
  78168. * Returns client's status
  78169. */
  78170. status: number;
  78171. /**
  78172. * Returns client's status as a text
  78173. */
  78174. statusText: string;
  78175. }
  78176. }
  78177. declare module BABYLON {
  78178. /**
  78179. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78180. */
  78181. export class WebRequest implements IWebRequest {
  78182. private _xhr;
  78183. /**
  78184. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78185. * i.e. when loading files, where the server/service expects an Authorization header
  78186. */
  78187. static CustomRequestHeaders: {
  78188. [key: string]: string;
  78189. };
  78190. /**
  78191. * Add callback functions in this array to update all the requests before they get sent to the network
  78192. */
  78193. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78194. private _injectCustomRequestHeaders;
  78195. /**
  78196. * Gets or sets a function to be called when loading progress changes
  78197. */
  78198. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78199. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78200. /**
  78201. * Returns client's state
  78202. */
  78203. get readyState(): number;
  78204. /**
  78205. * Returns client's status
  78206. */
  78207. get status(): number;
  78208. /**
  78209. * Returns client's status as a text
  78210. */
  78211. get statusText(): string;
  78212. /**
  78213. * Returns client's response
  78214. */
  78215. get response(): any;
  78216. /**
  78217. * Returns client's response url
  78218. */
  78219. get responseURL(): string;
  78220. /**
  78221. * Returns client's response as text
  78222. */
  78223. get responseText(): string;
  78224. /**
  78225. * Gets or sets the expected response type
  78226. */
  78227. get responseType(): XMLHttpRequestResponseType;
  78228. set responseType(value: XMLHttpRequestResponseType);
  78229. /** @hidden */
  78230. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78231. /** @hidden */
  78232. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78233. /**
  78234. * Cancels any network activity
  78235. */
  78236. abort(): void;
  78237. /**
  78238. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78239. * @param body defines an optional request body
  78240. */
  78241. send(body?: Document | BodyInit | null): void;
  78242. /**
  78243. * Sets the request method, request URL
  78244. * @param method defines the method to use (GET, POST, etc..)
  78245. * @param url defines the url to connect with
  78246. */
  78247. open(method: string, url: string): void;
  78248. /**
  78249. * Sets the value of a request header.
  78250. * @param name The name of the header whose value is to be set
  78251. * @param value The value to set as the body of the header
  78252. */
  78253. setRequestHeader(name: string, value: string): void;
  78254. /**
  78255. * Get the string containing the text of a particular header's value.
  78256. * @param name The name of the header
  78257. * @returns The string containing the text of the given header name
  78258. */
  78259. getResponseHeader(name: string): Nullable<string>;
  78260. }
  78261. }
  78262. declare module BABYLON {
  78263. /**
  78264. * File request interface
  78265. */
  78266. export interface IFileRequest {
  78267. /**
  78268. * Raised when the request is complete (success or error).
  78269. */
  78270. onCompleteObservable: Observable<IFileRequest>;
  78271. /**
  78272. * Aborts the request for a file.
  78273. */
  78274. abort: () => void;
  78275. }
  78276. }
  78277. declare module BABYLON {
  78278. /**
  78279. * Define options used to create a render target texture
  78280. */
  78281. export class RenderTargetCreationOptions {
  78282. /**
  78283. * Specifies is mipmaps must be generated
  78284. */
  78285. generateMipMaps?: boolean;
  78286. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78287. generateDepthBuffer?: boolean;
  78288. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78289. generateStencilBuffer?: boolean;
  78290. /** Defines texture type (int by default) */
  78291. type?: number;
  78292. /** Defines sampling mode (trilinear by default) */
  78293. samplingMode?: number;
  78294. /** Defines format (RGBA by default) */
  78295. format?: number;
  78296. }
  78297. }
  78298. declare module BABYLON {
  78299. /** Defines the cross module used constants to avoid circular dependncies */
  78300. export class Constants {
  78301. /** Defines that alpha blending is disabled */
  78302. static readonly ALPHA_DISABLE: number;
  78303. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78304. static readonly ALPHA_ADD: number;
  78305. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78306. static readonly ALPHA_COMBINE: number;
  78307. /** Defines that alpha blending is DEST - SRC * DEST */
  78308. static readonly ALPHA_SUBTRACT: number;
  78309. /** Defines that alpha blending is SRC * DEST */
  78310. static readonly ALPHA_MULTIPLY: number;
  78311. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78312. static readonly ALPHA_MAXIMIZED: number;
  78313. /** Defines that alpha blending is SRC + DEST */
  78314. static readonly ALPHA_ONEONE: number;
  78315. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78316. static readonly ALPHA_PREMULTIPLIED: number;
  78317. /**
  78318. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78319. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78320. */
  78321. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78322. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78323. static readonly ALPHA_INTERPOLATE: number;
  78324. /**
  78325. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78326. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78327. */
  78328. static readonly ALPHA_SCREENMODE: number;
  78329. /**
  78330. * Defines that alpha blending is SRC + DST
  78331. * Alpha will be set to SRC ALPHA + DST ALPHA
  78332. */
  78333. static readonly ALPHA_ONEONE_ONEONE: number;
  78334. /**
  78335. * Defines that alpha blending is SRC * DST ALPHA + DST
  78336. * Alpha will be set to 0
  78337. */
  78338. static readonly ALPHA_ALPHATOCOLOR: number;
  78339. /**
  78340. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78341. */
  78342. static readonly ALPHA_REVERSEONEMINUS: number;
  78343. /**
  78344. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  78345. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  78346. */
  78347. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  78348. /**
  78349. * Defines that alpha blending is SRC + DST
  78350. * Alpha will be set to SRC ALPHA
  78351. */
  78352. static readonly ALPHA_ONEONE_ONEZERO: number;
  78353. /**
  78354. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78355. * Alpha will be set to DST ALPHA
  78356. */
  78357. static readonly ALPHA_EXCLUSION: number;
  78358. /** Defines that alpha blending equation a SUM */
  78359. static readonly ALPHA_EQUATION_ADD: number;
  78360. /** Defines that alpha blending equation a SUBSTRACTION */
  78361. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  78362. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  78363. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  78364. /** Defines that alpha blending equation a MAX operation */
  78365. static readonly ALPHA_EQUATION_MAX: number;
  78366. /** Defines that alpha blending equation a MIN operation */
  78367. static readonly ALPHA_EQUATION_MIN: number;
  78368. /**
  78369. * Defines that alpha blending equation a DARKEN operation:
  78370. * It takes the min of the src and sums the alpha channels.
  78371. */
  78372. static readonly ALPHA_EQUATION_DARKEN: number;
  78373. /** Defines that the ressource is not delayed*/
  78374. static readonly DELAYLOADSTATE_NONE: number;
  78375. /** Defines that the ressource was successfully delay loaded */
  78376. static readonly DELAYLOADSTATE_LOADED: number;
  78377. /** Defines that the ressource is currently delay loading */
  78378. static readonly DELAYLOADSTATE_LOADING: number;
  78379. /** Defines that the ressource is delayed and has not started loading */
  78380. static readonly DELAYLOADSTATE_NOTLOADED: number;
  78381. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  78382. static readonly NEVER: number;
  78383. /** 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 */
  78384. static readonly ALWAYS: number;
  78385. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  78386. static readonly LESS: number;
  78387. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  78388. static readonly EQUAL: number;
  78389. /** 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 */
  78390. static readonly LEQUAL: number;
  78391. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  78392. static readonly GREATER: number;
  78393. /** 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 */
  78394. static readonly GEQUAL: number;
  78395. /** 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 */
  78396. static readonly NOTEQUAL: number;
  78397. /** Passed to stencilOperation to specify that stencil value must be kept */
  78398. static readonly KEEP: number;
  78399. /** Passed to stencilOperation to specify that stencil value must be replaced */
  78400. static readonly REPLACE: number;
  78401. /** Passed to stencilOperation to specify that stencil value must be incremented */
  78402. static readonly INCR: number;
  78403. /** Passed to stencilOperation to specify that stencil value must be decremented */
  78404. static readonly DECR: number;
  78405. /** Passed to stencilOperation to specify that stencil value must be inverted */
  78406. static readonly INVERT: number;
  78407. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  78408. static readonly INCR_WRAP: number;
  78409. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  78410. static readonly DECR_WRAP: number;
  78411. /** Texture is not repeating outside of 0..1 UVs */
  78412. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  78413. /** Texture is repeating outside of 0..1 UVs */
  78414. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78415. /** Texture is repeating and mirrored */
  78416. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78417. /** ALPHA */
  78418. static readonly TEXTUREFORMAT_ALPHA: number;
  78419. /** LUMINANCE */
  78420. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78421. /** LUMINANCE_ALPHA */
  78422. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78423. /** RGB */
  78424. static readonly TEXTUREFORMAT_RGB: number;
  78425. /** RGBA */
  78426. static readonly TEXTUREFORMAT_RGBA: number;
  78427. /** RED */
  78428. static readonly TEXTUREFORMAT_RED: number;
  78429. /** RED (2nd reference) */
  78430. static readonly TEXTUREFORMAT_R: number;
  78431. /** RG */
  78432. static readonly TEXTUREFORMAT_RG: number;
  78433. /** RED_INTEGER */
  78434. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78435. /** RED_INTEGER (2nd reference) */
  78436. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78437. /** RG_INTEGER */
  78438. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78439. /** RGB_INTEGER */
  78440. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78441. /** RGBA_INTEGER */
  78442. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78443. /** UNSIGNED_BYTE */
  78444. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78445. /** UNSIGNED_BYTE (2nd reference) */
  78446. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78447. /** FLOAT */
  78448. static readonly TEXTURETYPE_FLOAT: number;
  78449. /** HALF_FLOAT */
  78450. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78451. /** BYTE */
  78452. static readonly TEXTURETYPE_BYTE: number;
  78453. /** SHORT */
  78454. static readonly TEXTURETYPE_SHORT: number;
  78455. /** UNSIGNED_SHORT */
  78456. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78457. /** INT */
  78458. static readonly TEXTURETYPE_INT: number;
  78459. /** UNSIGNED_INT */
  78460. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78461. /** UNSIGNED_SHORT_4_4_4_4 */
  78462. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78463. /** UNSIGNED_SHORT_5_5_5_1 */
  78464. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78465. /** UNSIGNED_SHORT_5_6_5 */
  78466. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78467. /** UNSIGNED_INT_2_10_10_10_REV */
  78468. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78469. /** UNSIGNED_INT_24_8 */
  78470. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  78471. /** UNSIGNED_INT_10F_11F_11F_REV */
  78472. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  78473. /** UNSIGNED_INT_5_9_9_9_REV */
  78474. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  78475. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  78476. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  78477. /** nearest is mag = nearest and min = nearest and no mip */
  78478. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  78479. /** mag = nearest and min = nearest and mip = none */
  78480. static readonly TEXTURE_NEAREST_NEAREST: number;
  78481. /** Bilinear is mag = linear and min = linear and no mip */
  78482. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  78483. /** mag = linear and min = linear and mip = none */
  78484. static readonly TEXTURE_LINEAR_LINEAR: number;
  78485. /** Trilinear is mag = linear and min = linear and mip = linear */
  78486. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  78487. /** Trilinear is mag = linear and min = linear and mip = linear */
  78488. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  78489. /** mag = nearest and min = nearest and mip = nearest */
  78490. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  78491. /** mag = nearest and min = linear and mip = nearest */
  78492. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  78493. /** mag = nearest and min = linear and mip = linear */
  78494. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  78495. /** mag = nearest and min = linear and mip = none */
  78496. static readonly TEXTURE_NEAREST_LINEAR: number;
  78497. /** nearest is mag = nearest and min = nearest and mip = linear */
  78498. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  78499. /** mag = linear and min = nearest and mip = nearest */
  78500. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  78501. /** mag = linear and min = nearest and mip = linear */
  78502. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  78503. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78504. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  78505. /** mag = linear and min = nearest and mip = none */
  78506. static readonly TEXTURE_LINEAR_NEAREST: number;
  78507. /** Explicit coordinates mode */
  78508. static readonly TEXTURE_EXPLICIT_MODE: number;
  78509. /** Spherical coordinates mode */
  78510. static readonly TEXTURE_SPHERICAL_MODE: number;
  78511. /** Planar coordinates mode */
  78512. static readonly TEXTURE_PLANAR_MODE: number;
  78513. /** Cubic coordinates mode */
  78514. static readonly TEXTURE_CUBIC_MODE: number;
  78515. /** Projection coordinates mode */
  78516. static readonly TEXTURE_PROJECTION_MODE: number;
  78517. /** Skybox coordinates mode */
  78518. static readonly TEXTURE_SKYBOX_MODE: number;
  78519. /** Inverse Cubic coordinates mode */
  78520. static readonly TEXTURE_INVCUBIC_MODE: number;
  78521. /** Equirectangular coordinates mode */
  78522. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  78523. /** Equirectangular Fixed coordinates mode */
  78524. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  78525. /** Equirectangular Fixed Mirrored coordinates mode */
  78526. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78527. /** Offline (baking) quality for texture filtering */
  78528. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  78529. /** High quality for texture filtering */
  78530. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  78531. /** Medium quality for texture filtering */
  78532. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  78533. /** Low quality for texture filtering */
  78534. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  78535. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  78536. static readonly SCALEMODE_FLOOR: number;
  78537. /** Defines that texture rescaling will look for the nearest power of 2 size */
  78538. static readonly SCALEMODE_NEAREST: number;
  78539. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  78540. static readonly SCALEMODE_CEILING: number;
  78541. /**
  78542. * The dirty texture flag value
  78543. */
  78544. static readonly MATERIAL_TextureDirtyFlag: number;
  78545. /**
  78546. * The dirty light flag value
  78547. */
  78548. static readonly MATERIAL_LightDirtyFlag: number;
  78549. /**
  78550. * The dirty fresnel flag value
  78551. */
  78552. static readonly MATERIAL_FresnelDirtyFlag: number;
  78553. /**
  78554. * The dirty attribute flag value
  78555. */
  78556. static readonly MATERIAL_AttributesDirtyFlag: number;
  78557. /**
  78558. * The dirty misc flag value
  78559. */
  78560. static readonly MATERIAL_MiscDirtyFlag: number;
  78561. /**
  78562. * The all dirty flag value
  78563. */
  78564. static readonly MATERIAL_AllDirtyFlag: number;
  78565. /**
  78566. * Returns the triangle fill mode
  78567. */
  78568. static readonly MATERIAL_TriangleFillMode: number;
  78569. /**
  78570. * Returns the wireframe mode
  78571. */
  78572. static readonly MATERIAL_WireFrameFillMode: number;
  78573. /**
  78574. * Returns the point fill mode
  78575. */
  78576. static readonly MATERIAL_PointFillMode: number;
  78577. /**
  78578. * Returns the point list draw mode
  78579. */
  78580. static readonly MATERIAL_PointListDrawMode: number;
  78581. /**
  78582. * Returns the line list draw mode
  78583. */
  78584. static readonly MATERIAL_LineListDrawMode: number;
  78585. /**
  78586. * Returns the line loop draw mode
  78587. */
  78588. static readonly MATERIAL_LineLoopDrawMode: number;
  78589. /**
  78590. * Returns the line strip draw mode
  78591. */
  78592. static readonly MATERIAL_LineStripDrawMode: number;
  78593. /**
  78594. * Returns the triangle strip draw mode
  78595. */
  78596. static readonly MATERIAL_TriangleStripDrawMode: number;
  78597. /**
  78598. * Returns the triangle fan draw mode
  78599. */
  78600. static readonly MATERIAL_TriangleFanDrawMode: number;
  78601. /**
  78602. * Stores the clock-wise side orientation
  78603. */
  78604. static readonly MATERIAL_ClockWiseSideOrientation: number;
  78605. /**
  78606. * Stores the counter clock-wise side orientation
  78607. */
  78608. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  78609. /**
  78610. * Nothing
  78611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78612. */
  78613. static readonly ACTION_NothingTrigger: number;
  78614. /**
  78615. * On pick
  78616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78617. */
  78618. static readonly ACTION_OnPickTrigger: number;
  78619. /**
  78620. * On left pick
  78621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78622. */
  78623. static readonly ACTION_OnLeftPickTrigger: number;
  78624. /**
  78625. * On right pick
  78626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78627. */
  78628. static readonly ACTION_OnRightPickTrigger: number;
  78629. /**
  78630. * On center pick
  78631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78632. */
  78633. static readonly ACTION_OnCenterPickTrigger: number;
  78634. /**
  78635. * On pick down
  78636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78637. */
  78638. static readonly ACTION_OnPickDownTrigger: number;
  78639. /**
  78640. * On double pick
  78641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78642. */
  78643. static readonly ACTION_OnDoublePickTrigger: number;
  78644. /**
  78645. * On pick up
  78646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78647. */
  78648. static readonly ACTION_OnPickUpTrigger: number;
  78649. /**
  78650. * On pick out.
  78651. * This trigger will only be raised if you also declared a OnPickDown
  78652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78653. */
  78654. static readonly ACTION_OnPickOutTrigger: number;
  78655. /**
  78656. * On long press
  78657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78658. */
  78659. static readonly ACTION_OnLongPressTrigger: number;
  78660. /**
  78661. * On pointer over
  78662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78663. */
  78664. static readonly ACTION_OnPointerOverTrigger: number;
  78665. /**
  78666. * On pointer out
  78667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78668. */
  78669. static readonly ACTION_OnPointerOutTrigger: number;
  78670. /**
  78671. * On every frame
  78672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78673. */
  78674. static readonly ACTION_OnEveryFrameTrigger: number;
  78675. /**
  78676. * On intersection enter
  78677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78678. */
  78679. static readonly ACTION_OnIntersectionEnterTrigger: number;
  78680. /**
  78681. * On intersection exit
  78682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78683. */
  78684. static readonly ACTION_OnIntersectionExitTrigger: number;
  78685. /**
  78686. * On key down
  78687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78688. */
  78689. static readonly ACTION_OnKeyDownTrigger: number;
  78690. /**
  78691. * On key up
  78692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78693. */
  78694. static readonly ACTION_OnKeyUpTrigger: number;
  78695. /**
  78696. * Billboard mode will only apply to Y axis
  78697. */
  78698. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  78699. /**
  78700. * Billboard mode will apply to all axes
  78701. */
  78702. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  78703. /**
  78704. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  78705. */
  78706. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  78707. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78708. * Test order :
  78709. * Is the bounding sphere outside the frustum ?
  78710. * If not, are the bounding box vertices outside the frustum ?
  78711. * It not, then the cullable object is in the frustum.
  78712. */
  78713. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  78714. /** Culling strategy : Bounding Sphere Only.
  78715. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78716. * It's also less accurate than the standard because some not visible objects can still be selected.
  78717. * Test : is the bounding sphere outside the frustum ?
  78718. * If not, then the cullable object is in the frustum.
  78719. */
  78720. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78721. /** Culling strategy : Optimistic Inclusion.
  78722. * This in an inclusion test first, then the standard exclusion test.
  78723. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78724. * 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.
  78725. * Anyway, it's as accurate as the standard strategy.
  78726. * Test :
  78727. * Is the cullable object bounding sphere center in the frustum ?
  78728. * If not, apply the default culling strategy.
  78729. */
  78730. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78731. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78732. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78733. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78734. * 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.
  78735. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78736. * Test :
  78737. * Is the cullable object bounding sphere center in the frustum ?
  78738. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78739. */
  78740. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78741. /**
  78742. * No logging while loading
  78743. */
  78744. static readonly SCENELOADER_NO_LOGGING: number;
  78745. /**
  78746. * Minimal logging while loading
  78747. */
  78748. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  78749. /**
  78750. * Summary logging while loading
  78751. */
  78752. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  78753. /**
  78754. * Detailled logging while loading
  78755. */
  78756. static readonly SCENELOADER_DETAILED_LOGGING: number;
  78757. }
  78758. }
  78759. declare module BABYLON {
  78760. /**
  78761. * This represents the required contract to create a new type of texture loader.
  78762. */
  78763. export interface IInternalTextureLoader {
  78764. /**
  78765. * Defines wether the loader supports cascade loading the different faces.
  78766. */
  78767. supportCascades: boolean;
  78768. /**
  78769. * This returns if the loader support the current file information.
  78770. * @param extension defines the file extension of the file being loaded
  78771. * @returns true if the loader can load the specified file
  78772. */
  78773. canLoad(extension: string): boolean;
  78774. /**
  78775. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78776. * @param data contains the texture data
  78777. * @param texture defines the BabylonJS internal texture
  78778. * @param createPolynomials will be true if polynomials have been requested
  78779. * @param onLoad defines the callback to trigger once the texture is ready
  78780. * @param onError defines the callback to trigger in case of error
  78781. */
  78782. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78783. /**
  78784. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78785. * @param data contains the texture data
  78786. * @param texture defines the BabylonJS internal texture
  78787. * @param callback defines the method to call once ready to upload
  78788. */
  78789. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78790. }
  78791. }
  78792. declare module BABYLON {
  78793. /**
  78794. * Class used to store and describe the pipeline context associated with an effect
  78795. */
  78796. export interface IPipelineContext {
  78797. /**
  78798. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78799. */
  78800. isAsync: boolean;
  78801. /**
  78802. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78803. */
  78804. isReady: boolean;
  78805. /** @hidden */
  78806. _getVertexShaderCode(): string | null;
  78807. /** @hidden */
  78808. _getFragmentShaderCode(): string | null;
  78809. /** @hidden */
  78810. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78811. }
  78812. }
  78813. declare module BABYLON {
  78814. /**
  78815. * Class used to store gfx data (like WebGLBuffer)
  78816. */
  78817. export class DataBuffer {
  78818. /**
  78819. * Gets or sets the number of objects referencing this buffer
  78820. */
  78821. references: number;
  78822. /** Gets or sets the size of the underlying buffer */
  78823. capacity: number;
  78824. /**
  78825. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78826. */
  78827. is32Bits: boolean;
  78828. /**
  78829. * Gets the underlying buffer
  78830. */
  78831. get underlyingResource(): any;
  78832. }
  78833. }
  78834. declare module BABYLON {
  78835. /** @hidden */
  78836. export interface IShaderProcessor {
  78837. attributeProcessor?: (attribute: string) => string;
  78838. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78839. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78840. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78841. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78842. lineProcessor?: (line: string, isFragment: boolean) => string;
  78843. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78844. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78845. }
  78846. }
  78847. declare module BABYLON {
  78848. /** @hidden */
  78849. export interface ProcessingOptions {
  78850. defines: string[];
  78851. indexParameters: any;
  78852. isFragment: boolean;
  78853. shouldUseHighPrecisionShader: boolean;
  78854. supportsUniformBuffers: boolean;
  78855. shadersRepository: string;
  78856. includesShadersStore: {
  78857. [key: string]: string;
  78858. };
  78859. processor?: IShaderProcessor;
  78860. version: string;
  78861. platformName: string;
  78862. lookForClosingBracketForUniformBuffer?: boolean;
  78863. }
  78864. }
  78865. declare module BABYLON {
  78866. /** @hidden */
  78867. export class ShaderCodeNode {
  78868. line: string;
  78869. children: ShaderCodeNode[];
  78870. additionalDefineKey?: string;
  78871. additionalDefineValue?: string;
  78872. isValid(preprocessors: {
  78873. [key: string]: string;
  78874. }): boolean;
  78875. process(preprocessors: {
  78876. [key: string]: string;
  78877. }, options: ProcessingOptions): string;
  78878. }
  78879. }
  78880. declare module BABYLON {
  78881. /** @hidden */
  78882. export class ShaderCodeCursor {
  78883. private _lines;
  78884. lineIndex: number;
  78885. get currentLine(): string;
  78886. get canRead(): boolean;
  78887. set lines(value: string[]);
  78888. }
  78889. }
  78890. declare module BABYLON {
  78891. /** @hidden */
  78892. export class ShaderCodeConditionNode extends ShaderCodeNode {
  78893. process(preprocessors: {
  78894. [key: string]: string;
  78895. }, options: ProcessingOptions): string;
  78896. }
  78897. }
  78898. declare module BABYLON {
  78899. /** @hidden */
  78900. export class ShaderDefineExpression {
  78901. isTrue(preprocessors: {
  78902. [key: string]: string;
  78903. }): boolean;
  78904. private static _OperatorPriority;
  78905. private static _Stack;
  78906. static postfixToInfix(postfix: string[]): string;
  78907. static infixToPostfix(infix: string): string[];
  78908. }
  78909. }
  78910. declare module BABYLON {
  78911. /** @hidden */
  78912. export class ShaderCodeTestNode extends ShaderCodeNode {
  78913. testExpression: ShaderDefineExpression;
  78914. isValid(preprocessors: {
  78915. [key: string]: string;
  78916. }): boolean;
  78917. }
  78918. }
  78919. declare module BABYLON {
  78920. /** @hidden */
  78921. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  78922. define: string;
  78923. not: boolean;
  78924. constructor(define: string, not?: boolean);
  78925. isTrue(preprocessors: {
  78926. [key: string]: string;
  78927. }): boolean;
  78928. }
  78929. }
  78930. declare module BABYLON {
  78931. /** @hidden */
  78932. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  78933. leftOperand: ShaderDefineExpression;
  78934. rightOperand: ShaderDefineExpression;
  78935. isTrue(preprocessors: {
  78936. [key: string]: string;
  78937. }): boolean;
  78938. }
  78939. }
  78940. declare module BABYLON {
  78941. /** @hidden */
  78942. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  78943. leftOperand: ShaderDefineExpression;
  78944. rightOperand: ShaderDefineExpression;
  78945. isTrue(preprocessors: {
  78946. [key: string]: string;
  78947. }): boolean;
  78948. }
  78949. }
  78950. declare module BABYLON {
  78951. /** @hidden */
  78952. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  78953. define: string;
  78954. operand: string;
  78955. testValue: string;
  78956. constructor(define: string, operand: string, testValue: string);
  78957. isTrue(preprocessors: {
  78958. [key: string]: string;
  78959. }): boolean;
  78960. }
  78961. }
  78962. declare module BABYLON {
  78963. /**
  78964. * Class used to enable access to offline support
  78965. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  78966. */
  78967. export interface IOfflineProvider {
  78968. /**
  78969. * Gets a boolean indicating if scene must be saved in the database
  78970. */
  78971. enableSceneOffline: boolean;
  78972. /**
  78973. * Gets a boolean indicating if textures must be saved in the database
  78974. */
  78975. enableTexturesOffline: boolean;
  78976. /**
  78977. * Open the offline support and make it available
  78978. * @param successCallback defines the callback to call on success
  78979. * @param errorCallback defines the callback to call on error
  78980. */
  78981. open(successCallback: () => void, errorCallback: () => void): void;
  78982. /**
  78983. * Loads an image from the offline support
  78984. * @param url defines the url to load from
  78985. * @param image defines the target DOM image
  78986. */
  78987. loadImage(url: string, image: HTMLImageElement): void;
  78988. /**
  78989. * Loads a file from offline support
  78990. * @param url defines the URL to load from
  78991. * @param sceneLoaded defines a callback to call on success
  78992. * @param progressCallBack defines a callback to call when progress changed
  78993. * @param errorCallback defines a callback to call on error
  78994. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  78995. */
  78996. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  78997. }
  78998. }
  78999. declare module BABYLON {
  79000. /**
  79001. * Class used to help managing file picking and drag'n'drop
  79002. * File Storage
  79003. */
  79004. export class FilesInputStore {
  79005. /**
  79006. * List of files ready to be loaded
  79007. */
  79008. static FilesToLoad: {
  79009. [key: string]: File;
  79010. };
  79011. }
  79012. }
  79013. declare module BABYLON {
  79014. /**
  79015. * Class used to define a retry strategy when error happens while loading assets
  79016. */
  79017. export class RetryStrategy {
  79018. /**
  79019. * Function used to defines an exponential back off strategy
  79020. * @param maxRetries defines the maximum number of retries (3 by default)
  79021. * @param baseInterval defines the interval between retries
  79022. * @returns the strategy function to use
  79023. */
  79024. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79025. }
  79026. }
  79027. declare module BABYLON {
  79028. /**
  79029. * @ignore
  79030. * Application error to support additional information when loading a file
  79031. */
  79032. export abstract class BaseError extends Error {
  79033. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79034. }
  79035. }
  79036. declare module BABYLON {
  79037. /** @ignore */
  79038. export class LoadFileError extends BaseError {
  79039. request?: WebRequest;
  79040. file?: File;
  79041. /**
  79042. * Creates a new LoadFileError
  79043. * @param message defines the message of the error
  79044. * @param request defines the optional web request
  79045. * @param file defines the optional file
  79046. */
  79047. constructor(message: string, object?: WebRequest | File);
  79048. }
  79049. /** @ignore */
  79050. export class RequestFileError extends BaseError {
  79051. request: WebRequest;
  79052. /**
  79053. * Creates a new LoadFileError
  79054. * @param message defines the message of the error
  79055. * @param request defines the optional web request
  79056. */
  79057. constructor(message: string, request: WebRequest);
  79058. }
  79059. /** @ignore */
  79060. export class ReadFileError extends BaseError {
  79061. file: File;
  79062. /**
  79063. * Creates a new ReadFileError
  79064. * @param message defines the message of the error
  79065. * @param file defines the optional file
  79066. */
  79067. constructor(message: string, file: File);
  79068. }
  79069. /**
  79070. * @hidden
  79071. */
  79072. export class FileTools {
  79073. /**
  79074. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79075. */
  79076. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79077. /**
  79078. * Gets or sets the base URL to use to load assets
  79079. */
  79080. static BaseUrl: string;
  79081. /**
  79082. * Default behaviour for cors in the application.
  79083. * It can be a string if the expected behavior is identical in the entire app.
  79084. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79085. */
  79086. static CorsBehavior: string | ((url: string | string[]) => string);
  79087. /**
  79088. * Gets or sets a function used to pre-process url before using them to load assets
  79089. */
  79090. static PreprocessUrl: (url: string) => string;
  79091. /**
  79092. * Removes unwanted characters from an url
  79093. * @param url defines the url to clean
  79094. * @returns the cleaned url
  79095. */
  79096. private static _CleanUrl;
  79097. /**
  79098. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79099. * @param url define the url we are trying
  79100. * @param element define the dom element where to configure the cors policy
  79101. */
  79102. static SetCorsBehavior(url: string | string[], element: {
  79103. crossOrigin: string | null;
  79104. }): void;
  79105. /**
  79106. * Loads an image as an HTMLImageElement.
  79107. * @param input url string, ArrayBuffer, or Blob to load
  79108. * @param onLoad callback called when the image successfully loads
  79109. * @param onError callback called when the image fails to load
  79110. * @param offlineProvider offline provider for caching
  79111. * @param mimeType optional mime type
  79112. * @returns the HTMLImageElement of the loaded image
  79113. */
  79114. 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>;
  79115. /**
  79116. * Reads a file from a File object
  79117. * @param file defines the file to load
  79118. * @param onSuccess defines the callback to call when data is loaded
  79119. * @param onProgress defines the callback to call during loading process
  79120. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79121. * @param onError defines the callback to call when an error occurs
  79122. * @returns a file request object
  79123. */
  79124. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79125. /**
  79126. * Loads a file from a url
  79127. * @param url url to load
  79128. * @param onSuccess callback called when the file successfully loads
  79129. * @param onProgress callback called while file is loading (if the server supports this mode)
  79130. * @param offlineProvider defines the offline provider for caching
  79131. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79132. * @param onError callback called when the file fails to load
  79133. * @returns a file request object
  79134. */
  79135. 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;
  79136. /**
  79137. * Loads a file
  79138. * @param url url to load
  79139. * @param onSuccess callback called when the file successfully loads
  79140. * @param onProgress callback called while file is loading (if the server supports this mode)
  79141. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79142. * @param onError callback called when the file fails to load
  79143. * @param onOpened callback called when the web request is opened
  79144. * @returns a file request object
  79145. */
  79146. 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;
  79147. /**
  79148. * Checks if the loaded document was accessed via `file:`-Protocol.
  79149. * @returns boolean
  79150. */
  79151. static IsFileURL(): boolean;
  79152. }
  79153. }
  79154. declare module BABYLON {
  79155. /** @hidden */
  79156. export class ShaderProcessor {
  79157. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79158. private static _ProcessPrecision;
  79159. private static _ExtractOperation;
  79160. private static _BuildSubExpression;
  79161. private static _BuildExpression;
  79162. private static _MoveCursorWithinIf;
  79163. private static _MoveCursor;
  79164. private static _EvaluatePreProcessors;
  79165. private static _PreparePreProcessors;
  79166. private static _ProcessShaderConversion;
  79167. private static _ProcessIncludes;
  79168. /**
  79169. * Loads a file from a url
  79170. * @param url url to load
  79171. * @param onSuccess callback called when the file successfully loads
  79172. * @param onProgress callback called while file is loading (if the server supports this mode)
  79173. * @param offlineProvider defines the offline provider for caching
  79174. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79175. * @param onError callback called when the file fails to load
  79176. * @returns a file request object
  79177. * @hidden
  79178. */
  79179. 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;
  79180. }
  79181. }
  79182. declare module BABYLON {
  79183. /**
  79184. * @hidden
  79185. */
  79186. export interface IColor4Like {
  79187. r: float;
  79188. g: float;
  79189. b: float;
  79190. a: float;
  79191. }
  79192. /**
  79193. * @hidden
  79194. */
  79195. export interface IColor3Like {
  79196. r: float;
  79197. g: float;
  79198. b: float;
  79199. }
  79200. /**
  79201. * @hidden
  79202. */
  79203. export interface IVector4Like {
  79204. x: float;
  79205. y: float;
  79206. z: float;
  79207. w: float;
  79208. }
  79209. /**
  79210. * @hidden
  79211. */
  79212. export interface IVector3Like {
  79213. x: float;
  79214. y: float;
  79215. z: float;
  79216. }
  79217. /**
  79218. * @hidden
  79219. */
  79220. export interface IVector2Like {
  79221. x: float;
  79222. y: float;
  79223. }
  79224. /**
  79225. * @hidden
  79226. */
  79227. export interface IMatrixLike {
  79228. toArray(): DeepImmutable<Float32Array>;
  79229. updateFlag: int;
  79230. }
  79231. /**
  79232. * @hidden
  79233. */
  79234. export interface IViewportLike {
  79235. x: float;
  79236. y: float;
  79237. width: float;
  79238. height: float;
  79239. }
  79240. /**
  79241. * @hidden
  79242. */
  79243. export interface IPlaneLike {
  79244. normal: IVector3Like;
  79245. d: float;
  79246. normalize(): void;
  79247. }
  79248. }
  79249. declare module BABYLON {
  79250. /**
  79251. * Interface used to define common properties for effect fallbacks
  79252. */
  79253. export interface IEffectFallbacks {
  79254. /**
  79255. * Removes the defines that should be removed when falling back.
  79256. * @param currentDefines defines the current define statements for the shader.
  79257. * @param effect defines the current effect we try to compile
  79258. * @returns The resulting defines with defines of the current rank removed.
  79259. */
  79260. reduce(currentDefines: string, effect: Effect): string;
  79261. /**
  79262. * Removes the fallback from the bound mesh.
  79263. */
  79264. unBindMesh(): void;
  79265. /**
  79266. * Checks to see if more fallbacks are still availible.
  79267. */
  79268. hasMoreFallbacks: boolean;
  79269. }
  79270. }
  79271. declare module BABYLON {
  79272. /**
  79273. * Class used to evalaute queries containing `and` and `or` operators
  79274. */
  79275. export class AndOrNotEvaluator {
  79276. /**
  79277. * Evaluate a query
  79278. * @param query defines the query to evaluate
  79279. * @param evaluateCallback defines the callback used to filter result
  79280. * @returns true if the query matches
  79281. */
  79282. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79283. private static _HandleParenthesisContent;
  79284. private static _SimplifyNegation;
  79285. }
  79286. }
  79287. declare module BABYLON {
  79288. /**
  79289. * Class used to store custom tags
  79290. */
  79291. export class Tags {
  79292. /**
  79293. * Adds support for tags on the given object
  79294. * @param obj defines the object to use
  79295. */
  79296. static EnableFor(obj: any): void;
  79297. /**
  79298. * Removes tags support
  79299. * @param obj defines the object to use
  79300. */
  79301. static DisableFor(obj: any): void;
  79302. /**
  79303. * Gets a boolean indicating if the given object has tags
  79304. * @param obj defines the object to use
  79305. * @returns a boolean
  79306. */
  79307. static HasTags(obj: any): boolean;
  79308. /**
  79309. * Gets the tags available on a given object
  79310. * @param obj defines the object to use
  79311. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79312. * @returns the tags
  79313. */
  79314. static GetTags(obj: any, asString?: boolean): any;
  79315. /**
  79316. * Adds tags to an object
  79317. * @param obj defines the object to use
  79318. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79319. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79320. */
  79321. static AddTagsTo(obj: any, tagsString: string): void;
  79322. /**
  79323. * @hidden
  79324. */
  79325. static _AddTagTo(obj: any, tag: string): void;
  79326. /**
  79327. * Removes specific tags from a specific object
  79328. * @param obj defines the object to use
  79329. * @param tagsString defines the tags to remove
  79330. */
  79331. static RemoveTagsFrom(obj: any, tagsString: string): void;
  79332. /**
  79333. * @hidden
  79334. */
  79335. static _RemoveTagFrom(obj: any, tag: string): void;
  79336. /**
  79337. * Defines if tags hosted on an object match a given query
  79338. * @param obj defines the object to use
  79339. * @param tagsQuery defines the tag query
  79340. * @returns a boolean
  79341. */
  79342. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  79343. }
  79344. }
  79345. declare module BABYLON {
  79346. /**
  79347. * Scalar computation library
  79348. */
  79349. export class Scalar {
  79350. /**
  79351. * Two pi constants convenient for computation.
  79352. */
  79353. static TwoPi: number;
  79354. /**
  79355. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79356. * @param a number
  79357. * @param b number
  79358. * @param epsilon (default = 1.401298E-45)
  79359. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79360. */
  79361. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  79362. /**
  79363. * Returns a string : the upper case translation of the number i to hexadecimal.
  79364. * @param i number
  79365. * @returns the upper case translation of the number i to hexadecimal.
  79366. */
  79367. static ToHex(i: number): string;
  79368. /**
  79369. * Returns -1 if value is negative and +1 is value is positive.
  79370. * @param value the value
  79371. * @returns the value itself if it's equal to zero.
  79372. */
  79373. static Sign(value: number): number;
  79374. /**
  79375. * Returns the value itself if it's between min and max.
  79376. * Returns min if the value is lower than min.
  79377. * Returns max if the value is greater than max.
  79378. * @param value the value to clmap
  79379. * @param min the min value to clamp to (default: 0)
  79380. * @param max the max value to clamp to (default: 1)
  79381. * @returns the clamped value
  79382. */
  79383. static Clamp(value: number, min?: number, max?: number): number;
  79384. /**
  79385. * the log2 of value.
  79386. * @param value the value to compute log2 of
  79387. * @returns the log2 of value.
  79388. */
  79389. static Log2(value: number): number;
  79390. /**
  79391. * Loops the value, so that it is never larger than length and never smaller than 0.
  79392. *
  79393. * This is similar to the modulo operator but it works with floating point numbers.
  79394. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  79395. * With t = 5 and length = 2.5, the result would be 0.0.
  79396. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  79397. * @param value the value
  79398. * @param length the length
  79399. * @returns the looped value
  79400. */
  79401. static Repeat(value: number, length: number): number;
  79402. /**
  79403. * Normalize the value between 0.0 and 1.0 using min and max values
  79404. * @param value value to normalize
  79405. * @param min max to normalize between
  79406. * @param max min to normalize between
  79407. * @returns the normalized value
  79408. */
  79409. static Normalize(value: number, min: number, max: number): number;
  79410. /**
  79411. * Denormalize the value from 0.0 and 1.0 using min and max values
  79412. * @param normalized value to denormalize
  79413. * @param min max to denormalize between
  79414. * @param max min to denormalize between
  79415. * @returns the denormalized value
  79416. */
  79417. static Denormalize(normalized: number, min: number, max: number): number;
  79418. /**
  79419. * Calculates the shortest difference between two given angles given in degrees.
  79420. * @param current current angle in degrees
  79421. * @param target target angle in degrees
  79422. * @returns the delta
  79423. */
  79424. static DeltaAngle(current: number, target: number): number;
  79425. /**
  79426. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79427. * @param tx value
  79428. * @param length length
  79429. * @returns The returned value will move back and forth between 0 and length
  79430. */
  79431. static PingPong(tx: number, length: number): number;
  79432. /**
  79433. * Interpolates between min and max with smoothing at the limits.
  79434. *
  79435. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79436. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79437. * @param from from
  79438. * @param to to
  79439. * @param tx value
  79440. * @returns the smooth stepped value
  79441. */
  79442. static SmoothStep(from: number, to: number, tx: number): number;
  79443. /**
  79444. * Moves a value current towards target.
  79445. *
  79446. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79447. * Negative values of maxDelta pushes the value away from target.
  79448. * @param current current value
  79449. * @param target target value
  79450. * @param maxDelta max distance to move
  79451. * @returns resulting value
  79452. */
  79453. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79454. /**
  79455. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79456. *
  79457. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79458. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79459. * @param current current value
  79460. * @param target target value
  79461. * @param maxDelta max distance to move
  79462. * @returns resulting angle
  79463. */
  79464. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79465. /**
  79466. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79467. * @param start start value
  79468. * @param end target value
  79469. * @param amount amount to lerp between
  79470. * @returns the lerped value
  79471. */
  79472. static Lerp(start: number, end: number, amount: number): number;
  79473. /**
  79474. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79475. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  79476. * @param start start value
  79477. * @param end target value
  79478. * @param amount amount to lerp between
  79479. * @returns the lerped value
  79480. */
  79481. static LerpAngle(start: number, end: number, amount: number): number;
  79482. /**
  79483. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  79484. * @param a start value
  79485. * @param b target value
  79486. * @param value value between a and b
  79487. * @returns the inverseLerp value
  79488. */
  79489. static InverseLerp(a: number, b: number, value: number): number;
  79490. /**
  79491. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  79492. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  79493. * @param value1 spline value
  79494. * @param tangent1 spline value
  79495. * @param value2 spline value
  79496. * @param tangent2 spline value
  79497. * @param amount input value
  79498. * @returns hermite result
  79499. */
  79500. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  79501. /**
  79502. * Returns a random float number between and min and max values
  79503. * @param min min value of random
  79504. * @param max max value of random
  79505. * @returns random value
  79506. */
  79507. static RandomRange(min: number, max: number): number;
  79508. /**
  79509. * This function returns percentage of a number in a given range.
  79510. *
  79511. * RangeToPercent(40,20,60) will return 0.5 (50%)
  79512. * RangeToPercent(34,0,100) will return 0.34 (34%)
  79513. * @param number to convert to percentage
  79514. * @param min min range
  79515. * @param max max range
  79516. * @returns the percentage
  79517. */
  79518. static RangeToPercent(number: number, min: number, max: number): number;
  79519. /**
  79520. * This function returns number that corresponds to the percentage in a given range.
  79521. *
  79522. * PercentToRange(0.34,0,100) will return 34.
  79523. * @param percent to convert to number
  79524. * @param min min range
  79525. * @param max max range
  79526. * @returns the number
  79527. */
  79528. static PercentToRange(percent: number, min: number, max: number): number;
  79529. /**
  79530. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  79531. * @param angle The angle to normalize in radian.
  79532. * @return The converted angle.
  79533. */
  79534. static NormalizeRadians(angle: number): number;
  79535. }
  79536. }
  79537. declare module BABYLON {
  79538. /**
  79539. * Constant used to convert a value to gamma space
  79540. * @ignorenaming
  79541. */
  79542. export const ToGammaSpace: number;
  79543. /**
  79544. * Constant used to convert a value to linear space
  79545. * @ignorenaming
  79546. */
  79547. export const ToLinearSpace = 2.2;
  79548. /**
  79549. * Constant used to define the minimal number value in Babylon.js
  79550. * @ignorenaming
  79551. */
  79552. let Epsilon: number;
  79553. }
  79554. declare module BABYLON {
  79555. /**
  79556. * Class used to represent a viewport on screen
  79557. */
  79558. export class Viewport {
  79559. /** viewport left coordinate */
  79560. x: number;
  79561. /** viewport top coordinate */
  79562. y: number;
  79563. /**viewport width */
  79564. width: number;
  79565. /** viewport height */
  79566. height: number;
  79567. /**
  79568. * Creates a Viewport object located at (x, y) and sized (width, height)
  79569. * @param x defines viewport left coordinate
  79570. * @param y defines viewport top coordinate
  79571. * @param width defines the viewport width
  79572. * @param height defines the viewport height
  79573. */
  79574. constructor(
  79575. /** viewport left coordinate */
  79576. x: number,
  79577. /** viewport top coordinate */
  79578. y: number,
  79579. /**viewport width */
  79580. width: number,
  79581. /** viewport height */
  79582. height: number);
  79583. /**
  79584. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  79585. * @param renderWidth defines the rendering width
  79586. * @param renderHeight defines the rendering height
  79587. * @returns a new Viewport
  79588. */
  79589. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  79590. /**
  79591. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  79592. * @param renderWidth defines the rendering width
  79593. * @param renderHeight defines the rendering height
  79594. * @param ref defines the target viewport
  79595. * @returns the current viewport
  79596. */
  79597. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  79598. /**
  79599. * Returns a new Viewport copied from the current one
  79600. * @returns a new Viewport
  79601. */
  79602. clone(): Viewport;
  79603. }
  79604. }
  79605. declare module BABYLON {
  79606. /**
  79607. * Class containing a set of static utilities functions for arrays.
  79608. */
  79609. export class ArrayTools {
  79610. /**
  79611. * Returns an array of the given size filled with element built from the given constructor and the paramters
  79612. * @param size the number of element to construct and put in the array
  79613. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  79614. * @returns a new array filled with new objects
  79615. */
  79616. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  79617. }
  79618. }
  79619. declare module BABYLON {
  79620. /**
  79621. * Represents a plane by the equation ax + by + cz + d = 0
  79622. */
  79623. export class Plane {
  79624. private static _TmpMatrix;
  79625. /**
  79626. * Normal of the plane (a,b,c)
  79627. */
  79628. normal: Vector3;
  79629. /**
  79630. * d component of the plane
  79631. */
  79632. d: number;
  79633. /**
  79634. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79635. * @param a a component of the plane
  79636. * @param b b component of the plane
  79637. * @param c c component of the plane
  79638. * @param d d component of the plane
  79639. */
  79640. constructor(a: number, b: number, c: number, d: number);
  79641. /**
  79642. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79643. */
  79644. asArray(): number[];
  79645. /**
  79646. * @returns a new plane copied from the current Plane.
  79647. */
  79648. clone(): Plane;
  79649. /**
  79650. * @returns the string "Plane".
  79651. */
  79652. getClassName(): string;
  79653. /**
  79654. * @returns the Plane hash code.
  79655. */
  79656. getHashCode(): number;
  79657. /**
  79658. * Normalize the current Plane in place.
  79659. * @returns the updated Plane.
  79660. */
  79661. normalize(): Plane;
  79662. /**
  79663. * Applies a transformation the plane and returns the result
  79664. * @param transformation the transformation matrix to be applied to the plane
  79665. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79666. */
  79667. transform(transformation: DeepImmutable<Matrix>): Plane;
  79668. /**
  79669. * Compute the dot product between the point and the plane normal
  79670. * @param point point to calculate the dot product with
  79671. * @returns the dot product (float) of the point coordinates and the plane normal.
  79672. */
  79673. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79674. /**
  79675. * Updates the current Plane from the plane defined by the three given points.
  79676. * @param point1 one of the points used to contruct the plane
  79677. * @param point2 one of the points used to contruct the plane
  79678. * @param point3 one of the points used to contruct the plane
  79679. * @returns the updated Plane.
  79680. */
  79681. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79682. /**
  79683. * Checks if the plane is facing a given direction
  79684. * @param direction the direction to check if the plane is facing
  79685. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79686. * @returns True is the vector "direction" is the same side than the plane normal.
  79687. */
  79688. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79689. /**
  79690. * Calculates the distance to a point
  79691. * @param point point to calculate distance to
  79692. * @returns the signed distance (float) from the given point to the Plane.
  79693. */
  79694. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79695. /**
  79696. * Creates a plane from an array
  79697. * @param array the array to create a plane from
  79698. * @returns a new Plane from the given array.
  79699. */
  79700. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79701. /**
  79702. * Creates a plane from three points
  79703. * @param point1 point used to create the plane
  79704. * @param point2 point used to create the plane
  79705. * @param point3 point used to create the plane
  79706. * @returns a new Plane defined by the three given points.
  79707. */
  79708. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79709. /**
  79710. * Creates a plane from an origin point and a normal
  79711. * @param origin origin of the plane to be constructed
  79712. * @param normal normal of the plane to be constructed
  79713. * @returns a new Plane the normal vector to this plane at the given origin point.
  79714. * Note : the vector "normal" is updated because normalized.
  79715. */
  79716. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  79717. /**
  79718. * Calculates the distance from a plane and a point
  79719. * @param origin origin of the plane to be constructed
  79720. * @param normal normal of the plane to be constructed
  79721. * @param point point to calculate distance to
  79722. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79723. */
  79724. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79725. }
  79726. }
  79727. declare module BABYLON {
  79728. /**
  79729. * Class representing a vector containing 2 coordinates
  79730. */
  79731. export class Vector2 {
  79732. /** defines the first coordinate */
  79733. x: number;
  79734. /** defines the second coordinate */
  79735. y: number;
  79736. /**
  79737. * Creates a new Vector2 from the given x and y coordinates
  79738. * @param x defines the first coordinate
  79739. * @param y defines the second coordinate
  79740. */
  79741. constructor(
  79742. /** defines the first coordinate */
  79743. x?: number,
  79744. /** defines the second coordinate */
  79745. y?: number);
  79746. /**
  79747. * Gets a string with the Vector2 coordinates
  79748. * @returns a string with the Vector2 coordinates
  79749. */
  79750. toString(): string;
  79751. /**
  79752. * Gets class name
  79753. * @returns the string "Vector2"
  79754. */
  79755. getClassName(): string;
  79756. /**
  79757. * Gets current vector hash code
  79758. * @returns the Vector2 hash code as a number
  79759. */
  79760. getHashCode(): number;
  79761. /**
  79762. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  79763. * @param array defines the source array
  79764. * @param index defines the offset in source array
  79765. * @returns the current Vector2
  79766. */
  79767. toArray(array: FloatArray, index?: number): Vector2;
  79768. /**
  79769. * Copy the current vector to an array
  79770. * @returns a new array with 2 elements: the Vector2 coordinates.
  79771. */
  79772. asArray(): number[];
  79773. /**
  79774. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79775. * @param source defines the source Vector2
  79776. * @returns the current updated Vector2
  79777. */
  79778. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79779. /**
  79780. * Sets the Vector2 coordinates with the given floats
  79781. * @param x defines the first coordinate
  79782. * @param y defines the second coordinate
  79783. * @returns the current updated Vector2
  79784. */
  79785. copyFromFloats(x: number, y: number): Vector2;
  79786. /**
  79787. * Sets the Vector2 coordinates with the given floats
  79788. * @param x defines the first coordinate
  79789. * @param y defines the second coordinate
  79790. * @returns the current updated Vector2
  79791. */
  79792. set(x: number, y: number): Vector2;
  79793. /**
  79794. * Add another vector with the current one
  79795. * @param otherVector defines the other vector
  79796. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79797. */
  79798. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79799. /**
  79800. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79801. * @param otherVector defines the other vector
  79802. * @param result defines the target vector
  79803. * @returns the unmodified current Vector2
  79804. */
  79805. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79806. /**
  79807. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79808. * @param otherVector defines the other vector
  79809. * @returns the current updated Vector2
  79810. */
  79811. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79812. /**
  79813. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79814. * @param otherVector defines the other vector
  79815. * @returns a new Vector2
  79816. */
  79817. addVector3(otherVector: Vector3): Vector2;
  79818. /**
  79819. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79820. * @param otherVector defines the other vector
  79821. * @returns a new Vector2
  79822. */
  79823. subtract(otherVector: Vector2): Vector2;
  79824. /**
  79825. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79826. * @param otherVector defines the other vector
  79827. * @param result defines the target vector
  79828. * @returns the unmodified current Vector2
  79829. */
  79830. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79831. /**
  79832. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79833. * @param otherVector defines the other vector
  79834. * @returns the current updated Vector2
  79835. */
  79836. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79837. /**
  79838. * Multiplies in place the current Vector2 coordinates by the given ones
  79839. * @param otherVector defines the other vector
  79840. * @returns the current updated Vector2
  79841. */
  79842. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79843. /**
  79844. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79845. * @param otherVector defines the other vector
  79846. * @returns a new Vector2
  79847. */
  79848. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79849. /**
  79850. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79851. * @param otherVector defines the other vector
  79852. * @param result defines the target vector
  79853. * @returns the unmodified current Vector2
  79854. */
  79855. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79856. /**
  79857. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  79858. * @param x defines the first coordinate
  79859. * @param y defines the second coordinate
  79860. * @returns a new Vector2
  79861. */
  79862. multiplyByFloats(x: number, y: number): Vector2;
  79863. /**
  79864. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  79865. * @param otherVector defines the other vector
  79866. * @returns a new Vector2
  79867. */
  79868. divide(otherVector: Vector2): Vector2;
  79869. /**
  79870. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  79871. * @param otherVector defines the other vector
  79872. * @param result defines the target vector
  79873. * @returns the unmodified current Vector2
  79874. */
  79875. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79876. /**
  79877. * Divides the current Vector2 coordinates by the given ones
  79878. * @param otherVector defines the other vector
  79879. * @returns the current updated Vector2
  79880. */
  79881. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79882. /**
  79883. * Gets a new Vector2 with current Vector2 negated coordinates
  79884. * @returns a new Vector2
  79885. */
  79886. negate(): Vector2;
  79887. /**
  79888. * Negate this vector in place
  79889. * @returns this
  79890. */
  79891. negateInPlace(): Vector2;
  79892. /**
  79893. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  79894. * @param result defines the Vector3 object where to store the result
  79895. * @returns the current Vector2
  79896. */
  79897. negateToRef(result: Vector2): Vector2;
  79898. /**
  79899. * Multiply the Vector2 coordinates by scale
  79900. * @param scale defines the scaling factor
  79901. * @returns the current updated Vector2
  79902. */
  79903. scaleInPlace(scale: number): Vector2;
  79904. /**
  79905. * Returns a new Vector2 scaled by "scale" from the current Vector2
  79906. * @param scale defines the scaling factor
  79907. * @returns a new Vector2
  79908. */
  79909. scale(scale: number): Vector2;
  79910. /**
  79911. * Scale the current Vector2 values by a factor to a given Vector2
  79912. * @param scale defines the scale factor
  79913. * @param result defines the Vector2 object where to store the result
  79914. * @returns the unmodified current Vector2
  79915. */
  79916. scaleToRef(scale: number, result: Vector2): Vector2;
  79917. /**
  79918. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  79919. * @param scale defines the scale factor
  79920. * @param result defines the Vector2 object where to store the result
  79921. * @returns the unmodified current Vector2
  79922. */
  79923. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  79924. /**
  79925. * Gets a boolean if two vectors are equals
  79926. * @param otherVector defines the other vector
  79927. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  79928. */
  79929. equals(otherVector: DeepImmutable<Vector2>): boolean;
  79930. /**
  79931. * Gets a boolean if two vectors are equals (using an epsilon value)
  79932. * @param otherVector defines the other vector
  79933. * @param epsilon defines the minimal distance to consider equality
  79934. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  79935. */
  79936. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  79937. /**
  79938. * Gets a new Vector2 from current Vector2 floored values
  79939. * @returns a new Vector2
  79940. */
  79941. floor(): Vector2;
  79942. /**
  79943. * Gets a new Vector2 from current Vector2 floored values
  79944. * @returns a new Vector2
  79945. */
  79946. fract(): Vector2;
  79947. /**
  79948. * Gets the length of the vector
  79949. * @returns the vector length (float)
  79950. */
  79951. length(): number;
  79952. /**
  79953. * Gets the vector squared length
  79954. * @returns the vector squared length (float)
  79955. */
  79956. lengthSquared(): number;
  79957. /**
  79958. * Normalize the vector
  79959. * @returns the current updated Vector2
  79960. */
  79961. normalize(): Vector2;
  79962. /**
  79963. * Gets a new Vector2 copied from the Vector2
  79964. * @returns a new Vector2
  79965. */
  79966. clone(): Vector2;
  79967. /**
  79968. * Gets a new Vector2(0, 0)
  79969. * @returns a new Vector2
  79970. */
  79971. static Zero(): Vector2;
  79972. /**
  79973. * Gets a new Vector2(1, 1)
  79974. * @returns a new Vector2
  79975. */
  79976. static One(): Vector2;
  79977. /**
  79978. * Gets a new Vector2 set from the given index element of the given array
  79979. * @param array defines the data source
  79980. * @param offset defines the offset in the data source
  79981. * @returns a new Vector2
  79982. */
  79983. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  79984. /**
  79985. * Sets "result" from the given index element of the given array
  79986. * @param array defines the data source
  79987. * @param offset defines the offset in the data source
  79988. * @param result defines the target vector
  79989. */
  79990. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  79991. /**
  79992. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  79993. * @param value1 defines 1st point of control
  79994. * @param value2 defines 2nd point of control
  79995. * @param value3 defines 3rd point of control
  79996. * @param value4 defines 4th point of control
  79997. * @param amount defines the interpolation factor
  79998. * @returns a new Vector2
  79999. */
  80000. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80001. /**
  80002. * 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".
  80003. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80004. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80005. * @param value defines the value to clamp
  80006. * @param min defines the lower limit
  80007. * @param max defines the upper limit
  80008. * @returns a new Vector2
  80009. */
  80010. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80011. /**
  80012. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80013. * @param value1 defines the 1st control point
  80014. * @param tangent1 defines the outgoing tangent
  80015. * @param value2 defines the 2nd control point
  80016. * @param tangent2 defines the incoming tangent
  80017. * @param amount defines the interpolation factor
  80018. * @returns a new Vector2
  80019. */
  80020. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80021. /**
  80022. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80023. * @param start defines the start vector
  80024. * @param end defines the end vector
  80025. * @param amount defines the interpolation factor
  80026. * @returns a new Vector2
  80027. */
  80028. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80029. /**
  80030. * Gets the dot product of the vector "left" and the vector "right"
  80031. * @param left defines first vector
  80032. * @param right defines second vector
  80033. * @returns the dot product (float)
  80034. */
  80035. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80036. /**
  80037. * Returns a new Vector2 equal to the normalized given vector
  80038. * @param vector defines the vector to normalize
  80039. * @returns a new Vector2
  80040. */
  80041. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80042. /**
  80043. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80044. * @param left defines 1st vector
  80045. * @param right defines 2nd vector
  80046. * @returns a new Vector2
  80047. */
  80048. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80049. /**
  80050. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80051. * @param left defines 1st vector
  80052. * @param right defines 2nd vector
  80053. * @returns a new Vector2
  80054. */
  80055. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80056. /**
  80057. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80058. * @param vector defines the vector to transform
  80059. * @param transformation defines the matrix to apply
  80060. * @returns a new Vector2
  80061. */
  80062. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80063. /**
  80064. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80065. * @param vector defines the vector to transform
  80066. * @param transformation defines the matrix to apply
  80067. * @param result defines the target vector
  80068. */
  80069. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80070. /**
  80071. * Determines if a given vector is included in a triangle
  80072. * @param p defines the vector to test
  80073. * @param p0 defines 1st triangle point
  80074. * @param p1 defines 2nd triangle point
  80075. * @param p2 defines 3rd triangle point
  80076. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80077. */
  80078. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80079. /**
  80080. * Gets the distance between the vectors "value1" and "value2"
  80081. * @param value1 defines first vector
  80082. * @param value2 defines second vector
  80083. * @returns the distance between vectors
  80084. */
  80085. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80086. /**
  80087. * Returns the squared distance between the vectors "value1" and "value2"
  80088. * @param value1 defines first vector
  80089. * @param value2 defines second vector
  80090. * @returns the squared distance between vectors
  80091. */
  80092. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80093. /**
  80094. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80095. * @param value1 defines first vector
  80096. * @param value2 defines second vector
  80097. * @returns a new Vector2
  80098. */
  80099. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80100. /**
  80101. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80102. * @param p defines the middle point
  80103. * @param segA defines one point of the segment
  80104. * @param segB defines the other point of the segment
  80105. * @returns the shortest distance
  80106. */
  80107. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80108. }
  80109. /**
  80110. * Class used to store (x,y,z) vector representation
  80111. * A Vector3 is the main object used in 3D geometry
  80112. * It can represent etiher the coordinates of a point the space, either a direction
  80113. * Reminder: js uses a left handed forward facing system
  80114. */
  80115. export class Vector3 {
  80116. private static _UpReadOnly;
  80117. private static _ZeroReadOnly;
  80118. /** @hidden */
  80119. _x: number;
  80120. /** @hidden */
  80121. _y: number;
  80122. /** @hidden */
  80123. _z: number;
  80124. /** @hidden */
  80125. _isDirty: boolean;
  80126. /** Gets or sets the x coordinate */
  80127. get x(): number;
  80128. set x(value: number);
  80129. /** Gets or sets the y coordinate */
  80130. get y(): number;
  80131. set y(value: number);
  80132. /** Gets or sets the z coordinate */
  80133. get z(): number;
  80134. set z(value: number);
  80135. /**
  80136. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80137. * @param x defines the first coordinates (on X axis)
  80138. * @param y defines the second coordinates (on Y axis)
  80139. * @param z defines the third coordinates (on Z axis)
  80140. */
  80141. constructor(x?: number, y?: number, z?: number);
  80142. /**
  80143. * Creates a string representation of the Vector3
  80144. * @returns a string with the Vector3 coordinates.
  80145. */
  80146. toString(): string;
  80147. /**
  80148. * Gets the class name
  80149. * @returns the string "Vector3"
  80150. */
  80151. getClassName(): string;
  80152. /**
  80153. * Creates the Vector3 hash code
  80154. * @returns a number which tends to be unique between Vector3 instances
  80155. */
  80156. getHashCode(): number;
  80157. /**
  80158. * Creates an array containing three elements : the coordinates of the Vector3
  80159. * @returns a new array of numbers
  80160. */
  80161. asArray(): number[];
  80162. /**
  80163. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80164. * @param array defines the destination array
  80165. * @param index defines the offset in the destination array
  80166. * @returns the current Vector3
  80167. */
  80168. toArray(array: FloatArray, index?: number): Vector3;
  80169. /**
  80170. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80171. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80172. */
  80173. toQuaternion(): Quaternion;
  80174. /**
  80175. * Adds the given vector to the current Vector3
  80176. * @param otherVector defines the second operand
  80177. * @returns the current updated Vector3
  80178. */
  80179. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80180. /**
  80181. * Adds the given coordinates to the current Vector3
  80182. * @param x defines the x coordinate of the operand
  80183. * @param y defines the y coordinate of the operand
  80184. * @param z defines the z coordinate of the operand
  80185. * @returns the current updated Vector3
  80186. */
  80187. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80188. /**
  80189. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80190. * @param otherVector defines the second operand
  80191. * @returns the resulting Vector3
  80192. */
  80193. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80194. /**
  80195. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80196. * @param otherVector defines the second operand
  80197. * @param result defines the Vector3 object where to store the result
  80198. * @returns the current Vector3
  80199. */
  80200. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80201. /**
  80202. * Subtract the given vector from the current Vector3
  80203. * @param otherVector defines the second operand
  80204. * @returns the current updated Vector3
  80205. */
  80206. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80207. /**
  80208. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80209. * @param otherVector defines the second operand
  80210. * @returns the resulting Vector3
  80211. */
  80212. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80213. /**
  80214. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80215. * @param otherVector defines the second operand
  80216. * @param result defines the Vector3 object where to store the result
  80217. * @returns the current Vector3
  80218. */
  80219. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80220. /**
  80221. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80222. * @param x defines the x coordinate of the operand
  80223. * @param y defines the y coordinate of the operand
  80224. * @param z defines the z coordinate of the operand
  80225. * @returns the resulting Vector3
  80226. */
  80227. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80228. /**
  80229. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80230. * @param x defines the x coordinate of the operand
  80231. * @param y defines the y coordinate of the operand
  80232. * @param z defines the z coordinate of the operand
  80233. * @param result defines the Vector3 object where to store the result
  80234. * @returns the current Vector3
  80235. */
  80236. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80237. /**
  80238. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80239. * @returns a new Vector3
  80240. */
  80241. negate(): Vector3;
  80242. /**
  80243. * Negate this vector in place
  80244. * @returns this
  80245. */
  80246. negateInPlace(): Vector3;
  80247. /**
  80248. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80249. * @param result defines the Vector3 object where to store the result
  80250. * @returns the current Vector3
  80251. */
  80252. negateToRef(result: Vector3): Vector3;
  80253. /**
  80254. * Multiplies the Vector3 coordinates by the float "scale"
  80255. * @param scale defines the multiplier factor
  80256. * @returns the current updated Vector3
  80257. */
  80258. scaleInPlace(scale: number): Vector3;
  80259. /**
  80260. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80261. * @param scale defines the multiplier factor
  80262. * @returns a new Vector3
  80263. */
  80264. scale(scale: number): Vector3;
  80265. /**
  80266. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80267. * @param scale defines the multiplier factor
  80268. * @param result defines the Vector3 object where to store the result
  80269. * @returns the current Vector3
  80270. */
  80271. scaleToRef(scale: number, result: Vector3): Vector3;
  80272. /**
  80273. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80274. * @param scale defines the scale factor
  80275. * @param result defines the Vector3 object where to store the result
  80276. * @returns the unmodified current Vector3
  80277. */
  80278. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80279. /**
  80280. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80281. * @param origin defines the origin of the projection ray
  80282. * @param plane defines the plane to project to
  80283. * @returns the projected vector3
  80284. */
  80285. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80286. /**
  80287. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80288. * @param origin defines the origin of the projection ray
  80289. * @param plane defines the plane to project to
  80290. * @param result defines the Vector3 where to store the result
  80291. */
  80292. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80293. /**
  80294. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80295. * @param otherVector defines the second operand
  80296. * @returns true if both vectors are equals
  80297. */
  80298. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80299. /**
  80300. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80301. * @param otherVector defines the second operand
  80302. * @param epsilon defines the minimal distance to define values as equals
  80303. * @returns true if both vectors are distant less than epsilon
  80304. */
  80305. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80306. /**
  80307. * Returns true if the current Vector3 coordinates equals the given floats
  80308. * @param x defines the x coordinate of the operand
  80309. * @param y defines the y coordinate of the operand
  80310. * @param z defines the z coordinate of the operand
  80311. * @returns true if both vectors are equals
  80312. */
  80313. equalsToFloats(x: number, y: number, z: number): boolean;
  80314. /**
  80315. * Multiplies the current Vector3 coordinates by the given ones
  80316. * @param otherVector defines the second operand
  80317. * @returns the current updated Vector3
  80318. */
  80319. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80320. /**
  80321. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80322. * @param otherVector defines the second operand
  80323. * @returns the new Vector3
  80324. */
  80325. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80326. /**
  80327. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  80328. * @param otherVector defines the second operand
  80329. * @param result defines the Vector3 object where to store the result
  80330. * @returns the current Vector3
  80331. */
  80332. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80333. /**
  80334. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  80335. * @param x defines the x coordinate of the operand
  80336. * @param y defines the y coordinate of the operand
  80337. * @param z defines the z coordinate of the operand
  80338. * @returns the new Vector3
  80339. */
  80340. multiplyByFloats(x: number, y: number, z: number): Vector3;
  80341. /**
  80342. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  80343. * @param otherVector defines the second operand
  80344. * @returns the new Vector3
  80345. */
  80346. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  80347. /**
  80348. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  80349. * @param otherVector defines the second operand
  80350. * @param result defines the Vector3 object where to store the result
  80351. * @returns the current Vector3
  80352. */
  80353. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80354. /**
  80355. * Divides the current Vector3 coordinates by the given ones.
  80356. * @param otherVector defines the second operand
  80357. * @returns the current updated Vector3
  80358. */
  80359. divideInPlace(otherVector: Vector3): Vector3;
  80360. /**
  80361. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  80362. * @param other defines the second operand
  80363. * @returns the current updated Vector3
  80364. */
  80365. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80366. /**
  80367. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  80368. * @param other defines the second operand
  80369. * @returns the current updated Vector3
  80370. */
  80371. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80372. /**
  80373. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  80374. * @param x defines the x coordinate of the operand
  80375. * @param y defines the y coordinate of the operand
  80376. * @param z defines the z coordinate of the operand
  80377. * @returns the current updated Vector3
  80378. */
  80379. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80380. /**
  80381. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  80382. * @param x defines the x coordinate of the operand
  80383. * @param y defines the y coordinate of the operand
  80384. * @param z defines the z coordinate of the operand
  80385. * @returns the current updated Vector3
  80386. */
  80387. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80388. /**
  80389. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  80390. * Check if is non uniform within a certain amount of decimal places to account for this
  80391. * @param epsilon the amount the values can differ
  80392. * @returns if the the vector is non uniform to a certain number of decimal places
  80393. */
  80394. isNonUniformWithinEpsilon(epsilon: number): boolean;
  80395. /**
  80396. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  80397. */
  80398. get isNonUniform(): boolean;
  80399. /**
  80400. * Gets a new Vector3 from current Vector3 floored values
  80401. * @returns a new Vector3
  80402. */
  80403. floor(): Vector3;
  80404. /**
  80405. * Gets a new Vector3 from current Vector3 floored values
  80406. * @returns a new Vector3
  80407. */
  80408. fract(): Vector3;
  80409. /**
  80410. * Gets the length of the Vector3
  80411. * @returns the length of the Vector3
  80412. */
  80413. length(): number;
  80414. /**
  80415. * Gets the squared length of the Vector3
  80416. * @returns squared length of the Vector3
  80417. */
  80418. lengthSquared(): number;
  80419. /**
  80420. * Normalize the current Vector3.
  80421. * Please note that this is an in place operation.
  80422. * @returns the current updated Vector3
  80423. */
  80424. normalize(): Vector3;
  80425. /**
  80426. * Reorders the x y z properties of the vector in place
  80427. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80428. * @returns the current updated vector
  80429. */
  80430. reorderInPlace(order: string): this;
  80431. /**
  80432. * Rotates the vector around 0,0,0 by a quaternion
  80433. * @param quaternion the rotation quaternion
  80434. * @param result vector to store the result
  80435. * @returns the resulting vector
  80436. */
  80437. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80438. /**
  80439. * Rotates a vector around a given point
  80440. * @param quaternion the rotation quaternion
  80441. * @param point the point to rotate around
  80442. * @param result vector to store the result
  80443. * @returns the resulting vector
  80444. */
  80445. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80446. /**
  80447. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80448. * The cross product is then orthogonal to both current and "other"
  80449. * @param other defines the right operand
  80450. * @returns the cross product
  80451. */
  80452. cross(other: Vector3): Vector3;
  80453. /**
  80454. * Normalize the current Vector3 with the given input length.
  80455. * Please note that this is an in place operation.
  80456. * @param len the length of the vector
  80457. * @returns the current updated Vector3
  80458. */
  80459. normalizeFromLength(len: number): Vector3;
  80460. /**
  80461. * Normalize the current Vector3 to a new vector
  80462. * @returns the new Vector3
  80463. */
  80464. normalizeToNew(): Vector3;
  80465. /**
  80466. * Normalize the current Vector3 to the reference
  80467. * @param reference define the Vector3 to update
  80468. * @returns the updated Vector3
  80469. */
  80470. normalizeToRef(reference: Vector3): Vector3;
  80471. /**
  80472. * Creates a new Vector3 copied from the current Vector3
  80473. * @returns the new Vector3
  80474. */
  80475. clone(): Vector3;
  80476. /**
  80477. * Copies the given vector coordinates to the current Vector3 ones
  80478. * @param source defines the source Vector3
  80479. * @returns the current updated Vector3
  80480. */
  80481. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  80482. /**
  80483. * Copies the given floats to the current Vector3 coordinates
  80484. * @param x defines the x coordinate of the operand
  80485. * @param y defines the y coordinate of the operand
  80486. * @param z defines the z coordinate of the operand
  80487. * @returns the current updated Vector3
  80488. */
  80489. copyFromFloats(x: number, y: number, z: number): Vector3;
  80490. /**
  80491. * Copies the given floats to the current Vector3 coordinates
  80492. * @param x defines the x coordinate of the operand
  80493. * @param y defines the y coordinate of the operand
  80494. * @param z defines the z coordinate of the operand
  80495. * @returns the current updated Vector3
  80496. */
  80497. set(x: number, y: number, z: number): Vector3;
  80498. /**
  80499. * Copies the given float to the current Vector3 coordinates
  80500. * @param v defines the x, y and z coordinates of the operand
  80501. * @returns the current updated Vector3
  80502. */
  80503. setAll(v: number): Vector3;
  80504. /**
  80505. * Get the clip factor between two vectors
  80506. * @param vector0 defines the first operand
  80507. * @param vector1 defines the second operand
  80508. * @param axis defines the axis to use
  80509. * @param size defines the size along the axis
  80510. * @returns the clip factor
  80511. */
  80512. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  80513. /**
  80514. * Get angle between two vectors
  80515. * @param vector0 angle between vector0 and vector1
  80516. * @param vector1 angle between vector0 and vector1
  80517. * @param normal direction of the normal
  80518. * @return the angle between vector0 and vector1
  80519. */
  80520. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  80521. /**
  80522. * Returns a new Vector3 set from the index "offset" of the given array
  80523. * @param array defines the source array
  80524. * @param offset defines the offset in the source array
  80525. * @returns the new Vector3
  80526. */
  80527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  80528. /**
  80529. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  80530. * @param array defines the source array
  80531. * @param offset defines the offset in the source array
  80532. * @returns the new Vector3
  80533. * @deprecated Please use FromArray instead.
  80534. */
  80535. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  80536. /**
  80537. * Sets the given vector "result" with the element values from the index "offset" of the given array
  80538. * @param array defines the source array
  80539. * @param offset defines the offset in the source array
  80540. * @param result defines the Vector3 where to store the result
  80541. */
  80542. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  80543. /**
  80544. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  80545. * @param array defines the source array
  80546. * @param offset defines the offset in the source array
  80547. * @param result defines the Vector3 where to store the result
  80548. * @deprecated Please use FromArrayToRef instead.
  80549. */
  80550. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  80551. /**
  80552. * Sets the given vector "result" with the given floats.
  80553. * @param x defines the x coordinate of the source
  80554. * @param y defines the y coordinate of the source
  80555. * @param z defines the z coordinate of the source
  80556. * @param result defines the Vector3 where to store the result
  80557. */
  80558. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  80559. /**
  80560. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  80561. * @returns a new empty Vector3
  80562. */
  80563. static Zero(): Vector3;
  80564. /**
  80565. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  80566. * @returns a new unit Vector3
  80567. */
  80568. static One(): Vector3;
  80569. /**
  80570. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  80571. * @returns a new up Vector3
  80572. */
  80573. static Up(): Vector3;
  80574. /**
  80575. * Gets a up Vector3 that must not be updated
  80576. */
  80577. static get UpReadOnly(): DeepImmutable<Vector3>;
  80578. /**
  80579. * Gets a zero Vector3 that must not be updated
  80580. */
  80581. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  80582. /**
  80583. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  80584. * @returns a new down Vector3
  80585. */
  80586. static Down(): Vector3;
  80587. /**
  80588. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  80589. * @param rightHandedSystem is the scene right-handed (negative z)
  80590. * @returns a new forward Vector3
  80591. */
  80592. static Forward(rightHandedSystem?: boolean): Vector3;
  80593. /**
  80594. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  80595. * @param rightHandedSystem is the scene right-handed (negative-z)
  80596. * @returns a new forward Vector3
  80597. */
  80598. static Backward(rightHandedSystem?: boolean): Vector3;
  80599. /**
  80600. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  80601. * @returns a new right Vector3
  80602. */
  80603. static Right(): Vector3;
  80604. /**
  80605. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  80606. * @returns a new left Vector3
  80607. */
  80608. static Left(): Vector3;
  80609. /**
  80610. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  80611. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80612. * @param vector defines the Vector3 to transform
  80613. * @param transformation defines the transformation matrix
  80614. * @returns the transformed Vector3
  80615. */
  80616. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80617. /**
  80618. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  80619. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80620. * @param vector defines the Vector3 to transform
  80621. * @param transformation defines the transformation matrix
  80622. * @param result defines the Vector3 where to store the result
  80623. */
  80624. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80625. /**
  80626. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  80627. * This method computes tranformed coordinates only, not transformed direction vectors
  80628. * @param x define the x coordinate of the source vector
  80629. * @param y define the y coordinate of the source vector
  80630. * @param z define the z coordinate of the source vector
  80631. * @param transformation defines the transformation matrix
  80632. * @param result defines the Vector3 where to store the result
  80633. */
  80634. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80635. /**
  80636. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  80637. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80638. * @param vector defines the Vector3 to transform
  80639. * @param transformation defines the transformation matrix
  80640. * @returns the new Vector3
  80641. */
  80642. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80643. /**
  80644. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  80645. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80646. * @param vector defines the Vector3 to transform
  80647. * @param transformation defines the transformation matrix
  80648. * @param result defines the Vector3 where to store the result
  80649. */
  80650. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80651. /**
  80652. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  80653. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80654. * @param x define the x coordinate of the source vector
  80655. * @param y define the y coordinate of the source vector
  80656. * @param z define the z coordinate of the source vector
  80657. * @param transformation defines the transformation matrix
  80658. * @param result defines the Vector3 where to store the result
  80659. */
  80660. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80661. /**
  80662. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  80663. * @param value1 defines the first control point
  80664. * @param value2 defines the second control point
  80665. * @param value3 defines the third control point
  80666. * @param value4 defines the fourth control point
  80667. * @param amount defines the amount on the spline to use
  80668. * @returns the new Vector3
  80669. */
  80670. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  80671. /**
  80672. * 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"
  80673. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80674. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80675. * @param value defines the current value
  80676. * @param min defines the lower range value
  80677. * @param max defines the upper range value
  80678. * @returns the new Vector3
  80679. */
  80680. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  80681. /**
  80682. * 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"
  80683. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80684. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80685. * @param value defines the current value
  80686. * @param min defines the lower range value
  80687. * @param max defines the upper range value
  80688. * @param result defines the Vector3 where to store the result
  80689. */
  80690. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  80691. /**
  80692. * Checks if a given vector is inside a specific range
  80693. * @param v defines the vector to test
  80694. * @param min defines the minimum range
  80695. * @param max defines the maximum range
  80696. */
  80697. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  80698. /**
  80699. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  80700. * @param value1 defines the first control point
  80701. * @param tangent1 defines the first tangent vector
  80702. * @param value2 defines the second control point
  80703. * @param tangent2 defines the second tangent vector
  80704. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  80705. * @returns the new Vector3
  80706. */
  80707. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  80708. /**
  80709. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  80710. * @param start defines the start value
  80711. * @param end defines the end value
  80712. * @param amount max defines amount between both (between 0 and 1)
  80713. * @returns the new Vector3
  80714. */
  80715. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  80716. /**
  80717. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  80718. * @param start defines the start value
  80719. * @param end defines the end value
  80720. * @param amount max defines amount between both (between 0 and 1)
  80721. * @param result defines the Vector3 where to store the result
  80722. */
  80723. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  80724. /**
  80725. * Returns the dot product (float) between the vectors "left" and "right"
  80726. * @param left defines the left operand
  80727. * @param right defines the right operand
  80728. * @returns the dot product
  80729. */
  80730. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  80731. /**
  80732. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  80733. * The cross product is then orthogonal to both "left" and "right"
  80734. * @param left defines the left operand
  80735. * @param right defines the right operand
  80736. * @returns the cross product
  80737. */
  80738. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80739. /**
  80740. * Sets the given vector "result" with the cross product of "left" and "right"
  80741. * The cross product is then orthogonal to both "left" and "right"
  80742. * @param left defines the left operand
  80743. * @param right defines the right operand
  80744. * @param result defines the Vector3 where to store the result
  80745. */
  80746. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  80747. /**
  80748. * Returns a new Vector3 as the normalization of the given vector
  80749. * @param vector defines the Vector3 to normalize
  80750. * @returns the new Vector3
  80751. */
  80752. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  80753. /**
  80754. * Sets the given vector "result" with the normalization of the given first vector
  80755. * @param vector defines the Vector3 to normalize
  80756. * @param result defines the Vector3 where to store the result
  80757. */
  80758. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  80759. /**
  80760. * Project a Vector3 onto screen space
  80761. * @param vector defines the Vector3 to project
  80762. * @param world defines the world matrix to use
  80763. * @param transform defines the transform (view x projection) matrix to use
  80764. * @param viewport defines the screen viewport to use
  80765. * @returns the new Vector3
  80766. */
  80767. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80768. /** @hidden */
  80769. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80770. /**
  80771. * Unproject from screen space to object space
  80772. * @param source defines the screen space Vector3 to use
  80773. * @param viewportWidth defines the current width of the viewport
  80774. * @param viewportHeight defines the current height of the viewport
  80775. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80776. * @param transform defines the transform (view x projection) matrix to use
  80777. * @returns the new Vector3
  80778. */
  80779. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80780. /**
  80781. * Unproject from screen space to object space
  80782. * @param source defines the screen space Vector3 to use
  80783. * @param viewportWidth defines the current width of the viewport
  80784. * @param viewportHeight defines the current height of the viewport
  80785. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80786. * @param view defines the view matrix to use
  80787. * @param projection defines the projection matrix to use
  80788. * @returns the new Vector3
  80789. */
  80790. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80791. /**
  80792. * Unproject from screen space to object space
  80793. * @param source defines the screen space Vector3 to use
  80794. * @param viewportWidth defines the current width of the viewport
  80795. * @param viewportHeight defines the current height of the viewport
  80796. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80797. * @param view defines the view matrix to use
  80798. * @param projection defines the projection matrix to use
  80799. * @param result defines the Vector3 where to store the result
  80800. */
  80801. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80802. /**
  80803. * Unproject from screen space to object space
  80804. * @param sourceX defines the screen space x coordinate to use
  80805. * @param sourceY defines the screen space y coordinate to use
  80806. * @param sourceZ defines the screen space z coordinate to use
  80807. * @param viewportWidth defines the current width of the viewport
  80808. * @param viewportHeight defines the current height of the viewport
  80809. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80810. * @param view defines the view matrix to use
  80811. * @param projection defines the projection matrix to use
  80812. * @param result defines the Vector3 where to store the result
  80813. */
  80814. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80815. /**
  80816. * Gets the minimal coordinate values between two Vector3
  80817. * @param left defines the first operand
  80818. * @param right defines the second operand
  80819. * @returns the new Vector3
  80820. */
  80821. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80822. /**
  80823. * Gets the maximal coordinate values between two Vector3
  80824. * @param left defines the first operand
  80825. * @param right defines the second operand
  80826. * @returns the new Vector3
  80827. */
  80828. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80829. /**
  80830. * Returns the distance between the vectors "value1" and "value2"
  80831. * @param value1 defines the first operand
  80832. * @param value2 defines the second operand
  80833. * @returns the distance
  80834. */
  80835. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80836. /**
  80837. * Returns the squared distance between the vectors "value1" and "value2"
  80838. * @param value1 defines the first operand
  80839. * @param value2 defines the second operand
  80840. * @returns the squared distance
  80841. */
  80842. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80843. /**
  80844. * Returns a new Vector3 located at the center between "value1" and "value2"
  80845. * @param value1 defines the first operand
  80846. * @param value2 defines the second operand
  80847. * @returns the new Vector3
  80848. */
  80849. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80850. /**
  80851. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80852. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80853. * to something in order to rotate it from its local system to the given target system
  80854. * Note: axis1, axis2 and axis3 are normalized during this operation
  80855. * @param axis1 defines the first axis
  80856. * @param axis2 defines the second axis
  80857. * @param axis3 defines the third axis
  80858. * @returns a new Vector3
  80859. */
  80860. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  80861. /**
  80862. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  80863. * @param axis1 defines the first axis
  80864. * @param axis2 defines the second axis
  80865. * @param axis3 defines the third axis
  80866. * @param ref defines the Vector3 where to store the result
  80867. */
  80868. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  80869. }
  80870. /**
  80871. * Vector4 class created for EulerAngle class conversion to Quaternion
  80872. */
  80873. export class Vector4 {
  80874. /** x value of the vector */
  80875. x: number;
  80876. /** y value of the vector */
  80877. y: number;
  80878. /** z value of the vector */
  80879. z: number;
  80880. /** w value of the vector */
  80881. w: number;
  80882. /**
  80883. * Creates a Vector4 object from the given floats.
  80884. * @param x x value of the vector
  80885. * @param y y value of the vector
  80886. * @param z z value of the vector
  80887. * @param w w value of the vector
  80888. */
  80889. constructor(
  80890. /** x value of the vector */
  80891. x: number,
  80892. /** y value of the vector */
  80893. y: number,
  80894. /** z value of the vector */
  80895. z: number,
  80896. /** w value of the vector */
  80897. w: number);
  80898. /**
  80899. * Returns the string with the Vector4 coordinates.
  80900. * @returns a string containing all the vector values
  80901. */
  80902. toString(): string;
  80903. /**
  80904. * Returns the string "Vector4".
  80905. * @returns "Vector4"
  80906. */
  80907. getClassName(): string;
  80908. /**
  80909. * Returns the Vector4 hash code.
  80910. * @returns a unique hash code
  80911. */
  80912. getHashCode(): number;
  80913. /**
  80914. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  80915. * @returns the resulting array
  80916. */
  80917. asArray(): number[];
  80918. /**
  80919. * Populates the given array from the given index with the Vector4 coordinates.
  80920. * @param array array to populate
  80921. * @param index index of the array to start at (default: 0)
  80922. * @returns the Vector4.
  80923. */
  80924. toArray(array: FloatArray, index?: number): Vector4;
  80925. /**
  80926. * Adds the given vector to the current Vector4.
  80927. * @param otherVector the vector to add
  80928. * @returns the updated Vector4.
  80929. */
  80930. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80931. /**
  80932. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  80933. * @param otherVector the vector to add
  80934. * @returns the resulting vector
  80935. */
  80936. add(otherVector: DeepImmutable<Vector4>): Vector4;
  80937. /**
  80938. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  80939. * @param otherVector the vector to add
  80940. * @param result the vector to store the result
  80941. * @returns the current Vector4.
  80942. */
  80943. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80944. /**
  80945. * Subtract in place the given vector from the current Vector4.
  80946. * @param otherVector the vector to subtract
  80947. * @returns the updated Vector4.
  80948. */
  80949. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80950. /**
  80951. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  80952. * @param otherVector the vector to add
  80953. * @returns the new vector with the result
  80954. */
  80955. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  80956. /**
  80957. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  80958. * @param otherVector the vector to subtract
  80959. * @param result the vector to store the result
  80960. * @returns the current Vector4.
  80961. */
  80962. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80963. /**
  80964. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80965. */
  80966. /**
  80967. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80968. * @param x value to subtract
  80969. * @param y value to subtract
  80970. * @param z value to subtract
  80971. * @param w value to subtract
  80972. * @returns new vector containing the result
  80973. */
  80974. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80975. /**
  80976. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80977. * @param x value to subtract
  80978. * @param y value to subtract
  80979. * @param z value to subtract
  80980. * @param w value to subtract
  80981. * @param result the vector to store the result in
  80982. * @returns the current Vector4.
  80983. */
  80984. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  80985. /**
  80986. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  80987. * @returns a new vector with the negated values
  80988. */
  80989. negate(): Vector4;
  80990. /**
  80991. * Negate this vector in place
  80992. * @returns this
  80993. */
  80994. negateInPlace(): Vector4;
  80995. /**
  80996. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  80997. * @param result defines the Vector3 object where to store the result
  80998. * @returns the current Vector4
  80999. */
  81000. negateToRef(result: Vector4): Vector4;
  81001. /**
  81002. * Multiplies the current Vector4 coordinates by scale (float).
  81003. * @param scale the number to scale with
  81004. * @returns the updated Vector4.
  81005. */
  81006. scaleInPlace(scale: number): Vector4;
  81007. /**
  81008. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81009. * @param scale the number to scale with
  81010. * @returns a new vector with the result
  81011. */
  81012. scale(scale: number): Vector4;
  81013. /**
  81014. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81015. * @param scale the number to scale with
  81016. * @param result a vector to store the result in
  81017. * @returns the current Vector4.
  81018. */
  81019. scaleToRef(scale: number, result: Vector4): Vector4;
  81020. /**
  81021. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81022. * @param scale defines the scale factor
  81023. * @param result defines the Vector4 object where to store the result
  81024. * @returns the unmodified current Vector4
  81025. */
  81026. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81027. /**
  81028. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81029. * @param otherVector the vector to compare against
  81030. * @returns true if they are equal
  81031. */
  81032. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81033. /**
  81034. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81035. * @param otherVector vector to compare against
  81036. * @param epsilon (Default: very small number)
  81037. * @returns true if they are equal
  81038. */
  81039. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81040. /**
  81041. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81042. * @param x x value to compare against
  81043. * @param y y value to compare against
  81044. * @param z z value to compare against
  81045. * @param w w value to compare against
  81046. * @returns true if equal
  81047. */
  81048. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81049. /**
  81050. * Multiplies in place the current Vector4 by the given one.
  81051. * @param otherVector vector to multiple with
  81052. * @returns the updated Vector4.
  81053. */
  81054. multiplyInPlace(otherVector: Vector4): Vector4;
  81055. /**
  81056. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81057. * @param otherVector vector to multiple with
  81058. * @returns resulting new vector
  81059. */
  81060. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81061. /**
  81062. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81063. * @param otherVector vector to multiple with
  81064. * @param result vector to store the result
  81065. * @returns the current Vector4.
  81066. */
  81067. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81068. /**
  81069. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81070. * @param x x value multiply with
  81071. * @param y y value multiply with
  81072. * @param z z value multiply with
  81073. * @param w w value multiply with
  81074. * @returns resulting new vector
  81075. */
  81076. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81077. /**
  81078. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81079. * @param otherVector vector to devide with
  81080. * @returns resulting new vector
  81081. */
  81082. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81083. /**
  81084. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81085. * @param otherVector vector to devide with
  81086. * @param result vector to store the result
  81087. * @returns the current Vector4.
  81088. */
  81089. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81090. /**
  81091. * Divides the current Vector3 coordinates by the given ones.
  81092. * @param otherVector vector to devide with
  81093. * @returns the updated Vector3.
  81094. */
  81095. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81096. /**
  81097. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81098. * @param other defines the second operand
  81099. * @returns the current updated Vector4
  81100. */
  81101. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81102. /**
  81103. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81104. * @param other defines the second operand
  81105. * @returns the current updated Vector4
  81106. */
  81107. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81108. /**
  81109. * Gets a new Vector4 from current Vector4 floored values
  81110. * @returns a new Vector4
  81111. */
  81112. floor(): Vector4;
  81113. /**
  81114. * Gets a new Vector4 from current Vector3 floored values
  81115. * @returns a new Vector4
  81116. */
  81117. fract(): Vector4;
  81118. /**
  81119. * Returns the Vector4 length (float).
  81120. * @returns the length
  81121. */
  81122. length(): number;
  81123. /**
  81124. * Returns the Vector4 squared length (float).
  81125. * @returns the length squared
  81126. */
  81127. lengthSquared(): number;
  81128. /**
  81129. * Normalizes in place the Vector4.
  81130. * @returns the updated Vector4.
  81131. */
  81132. normalize(): Vector4;
  81133. /**
  81134. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81135. * @returns this converted to a new vector3
  81136. */
  81137. toVector3(): Vector3;
  81138. /**
  81139. * Returns a new Vector4 copied from the current one.
  81140. * @returns the new cloned vector
  81141. */
  81142. clone(): Vector4;
  81143. /**
  81144. * Updates the current Vector4 with the given one coordinates.
  81145. * @param source the source vector to copy from
  81146. * @returns the updated Vector4.
  81147. */
  81148. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81149. /**
  81150. * Updates the current Vector4 coordinates with the given floats.
  81151. * @param x float to copy from
  81152. * @param y float to copy from
  81153. * @param z float to copy from
  81154. * @param w float to copy from
  81155. * @returns the updated Vector4.
  81156. */
  81157. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81158. /**
  81159. * Updates the current Vector4 coordinates with the given floats.
  81160. * @param x float to set from
  81161. * @param y float to set from
  81162. * @param z float to set from
  81163. * @param w float to set from
  81164. * @returns the updated Vector4.
  81165. */
  81166. set(x: number, y: number, z: number, w: number): Vector4;
  81167. /**
  81168. * Copies the given float to the current Vector3 coordinates
  81169. * @param v defines the x, y, z and w coordinates of the operand
  81170. * @returns the current updated Vector3
  81171. */
  81172. setAll(v: number): Vector4;
  81173. /**
  81174. * Returns a new Vector4 set from the starting index of the given array.
  81175. * @param array the array to pull values from
  81176. * @param offset the offset into the array to start at
  81177. * @returns the new vector
  81178. */
  81179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81180. /**
  81181. * Updates the given vector "result" from the starting index of the given array.
  81182. * @param array the array to pull values from
  81183. * @param offset the offset into the array to start at
  81184. * @param result the vector to store the result in
  81185. */
  81186. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81187. /**
  81188. * Updates the given vector "result" from the starting index of the given Float32Array.
  81189. * @param array the array to pull values from
  81190. * @param offset the offset into the array to start at
  81191. * @param result the vector to store the result in
  81192. */
  81193. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81194. /**
  81195. * Updates the given vector "result" coordinates from the given floats.
  81196. * @param x float to set from
  81197. * @param y float to set from
  81198. * @param z float to set from
  81199. * @param w float to set from
  81200. * @param result the vector to the floats in
  81201. */
  81202. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81203. /**
  81204. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81205. * @returns the new vector
  81206. */
  81207. static Zero(): Vector4;
  81208. /**
  81209. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81210. * @returns the new vector
  81211. */
  81212. static One(): Vector4;
  81213. /**
  81214. * Returns a new normalized Vector4 from the given one.
  81215. * @param vector the vector to normalize
  81216. * @returns the vector
  81217. */
  81218. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81219. /**
  81220. * Updates the given vector "result" from the normalization of the given one.
  81221. * @param vector the vector to normalize
  81222. * @param result the vector to store the result in
  81223. */
  81224. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81225. /**
  81226. * Returns a vector with the minimum values from the left and right vectors
  81227. * @param left left vector to minimize
  81228. * @param right right vector to minimize
  81229. * @returns a new vector with the minimum of the left and right vector values
  81230. */
  81231. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81232. /**
  81233. * Returns a vector with the maximum values from the left and right vectors
  81234. * @param left left vector to maximize
  81235. * @param right right vector to maximize
  81236. * @returns a new vector with the maximum of the left and right vector values
  81237. */
  81238. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81239. /**
  81240. * Returns the distance (float) between the vectors "value1" and "value2".
  81241. * @param value1 value to calulate the distance between
  81242. * @param value2 value to calulate the distance between
  81243. * @return the distance between the two vectors
  81244. */
  81245. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81246. /**
  81247. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81248. * @param value1 value to calulate the distance between
  81249. * @param value2 value to calulate the distance between
  81250. * @return the distance between the two vectors squared
  81251. */
  81252. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81253. /**
  81254. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81255. * @param value1 value to calulate the center between
  81256. * @param value2 value to calulate the center between
  81257. * @return the center between the two vectors
  81258. */
  81259. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81260. /**
  81261. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81262. * This methods computes transformed normalized direction vectors only.
  81263. * @param vector the vector to transform
  81264. * @param transformation the transformation matrix to apply
  81265. * @returns the new vector
  81266. */
  81267. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81268. /**
  81269. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81270. * This methods computes transformed normalized direction vectors only.
  81271. * @param vector the vector to transform
  81272. * @param transformation the transformation matrix to apply
  81273. * @param result the vector to store the result in
  81274. */
  81275. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81276. /**
  81277. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81278. * This methods computes transformed normalized direction vectors only.
  81279. * @param x value to transform
  81280. * @param y value to transform
  81281. * @param z value to transform
  81282. * @param w value to transform
  81283. * @param transformation the transformation matrix to apply
  81284. * @param result the vector to store the results in
  81285. */
  81286. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81287. /**
  81288. * Creates a new Vector4 from a Vector3
  81289. * @param source defines the source data
  81290. * @param w defines the 4th component (default is 0)
  81291. * @returns a new Vector4
  81292. */
  81293. static FromVector3(source: Vector3, w?: number): Vector4;
  81294. }
  81295. /**
  81296. * Class used to store quaternion data
  81297. * @see https://en.wikipedia.org/wiki/Quaternion
  81298. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  81299. */
  81300. export class Quaternion {
  81301. /** @hidden */
  81302. _x: number;
  81303. /** @hidden */
  81304. _y: number;
  81305. /** @hidden */
  81306. _z: number;
  81307. /** @hidden */
  81308. _w: number;
  81309. /** @hidden */
  81310. _isDirty: boolean;
  81311. /** Gets or sets the x coordinate */
  81312. get x(): number;
  81313. set x(value: number);
  81314. /** Gets or sets the y coordinate */
  81315. get y(): number;
  81316. set y(value: number);
  81317. /** Gets or sets the z coordinate */
  81318. get z(): number;
  81319. set z(value: number);
  81320. /** Gets or sets the w coordinate */
  81321. get w(): number;
  81322. set w(value: number);
  81323. /**
  81324. * Creates a new Quaternion from the given floats
  81325. * @param x defines the first component (0 by default)
  81326. * @param y defines the second component (0 by default)
  81327. * @param z defines the third component (0 by default)
  81328. * @param w defines the fourth component (1.0 by default)
  81329. */
  81330. constructor(x?: number, y?: number, z?: number, w?: number);
  81331. /**
  81332. * Gets a string representation for the current quaternion
  81333. * @returns a string with the Quaternion coordinates
  81334. */
  81335. toString(): string;
  81336. /**
  81337. * Gets the class name of the quaternion
  81338. * @returns the string "Quaternion"
  81339. */
  81340. getClassName(): string;
  81341. /**
  81342. * Gets a hash code for this quaternion
  81343. * @returns the quaternion hash code
  81344. */
  81345. getHashCode(): number;
  81346. /**
  81347. * Copy the quaternion to an array
  81348. * @returns a new array populated with 4 elements from the quaternion coordinates
  81349. */
  81350. asArray(): number[];
  81351. /**
  81352. * Check if two quaternions are equals
  81353. * @param otherQuaternion defines the second operand
  81354. * @return true if the current quaternion and the given one coordinates are strictly equals
  81355. */
  81356. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  81357. /**
  81358. * Gets a boolean if two quaternions are equals (using an epsilon value)
  81359. * @param otherQuaternion defines the other quaternion
  81360. * @param epsilon defines the minimal distance to consider equality
  81361. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  81362. */
  81363. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  81364. /**
  81365. * Clone the current quaternion
  81366. * @returns a new quaternion copied from the current one
  81367. */
  81368. clone(): Quaternion;
  81369. /**
  81370. * Copy a quaternion to the current one
  81371. * @param other defines the other quaternion
  81372. * @returns the updated current quaternion
  81373. */
  81374. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  81375. /**
  81376. * Updates the current quaternion with the given float coordinates
  81377. * @param x defines the x coordinate
  81378. * @param y defines the y coordinate
  81379. * @param z defines the z coordinate
  81380. * @param w defines the w coordinate
  81381. * @returns the updated current quaternion
  81382. */
  81383. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  81384. /**
  81385. * Updates the current quaternion from the given float coordinates
  81386. * @param x defines the x coordinate
  81387. * @param y defines the y coordinate
  81388. * @param z defines the z coordinate
  81389. * @param w defines the w coordinate
  81390. * @returns the updated current quaternion
  81391. */
  81392. set(x: number, y: number, z: number, w: number): Quaternion;
  81393. /**
  81394. * Adds two quaternions
  81395. * @param other defines the second operand
  81396. * @returns a new quaternion as the addition result of the given one and the current quaternion
  81397. */
  81398. add(other: DeepImmutable<Quaternion>): Quaternion;
  81399. /**
  81400. * Add a quaternion to the current one
  81401. * @param other defines the quaternion to add
  81402. * @returns the current quaternion
  81403. */
  81404. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  81405. /**
  81406. * Subtract two quaternions
  81407. * @param other defines the second operand
  81408. * @returns a new quaternion as the subtraction result of the given one from the current one
  81409. */
  81410. subtract(other: Quaternion): Quaternion;
  81411. /**
  81412. * Multiplies the current quaternion by a scale factor
  81413. * @param value defines the scale factor
  81414. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81415. */
  81416. scale(value: number): Quaternion;
  81417. /**
  81418. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81419. * @param scale defines the scale factor
  81420. * @param result defines the Quaternion object where to store the result
  81421. * @returns the unmodified current quaternion
  81422. */
  81423. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81424. /**
  81425. * Multiplies in place the current quaternion by a scale factor
  81426. * @param value defines the scale factor
  81427. * @returns the current modified quaternion
  81428. */
  81429. scaleInPlace(value: number): Quaternion;
  81430. /**
  81431. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81432. * @param scale defines the scale factor
  81433. * @param result defines the Quaternion object where to store the result
  81434. * @returns the unmodified current quaternion
  81435. */
  81436. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81437. /**
  81438. * Multiplies two quaternions
  81439. * @param q1 defines the second operand
  81440. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81441. */
  81442. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81443. /**
  81444. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81445. * @param q1 defines the second operand
  81446. * @param result defines the target quaternion
  81447. * @returns the current quaternion
  81448. */
  81449. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81450. /**
  81451. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81452. * @param q1 defines the second operand
  81453. * @returns the currentupdated quaternion
  81454. */
  81455. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81456. /**
  81457. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81458. * @param ref defines the target quaternion
  81459. * @returns the current quaternion
  81460. */
  81461. conjugateToRef(ref: Quaternion): Quaternion;
  81462. /**
  81463. * Conjugates in place (1-q) the current quaternion
  81464. * @returns the current updated quaternion
  81465. */
  81466. conjugateInPlace(): Quaternion;
  81467. /**
  81468. * Conjugates in place (1-q) the current quaternion
  81469. * @returns a new quaternion
  81470. */
  81471. conjugate(): Quaternion;
  81472. /**
  81473. * Gets length of current quaternion
  81474. * @returns the quaternion length (float)
  81475. */
  81476. length(): number;
  81477. /**
  81478. * Normalize in place the current quaternion
  81479. * @returns the current updated quaternion
  81480. */
  81481. normalize(): Quaternion;
  81482. /**
  81483. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  81484. * @param order is a reserved parameter and is ignore for now
  81485. * @returns a new Vector3 containing the Euler angles
  81486. */
  81487. toEulerAngles(order?: string): Vector3;
  81488. /**
  81489. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  81490. * @param result defines the vector which will be filled with the Euler angles
  81491. * @param order is a reserved parameter and is ignore for now
  81492. * @returns the current unchanged quaternion
  81493. */
  81494. toEulerAnglesToRef(result: Vector3): Quaternion;
  81495. /**
  81496. * Updates the given rotation matrix with the current quaternion values
  81497. * @param result defines the target matrix
  81498. * @returns the current unchanged quaternion
  81499. */
  81500. toRotationMatrix(result: Matrix): Quaternion;
  81501. /**
  81502. * Updates the current quaternion from the given rotation matrix values
  81503. * @param matrix defines the source matrix
  81504. * @returns the current updated quaternion
  81505. */
  81506. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81507. /**
  81508. * Creates a new quaternion from a rotation matrix
  81509. * @param matrix defines the source matrix
  81510. * @returns a new quaternion created from the given rotation matrix values
  81511. */
  81512. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81513. /**
  81514. * Updates the given quaternion with the given rotation matrix values
  81515. * @param matrix defines the source matrix
  81516. * @param result defines the target quaternion
  81517. */
  81518. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  81519. /**
  81520. * Returns the dot product (float) between the quaternions "left" and "right"
  81521. * @param left defines the left operand
  81522. * @param right defines the right operand
  81523. * @returns the dot product
  81524. */
  81525. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  81526. /**
  81527. * Checks if the two quaternions are close to each other
  81528. * @param quat0 defines the first quaternion to check
  81529. * @param quat1 defines the second quaternion to check
  81530. * @returns true if the two quaternions are close to each other
  81531. */
  81532. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  81533. /**
  81534. * Creates an empty quaternion
  81535. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  81536. */
  81537. static Zero(): Quaternion;
  81538. /**
  81539. * Inverse a given quaternion
  81540. * @param q defines the source quaternion
  81541. * @returns a new quaternion as the inverted current quaternion
  81542. */
  81543. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  81544. /**
  81545. * Inverse a given quaternion
  81546. * @param q defines the source quaternion
  81547. * @param result the quaternion the result will be stored in
  81548. * @returns the result quaternion
  81549. */
  81550. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  81551. /**
  81552. * Creates an identity quaternion
  81553. * @returns the identity quaternion
  81554. */
  81555. static Identity(): Quaternion;
  81556. /**
  81557. * Gets a boolean indicating if the given quaternion is identity
  81558. * @param quaternion defines the quaternion to check
  81559. * @returns true if the quaternion is identity
  81560. */
  81561. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  81562. /**
  81563. * Creates a quaternion from a rotation around an axis
  81564. * @param axis defines the axis to use
  81565. * @param angle defines the angle to use
  81566. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  81567. */
  81568. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  81569. /**
  81570. * Creates a rotation around an axis and stores it into the given quaternion
  81571. * @param axis defines the axis to use
  81572. * @param angle defines the angle to use
  81573. * @param result defines the target quaternion
  81574. * @returns the target quaternion
  81575. */
  81576. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  81577. /**
  81578. * Creates a new quaternion from data stored into an array
  81579. * @param array defines the data source
  81580. * @param offset defines the offset in the source array where the data starts
  81581. * @returns a new quaternion
  81582. */
  81583. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  81584. /**
  81585. * Updates the given quaternion "result" from the starting index of the given array.
  81586. * @param array the array to pull values from
  81587. * @param offset the offset into the array to start at
  81588. * @param result the quaternion to store the result in
  81589. */
  81590. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  81591. /**
  81592. * Create a quaternion from Euler rotation angles
  81593. * @param x Pitch
  81594. * @param y Yaw
  81595. * @param z Roll
  81596. * @returns the new Quaternion
  81597. */
  81598. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  81599. /**
  81600. * Updates a quaternion from Euler rotation angles
  81601. * @param x Pitch
  81602. * @param y Yaw
  81603. * @param z Roll
  81604. * @param result the quaternion to store the result
  81605. * @returns the updated quaternion
  81606. */
  81607. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  81608. /**
  81609. * Create a quaternion from Euler rotation vector
  81610. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81611. * @returns the new Quaternion
  81612. */
  81613. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  81614. /**
  81615. * Updates a quaternion from Euler rotation vector
  81616. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81617. * @param result the quaternion to store the result
  81618. * @returns the updated quaternion
  81619. */
  81620. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  81621. /**
  81622. * Creates a new quaternion from the given Euler float angles (y, x, z)
  81623. * @param yaw defines the rotation around Y axis
  81624. * @param pitch defines the rotation around X axis
  81625. * @param roll defines the rotation around Z axis
  81626. * @returns the new quaternion
  81627. */
  81628. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  81629. /**
  81630. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  81631. * @param yaw defines the rotation around Y axis
  81632. * @param pitch defines the rotation around X axis
  81633. * @param roll defines the rotation around Z axis
  81634. * @param result defines the target quaternion
  81635. */
  81636. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  81637. /**
  81638. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  81639. * @param alpha defines the rotation around first axis
  81640. * @param beta defines the rotation around second axis
  81641. * @param gamma defines the rotation around third axis
  81642. * @returns the new quaternion
  81643. */
  81644. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  81645. /**
  81646. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  81647. * @param alpha defines the rotation around first axis
  81648. * @param beta defines the rotation around second axis
  81649. * @param gamma defines the rotation around third axis
  81650. * @param result defines the target quaternion
  81651. */
  81652. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  81653. /**
  81654. * 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)
  81655. * @param axis1 defines the first axis
  81656. * @param axis2 defines the second axis
  81657. * @param axis3 defines the third axis
  81658. * @returns the new quaternion
  81659. */
  81660. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  81661. /**
  81662. * 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
  81663. * @param axis1 defines the first axis
  81664. * @param axis2 defines the second axis
  81665. * @param axis3 defines the third axis
  81666. * @param ref defines the target quaternion
  81667. */
  81668. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  81669. /**
  81670. * Interpolates between two quaternions
  81671. * @param left defines first quaternion
  81672. * @param right defines second quaternion
  81673. * @param amount defines the gradient to use
  81674. * @returns the new interpolated quaternion
  81675. */
  81676. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81677. /**
  81678. * Interpolates between two quaternions and stores it into a target quaternion
  81679. * @param left defines first quaternion
  81680. * @param right defines second quaternion
  81681. * @param amount defines the gradient to use
  81682. * @param result defines the target quaternion
  81683. */
  81684. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  81685. /**
  81686. * Interpolate between two quaternions using Hermite interpolation
  81687. * @param value1 defines first quaternion
  81688. * @param tangent1 defines the incoming tangent
  81689. * @param value2 defines second quaternion
  81690. * @param tangent2 defines the outgoing tangent
  81691. * @param amount defines the target quaternion
  81692. * @returns the new interpolated quaternion
  81693. */
  81694. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81695. }
  81696. /**
  81697. * Class used to store matrix data (4x4)
  81698. */
  81699. export class Matrix {
  81700. private static _updateFlagSeed;
  81701. private static _identityReadOnly;
  81702. private _isIdentity;
  81703. private _isIdentityDirty;
  81704. private _isIdentity3x2;
  81705. private _isIdentity3x2Dirty;
  81706. /**
  81707. * Gets the update flag of the matrix which is an unique number for the matrix.
  81708. * It will be incremented every time the matrix data change.
  81709. * You can use it to speed the comparison between two versions of the same matrix.
  81710. */
  81711. updateFlag: number;
  81712. private readonly _m;
  81713. /**
  81714. * Gets the internal data of the matrix
  81715. */
  81716. get m(): DeepImmutable<Float32Array>;
  81717. /** @hidden */
  81718. _markAsUpdated(): void;
  81719. /** @hidden */
  81720. private _updateIdentityStatus;
  81721. /**
  81722. * Creates an empty matrix (filled with zeros)
  81723. */
  81724. constructor();
  81725. /**
  81726. * Check if the current matrix is identity
  81727. * @returns true is the matrix is the identity matrix
  81728. */
  81729. isIdentity(): boolean;
  81730. /**
  81731. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  81732. * @returns true is the matrix is the identity matrix
  81733. */
  81734. isIdentityAs3x2(): boolean;
  81735. /**
  81736. * Gets the determinant of the matrix
  81737. * @returns the matrix determinant
  81738. */
  81739. determinant(): number;
  81740. /**
  81741. * Returns the matrix as a Float32Array
  81742. * @returns the matrix underlying array
  81743. */
  81744. toArray(): DeepImmutable<Float32Array>;
  81745. /**
  81746. * Returns the matrix as a Float32Array
  81747. * @returns the matrix underlying array.
  81748. */
  81749. asArray(): DeepImmutable<Float32Array>;
  81750. /**
  81751. * Inverts the current matrix in place
  81752. * @returns the current inverted matrix
  81753. */
  81754. invert(): Matrix;
  81755. /**
  81756. * Sets all the matrix elements to zero
  81757. * @returns the current matrix
  81758. */
  81759. reset(): Matrix;
  81760. /**
  81761. * Adds the current matrix with a second one
  81762. * @param other defines the matrix to add
  81763. * @returns a new matrix as the addition of the current matrix and the given one
  81764. */
  81765. add(other: DeepImmutable<Matrix>): Matrix;
  81766. /**
  81767. * Sets the given matrix "result" to the addition of the current matrix and the given one
  81768. * @param other defines the matrix to add
  81769. * @param result defines the target matrix
  81770. * @returns the current matrix
  81771. */
  81772. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81773. /**
  81774. * Adds in place the given matrix to the current matrix
  81775. * @param other defines the second operand
  81776. * @returns the current updated matrix
  81777. */
  81778. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81779. /**
  81780. * Sets the given matrix to the current inverted Matrix
  81781. * @param other defines the target matrix
  81782. * @returns the unmodified current matrix
  81783. */
  81784. invertToRef(other: Matrix): Matrix;
  81785. /**
  81786. * add a value at the specified position in the current Matrix
  81787. * @param index the index of the value within the matrix. between 0 and 15.
  81788. * @param value the value to be added
  81789. * @returns the current updated matrix
  81790. */
  81791. addAtIndex(index: number, value: number): Matrix;
  81792. /**
  81793. * mutiply the specified position in the current Matrix by a value
  81794. * @param index the index of the value within the matrix. between 0 and 15.
  81795. * @param value the value to be added
  81796. * @returns the current updated matrix
  81797. */
  81798. multiplyAtIndex(index: number, value: number): Matrix;
  81799. /**
  81800. * Inserts the translation vector (using 3 floats) in the current matrix
  81801. * @param x defines the 1st component of the translation
  81802. * @param y defines the 2nd component of the translation
  81803. * @param z defines the 3rd component of the translation
  81804. * @returns the current updated matrix
  81805. */
  81806. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81807. /**
  81808. * Adds the translation vector (using 3 floats) in the current matrix
  81809. * @param x defines the 1st component of the translation
  81810. * @param y defines the 2nd component of the translation
  81811. * @param z defines the 3rd component of the translation
  81812. * @returns the current updated matrix
  81813. */
  81814. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81815. /**
  81816. * Inserts the translation vector in the current matrix
  81817. * @param vector3 defines the translation to insert
  81818. * @returns the current updated matrix
  81819. */
  81820. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81821. /**
  81822. * Gets the translation value of the current matrix
  81823. * @returns a new Vector3 as the extracted translation from the matrix
  81824. */
  81825. getTranslation(): Vector3;
  81826. /**
  81827. * Fill a Vector3 with the extracted translation from the matrix
  81828. * @param result defines the Vector3 where to store the translation
  81829. * @returns the current matrix
  81830. */
  81831. getTranslationToRef(result: Vector3): Matrix;
  81832. /**
  81833. * Remove rotation and scaling part from the matrix
  81834. * @returns the updated matrix
  81835. */
  81836. removeRotationAndScaling(): Matrix;
  81837. /**
  81838. * Multiply two matrices
  81839. * @param other defines the second operand
  81840. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81841. */
  81842. multiply(other: DeepImmutable<Matrix>): Matrix;
  81843. /**
  81844. * Copy the current matrix from the given one
  81845. * @param other defines the source matrix
  81846. * @returns the current updated matrix
  81847. */
  81848. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81849. /**
  81850. * Populates the given array from the starting index with the current matrix values
  81851. * @param array defines the target array
  81852. * @param offset defines the offset in the target array where to start storing values
  81853. * @returns the current matrix
  81854. */
  81855. copyToArray(array: Float32Array, offset?: number): Matrix;
  81856. /**
  81857. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  81858. * @param other defines the second operand
  81859. * @param result defines the matrix where to store the multiplication
  81860. * @returns the current matrix
  81861. */
  81862. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81863. /**
  81864. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  81865. * @param other defines the second operand
  81866. * @param result defines the array where to store the multiplication
  81867. * @param offset defines the offset in the target array where to start storing values
  81868. * @returns the current matrix
  81869. */
  81870. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  81871. /**
  81872. * Check equality between this matrix and a second one
  81873. * @param value defines the second matrix to compare
  81874. * @returns true is the current matrix and the given one values are strictly equal
  81875. */
  81876. equals(value: DeepImmutable<Matrix>): boolean;
  81877. /**
  81878. * Clone the current matrix
  81879. * @returns a new matrix from the current matrix
  81880. */
  81881. clone(): Matrix;
  81882. /**
  81883. * Returns the name of the current matrix class
  81884. * @returns the string "Matrix"
  81885. */
  81886. getClassName(): string;
  81887. /**
  81888. * Gets the hash code of the current matrix
  81889. * @returns the hash code
  81890. */
  81891. getHashCode(): number;
  81892. /**
  81893. * Decomposes the current Matrix into a translation, rotation and scaling components
  81894. * @param scale defines the scale vector3 given as a reference to update
  81895. * @param rotation defines the rotation quaternion given as a reference to update
  81896. * @param translation defines the translation vector3 given as a reference to update
  81897. * @returns true if operation was successful
  81898. */
  81899. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  81900. /**
  81901. * Gets specific row of the matrix
  81902. * @param index defines the number of the row to get
  81903. * @returns the index-th row of the current matrix as a new Vector4
  81904. */
  81905. getRow(index: number): Nullable<Vector4>;
  81906. /**
  81907. * Sets the index-th row of the current matrix to the vector4 values
  81908. * @param index defines the number of the row to set
  81909. * @param row defines the target vector4
  81910. * @returns the updated current matrix
  81911. */
  81912. setRow(index: number, row: Vector4): Matrix;
  81913. /**
  81914. * Compute the transpose of the matrix
  81915. * @returns the new transposed matrix
  81916. */
  81917. transpose(): Matrix;
  81918. /**
  81919. * Compute the transpose of the matrix and store it in a given matrix
  81920. * @param result defines the target matrix
  81921. * @returns the current matrix
  81922. */
  81923. transposeToRef(result: Matrix): Matrix;
  81924. /**
  81925. * Sets the index-th row of the current matrix with the given 4 x float values
  81926. * @param index defines the row index
  81927. * @param x defines the x component to set
  81928. * @param y defines the y component to set
  81929. * @param z defines the z component to set
  81930. * @param w defines the w component to set
  81931. * @returns the updated current matrix
  81932. */
  81933. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  81934. /**
  81935. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  81936. * @param scale defines the scale factor
  81937. * @returns a new matrix
  81938. */
  81939. scale(scale: number): Matrix;
  81940. /**
  81941. * Scale the current matrix values by a factor to a given result matrix
  81942. * @param scale defines the scale factor
  81943. * @param result defines the matrix to store the result
  81944. * @returns the current matrix
  81945. */
  81946. scaleToRef(scale: number, result: Matrix): Matrix;
  81947. /**
  81948. * Scale the current matrix values by a factor and add the result to a given matrix
  81949. * @param scale defines the scale factor
  81950. * @param result defines the Matrix to store the result
  81951. * @returns the current matrix
  81952. */
  81953. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  81954. /**
  81955. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  81956. * @param ref matrix to store the result
  81957. */
  81958. toNormalMatrix(ref: Matrix): void;
  81959. /**
  81960. * Gets only rotation part of the current matrix
  81961. * @returns a new matrix sets to the extracted rotation matrix from the current one
  81962. */
  81963. getRotationMatrix(): Matrix;
  81964. /**
  81965. * Extracts the rotation matrix from the current one and sets it as the given "result"
  81966. * @param result defines the target matrix to store data to
  81967. * @returns the current matrix
  81968. */
  81969. getRotationMatrixToRef(result: Matrix): Matrix;
  81970. /**
  81971. * Toggles model matrix from being right handed to left handed in place and vice versa
  81972. */
  81973. toggleModelMatrixHandInPlace(): void;
  81974. /**
  81975. * Toggles projection matrix from being right handed to left handed in place and vice versa
  81976. */
  81977. toggleProjectionMatrixHandInPlace(): void;
  81978. /**
  81979. * Creates a matrix from an array
  81980. * @param array defines the source array
  81981. * @param offset defines an offset in the source array
  81982. * @returns a new Matrix set from the starting index of the given array
  81983. */
  81984. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  81985. /**
  81986. * Copy the content of an array into a given matrix
  81987. * @param array defines the source array
  81988. * @param offset defines an offset in the source array
  81989. * @param result defines the target matrix
  81990. */
  81991. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  81992. /**
  81993. * Stores an array into a matrix after having multiplied each component by a given factor
  81994. * @param array defines the source array
  81995. * @param offset defines the offset in the source array
  81996. * @param scale defines the scaling factor
  81997. * @param result defines the target matrix
  81998. */
  81999. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  82000. /**
  82001. * Gets an identity matrix that must not be updated
  82002. */
  82003. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82004. /**
  82005. * Stores a list of values (16) inside a given matrix
  82006. * @param initialM11 defines 1st value of 1st row
  82007. * @param initialM12 defines 2nd value of 1st row
  82008. * @param initialM13 defines 3rd value of 1st row
  82009. * @param initialM14 defines 4th value of 1st row
  82010. * @param initialM21 defines 1st value of 2nd row
  82011. * @param initialM22 defines 2nd value of 2nd row
  82012. * @param initialM23 defines 3rd value of 2nd row
  82013. * @param initialM24 defines 4th value of 2nd row
  82014. * @param initialM31 defines 1st value of 3rd row
  82015. * @param initialM32 defines 2nd value of 3rd row
  82016. * @param initialM33 defines 3rd value of 3rd row
  82017. * @param initialM34 defines 4th value of 3rd row
  82018. * @param initialM41 defines 1st value of 4th row
  82019. * @param initialM42 defines 2nd value of 4th row
  82020. * @param initialM43 defines 3rd value of 4th row
  82021. * @param initialM44 defines 4th value of 4th row
  82022. * @param result defines the target matrix
  82023. */
  82024. 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;
  82025. /**
  82026. * Creates new matrix from a list of values (16)
  82027. * @param initialM11 defines 1st value of 1st row
  82028. * @param initialM12 defines 2nd value of 1st row
  82029. * @param initialM13 defines 3rd value of 1st row
  82030. * @param initialM14 defines 4th value of 1st row
  82031. * @param initialM21 defines 1st value of 2nd row
  82032. * @param initialM22 defines 2nd value of 2nd row
  82033. * @param initialM23 defines 3rd value of 2nd row
  82034. * @param initialM24 defines 4th value of 2nd row
  82035. * @param initialM31 defines 1st value of 3rd row
  82036. * @param initialM32 defines 2nd value of 3rd row
  82037. * @param initialM33 defines 3rd value of 3rd row
  82038. * @param initialM34 defines 4th value of 3rd row
  82039. * @param initialM41 defines 1st value of 4th row
  82040. * @param initialM42 defines 2nd value of 4th row
  82041. * @param initialM43 defines 3rd value of 4th row
  82042. * @param initialM44 defines 4th value of 4th row
  82043. * @returns the new matrix
  82044. */
  82045. 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;
  82046. /**
  82047. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82048. * @param scale defines the scale vector3
  82049. * @param rotation defines the rotation quaternion
  82050. * @param translation defines the translation vector3
  82051. * @returns a new matrix
  82052. */
  82053. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82054. /**
  82055. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82056. * @param scale defines the scale vector3
  82057. * @param rotation defines the rotation quaternion
  82058. * @param translation defines the translation vector3
  82059. * @param result defines the target matrix
  82060. */
  82061. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82062. /**
  82063. * Creates a new identity matrix
  82064. * @returns a new identity matrix
  82065. */
  82066. static Identity(): Matrix;
  82067. /**
  82068. * Creates a new identity matrix and stores the result in a given matrix
  82069. * @param result defines the target matrix
  82070. */
  82071. static IdentityToRef(result: Matrix): void;
  82072. /**
  82073. * Creates a new zero matrix
  82074. * @returns a new zero matrix
  82075. */
  82076. static Zero(): Matrix;
  82077. /**
  82078. * Creates a new rotation matrix for "angle" radians around the X axis
  82079. * @param angle defines the angle (in radians) to use
  82080. * @return the new matrix
  82081. */
  82082. static RotationX(angle: number): Matrix;
  82083. /**
  82084. * Creates a new matrix as the invert of a given matrix
  82085. * @param source defines the source matrix
  82086. * @returns the new matrix
  82087. */
  82088. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82089. /**
  82090. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82091. * @param angle defines the angle (in radians) to use
  82092. * @param result defines the target matrix
  82093. */
  82094. static RotationXToRef(angle: number, result: Matrix): void;
  82095. /**
  82096. * Creates a new rotation matrix for "angle" radians around the Y axis
  82097. * @param angle defines the angle (in radians) to use
  82098. * @return the new matrix
  82099. */
  82100. static RotationY(angle: number): Matrix;
  82101. /**
  82102. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82103. * @param angle defines the angle (in radians) to use
  82104. * @param result defines the target matrix
  82105. */
  82106. static RotationYToRef(angle: number, result: Matrix): void;
  82107. /**
  82108. * Creates a new rotation matrix for "angle" radians around the Z axis
  82109. * @param angle defines the angle (in radians) to use
  82110. * @return the new matrix
  82111. */
  82112. static RotationZ(angle: number): Matrix;
  82113. /**
  82114. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82115. * @param angle defines the angle (in radians) to use
  82116. * @param result defines the target matrix
  82117. */
  82118. static RotationZToRef(angle: number, result: Matrix): void;
  82119. /**
  82120. * Creates a new rotation matrix for "angle" radians around the given axis
  82121. * @param axis defines the axis to use
  82122. * @param angle defines the angle (in radians) to use
  82123. * @return the new matrix
  82124. */
  82125. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82126. /**
  82127. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82128. * @param axis defines the axis to use
  82129. * @param angle defines the angle (in radians) to use
  82130. * @param result defines the target matrix
  82131. */
  82132. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82133. /**
  82134. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82135. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82136. * @param from defines the vector to align
  82137. * @param to defines the vector to align to
  82138. * @param result defines the target matrix
  82139. */
  82140. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82141. /**
  82142. * Creates a rotation matrix
  82143. * @param yaw defines the yaw angle in radians (Y axis)
  82144. * @param pitch defines the pitch angle in radians (X axis)
  82145. * @param roll defines the roll angle in radians (X axis)
  82146. * @returns the new rotation matrix
  82147. */
  82148. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82149. /**
  82150. * Creates a rotation matrix and stores it in a given matrix
  82151. * @param yaw defines the yaw angle in radians (Y axis)
  82152. * @param pitch defines the pitch angle in radians (X axis)
  82153. * @param roll defines the roll angle in radians (X axis)
  82154. * @param result defines the target matrix
  82155. */
  82156. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82157. /**
  82158. * Creates a scaling matrix
  82159. * @param x defines the scale factor on X axis
  82160. * @param y defines the scale factor on Y axis
  82161. * @param z defines the scale factor on Z axis
  82162. * @returns the new matrix
  82163. */
  82164. static Scaling(x: number, y: number, z: number): Matrix;
  82165. /**
  82166. * Creates a scaling matrix and stores it in a given matrix
  82167. * @param x defines the scale factor on X axis
  82168. * @param y defines the scale factor on Y axis
  82169. * @param z defines the scale factor on Z axis
  82170. * @param result defines the target matrix
  82171. */
  82172. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82173. /**
  82174. * Creates a translation matrix
  82175. * @param x defines the translation on X axis
  82176. * @param y defines the translation on Y axis
  82177. * @param z defines the translationon Z axis
  82178. * @returns the new matrix
  82179. */
  82180. static Translation(x: number, y: number, z: number): Matrix;
  82181. /**
  82182. * Creates a translation matrix and stores it in a given matrix
  82183. * @param x defines the translation on X axis
  82184. * @param y defines the translation on Y axis
  82185. * @param z defines the translationon Z axis
  82186. * @param result defines the target matrix
  82187. */
  82188. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82189. /**
  82190. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82191. * @param startValue defines the start value
  82192. * @param endValue defines the end value
  82193. * @param gradient defines the gradient factor
  82194. * @returns the new matrix
  82195. */
  82196. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82197. /**
  82198. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82199. * @param startValue defines the start value
  82200. * @param endValue defines the end value
  82201. * @param gradient defines the gradient factor
  82202. * @param result defines the Matrix object where to store data
  82203. */
  82204. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82205. /**
  82206. * Builds a new matrix whose values are computed by:
  82207. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82208. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82209. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82210. * @param startValue defines the first matrix
  82211. * @param endValue defines the second matrix
  82212. * @param gradient defines the gradient between the two matrices
  82213. * @returns the new matrix
  82214. */
  82215. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82216. /**
  82217. * Update a matrix to values which are computed by:
  82218. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82219. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82220. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82221. * @param startValue defines the first matrix
  82222. * @param endValue defines the second matrix
  82223. * @param gradient defines the gradient between the two matrices
  82224. * @param result defines the target matrix
  82225. */
  82226. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82227. /**
  82228. * 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"
  82229. * This function works in left handed mode
  82230. * @param eye defines the final position of the entity
  82231. * @param target defines where the entity should look at
  82232. * @param up defines the up vector for the entity
  82233. * @returns the new matrix
  82234. */
  82235. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82236. /**
  82237. * 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".
  82238. * This function works in left handed mode
  82239. * @param eye defines the final position of the entity
  82240. * @param target defines where the entity should look at
  82241. * @param up defines the up vector for the entity
  82242. * @param result defines the target matrix
  82243. */
  82244. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82245. /**
  82246. * 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"
  82247. * This function works in right handed mode
  82248. * @param eye defines the final position of the entity
  82249. * @param target defines where the entity should look at
  82250. * @param up defines the up vector for the entity
  82251. * @returns the new matrix
  82252. */
  82253. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82254. /**
  82255. * 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".
  82256. * This function works in right handed mode
  82257. * @param eye defines the final position of the entity
  82258. * @param target defines where the entity should look at
  82259. * @param up defines the up vector for the entity
  82260. * @param result defines the target matrix
  82261. */
  82262. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82263. /**
  82264. * Create a left-handed orthographic projection matrix
  82265. * @param width defines the viewport width
  82266. * @param height defines the viewport height
  82267. * @param znear defines the near clip plane
  82268. * @param zfar defines the far clip plane
  82269. * @returns a new matrix as a left-handed orthographic projection matrix
  82270. */
  82271. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82272. /**
  82273. * Store a left-handed orthographic projection to a given matrix
  82274. * @param width defines the viewport width
  82275. * @param height defines the viewport height
  82276. * @param znear defines the near clip plane
  82277. * @param zfar defines the far clip plane
  82278. * @param result defines the target matrix
  82279. */
  82280. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82281. /**
  82282. * Create a left-handed orthographic projection matrix
  82283. * @param left defines the viewport left coordinate
  82284. * @param right defines the viewport right coordinate
  82285. * @param bottom defines the viewport bottom coordinate
  82286. * @param top defines the viewport top coordinate
  82287. * @param znear defines the near clip plane
  82288. * @param zfar defines the far clip plane
  82289. * @returns a new matrix as a left-handed orthographic projection matrix
  82290. */
  82291. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82292. /**
  82293. * Stores a left-handed orthographic projection into a given matrix
  82294. * @param left defines the viewport left coordinate
  82295. * @param right defines the viewport right coordinate
  82296. * @param bottom defines the viewport bottom coordinate
  82297. * @param top defines the viewport top coordinate
  82298. * @param znear defines the near clip plane
  82299. * @param zfar defines the far clip plane
  82300. * @param result defines the target matrix
  82301. */
  82302. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82303. /**
  82304. * Creates a right-handed orthographic projection matrix
  82305. * @param left defines the viewport left coordinate
  82306. * @param right defines the viewport right coordinate
  82307. * @param bottom defines the viewport bottom coordinate
  82308. * @param top defines the viewport top coordinate
  82309. * @param znear defines the near clip plane
  82310. * @param zfar defines the far clip plane
  82311. * @returns a new matrix as a right-handed orthographic projection matrix
  82312. */
  82313. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82314. /**
  82315. * Stores a right-handed orthographic projection into a given matrix
  82316. * @param left defines the viewport left coordinate
  82317. * @param right defines the viewport right coordinate
  82318. * @param bottom defines the viewport bottom coordinate
  82319. * @param top defines the viewport top coordinate
  82320. * @param znear defines the near clip plane
  82321. * @param zfar defines the far clip plane
  82322. * @param result defines the target matrix
  82323. */
  82324. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82325. /**
  82326. * Creates a left-handed perspective projection matrix
  82327. * @param width defines the viewport width
  82328. * @param height defines the viewport height
  82329. * @param znear defines the near clip plane
  82330. * @param zfar defines the far clip plane
  82331. * @returns a new matrix as a left-handed perspective projection matrix
  82332. */
  82333. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82334. /**
  82335. * Creates a left-handed perspective projection matrix
  82336. * @param fov defines the horizontal field of view
  82337. * @param aspect defines the aspect ratio
  82338. * @param znear defines the near clip plane
  82339. * @param zfar defines the far clip plane
  82340. * @returns a new matrix as a left-handed perspective projection matrix
  82341. */
  82342. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82343. /**
  82344. * Stores a left-handed perspective projection into a given matrix
  82345. * @param fov defines the horizontal field of view
  82346. * @param aspect defines the aspect ratio
  82347. * @param znear defines the near clip plane
  82348. * @param zfar defines the far clip plane
  82349. * @param result defines the target matrix
  82350. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82351. */
  82352. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82353. /**
  82354. * Stores a left-handed perspective projection into a given matrix with depth reversed
  82355. * @param fov defines the horizontal field of view
  82356. * @param aspect defines the aspect ratio
  82357. * @param znear defines the near clip plane
  82358. * @param zfar not used as infinity is used as far clip
  82359. * @param result defines the target matrix
  82360. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82361. */
  82362. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82363. /**
  82364. * Creates a right-handed perspective projection matrix
  82365. * @param fov defines the horizontal field of view
  82366. * @param aspect defines the aspect ratio
  82367. * @param znear defines the near clip plane
  82368. * @param zfar defines the far clip plane
  82369. * @returns a new matrix as a right-handed perspective projection matrix
  82370. */
  82371. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82372. /**
  82373. * Stores a right-handed perspective projection into a given matrix
  82374. * @param fov defines the horizontal field of view
  82375. * @param aspect defines the aspect ratio
  82376. * @param znear defines the near clip plane
  82377. * @param zfar defines the far clip plane
  82378. * @param result defines the target matrix
  82379. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82380. */
  82381. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82382. /**
  82383. * Stores a right-handed perspective projection into a given matrix
  82384. * @param fov defines the horizontal field of view
  82385. * @param aspect defines the aspect ratio
  82386. * @param znear defines the near clip plane
  82387. * @param zfar not used as infinity is used as far clip
  82388. * @param result defines the target matrix
  82389. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82390. */
  82391. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82392. /**
  82393. * Stores a perspective projection for WebVR info a given matrix
  82394. * @param fov defines the field of view
  82395. * @param znear defines the near clip plane
  82396. * @param zfar defines the far clip plane
  82397. * @param result defines the target matrix
  82398. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  82399. */
  82400. static PerspectiveFovWebVRToRef(fov: {
  82401. upDegrees: number;
  82402. downDegrees: number;
  82403. leftDegrees: number;
  82404. rightDegrees: number;
  82405. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  82406. /**
  82407. * Computes a complete transformation matrix
  82408. * @param viewport defines the viewport to use
  82409. * @param world defines the world matrix
  82410. * @param view defines the view matrix
  82411. * @param projection defines the projection matrix
  82412. * @param zmin defines the near clip plane
  82413. * @param zmax defines the far clip plane
  82414. * @returns the transformation matrix
  82415. */
  82416. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82417. /**
  82418. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82419. * @param matrix defines the matrix to use
  82420. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82421. */
  82422. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82423. /**
  82424. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82425. * @param matrix defines the matrix to use
  82426. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82427. */
  82428. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82429. /**
  82430. * Compute the transpose of a given matrix
  82431. * @param matrix defines the matrix to transpose
  82432. * @returns the new matrix
  82433. */
  82434. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82435. /**
  82436. * Compute the transpose of a matrix and store it in a target matrix
  82437. * @param matrix defines the matrix to transpose
  82438. * @param result defines the target matrix
  82439. */
  82440. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82441. /**
  82442. * Computes a reflection matrix from a plane
  82443. * @param plane defines the reflection plane
  82444. * @returns a new matrix
  82445. */
  82446. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82447. /**
  82448. * Computes a reflection matrix from a plane
  82449. * @param plane defines the reflection plane
  82450. * @param result defines the target matrix
  82451. */
  82452. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82453. /**
  82454. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82455. * @param xaxis defines the value of the 1st axis
  82456. * @param yaxis defines the value of the 2nd axis
  82457. * @param zaxis defines the value of the 3rd axis
  82458. * @param result defines the target matrix
  82459. */
  82460. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82461. /**
  82462. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82463. * @param quat defines the quaternion to use
  82464. * @param result defines the target matrix
  82465. */
  82466. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82467. }
  82468. /**
  82469. * @hidden
  82470. */
  82471. export class TmpVectors {
  82472. static Vector2: Vector2[];
  82473. static Vector3: Vector3[];
  82474. static Vector4: Vector4[];
  82475. static Quaternion: Quaternion[];
  82476. static Matrix: Matrix[];
  82477. }
  82478. }
  82479. declare module BABYLON {
  82480. /**
  82481. * Defines potential orientation for back face culling
  82482. */
  82483. export enum Orientation {
  82484. /**
  82485. * Clockwise
  82486. */
  82487. CW = 0,
  82488. /** Counter clockwise */
  82489. CCW = 1
  82490. }
  82491. /** Class used to represent a Bezier curve */
  82492. export class BezierCurve {
  82493. /**
  82494. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  82495. * @param t defines the time
  82496. * @param x1 defines the left coordinate on X axis
  82497. * @param y1 defines the left coordinate on Y axis
  82498. * @param x2 defines the right coordinate on X axis
  82499. * @param y2 defines the right coordinate on Y axis
  82500. * @returns the interpolated value
  82501. */
  82502. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  82503. }
  82504. /**
  82505. * Defines angle representation
  82506. */
  82507. export class Angle {
  82508. private _radians;
  82509. /**
  82510. * Creates an Angle object of "radians" radians (float).
  82511. * @param radians the angle in radians
  82512. */
  82513. constructor(radians: number);
  82514. /**
  82515. * Get value in degrees
  82516. * @returns the Angle value in degrees (float)
  82517. */
  82518. degrees(): number;
  82519. /**
  82520. * Get value in radians
  82521. * @returns the Angle value in radians (float)
  82522. */
  82523. radians(): number;
  82524. /**
  82525. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  82526. * @param a defines first vector
  82527. * @param b defines second vector
  82528. * @returns a new Angle
  82529. */
  82530. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  82531. /**
  82532. * Gets a new Angle object from the given float in radians
  82533. * @param radians defines the angle value in radians
  82534. * @returns a new Angle
  82535. */
  82536. static FromRadians(radians: number): Angle;
  82537. /**
  82538. * Gets a new Angle object from the given float in degrees
  82539. * @param degrees defines the angle value in degrees
  82540. * @returns a new Angle
  82541. */
  82542. static FromDegrees(degrees: number): Angle;
  82543. }
  82544. /**
  82545. * This represents an arc in a 2d space.
  82546. */
  82547. export class Arc2 {
  82548. /** Defines the start point of the arc */
  82549. startPoint: Vector2;
  82550. /** Defines the mid point of the arc */
  82551. midPoint: Vector2;
  82552. /** Defines the end point of the arc */
  82553. endPoint: Vector2;
  82554. /**
  82555. * Defines the center point of the arc.
  82556. */
  82557. centerPoint: Vector2;
  82558. /**
  82559. * Defines the radius of the arc.
  82560. */
  82561. radius: number;
  82562. /**
  82563. * Defines the angle of the arc (from mid point to end point).
  82564. */
  82565. angle: Angle;
  82566. /**
  82567. * Defines the start angle of the arc (from start point to middle point).
  82568. */
  82569. startAngle: Angle;
  82570. /**
  82571. * Defines the orientation of the arc (clock wise/counter clock wise).
  82572. */
  82573. orientation: Orientation;
  82574. /**
  82575. * Creates an Arc object from the three given points : start, middle and end.
  82576. * @param startPoint Defines the start point of the arc
  82577. * @param midPoint Defines the midlle point of the arc
  82578. * @param endPoint Defines the end point of the arc
  82579. */
  82580. constructor(
  82581. /** Defines the start point of the arc */
  82582. startPoint: Vector2,
  82583. /** Defines the mid point of the arc */
  82584. midPoint: Vector2,
  82585. /** Defines the end point of the arc */
  82586. endPoint: Vector2);
  82587. }
  82588. /**
  82589. * Represents a 2D path made up of multiple 2D points
  82590. */
  82591. export class Path2 {
  82592. private _points;
  82593. private _length;
  82594. /**
  82595. * If the path start and end point are the same
  82596. */
  82597. closed: boolean;
  82598. /**
  82599. * Creates a Path2 object from the starting 2D coordinates x and y.
  82600. * @param x the starting points x value
  82601. * @param y the starting points y value
  82602. */
  82603. constructor(x: number, y: number);
  82604. /**
  82605. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  82606. * @param x the added points x value
  82607. * @param y the added points y value
  82608. * @returns the updated Path2.
  82609. */
  82610. addLineTo(x: number, y: number): Path2;
  82611. /**
  82612. * 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.
  82613. * @param midX middle point x value
  82614. * @param midY middle point y value
  82615. * @param endX end point x value
  82616. * @param endY end point y value
  82617. * @param numberOfSegments (default: 36)
  82618. * @returns the updated Path2.
  82619. */
  82620. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  82621. /**
  82622. * Closes the Path2.
  82623. * @returns the Path2.
  82624. */
  82625. close(): Path2;
  82626. /**
  82627. * Gets the sum of the distance between each sequential point in the path
  82628. * @returns the Path2 total length (float).
  82629. */
  82630. length(): number;
  82631. /**
  82632. * Gets the points which construct the path
  82633. * @returns the Path2 internal array of points.
  82634. */
  82635. getPoints(): Vector2[];
  82636. /**
  82637. * Retreives the point at the distance aways from the starting point
  82638. * @param normalizedLengthPosition the length along the path to retreive the point from
  82639. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  82640. */
  82641. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  82642. /**
  82643. * Creates a new path starting from an x and y position
  82644. * @param x starting x value
  82645. * @param y starting y value
  82646. * @returns a new Path2 starting at the coordinates (x, y).
  82647. */
  82648. static StartingAt(x: number, y: number): Path2;
  82649. }
  82650. /**
  82651. * Represents a 3D path made up of multiple 3D points
  82652. */
  82653. export class Path3D {
  82654. /**
  82655. * an array of Vector3, the curve axis of the Path3D
  82656. */
  82657. path: Vector3[];
  82658. private _curve;
  82659. private _distances;
  82660. private _tangents;
  82661. private _normals;
  82662. private _binormals;
  82663. private _raw;
  82664. private _alignTangentsWithPath;
  82665. private readonly _pointAtData;
  82666. /**
  82667. * new Path3D(path, normal, raw)
  82668. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  82669. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  82670. * @param path an array of Vector3, the curve axis of the Path3D
  82671. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  82672. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  82673. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  82674. */
  82675. constructor(
  82676. /**
  82677. * an array of Vector3, the curve axis of the Path3D
  82678. */
  82679. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  82680. /**
  82681. * Returns the Path3D array of successive Vector3 designing its curve.
  82682. * @returns the Path3D array of successive Vector3 designing its curve.
  82683. */
  82684. getCurve(): Vector3[];
  82685. /**
  82686. * Returns the Path3D array of successive Vector3 designing its curve.
  82687. * @returns the Path3D array of successive Vector3 designing its curve.
  82688. */
  82689. getPoints(): Vector3[];
  82690. /**
  82691. * @returns the computed length (float) of the path.
  82692. */
  82693. length(): number;
  82694. /**
  82695. * Returns an array populated with tangent vectors on each Path3D curve point.
  82696. * @returns an array populated with tangent vectors on each Path3D curve point.
  82697. */
  82698. getTangents(): Vector3[];
  82699. /**
  82700. * Returns an array populated with normal vectors on each Path3D curve point.
  82701. * @returns an array populated with normal vectors on each Path3D curve point.
  82702. */
  82703. getNormals(): Vector3[];
  82704. /**
  82705. * Returns an array populated with binormal vectors on each Path3D curve point.
  82706. * @returns an array populated with binormal vectors on each Path3D curve point.
  82707. */
  82708. getBinormals(): Vector3[];
  82709. /**
  82710. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  82711. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  82712. */
  82713. getDistances(): number[];
  82714. /**
  82715. * Returns an interpolated point along this path
  82716. * @param position the position of the point along this path, from 0.0 to 1.0
  82717. * @returns a new Vector3 as the point
  82718. */
  82719. getPointAt(position: number): Vector3;
  82720. /**
  82721. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82722. * @param position the position of the point along this path, from 0.0 to 1.0
  82723. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  82724. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  82725. */
  82726. getTangentAt(position: number, interpolated?: boolean): Vector3;
  82727. /**
  82728. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82729. * @param position the position of the point along this path, from 0.0 to 1.0
  82730. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  82731. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  82732. */
  82733. getNormalAt(position: number, interpolated?: boolean): Vector3;
  82734. /**
  82735. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  82736. * @param position the position of the point along this path, from 0.0 to 1.0
  82737. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  82738. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  82739. */
  82740. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  82741. /**
  82742. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  82743. * @param position the position of the point along this path, from 0.0 to 1.0
  82744. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  82745. */
  82746. getDistanceAt(position: number): number;
  82747. /**
  82748. * Returns the array index of the previous point of an interpolated point along this path
  82749. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82750. * @returns the array index
  82751. */
  82752. getPreviousPointIndexAt(position: number): number;
  82753. /**
  82754. * 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)
  82755. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82756. * @returns the sub position
  82757. */
  82758. getSubPositionAt(position: number): number;
  82759. /**
  82760. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  82761. * @param target the vector of which to get the closest position to
  82762. * @returns the position of the closest virtual point on this path to the target vector
  82763. */
  82764. getClosestPositionTo(target: Vector3): number;
  82765. /**
  82766. * Returns a sub path (slice) of this path
  82767. * @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
  82768. * @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
  82769. * @returns a sub path (slice) of this path
  82770. */
  82771. slice(start?: number, end?: number): Path3D;
  82772. /**
  82773. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82774. * @param path path which all values are copied into the curves points
  82775. * @param firstNormal which should be projected onto the curve
  82776. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82777. * @returns the same object updated.
  82778. */
  82779. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82780. private _compute;
  82781. private _getFirstNonNullVector;
  82782. private _getLastNonNullVector;
  82783. private _normalVector;
  82784. /**
  82785. * Updates the point at data for an interpolated point along this curve
  82786. * @param position the position of the point along this curve, from 0.0 to 1.0
  82787. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82788. * @returns the (updated) point at data
  82789. */
  82790. private _updatePointAtData;
  82791. /**
  82792. * Updates the point at data from the specified parameters
  82793. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82794. * @param point the interpolated point
  82795. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82796. */
  82797. private _setPointAtData;
  82798. /**
  82799. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82800. */
  82801. private _updateInterpolationMatrix;
  82802. }
  82803. /**
  82804. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82805. * A Curve3 is designed from a series of successive Vector3.
  82806. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82807. */
  82808. export class Curve3 {
  82809. private _points;
  82810. private _length;
  82811. /**
  82812. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82813. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82814. * @param v1 (Vector3) the control point
  82815. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82816. * @param nbPoints (integer) the wanted number of points in the curve
  82817. * @returns the created Curve3
  82818. */
  82819. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82820. /**
  82821. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82822. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82823. * @param v1 (Vector3) the first control point
  82824. * @param v2 (Vector3) the second control point
  82825. * @param v3 (Vector3) the end point of the Cubic Bezier
  82826. * @param nbPoints (integer) the wanted number of points in the curve
  82827. * @returns the created Curve3
  82828. */
  82829. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82830. /**
  82831. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82832. * @param p1 (Vector3) the origin point of the Hermite Spline
  82833. * @param t1 (Vector3) the tangent vector at the origin point
  82834. * @param p2 (Vector3) the end point of the Hermite Spline
  82835. * @param t2 (Vector3) the tangent vector at the end point
  82836. * @param nbPoints (integer) the wanted number of points in the curve
  82837. * @returns the created Curve3
  82838. */
  82839. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82840. /**
  82841. * Returns a Curve3 object along a CatmullRom Spline curve :
  82842. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82843. * @param nbPoints (integer) the wanted number of points between each curve control points
  82844. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82845. * @returns the created Curve3
  82846. */
  82847. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82848. /**
  82849. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82850. * A Curve3 is designed from a series of successive Vector3.
  82851. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82852. * @param points points which make up the curve
  82853. */
  82854. constructor(points: Vector3[]);
  82855. /**
  82856. * @returns the Curve3 stored array of successive Vector3
  82857. */
  82858. getPoints(): Vector3[];
  82859. /**
  82860. * @returns the computed length (float) of the curve.
  82861. */
  82862. length(): number;
  82863. /**
  82864. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82865. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82866. * curveA and curveB keep unchanged.
  82867. * @param curve the curve to continue from this curve
  82868. * @returns the newly constructed curve
  82869. */
  82870. continue(curve: DeepImmutable<Curve3>): Curve3;
  82871. private _computeLength;
  82872. }
  82873. }
  82874. declare module BABYLON {
  82875. /**
  82876. * This represents the main contract an easing function should follow.
  82877. * Easing functions are used throughout the animation system.
  82878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82879. */
  82880. export interface IEasingFunction {
  82881. /**
  82882. * Given an input gradient between 0 and 1, this returns the corrseponding value
  82883. * of the easing function.
  82884. * The link below provides some of the most common examples of easing functions.
  82885. * @see https://easings.net/
  82886. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82887. * @returns the corresponding value on the curve defined by the easing function
  82888. */
  82889. ease(gradient: number): number;
  82890. }
  82891. /**
  82892. * Base class used for every default easing function.
  82893. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82894. */
  82895. export class EasingFunction implements IEasingFunction {
  82896. /**
  82897. * Interpolation follows the mathematical formula associated with the easing function.
  82898. */
  82899. static readonly EASINGMODE_EASEIN: number;
  82900. /**
  82901. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  82902. */
  82903. static readonly EASINGMODE_EASEOUT: number;
  82904. /**
  82905. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  82906. */
  82907. static readonly EASINGMODE_EASEINOUT: number;
  82908. private _easingMode;
  82909. /**
  82910. * Sets the easing mode of the current function.
  82911. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  82912. */
  82913. setEasingMode(easingMode: number): void;
  82914. /**
  82915. * Gets the current easing mode.
  82916. * @returns the easing mode
  82917. */
  82918. getEasingMode(): number;
  82919. /**
  82920. * @hidden
  82921. */
  82922. easeInCore(gradient: number): number;
  82923. /**
  82924. * Given an input gradient between 0 and 1, this returns the corresponding value
  82925. * of the easing function.
  82926. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82927. * @returns the corresponding value on the curve defined by the easing function
  82928. */
  82929. ease(gradient: number): number;
  82930. }
  82931. /**
  82932. * Easing function with a circle shape (see link below).
  82933. * @see https://easings.net/#easeInCirc
  82934. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82935. */
  82936. export class CircleEase extends EasingFunction implements IEasingFunction {
  82937. /** @hidden */
  82938. easeInCore(gradient: number): number;
  82939. }
  82940. /**
  82941. * Easing function with a ease back shape (see link below).
  82942. * @see https://easings.net/#easeInBack
  82943. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82944. */
  82945. export class BackEase extends EasingFunction implements IEasingFunction {
  82946. /** Defines the amplitude of the function */
  82947. amplitude: number;
  82948. /**
  82949. * Instantiates a back ease easing
  82950. * @see https://easings.net/#easeInBack
  82951. * @param amplitude Defines the amplitude of the function
  82952. */
  82953. constructor(
  82954. /** Defines the amplitude of the function */
  82955. amplitude?: number);
  82956. /** @hidden */
  82957. easeInCore(gradient: number): number;
  82958. }
  82959. /**
  82960. * Easing function with a bouncing shape (see link below).
  82961. * @see https://easings.net/#easeInBounce
  82962. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82963. */
  82964. export class BounceEase extends EasingFunction implements IEasingFunction {
  82965. /** Defines the number of bounces */
  82966. bounces: number;
  82967. /** Defines the amplitude of the bounce */
  82968. bounciness: number;
  82969. /**
  82970. * Instantiates a bounce easing
  82971. * @see https://easings.net/#easeInBounce
  82972. * @param bounces Defines the number of bounces
  82973. * @param bounciness Defines the amplitude of the bounce
  82974. */
  82975. constructor(
  82976. /** Defines the number of bounces */
  82977. bounces?: number,
  82978. /** Defines the amplitude of the bounce */
  82979. bounciness?: number);
  82980. /** @hidden */
  82981. easeInCore(gradient: number): number;
  82982. }
  82983. /**
  82984. * Easing function with a power of 3 shape (see link below).
  82985. * @see https://easings.net/#easeInCubic
  82986. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82987. */
  82988. export class CubicEase extends EasingFunction implements IEasingFunction {
  82989. /** @hidden */
  82990. easeInCore(gradient: number): number;
  82991. }
  82992. /**
  82993. * Easing function with an elastic shape (see link below).
  82994. * @see https://easings.net/#easeInElastic
  82995. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82996. */
  82997. export class ElasticEase extends EasingFunction implements IEasingFunction {
  82998. /** Defines the number of oscillations*/
  82999. oscillations: number;
  83000. /** Defines the amplitude of the oscillations*/
  83001. springiness: number;
  83002. /**
  83003. * Instantiates an elastic easing function
  83004. * @see https://easings.net/#easeInElastic
  83005. * @param oscillations Defines the number of oscillations
  83006. * @param springiness Defines the amplitude of the oscillations
  83007. */
  83008. constructor(
  83009. /** Defines the number of oscillations*/
  83010. oscillations?: number,
  83011. /** Defines the amplitude of the oscillations*/
  83012. springiness?: number);
  83013. /** @hidden */
  83014. easeInCore(gradient: number): number;
  83015. }
  83016. /**
  83017. * Easing function with an exponential shape (see link below).
  83018. * @see https://easings.net/#easeInExpo
  83019. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83020. */
  83021. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83022. /** Defines the exponent of the function */
  83023. exponent: number;
  83024. /**
  83025. * Instantiates an exponential easing function
  83026. * @see https://easings.net/#easeInExpo
  83027. * @param exponent Defines the exponent of the function
  83028. */
  83029. constructor(
  83030. /** Defines the exponent of the function */
  83031. exponent?: number);
  83032. /** @hidden */
  83033. easeInCore(gradient: number): number;
  83034. }
  83035. /**
  83036. * Easing function with a power shape (see link below).
  83037. * @see https://easings.net/#easeInQuad
  83038. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83039. */
  83040. export class PowerEase extends EasingFunction implements IEasingFunction {
  83041. /** Defines the power of the function */
  83042. power: number;
  83043. /**
  83044. * Instantiates an power base easing function
  83045. * @see https://easings.net/#easeInQuad
  83046. * @param power Defines the power of the function
  83047. */
  83048. constructor(
  83049. /** Defines the power of the function */
  83050. power?: number);
  83051. /** @hidden */
  83052. easeInCore(gradient: number): number;
  83053. }
  83054. /**
  83055. * Easing function with a power of 2 shape (see link below).
  83056. * @see https://easings.net/#easeInQuad
  83057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83058. */
  83059. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83060. /** @hidden */
  83061. easeInCore(gradient: number): number;
  83062. }
  83063. /**
  83064. * Easing function with a power of 4 shape (see link below).
  83065. * @see https://easings.net/#easeInQuart
  83066. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83067. */
  83068. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83069. /** @hidden */
  83070. easeInCore(gradient: number): number;
  83071. }
  83072. /**
  83073. * Easing function with a power of 5 shape (see link below).
  83074. * @see https://easings.net/#easeInQuint
  83075. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83076. */
  83077. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83078. /** @hidden */
  83079. easeInCore(gradient: number): number;
  83080. }
  83081. /**
  83082. * Easing function with a sin shape (see link below).
  83083. * @see https://easings.net/#easeInSine
  83084. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83085. */
  83086. export class SineEase extends EasingFunction implements IEasingFunction {
  83087. /** @hidden */
  83088. easeInCore(gradient: number): number;
  83089. }
  83090. /**
  83091. * Easing function with a bezier shape (see link below).
  83092. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83093. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83094. */
  83095. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83096. /** Defines the x component of the start tangent in the bezier curve */
  83097. x1: number;
  83098. /** Defines the y component of the start tangent in the bezier curve */
  83099. y1: number;
  83100. /** Defines the x component of the end tangent in the bezier curve */
  83101. x2: number;
  83102. /** Defines the y component of the end tangent in the bezier curve */
  83103. y2: number;
  83104. /**
  83105. * Instantiates a bezier function
  83106. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83107. * @param x1 Defines the x component of the start tangent in the bezier curve
  83108. * @param y1 Defines the y component of the start tangent in the bezier curve
  83109. * @param x2 Defines the x component of the end tangent in the bezier curve
  83110. * @param y2 Defines the y component of the end tangent in the bezier curve
  83111. */
  83112. constructor(
  83113. /** Defines the x component of the start tangent in the bezier curve */
  83114. x1?: number,
  83115. /** Defines the y component of the start tangent in the bezier curve */
  83116. y1?: number,
  83117. /** Defines the x component of the end tangent in the bezier curve */
  83118. x2?: number,
  83119. /** Defines the y component of the end tangent in the bezier curve */
  83120. y2?: number);
  83121. /** @hidden */
  83122. easeInCore(gradient: number): number;
  83123. }
  83124. }
  83125. declare module BABYLON {
  83126. /**
  83127. * Class used to hold a RBG color
  83128. */
  83129. export class Color3 {
  83130. /**
  83131. * Defines the red component (between 0 and 1, default is 0)
  83132. */
  83133. r: number;
  83134. /**
  83135. * Defines the green component (between 0 and 1, default is 0)
  83136. */
  83137. g: number;
  83138. /**
  83139. * Defines the blue component (between 0 and 1, default is 0)
  83140. */
  83141. b: number;
  83142. /**
  83143. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83144. * @param r defines the red component (between 0 and 1, default is 0)
  83145. * @param g defines the green component (between 0 and 1, default is 0)
  83146. * @param b defines the blue component (between 0 and 1, default is 0)
  83147. */
  83148. constructor(
  83149. /**
  83150. * Defines the red component (between 0 and 1, default is 0)
  83151. */
  83152. r?: number,
  83153. /**
  83154. * Defines the green component (between 0 and 1, default is 0)
  83155. */
  83156. g?: number,
  83157. /**
  83158. * Defines the blue component (between 0 and 1, default is 0)
  83159. */
  83160. b?: number);
  83161. /**
  83162. * Creates a string with the Color3 current values
  83163. * @returns the string representation of the Color3 object
  83164. */
  83165. toString(): string;
  83166. /**
  83167. * Returns the string "Color3"
  83168. * @returns "Color3"
  83169. */
  83170. getClassName(): string;
  83171. /**
  83172. * Compute the Color3 hash code
  83173. * @returns an unique number that can be used to hash Color3 objects
  83174. */
  83175. getHashCode(): number;
  83176. /**
  83177. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83178. * @param array defines the array where to store the r,g,b components
  83179. * @param index defines an optional index in the target array to define where to start storing values
  83180. * @returns the current Color3 object
  83181. */
  83182. toArray(array: FloatArray, index?: number): Color3;
  83183. /**
  83184. * Returns a new Color4 object from the current Color3 and the given alpha
  83185. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83186. * @returns a new Color4 object
  83187. */
  83188. toColor4(alpha?: number): Color4;
  83189. /**
  83190. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83191. * @returns the new array
  83192. */
  83193. asArray(): number[];
  83194. /**
  83195. * Returns the luminance value
  83196. * @returns a float value
  83197. */
  83198. toLuminance(): number;
  83199. /**
  83200. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83201. * @param otherColor defines the second operand
  83202. * @returns the new Color3 object
  83203. */
  83204. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83205. /**
  83206. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83207. * @param otherColor defines the second operand
  83208. * @param result defines the Color3 object where to store the result
  83209. * @returns the current Color3
  83210. */
  83211. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83212. /**
  83213. * Determines equality between Color3 objects
  83214. * @param otherColor defines the second operand
  83215. * @returns true if the rgb values are equal to the given ones
  83216. */
  83217. equals(otherColor: DeepImmutable<Color3>): boolean;
  83218. /**
  83219. * Determines equality between the current Color3 object and a set of r,b,g values
  83220. * @param r defines the red component to check
  83221. * @param g defines the green component to check
  83222. * @param b defines the blue component to check
  83223. * @returns true if the rgb values are equal to the given ones
  83224. */
  83225. equalsFloats(r: number, g: number, b: number): boolean;
  83226. /**
  83227. * Multiplies in place each rgb value by scale
  83228. * @param scale defines the scaling factor
  83229. * @returns the updated Color3
  83230. */
  83231. scale(scale: number): Color3;
  83232. /**
  83233. * Multiplies the rgb values by scale and stores the result into "result"
  83234. * @param scale defines the scaling factor
  83235. * @param result defines the Color3 object where to store the result
  83236. * @returns the unmodified current Color3
  83237. */
  83238. scaleToRef(scale: number, result: Color3): Color3;
  83239. /**
  83240. * Scale the current Color3 values by a factor and add the result to a given Color3
  83241. * @param scale defines the scale factor
  83242. * @param result defines color to store the result into
  83243. * @returns the unmodified current Color3
  83244. */
  83245. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83246. /**
  83247. * Clamps the rgb values by the min and max values and stores the result into "result"
  83248. * @param min defines minimum clamping value (default is 0)
  83249. * @param max defines maximum clamping value (default is 1)
  83250. * @param result defines color to store the result into
  83251. * @returns the original Color3
  83252. */
  83253. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83254. /**
  83255. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83256. * @param otherColor defines the second operand
  83257. * @returns the new Color3
  83258. */
  83259. add(otherColor: DeepImmutable<Color3>): Color3;
  83260. /**
  83261. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83262. * @param otherColor defines the second operand
  83263. * @param result defines Color3 object to store the result into
  83264. * @returns the unmodified current Color3
  83265. */
  83266. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83267. /**
  83268. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83269. * @param otherColor defines the second operand
  83270. * @returns the new Color3
  83271. */
  83272. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83273. /**
  83274. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83275. * @param otherColor defines the second operand
  83276. * @param result defines Color3 object to store the result into
  83277. * @returns the unmodified current Color3
  83278. */
  83279. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83280. /**
  83281. * Copy the current object
  83282. * @returns a new Color3 copied the current one
  83283. */
  83284. clone(): Color3;
  83285. /**
  83286. * Copies the rgb values from the source in the current Color3
  83287. * @param source defines the source Color3 object
  83288. * @returns the updated Color3 object
  83289. */
  83290. copyFrom(source: DeepImmutable<Color3>): Color3;
  83291. /**
  83292. * Updates the Color3 rgb values from the given floats
  83293. * @param r defines the red component to read from
  83294. * @param g defines the green component to read from
  83295. * @param b defines the blue component to read from
  83296. * @returns the current Color3 object
  83297. */
  83298. copyFromFloats(r: number, g: number, b: number): Color3;
  83299. /**
  83300. * Updates the Color3 rgb values from the given floats
  83301. * @param r defines the red component to read from
  83302. * @param g defines the green component to read from
  83303. * @param b defines the blue component to read from
  83304. * @returns the current Color3 object
  83305. */
  83306. set(r: number, g: number, b: number): Color3;
  83307. /**
  83308. * Compute the Color3 hexadecimal code as a string
  83309. * @returns a string containing the hexadecimal representation of the Color3 object
  83310. */
  83311. toHexString(): string;
  83312. /**
  83313. * Computes a new Color3 converted from the current one to linear space
  83314. * @returns a new Color3 object
  83315. */
  83316. toLinearSpace(): Color3;
  83317. /**
  83318. * Converts current color in rgb space to HSV values
  83319. * @returns a new color3 representing the HSV values
  83320. */
  83321. toHSV(): Color3;
  83322. /**
  83323. * Converts current color in rgb space to HSV values
  83324. * @param result defines the Color3 where to store the HSV values
  83325. */
  83326. toHSVToRef(result: Color3): void;
  83327. /**
  83328. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  83329. * @param convertedColor defines the Color3 object where to store the linear space version
  83330. * @returns the unmodified Color3
  83331. */
  83332. toLinearSpaceToRef(convertedColor: Color3): Color3;
  83333. /**
  83334. * Computes a new Color3 converted from the current one to gamma space
  83335. * @returns a new Color3 object
  83336. */
  83337. toGammaSpace(): Color3;
  83338. /**
  83339. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  83340. * @param convertedColor defines the Color3 object where to store the gamma space version
  83341. * @returns the unmodified Color3
  83342. */
  83343. toGammaSpaceToRef(convertedColor: Color3): Color3;
  83344. private static _BlackReadOnly;
  83345. /**
  83346. * Convert Hue, saturation and value to a Color3 (RGB)
  83347. * @param hue defines the hue
  83348. * @param saturation defines the saturation
  83349. * @param value defines the value
  83350. * @param result defines the Color3 where to store the RGB values
  83351. */
  83352. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  83353. /**
  83354. * Creates a new Color3 from the string containing valid hexadecimal values
  83355. * @param hex defines a string containing valid hexadecimal values
  83356. * @returns a new Color3 object
  83357. */
  83358. static FromHexString(hex: string): Color3;
  83359. /**
  83360. * Creates a new Color3 from the starting index of the given array
  83361. * @param array defines the source array
  83362. * @param offset defines an offset in the source array
  83363. * @returns a new Color3 object
  83364. */
  83365. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  83366. /**
  83367. * Creates a new Color3 from integer values (< 256)
  83368. * @param r defines the red component to read from (value between 0 and 255)
  83369. * @param g defines the green component to read from (value between 0 and 255)
  83370. * @param b defines the blue component to read from (value between 0 and 255)
  83371. * @returns a new Color3 object
  83372. */
  83373. static FromInts(r: number, g: number, b: number): Color3;
  83374. /**
  83375. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83376. * @param start defines the start Color3 value
  83377. * @param end defines the end Color3 value
  83378. * @param amount defines the gradient value between start and end
  83379. * @returns a new Color3 object
  83380. */
  83381. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  83382. /**
  83383. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83384. * @param left defines the start value
  83385. * @param right defines the end value
  83386. * @param amount defines the gradient factor
  83387. * @param result defines the Color3 object where to store the result
  83388. */
  83389. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  83390. /**
  83391. * Returns a Color3 value containing a red color
  83392. * @returns a new Color3 object
  83393. */
  83394. static Red(): Color3;
  83395. /**
  83396. * Returns a Color3 value containing a green color
  83397. * @returns a new Color3 object
  83398. */
  83399. static Green(): Color3;
  83400. /**
  83401. * Returns a Color3 value containing a blue color
  83402. * @returns a new Color3 object
  83403. */
  83404. static Blue(): Color3;
  83405. /**
  83406. * Returns a Color3 value containing a black color
  83407. * @returns a new Color3 object
  83408. */
  83409. static Black(): Color3;
  83410. /**
  83411. * Gets a Color3 value containing a black color that must not be updated
  83412. */
  83413. static get BlackReadOnly(): DeepImmutable<Color3>;
  83414. /**
  83415. * Returns a Color3 value containing a white color
  83416. * @returns a new Color3 object
  83417. */
  83418. static White(): Color3;
  83419. /**
  83420. * Returns a Color3 value containing a purple color
  83421. * @returns a new Color3 object
  83422. */
  83423. static Purple(): Color3;
  83424. /**
  83425. * Returns a Color3 value containing a magenta color
  83426. * @returns a new Color3 object
  83427. */
  83428. static Magenta(): Color3;
  83429. /**
  83430. * Returns a Color3 value containing a yellow color
  83431. * @returns a new Color3 object
  83432. */
  83433. static Yellow(): Color3;
  83434. /**
  83435. * Returns a Color3 value containing a gray color
  83436. * @returns a new Color3 object
  83437. */
  83438. static Gray(): Color3;
  83439. /**
  83440. * Returns a Color3 value containing a teal color
  83441. * @returns a new Color3 object
  83442. */
  83443. static Teal(): Color3;
  83444. /**
  83445. * Returns a Color3 value containing a random color
  83446. * @returns a new Color3 object
  83447. */
  83448. static Random(): Color3;
  83449. }
  83450. /**
  83451. * Class used to hold a RBGA color
  83452. */
  83453. export class Color4 {
  83454. /**
  83455. * Defines the red component (between 0 and 1, default is 0)
  83456. */
  83457. r: number;
  83458. /**
  83459. * Defines the green component (between 0 and 1, default is 0)
  83460. */
  83461. g: number;
  83462. /**
  83463. * Defines the blue component (between 0 and 1, default is 0)
  83464. */
  83465. b: number;
  83466. /**
  83467. * Defines the alpha component (between 0 and 1, default is 1)
  83468. */
  83469. a: number;
  83470. /**
  83471. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  83472. * @param r defines the red component (between 0 and 1, default is 0)
  83473. * @param g defines the green component (between 0 and 1, default is 0)
  83474. * @param b defines the blue component (between 0 and 1, default is 0)
  83475. * @param a defines the alpha component (between 0 and 1, default is 1)
  83476. */
  83477. constructor(
  83478. /**
  83479. * Defines the red component (between 0 and 1, default is 0)
  83480. */
  83481. r?: number,
  83482. /**
  83483. * Defines the green component (between 0 and 1, default is 0)
  83484. */
  83485. g?: number,
  83486. /**
  83487. * Defines the blue component (between 0 and 1, default is 0)
  83488. */
  83489. b?: number,
  83490. /**
  83491. * Defines the alpha component (between 0 and 1, default is 1)
  83492. */
  83493. a?: number);
  83494. /**
  83495. * Adds in place the given Color4 values to the current Color4 object
  83496. * @param right defines the second operand
  83497. * @returns the current updated Color4 object
  83498. */
  83499. addInPlace(right: DeepImmutable<Color4>): Color4;
  83500. /**
  83501. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  83502. * @returns the new array
  83503. */
  83504. asArray(): number[];
  83505. /**
  83506. * Stores from the starting index in the given array the Color4 successive values
  83507. * @param array defines the array where to store the r,g,b components
  83508. * @param index defines an optional index in the target array to define where to start storing values
  83509. * @returns the current Color4 object
  83510. */
  83511. toArray(array: number[], index?: number): Color4;
  83512. /**
  83513. * Determines equality between Color4 objects
  83514. * @param otherColor defines the second operand
  83515. * @returns true if the rgba values are equal to the given ones
  83516. */
  83517. equals(otherColor: DeepImmutable<Color4>): boolean;
  83518. /**
  83519. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  83520. * @param right defines the second operand
  83521. * @returns a new Color4 object
  83522. */
  83523. add(right: DeepImmutable<Color4>): Color4;
  83524. /**
  83525. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  83526. * @param right defines the second operand
  83527. * @returns a new Color4 object
  83528. */
  83529. subtract(right: DeepImmutable<Color4>): Color4;
  83530. /**
  83531. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  83532. * @param right defines the second operand
  83533. * @param result defines the Color4 object where to store the result
  83534. * @returns the current Color4 object
  83535. */
  83536. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  83537. /**
  83538. * Creates a new Color4 with the current Color4 values multiplied by scale
  83539. * @param scale defines the scaling factor to apply
  83540. * @returns a new Color4 object
  83541. */
  83542. scale(scale: number): Color4;
  83543. /**
  83544. * Multiplies the current Color4 values by scale and stores the result in "result"
  83545. * @param scale defines the scaling factor to apply
  83546. * @param result defines the Color4 object where to store the result
  83547. * @returns the current unmodified Color4
  83548. */
  83549. scaleToRef(scale: number, result: Color4): Color4;
  83550. /**
  83551. * Scale the current Color4 values by a factor and add the result to a given Color4
  83552. * @param scale defines the scale factor
  83553. * @param result defines the Color4 object where to store the result
  83554. * @returns the unmodified current Color4
  83555. */
  83556. scaleAndAddToRef(scale: number, result: Color4): Color4;
  83557. /**
  83558. * Clamps the rgb values by the min and max values and stores the result into "result"
  83559. * @param min defines minimum clamping value (default is 0)
  83560. * @param max defines maximum clamping value (default is 1)
  83561. * @param result defines color to store the result into.
  83562. * @returns the cuurent Color4
  83563. */
  83564. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  83565. /**
  83566. * Multipy an Color4 value by another and return a new Color4 object
  83567. * @param color defines the Color4 value to multiply by
  83568. * @returns a new Color4 object
  83569. */
  83570. multiply(color: Color4): Color4;
  83571. /**
  83572. * Multipy a Color4 value by another and push the result in a reference value
  83573. * @param color defines the Color4 value to multiply by
  83574. * @param result defines the Color4 to fill the result in
  83575. * @returns the result Color4
  83576. */
  83577. multiplyToRef(color: Color4, result: Color4): Color4;
  83578. /**
  83579. * Creates a string with the Color4 current values
  83580. * @returns the string representation of the Color4 object
  83581. */
  83582. toString(): string;
  83583. /**
  83584. * Returns the string "Color4"
  83585. * @returns "Color4"
  83586. */
  83587. getClassName(): string;
  83588. /**
  83589. * Compute the Color4 hash code
  83590. * @returns an unique number that can be used to hash Color4 objects
  83591. */
  83592. getHashCode(): number;
  83593. /**
  83594. * Creates a new Color4 copied from the current one
  83595. * @returns a new Color4 object
  83596. */
  83597. clone(): Color4;
  83598. /**
  83599. * Copies the given Color4 values into the current one
  83600. * @param source defines the source Color4 object
  83601. * @returns the current updated Color4 object
  83602. */
  83603. copyFrom(source: Color4): Color4;
  83604. /**
  83605. * Copies the given float values into the current one
  83606. * @param r defines the red component to read from
  83607. * @param g defines the green component to read from
  83608. * @param b defines the blue component to read from
  83609. * @param a defines the alpha component to read from
  83610. * @returns the current updated Color4 object
  83611. */
  83612. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  83613. /**
  83614. * Copies the given float values into the current one
  83615. * @param r defines the red component to read from
  83616. * @param g defines the green component to read from
  83617. * @param b defines the blue component to read from
  83618. * @param a defines the alpha component to read from
  83619. * @returns the current updated Color4 object
  83620. */
  83621. set(r: number, g: number, b: number, a: number): Color4;
  83622. /**
  83623. * Compute the Color4 hexadecimal code as a string
  83624. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  83625. * @returns a string containing the hexadecimal representation of the Color4 object
  83626. */
  83627. toHexString(returnAsColor3?: boolean): string;
  83628. /**
  83629. * Computes a new Color4 converted from the current one to linear space
  83630. * @returns a new Color4 object
  83631. */
  83632. toLinearSpace(): Color4;
  83633. /**
  83634. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  83635. * @param convertedColor defines the Color4 object where to store the linear space version
  83636. * @returns the unmodified Color4
  83637. */
  83638. toLinearSpaceToRef(convertedColor: Color4): Color4;
  83639. /**
  83640. * Computes a new Color4 converted from the current one to gamma space
  83641. * @returns a new Color4 object
  83642. */
  83643. toGammaSpace(): Color4;
  83644. /**
  83645. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  83646. * @param convertedColor defines the Color4 object where to store the gamma space version
  83647. * @returns the unmodified Color4
  83648. */
  83649. toGammaSpaceToRef(convertedColor: Color4): Color4;
  83650. /**
  83651. * Creates a new Color4 from the string containing valid hexadecimal values
  83652. * @param hex defines a string containing valid hexadecimal values
  83653. * @returns a new Color4 object
  83654. */
  83655. static FromHexString(hex: string): Color4;
  83656. /**
  83657. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83658. * @param left defines the start value
  83659. * @param right defines the end value
  83660. * @param amount defines the gradient factor
  83661. * @returns a new Color4 object
  83662. */
  83663. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  83664. /**
  83665. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83666. * @param left defines the start value
  83667. * @param right defines the end value
  83668. * @param amount defines the gradient factor
  83669. * @param result defines the Color4 object where to store data
  83670. */
  83671. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  83672. /**
  83673. * Creates a new Color4 from a Color3 and an alpha value
  83674. * @param color3 defines the source Color3 to read from
  83675. * @param alpha defines the alpha component (1.0 by default)
  83676. * @returns a new Color4 object
  83677. */
  83678. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  83679. /**
  83680. * Creates a new Color4 from the starting index element of the given array
  83681. * @param array defines the source array to read from
  83682. * @param offset defines the offset in the source array
  83683. * @returns a new Color4 object
  83684. */
  83685. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  83686. /**
  83687. * Creates a new Color3 from integer values (< 256)
  83688. * @param r defines the red component to read from (value between 0 and 255)
  83689. * @param g defines the green component to read from (value between 0 and 255)
  83690. * @param b defines the blue component to read from (value between 0 and 255)
  83691. * @param a defines the alpha component to read from (value between 0 and 255)
  83692. * @returns a new Color3 object
  83693. */
  83694. static FromInts(r: number, g: number, b: number, a: number): Color4;
  83695. /**
  83696. * Check the content of a given array and convert it to an array containing RGBA data
  83697. * If the original array was already containing count * 4 values then it is returned directly
  83698. * @param colors defines the array to check
  83699. * @param count defines the number of RGBA data to expect
  83700. * @returns an array containing count * 4 values (RGBA)
  83701. */
  83702. static CheckColors4(colors: number[], count: number): number[];
  83703. }
  83704. /**
  83705. * @hidden
  83706. */
  83707. export class TmpColors {
  83708. static Color3: Color3[];
  83709. static Color4: Color4[];
  83710. }
  83711. }
  83712. declare module BABYLON {
  83713. /**
  83714. * Defines an interface which represents an animation key frame
  83715. */
  83716. export interface IAnimationKey {
  83717. /**
  83718. * Frame of the key frame
  83719. */
  83720. frame: number;
  83721. /**
  83722. * Value at the specifies key frame
  83723. */
  83724. value: any;
  83725. /**
  83726. * The input tangent for the cubic hermite spline
  83727. */
  83728. inTangent?: any;
  83729. /**
  83730. * The output tangent for the cubic hermite spline
  83731. */
  83732. outTangent?: any;
  83733. /**
  83734. * The animation interpolation type
  83735. */
  83736. interpolation?: AnimationKeyInterpolation;
  83737. }
  83738. /**
  83739. * Enum for the animation key frame interpolation type
  83740. */
  83741. export enum AnimationKeyInterpolation {
  83742. /**
  83743. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  83744. */
  83745. STEP = 1
  83746. }
  83747. }
  83748. declare module BABYLON {
  83749. /**
  83750. * Represents the range of an animation
  83751. */
  83752. export class AnimationRange {
  83753. /**The name of the animation range**/
  83754. name: string;
  83755. /**The starting frame of the animation */
  83756. from: number;
  83757. /**The ending frame of the animation*/
  83758. to: number;
  83759. /**
  83760. * Initializes the range of an animation
  83761. * @param name The name of the animation range
  83762. * @param from The starting frame of the animation
  83763. * @param to The ending frame of the animation
  83764. */
  83765. constructor(
  83766. /**The name of the animation range**/
  83767. name: string,
  83768. /**The starting frame of the animation */
  83769. from: number,
  83770. /**The ending frame of the animation*/
  83771. to: number);
  83772. /**
  83773. * Makes a copy of the animation range
  83774. * @returns A copy of the animation range
  83775. */
  83776. clone(): AnimationRange;
  83777. }
  83778. }
  83779. declare module BABYLON {
  83780. /**
  83781. * Composed of a frame, and an action function
  83782. */
  83783. export class AnimationEvent {
  83784. /** The frame for which the event is triggered **/
  83785. frame: number;
  83786. /** The event to perform when triggered **/
  83787. action: (currentFrame: number) => void;
  83788. /** Specifies if the event should be triggered only once**/
  83789. onlyOnce?: boolean | undefined;
  83790. /**
  83791. * Specifies if the animation event is done
  83792. */
  83793. isDone: boolean;
  83794. /**
  83795. * Initializes the animation event
  83796. * @param frame The frame for which the event is triggered
  83797. * @param action The event to perform when triggered
  83798. * @param onlyOnce Specifies if the event should be triggered only once
  83799. */
  83800. constructor(
  83801. /** The frame for which the event is triggered **/
  83802. frame: number,
  83803. /** The event to perform when triggered **/
  83804. action: (currentFrame: number) => void,
  83805. /** Specifies if the event should be triggered only once**/
  83806. onlyOnce?: boolean | undefined);
  83807. /** @hidden */
  83808. _clone(): AnimationEvent;
  83809. }
  83810. }
  83811. declare module BABYLON {
  83812. /**
  83813. * Interface used to define a behavior
  83814. */
  83815. export interface Behavior<T> {
  83816. /** gets or sets behavior's name */
  83817. name: string;
  83818. /**
  83819. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83820. */
  83821. init(): void;
  83822. /**
  83823. * Called when the behavior is attached to a target
  83824. * @param target defines the target where the behavior is attached to
  83825. */
  83826. attach(target: T): void;
  83827. /**
  83828. * Called when the behavior is detached from its target
  83829. */
  83830. detach(): void;
  83831. }
  83832. /**
  83833. * Interface implemented by classes supporting behaviors
  83834. */
  83835. export interface IBehaviorAware<T> {
  83836. /**
  83837. * Attach a behavior
  83838. * @param behavior defines the behavior to attach
  83839. * @returns the current host
  83840. */
  83841. addBehavior(behavior: Behavior<T>): T;
  83842. /**
  83843. * Remove a behavior from the current object
  83844. * @param behavior defines the behavior to detach
  83845. * @returns the current host
  83846. */
  83847. removeBehavior(behavior: Behavior<T>): T;
  83848. /**
  83849. * Gets a behavior using its name to search
  83850. * @param name defines the name to search
  83851. * @returns the behavior or null if not found
  83852. */
  83853. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83854. }
  83855. }
  83856. declare module BABYLON {
  83857. /**
  83858. * Defines an array and its length.
  83859. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83860. */
  83861. export interface ISmartArrayLike<T> {
  83862. /**
  83863. * The data of the array.
  83864. */
  83865. data: Array<T>;
  83866. /**
  83867. * The active length of the array.
  83868. */
  83869. length: number;
  83870. }
  83871. /**
  83872. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83873. */
  83874. export class SmartArray<T> implements ISmartArrayLike<T> {
  83875. /**
  83876. * The full set of data from the array.
  83877. */
  83878. data: Array<T>;
  83879. /**
  83880. * The active length of the array.
  83881. */
  83882. length: number;
  83883. protected _id: number;
  83884. /**
  83885. * Instantiates a Smart Array.
  83886. * @param capacity defines the default capacity of the array.
  83887. */
  83888. constructor(capacity: number);
  83889. /**
  83890. * Pushes a value at the end of the active data.
  83891. * @param value defines the object to push in the array.
  83892. */
  83893. push(value: T): void;
  83894. /**
  83895. * Iterates over the active data and apply the lambda to them.
  83896. * @param func defines the action to apply on each value.
  83897. */
  83898. forEach(func: (content: T) => void): void;
  83899. /**
  83900. * Sorts the full sets of data.
  83901. * @param compareFn defines the comparison function to apply.
  83902. */
  83903. sort(compareFn: (a: T, b: T) => number): void;
  83904. /**
  83905. * Resets the active data to an empty array.
  83906. */
  83907. reset(): void;
  83908. /**
  83909. * Releases all the data from the array as well as the array.
  83910. */
  83911. dispose(): void;
  83912. /**
  83913. * Concats the active data with a given array.
  83914. * @param array defines the data to concatenate with.
  83915. */
  83916. concat(array: any): void;
  83917. /**
  83918. * Returns the position of a value in the active data.
  83919. * @param value defines the value to find the index for
  83920. * @returns the index if found in the active data otherwise -1
  83921. */
  83922. indexOf(value: T): number;
  83923. /**
  83924. * Returns whether an element is part of the active data.
  83925. * @param value defines the value to look for
  83926. * @returns true if found in the active data otherwise false
  83927. */
  83928. contains(value: T): boolean;
  83929. private static _GlobalId;
  83930. }
  83931. /**
  83932. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83933. * The data in this array can only be present once
  83934. */
  83935. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83936. private _duplicateId;
  83937. /**
  83938. * Pushes a value at the end of the active data.
  83939. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83940. * @param value defines the object to push in the array.
  83941. */
  83942. push(value: T): void;
  83943. /**
  83944. * Pushes a value at the end of the active data.
  83945. * If the data is already present, it won t be added again
  83946. * @param value defines the object to push in the array.
  83947. * @returns true if added false if it was already present
  83948. */
  83949. pushNoDuplicate(value: T): boolean;
  83950. /**
  83951. * Resets the active data to an empty array.
  83952. */
  83953. reset(): void;
  83954. /**
  83955. * Concats the active data with a given array.
  83956. * This ensures no dupplicate will be present in the result.
  83957. * @param array defines the data to concatenate with.
  83958. */
  83959. concatWithNoDuplicate(array: any): void;
  83960. }
  83961. }
  83962. declare module BABYLON {
  83963. /**
  83964. * @ignore
  83965. * This is a list of all the different input types that are available in the application.
  83966. * Fo instance: ArcRotateCameraGamepadInput...
  83967. */
  83968. export var CameraInputTypes: {};
  83969. /**
  83970. * This is the contract to implement in order to create a new input class.
  83971. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  83972. */
  83973. export interface ICameraInput<TCamera extends Camera> {
  83974. /**
  83975. * Defines the camera the input is attached to.
  83976. */
  83977. camera: Nullable<TCamera>;
  83978. /**
  83979. * Gets the class name of the current intput.
  83980. * @returns the class name
  83981. */
  83982. getClassName(): string;
  83983. /**
  83984. * Get the friendly name associated with the input class.
  83985. * @returns the input friendly name
  83986. */
  83987. getSimpleName(): string;
  83988. /**
  83989. * Attach the input controls to a specific dom element to get the input from.
  83990. * @param element Defines the element the controls should be listened from
  83991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83992. */
  83993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83994. /**
  83995. * Detach the current controls from the specified dom element.
  83996. * @param element Defines the element to stop listening the inputs from
  83997. */
  83998. detachControl(element: Nullable<HTMLElement>): void;
  83999. /**
  84000. * Update the current camera state depending on the inputs that have been used this frame.
  84001. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84002. */
  84003. checkInputs?: () => void;
  84004. }
  84005. /**
  84006. * Represents a map of input types to input instance or input index to input instance.
  84007. */
  84008. export interface CameraInputsMap<TCamera extends Camera> {
  84009. /**
  84010. * Accessor to the input by input type.
  84011. */
  84012. [name: string]: ICameraInput<TCamera>;
  84013. /**
  84014. * Accessor to the input by input index.
  84015. */
  84016. [idx: number]: ICameraInput<TCamera>;
  84017. }
  84018. /**
  84019. * This represents the input manager used within a camera.
  84020. * It helps dealing with all the different kind of input attached to a camera.
  84021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84022. */
  84023. export class CameraInputsManager<TCamera extends Camera> {
  84024. /**
  84025. * Defines the list of inputs attahed to the camera.
  84026. */
  84027. attached: CameraInputsMap<TCamera>;
  84028. /**
  84029. * Defines the dom element the camera is collecting inputs from.
  84030. * This is null if the controls have not been attached.
  84031. */
  84032. attachedElement: Nullable<HTMLElement>;
  84033. /**
  84034. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84035. */
  84036. noPreventDefault: boolean;
  84037. /**
  84038. * Defined the camera the input manager belongs to.
  84039. */
  84040. camera: TCamera;
  84041. /**
  84042. * Update the current camera state depending on the inputs that have been used this frame.
  84043. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84044. */
  84045. checkInputs: () => void;
  84046. /**
  84047. * Instantiate a new Camera Input Manager.
  84048. * @param camera Defines the camera the input manager blongs to
  84049. */
  84050. constructor(camera: TCamera);
  84051. /**
  84052. * Add an input method to a camera
  84053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84054. * @param input camera input method
  84055. */
  84056. add(input: ICameraInput<TCamera>): void;
  84057. /**
  84058. * Remove a specific input method from a camera
  84059. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84060. * @param inputToRemove camera input method
  84061. */
  84062. remove(inputToRemove: ICameraInput<TCamera>): void;
  84063. /**
  84064. * Remove a specific input type from a camera
  84065. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84066. * @param inputType the type of the input to remove
  84067. */
  84068. removeByType(inputType: string): void;
  84069. private _addCheckInputs;
  84070. /**
  84071. * Attach the input controls to the currently attached dom element to listen the events from.
  84072. * @param input Defines the input to attach
  84073. */
  84074. attachInput(input: ICameraInput<TCamera>): void;
  84075. /**
  84076. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84077. * @param element Defines the dom element to collect the events from
  84078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84079. */
  84080. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84081. /**
  84082. * Detach the current manager inputs controls from a specific dom element.
  84083. * @param element Defines the dom element to collect the events from
  84084. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84085. */
  84086. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84087. /**
  84088. * Rebuild the dynamic inputCheck function from the current list of
  84089. * defined inputs in the manager.
  84090. */
  84091. rebuildInputCheck(): void;
  84092. /**
  84093. * Remove all attached input methods from a camera
  84094. */
  84095. clear(): void;
  84096. /**
  84097. * Serialize the current input manager attached to a camera.
  84098. * This ensures than once parsed,
  84099. * the input associated to the camera will be identical to the current ones
  84100. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84101. */
  84102. serialize(serializedCamera: any): void;
  84103. /**
  84104. * Parses an input manager serialized JSON to restore the previous list of inputs
  84105. * and states associated to a camera.
  84106. * @param parsedCamera Defines the JSON to parse
  84107. */
  84108. parse(parsedCamera: any): void;
  84109. }
  84110. }
  84111. declare module BABYLON {
  84112. /**
  84113. * Class used to store data that will be store in GPU memory
  84114. */
  84115. export class Buffer {
  84116. private _engine;
  84117. private _buffer;
  84118. /** @hidden */
  84119. _data: Nullable<DataArray>;
  84120. private _updatable;
  84121. private _instanced;
  84122. private _divisor;
  84123. /**
  84124. * Gets the byte stride.
  84125. */
  84126. readonly byteStride: number;
  84127. /**
  84128. * Constructor
  84129. * @param engine the engine
  84130. * @param data the data to use for this buffer
  84131. * @param updatable whether the data is updatable
  84132. * @param stride the stride (optional)
  84133. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84134. * @param instanced whether the buffer is instanced (optional)
  84135. * @param useBytes set to true if the stride in in bytes (optional)
  84136. * @param divisor sets an optional divisor for instances (1 by default)
  84137. */
  84138. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84139. /**
  84140. * Create a new VertexBuffer based on the current buffer
  84141. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84142. * @param offset defines offset in the buffer (0 by default)
  84143. * @param size defines the size in floats of attributes (position is 3 for instance)
  84144. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84145. * @param instanced defines if the vertex buffer contains indexed data
  84146. * @param useBytes defines if the offset and stride are in bytes *
  84147. * @param divisor sets an optional divisor for instances (1 by default)
  84148. * @returns the new vertex buffer
  84149. */
  84150. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84151. /**
  84152. * Gets a boolean indicating if the Buffer is updatable?
  84153. * @returns true if the buffer is updatable
  84154. */
  84155. isUpdatable(): boolean;
  84156. /**
  84157. * Gets current buffer's data
  84158. * @returns a DataArray or null
  84159. */
  84160. getData(): Nullable<DataArray>;
  84161. /**
  84162. * Gets underlying native buffer
  84163. * @returns underlying native buffer
  84164. */
  84165. getBuffer(): Nullable<DataBuffer>;
  84166. /**
  84167. * Gets the stride in float32 units (i.e. byte stride / 4).
  84168. * May not be an integer if the byte stride is not divisible by 4.
  84169. * @returns the stride in float32 units
  84170. * @deprecated Please use byteStride instead.
  84171. */
  84172. getStrideSize(): number;
  84173. /**
  84174. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84175. * @param data defines the data to store
  84176. */
  84177. create(data?: Nullable<DataArray>): void;
  84178. /** @hidden */
  84179. _rebuild(): void;
  84180. /**
  84181. * Update current buffer data
  84182. * @param data defines the data to store
  84183. */
  84184. update(data: DataArray): void;
  84185. /**
  84186. * Updates the data directly.
  84187. * @param data the new data
  84188. * @param offset the new offset
  84189. * @param vertexCount the vertex count (optional)
  84190. * @param useBytes set to true if the offset is in bytes
  84191. */
  84192. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84193. /**
  84194. * Release all resources
  84195. */
  84196. dispose(): void;
  84197. }
  84198. /**
  84199. * Specialized buffer used to store vertex data
  84200. */
  84201. export class VertexBuffer {
  84202. /** @hidden */
  84203. _buffer: Buffer;
  84204. private _kind;
  84205. private _size;
  84206. private _ownsBuffer;
  84207. private _instanced;
  84208. private _instanceDivisor;
  84209. /**
  84210. * The byte type.
  84211. */
  84212. static readonly BYTE: number;
  84213. /**
  84214. * The unsigned byte type.
  84215. */
  84216. static readonly UNSIGNED_BYTE: number;
  84217. /**
  84218. * The short type.
  84219. */
  84220. static readonly SHORT: number;
  84221. /**
  84222. * The unsigned short type.
  84223. */
  84224. static readonly UNSIGNED_SHORT: number;
  84225. /**
  84226. * The integer type.
  84227. */
  84228. static readonly INT: number;
  84229. /**
  84230. * The unsigned integer type.
  84231. */
  84232. static readonly UNSIGNED_INT: number;
  84233. /**
  84234. * The float type.
  84235. */
  84236. static readonly FLOAT: number;
  84237. /**
  84238. * Gets or sets the instance divisor when in instanced mode
  84239. */
  84240. get instanceDivisor(): number;
  84241. set instanceDivisor(value: number);
  84242. /**
  84243. * Gets the byte stride.
  84244. */
  84245. readonly byteStride: number;
  84246. /**
  84247. * Gets the byte offset.
  84248. */
  84249. readonly byteOffset: number;
  84250. /**
  84251. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84252. */
  84253. readonly normalized: boolean;
  84254. /**
  84255. * Gets the data type of each component in the array.
  84256. */
  84257. readonly type: number;
  84258. /**
  84259. * Constructor
  84260. * @param engine the engine
  84261. * @param data the data to use for this vertex buffer
  84262. * @param kind the vertex buffer kind
  84263. * @param updatable whether the data is updatable
  84264. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84265. * @param stride the stride (optional)
  84266. * @param instanced whether the buffer is instanced (optional)
  84267. * @param offset the offset of the data (optional)
  84268. * @param size the number of components (optional)
  84269. * @param type the type of the component (optional)
  84270. * @param normalized whether the data contains normalized data (optional)
  84271. * @param useBytes set to true if stride and offset are in bytes (optional)
  84272. * @param divisor defines the instance divisor to use (1 by default)
  84273. */
  84274. 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);
  84275. /** @hidden */
  84276. _rebuild(): void;
  84277. /**
  84278. * Returns the kind of the VertexBuffer (string)
  84279. * @returns a string
  84280. */
  84281. getKind(): string;
  84282. /**
  84283. * Gets a boolean indicating if the VertexBuffer is updatable?
  84284. * @returns true if the buffer is updatable
  84285. */
  84286. isUpdatable(): boolean;
  84287. /**
  84288. * Gets current buffer's data
  84289. * @returns a DataArray or null
  84290. */
  84291. getData(): Nullable<DataArray>;
  84292. /**
  84293. * Gets underlying native buffer
  84294. * @returns underlying native buffer
  84295. */
  84296. getBuffer(): Nullable<DataBuffer>;
  84297. /**
  84298. * Gets the stride in float32 units (i.e. byte stride / 4).
  84299. * May not be an integer if the byte stride is not divisible by 4.
  84300. * @returns the stride in float32 units
  84301. * @deprecated Please use byteStride instead.
  84302. */
  84303. getStrideSize(): number;
  84304. /**
  84305. * Returns the offset as a multiple of the type byte length.
  84306. * @returns the offset in bytes
  84307. * @deprecated Please use byteOffset instead.
  84308. */
  84309. getOffset(): number;
  84310. /**
  84311. * Returns the number of components per vertex attribute (integer)
  84312. * @returns the size in float
  84313. */
  84314. getSize(): number;
  84315. /**
  84316. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84317. * @returns true if this buffer is instanced
  84318. */
  84319. getIsInstanced(): boolean;
  84320. /**
  84321. * Returns the instancing divisor, zero for non-instanced (integer).
  84322. * @returns a number
  84323. */
  84324. getInstanceDivisor(): number;
  84325. /**
  84326. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84327. * @param data defines the data to store
  84328. */
  84329. create(data?: DataArray): void;
  84330. /**
  84331. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84332. * This function will create a new buffer if the current one is not updatable
  84333. * @param data defines the data to store
  84334. */
  84335. update(data: DataArray): void;
  84336. /**
  84337. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84338. * Returns the directly updated WebGLBuffer.
  84339. * @param data the new data
  84340. * @param offset the new offset
  84341. * @param useBytes set to true if the offset is in bytes
  84342. */
  84343. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  84344. /**
  84345. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84346. */
  84347. dispose(): void;
  84348. /**
  84349. * Enumerates each value of this vertex buffer as numbers.
  84350. * @param count the number of values to enumerate
  84351. * @param callback the callback function called for each value
  84352. */
  84353. forEach(count: number, callback: (value: number, index: number) => void): void;
  84354. /**
  84355. * Positions
  84356. */
  84357. static readonly PositionKind: string;
  84358. /**
  84359. * Normals
  84360. */
  84361. static readonly NormalKind: string;
  84362. /**
  84363. * Tangents
  84364. */
  84365. static readonly TangentKind: string;
  84366. /**
  84367. * Texture coordinates
  84368. */
  84369. static readonly UVKind: string;
  84370. /**
  84371. * Texture coordinates 2
  84372. */
  84373. static readonly UV2Kind: string;
  84374. /**
  84375. * Texture coordinates 3
  84376. */
  84377. static readonly UV3Kind: string;
  84378. /**
  84379. * Texture coordinates 4
  84380. */
  84381. static readonly UV4Kind: string;
  84382. /**
  84383. * Texture coordinates 5
  84384. */
  84385. static readonly UV5Kind: string;
  84386. /**
  84387. * Texture coordinates 6
  84388. */
  84389. static readonly UV6Kind: string;
  84390. /**
  84391. * Colors
  84392. */
  84393. static readonly ColorKind: string;
  84394. /**
  84395. * Matrix indices (for bones)
  84396. */
  84397. static readonly MatricesIndicesKind: string;
  84398. /**
  84399. * Matrix weights (for bones)
  84400. */
  84401. static readonly MatricesWeightsKind: string;
  84402. /**
  84403. * Additional matrix indices (for bones)
  84404. */
  84405. static readonly MatricesIndicesExtraKind: string;
  84406. /**
  84407. * Additional matrix weights (for bones)
  84408. */
  84409. static readonly MatricesWeightsExtraKind: string;
  84410. /**
  84411. * Deduces the stride given a kind.
  84412. * @param kind The kind string to deduce
  84413. * @returns The deduced stride
  84414. */
  84415. static DeduceStride(kind: string): number;
  84416. /**
  84417. * Gets the byte length of the given type.
  84418. * @param type the type
  84419. * @returns the number of bytes
  84420. */
  84421. static GetTypeByteLength(type: number): number;
  84422. /**
  84423. * Enumerates each value of the given parameters as numbers.
  84424. * @param data the data to enumerate
  84425. * @param byteOffset the byte offset of the data
  84426. * @param byteStride the byte stride of the data
  84427. * @param componentCount the number of components per element
  84428. * @param componentType the type of the component
  84429. * @param count the number of values to enumerate
  84430. * @param normalized whether the data is normalized
  84431. * @param callback the callback function called for each value
  84432. */
  84433. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84434. private static _GetFloatValue;
  84435. }
  84436. }
  84437. declare module BABYLON {
  84438. /**
  84439. * @hidden
  84440. */
  84441. export class IntersectionInfo {
  84442. bu: Nullable<number>;
  84443. bv: Nullable<number>;
  84444. distance: number;
  84445. faceId: number;
  84446. subMeshId: number;
  84447. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84448. }
  84449. }
  84450. declare module BABYLON {
  84451. /**
  84452. * Class used to store bounding sphere information
  84453. */
  84454. export class BoundingSphere {
  84455. /**
  84456. * Gets the center of the bounding sphere in local space
  84457. */
  84458. readonly center: Vector3;
  84459. /**
  84460. * Radius of the bounding sphere in local space
  84461. */
  84462. radius: number;
  84463. /**
  84464. * Gets the center of the bounding sphere in world space
  84465. */
  84466. readonly centerWorld: Vector3;
  84467. /**
  84468. * Radius of the bounding sphere in world space
  84469. */
  84470. radiusWorld: number;
  84471. /**
  84472. * Gets the minimum vector in local space
  84473. */
  84474. readonly minimum: Vector3;
  84475. /**
  84476. * Gets the maximum vector in local space
  84477. */
  84478. readonly maximum: Vector3;
  84479. private _worldMatrix;
  84480. private static readonly TmpVector3;
  84481. /**
  84482. * Creates a new bounding sphere
  84483. * @param min defines the minimum vector (in local space)
  84484. * @param max defines the maximum vector (in local space)
  84485. * @param worldMatrix defines the new world matrix
  84486. */
  84487. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84488. /**
  84489. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  84490. * @param min defines the new minimum vector (in local space)
  84491. * @param max defines the new maximum vector (in local space)
  84492. * @param worldMatrix defines the new world matrix
  84493. */
  84494. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84495. /**
  84496. * Scale the current bounding sphere by applying a scale factor
  84497. * @param factor defines the scale factor to apply
  84498. * @returns the current bounding box
  84499. */
  84500. scale(factor: number): BoundingSphere;
  84501. /**
  84502. * Gets the world matrix of the bounding box
  84503. * @returns a matrix
  84504. */
  84505. getWorldMatrix(): DeepImmutable<Matrix>;
  84506. /** @hidden */
  84507. _update(worldMatrix: DeepImmutable<Matrix>): void;
  84508. /**
  84509. * Tests if the bounding sphere is intersecting the frustum planes
  84510. * @param frustumPlanes defines the frustum planes to test
  84511. * @returns true if there is an intersection
  84512. */
  84513. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84514. /**
  84515. * Tests if the bounding sphere center is in between the frustum planes.
  84516. * Used for optimistic fast inclusion.
  84517. * @param frustumPlanes defines the frustum planes to test
  84518. * @returns true if the sphere center is in between the frustum planes
  84519. */
  84520. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84521. /**
  84522. * Tests if a point is inside the bounding sphere
  84523. * @param point defines the point to test
  84524. * @returns true if the point is inside the bounding sphere
  84525. */
  84526. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84527. /**
  84528. * Checks if two sphere intersct
  84529. * @param sphere0 sphere 0
  84530. * @param sphere1 sphere 1
  84531. * @returns true if the speres intersect
  84532. */
  84533. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  84534. }
  84535. }
  84536. declare module BABYLON {
  84537. /**
  84538. * Class used to store bounding box information
  84539. */
  84540. export class BoundingBox implements ICullable {
  84541. /**
  84542. * Gets the 8 vectors representing the bounding box in local space
  84543. */
  84544. readonly vectors: Vector3[];
  84545. /**
  84546. * Gets the center of the bounding box in local space
  84547. */
  84548. readonly center: Vector3;
  84549. /**
  84550. * Gets the center of the bounding box in world space
  84551. */
  84552. readonly centerWorld: Vector3;
  84553. /**
  84554. * Gets the extend size in local space
  84555. */
  84556. readonly extendSize: Vector3;
  84557. /**
  84558. * Gets the extend size in world space
  84559. */
  84560. readonly extendSizeWorld: Vector3;
  84561. /**
  84562. * Gets the OBB (object bounding box) directions
  84563. */
  84564. readonly directions: Vector3[];
  84565. /**
  84566. * Gets the 8 vectors representing the bounding box in world space
  84567. */
  84568. readonly vectorsWorld: Vector3[];
  84569. /**
  84570. * Gets the minimum vector in world space
  84571. */
  84572. readonly minimumWorld: Vector3;
  84573. /**
  84574. * Gets the maximum vector in world space
  84575. */
  84576. readonly maximumWorld: Vector3;
  84577. /**
  84578. * Gets the minimum vector in local space
  84579. */
  84580. readonly minimum: Vector3;
  84581. /**
  84582. * Gets the maximum vector in local space
  84583. */
  84584. readonly maximum: Vector3;
  84585. private _worldMatrix;
  84586. private static readonly TmpVector3;
  84587. /**
  84588. * @hidden
  84589. */
  84590. _tag: number;
  84591. /**
  84592. * Creates a new bounding box
  84593. * @param min defines the minimum vector (in local space)
  84594. * @param max defines the maximum vector (in local space)
  84595. * @param worldMatrix defines the new world matrix
  84596. */
  84597. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84598. /**
  84599. * Recreates the entire bounding box from scratch as if we call the constructor in place
  84600. * @param min defines the new minimum vector (in local space)
  84601. * @param max defines the new maximum vector (in local space)
  84602. * @param worldMatrix defines the new world matrix
  84603. */
  84604. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84605. /**
  84606. * Scale the current bounding box by applying a scale factor
  84607. * @param factor defines the scale factor to apply
  84608. * @returns the current bounding box
  84609. */
  84610. scale(factor: number): BoundingBox;
  84611. /**
  84612. * Gets the world matrix of the bounding box
  84613. * @returns a matrix
  84614. */
  84615. getWorldMatrix(): DeepImmutable<Matrix>;
  84616. /** @hidden */
  84617. _update(world: DeepImmutable<Matrix>): void;
  84618. /**
  84619. * Tests if the bounding box is intersecting the frustum planes
  84620. * @param frustumPlanes defines the frustum planes to test
  84621. * @returns true if there is an intersection
  84622. */
  84623. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84624. /**
  84625. * Tests if the bounding box is entirely inside the frustum planes
  84626. * @param frustumPlanes defines the frustum planes to test
  84627. * @returns true if there is an inclusion
  84628. */
  84629. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84630. /**
  84631. * Tests if a point is inside the bounding box
  84632. * @param point defines the point to test
  84633. * @returns true if the point is inside the bounding box
  84634. */
  84635. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84636. /**
  84637. * Tests if the bounding box intersects with a bounding sphere
  84638. * @param sphere defines the sphere to test
  84639. * @returns true if there is an intersection
  84640. */
  84641. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  84642. /**
  84643. * Tests if the bounding box intersects with a box defined by a min and max vectors
  84644. * @param min defines the min vector to use
  84645. * @param max defines the max vector to use
  84646. * @returns true if there is an intersection
  84647. */
  84648. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  84649. /**
  84650. * Tests if two bounding boxes are intersections
  84651. * @param box0 defines the first box to test
  84652. * @param box1 defines the second box to test
  84653. * @returns true if there is an intersection
  84654. */
  84655. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  84656. /**
  84657. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  84658. * @param minPoint defines the minimum vector of the bounding box
  84659. * @param maxPoint defines the maximum vector of the bounding box
  84660. * @param sphereCenter defines the sphere center
  84661. * @param sphereRadius defines the sphere radius
  84662. * @returns true if there is an intersection
  84663. */
  84664. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  84665. /**
  84666. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  84667. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84668. * @param frustumPlanes defines the frustum planes to test
  84669. * @return true if there is an inclusion
  84670. */
  84671. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84672. /**
  84673. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  84674. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84675. * @param frustumPlanes defines the frustum planes to test
  84676. * @return true if there is an intersection
  84677. */
  84678. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84679. }
  84680. }
  84681. declare module BABYLON {
  84682. /** @hidden */
  84683. export class Collider {
  84684. /** Define if a collision was found */
  84685. collisionFound: boolean;
  84686. /**
  84687. * Define last intersection point in local space
  84688. */
  84689. intersectionPoint: Vector3;
  84690. /**
  84691. * Define last collided mesh
  84692. */
  84693. collidedMesh: Nullable<AbstractMesh>;
  84694. private _collisionPoint;
  84695. private _planeIntersectionPoint;
  84696. private _tempVector;
  84697. private _tempVector2;
  84698. private _tempVector3;
  84699. private _tempVector4;
  84700. private _edge;
  84701. private _baseToVertex;
  84702. private _destinationPoint;
  84703. private _slidePlaneNormal;
  84704. private _displacementVector;
  84705. /** @hidden */
  84706. _radius: Vector3;
  84707. /** @hidden */
  84708. _retry: number;
  84709. private _velocity;
  84710. private _basePoint;
  84711. private _epsilon;
  84712. /** @hidden */
  84713. _velocityWorldLength: number;
  84714. /** @hidden */
  84715. _basePointWorld: Vector3;
  84716. private _velocityWorld;
  84717. private _normalizedVelocity;
  84718. /** @hidden */
  84719. _initialVelocity: Vector3;
  84720. /** @hidden */
  84721. _initialPosition: Vector3;
  84722. private _nearestDistance;
  84723. private _collisionMask;
  84724. get collisionMask(): number;
  84725. set collisionMask(mask: number);
  84726. /**
  84727. * Gets the plane normal used to compute the sliding response (in local space)
  84728. */
  84729. get slidePlaneNormal(): Vector3;
  84730. /** @hidden */
  84731. _initialize(source: Vector3, dir: Vector3, e: number): void;
  84732. /** @hidden */
  84733. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  84734. /** @hidden */
  84735. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  84736. /** @hidden */
  84737. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84738. /** @hidden */
  84739. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84740. /** @hidden */
  84741. _getResponse(pos: Vector3, vel: Vector3): void;
  84742. }
  84743. }
  84744. declare module BABYLON {
  84745. /**
  84746. * Interface for cullable objects
  84747. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  84748. */
  84749. export interface ICullable {
  84750. /**
  84751. * Checks if the object or part of the object is in the frustum
  84752. * @param frustumPlanes Camera near/planes
  84753. * @returns true if the object is in frustum otherwise false
  84754. */
  84755. isInFrustum(frustumPlanes: Plane[]): boolean;
  84756. /**
  84757. * Checks if a cullable object (mesh...) is in the camera frustum
  84758. * Unlike isInFrustum this cheks the full bounding box
  84759. * @param frustumPlanes Camera near/planes
  84760. * @returns true if the object is in frustum otherwise false
  84761. */
  84762. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84763. }
  84764. /**
  84765. * Info for a bounding data of a mesh
  84766. */
  84767. export class BoundingInfo implements ICullable {
  84768. /**
  84769. * Bounding box for the mesh
  84770. */
  84771. readonly boundingBox: BoundingBox;
  84772. /**
  84773. * Bounding sphere for the mesh
  84774. */
  84775. readonly boundingSphere: BoundingSphere;
  84776. private _isLocked;
  84777. private static readonly TmpVector3;
  84778. /**
  84779. * Constructs bounding info
  84780. * @param minimum min vector of the bounding box/sphere
  84781. * @param maximum max vector of the bounding box/sphere
  84782. * @param worldMatrix defines the new world matrix
  84783. */
  84784. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84785. /**
  84786. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84787. * @param min defines the new minimum vector (in local space)
  84788. * @param max defines the new maximum vector (in local space)
  84789. * @param worldMatrix defines the new world matrix
  84790. */
  84791. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84792. /**
  84793. * min vector of the bounding box/sphere
  84794. */
  84795. get minimum(): Vector3;
  84796. /**
  84797. * max vector of the bounding box/sphere
  84798. */
  84799. get maximum(): Vector3;
  84800. /**
  84801. * If the info is locked and won't be updated to avoid perf overhead
  84802. */
  84803. get isLocked(): boolean;
  84804. set isLocked(value: boolean);
  84805. /**
  84806. * Updates the bounding sphere and box
  84807. * @param world world matrix to be used to update
  84808. */
  84809. update(world: DeepImmutable<Matrix>): void;
  84810. /**
  84811. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84812. * @param center New center of the bounding info
  84813. * @param extend New extend of the bounding info
  84814. * @returns the current bounding info
  84815. */
  84816. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84817. /**
  84818. * Scale the current bounding info by applying a scale factor
  84819. * @param factor defines the scale factor to apply
  84820. * @returns the current bounding info
  84821. */
  84822. scale(factor: number): BoundingInfo;
  84823. /**
  84824. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84825. * @param frustumPlanes defines the frustum to test
  84826. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84827. * @returns true if the bounding info is in the frustum planes
  84828. */
  84829. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84830. /**
  84831. * Gets the world distance between the min and max points of the bounding box
  84832. */
  84833. get diagonalLength(): number;
  84834. /**
  84835. * Checks if a cullable object (mesh...) is in the camera frustum
  84836. * Unlike isInFrustum this cheks the full bounding box
  84837. * @param frustumPlanes Camera near/planes
  84838. * @returns true if the object is in frustum otherwise false
  84839. */
  84840. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84841. /** @hidden */
  84842. _checkCollision(collider: Collider): boolean;
  84843. /**
  84844. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84845. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84846. * @param point the point to check intersection with
  84847. * @returns if the point intersects
  84848. */
  84849. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84850. /**
  84851. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84852. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84853. * @param boundingInfo the bounding info to check intersection with
  84854. * @param precise if the intersection should be done using OBB
  84855. * @returns if the bounding info intersects
  84856. */
  84857. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  84858. }
  84859. }
  84860. declare module BABYLON {
  84861. /**
  84862. * Extracts minimum and maximum values from a list of indexed positions
  84863. * @param positions defines the positions to use
  84864. * @param indices defines the indices to the positions
  84865. * @param indexStart defines the start index
  84866. * @param indexCount defines the end index
  84867. * @param bias defines bias value to add to the result
  84868. * @return minimum and maximum values
  84869. */
  84870. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  84871. minimum: Vector3;
  84872. maximum: Vector3;
  84873. };
  84874. /**
  84875. * Extracts minimum and maximum values from a list of positions
  84876. * @param positions defines the positions to use
  84877. * @param start defines the start index in the positions array
  84878. * @param count defines the number of positions to handle
  84879. * @param bias defines bias value to add to the result
  84880. * @param stride defines the stride size to use (distance between two positions in the positions array)
  84881. * @return minimum and maximum values
  84882. */
  84883. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  84884. minimum: Vector3;
  84885. maximum: Vector3;
  84886. };
  84887. }
  84888. declare module BABYLON {
  84889. /** @hidden */
  84890. export class WebGLDataBuffer extends DataBuffer {
  84891. private _buffer;
  84892. constructor(resource: WebGLBuffer);
  84893. get underlyingResource(): any;
  84894. }
  84895. }
  84896. declare module BABYLON {
  84897. /** @hidden */
  84898. export class WebGLPipelineContext implements IPipelineContext {
  84899. engine: ThinEngine;
  84900. program: Nullable<WebGLProgram>;
  84901. context?: WebGLRenderingContext;
  84902. vertexShader?: WebGLShader;
  84903. fragmentShader?: WebGLShader;
  84904. isParallelCompiled: boolean;
  84905. onCompiled?: () => void;
  84906. transformFeedback?: WebGLTransformFeedback | null;
  84907. vertexCompilationError: Nullable<string>;
  84908. fragmentCompilationError: Nullable<string>;
  84909. programLinkError: Nullable<string>;
  84910. programValidationError: Nullable<string>;
  84911. get isAsync(): boolean;
  84912. get isReady(): boolean;
  84913. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  84914. _getVertexShaderCode(): string | null;
  84915. _getFragmentShaderCode(): string | null;
  84916. }
  84917. }
  84918. declare module BABYLON {
  84919. interface ThinEngine {
  84920. /**
  84921. * Create an uniform buffer
  84922. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84923. * @param elements defines the content of the uniform buffer
  84924. * @returns the webGL uniform buffer
  84925. */
  84926. createUniformBuffer(elements: FloatArray): DataBuffer;
  84927. /**
  84928. * Create a dynamic uniform buffer
  84929. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84930. * @param elements defines the content of the uniform buffer
  84931. * @returns the webGL uniform buffer
  84932. */
  84933. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  84934. /**
  84935. * Update an existing uniform buffer
  84936. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84937. * @param uniformBuffer defines the target uniform buffer
  84938. * @param elements defines the content to update
  84939. * @param offset defines the offset in the uniform buffer where update should start
  84940. * @param count defines the size of the data to update
  84941. */
  84942. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84943. /**
  84944. * Bind an uniform buffer to the current webGL context
  84945. * @param buffer defines the buffer to bind
  84946. */
  84947. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  84948. /**
  84949. * Bind a buffer to the current webGL context at a given location
  84950. * @param buffer defines the buffer to bind
  84951. * @param location defines the index where to bind the buffer
  84952. */
  84953. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  84954. /**
  84955. * Bind a specific block at a given index in a specific shader program
  84956. * @param pipelineContext defines the pipeline context to use
  84957. * @param blockName defines the block name
  84958. * @param index defines the index where to bind the block
  84959. */
  84960. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  84961. }
  84962. }
  84963. declare module BABYLON {
  84964. /**
  84965. * Uniform buffer objects.
  84966. *
  84967. * Handles blocks of uniform on the GPU.
  84968. *
  84969. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84970. *
  84971. * For more information, please refer to :
  84972. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84973. */
  84974. export class UniformBuffer {
  84975. private _engine;
  84976. private _buffer;
  84977. private _data;
  84978. private _bufferData;
  84979. private _dynamic?;
  84980. private _uniformLocations;
  84981. private _uniformSizes;
  84982. private _uniformLocationPointer;
  84983. private _needSync;
  84984. private _noUBO;
  84985. private _currentEffect;
  84986. /** @hidden */
  84987. _alreadyBound: boolean;
  84988. private static _MAX_UNIFORM_SIZE;
  84989. private static _tempBuffer;
  84990. /**
  84991. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84992. * This is dynamic to allow compat with webgl 1 and 2.
  84993. * You will need to pass the name of the uniform as well as the value.
  84994. */
  84995. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84996. /**
  84997. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84998. * This is dynamic to allow compat with webgl 1 and 2.
  84999. * You will need to pass the name of the uniform as well as the value.
  85000. */
  85001. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85002. /**
  85003. * Lambda to Update a single float in a uniform buffer.
  85004. * This is dynamic to allow compat with webgl 1 and 2.
  85005. * You will need to pass the name of the uniform as well as the value.
  85006. */
  85007. updateFloat: (name: string, x: number) => void;
  85008. /**
  85009. * Lambda to Update a vec2 of float in a uniform buffer.
  85010. * This is dynamic to allow compat with webgl 1 and 2.
  85011. * You will need to pass the name of the uniform as well as the value.
  85012. */
  85013. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85014. /**
  85015. * Lambda to Update a vec3 of float in a uniform buffer.
  85016. * This is dynamic to allow compat with webgl 1 and 2.
  85017. * You will need to pass the name of the uniform as well as the value.
  85018. */
  85019. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85020. /**
  85021. * Lambda to Update a vec4 of float in a uniform buffer.
  85022. * This is dynamic to allow compat with webgl 1 and 2.
  85023. * You will need to pass the name of the uniform as well as the value.
  85024. */
  85025. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85026. /**
  85027. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85028. * This is dynamic to allow compat with webgl 1 and 2.
  85029. * You will need to pass the name of the uniform as well as the value.
  85030. */
  85031. updateMatrix: (name: string, mat: Matrix) => void;
  85032. /**
  85033. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85034. * This is dynamic to allow compat with webgl 1 and 2.
  85035. * You will need to pass the name of the uniform as well as the value.
  85036. */
  85037. updateVector3: (name: string, vector: Vector3) => void;
  85038. /**
  85039. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85040. * This is dynamic to allow compat with webgl 1 and 2.
  85041. * You will need to pass the name of the uniform as well as the value.
  85042. */
  85043. updateVector4: (name: string, vector: Vector4) => void;
  85044. /**
  85045. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85046. * This is dynamic to allow compat with webgl 1 and 2.
  85047. * You will need to pass the name of the uniform as well as the value.
  85048. */
  85049. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85050. /**
  85051. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85052. * This is dynamic to allow compat with webgl 1 and 2.
  85053. * You will need to pass the name of the uniform as well as the value.
  85054. */
  85055. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85056. /**
  85057. * Instantiates a new Uniform buffer objects.
  85058. *
  85059. * Handles blocks of uniform on the GPU.
  85060. *
  85061. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85062. *
  85063. * For more information, please refer to :
  85064. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85065. * @param engine Define the engine the buffer is associated with
  85066. * @param data Define the data contained in the buffer
  85067. * @param dynamic Define if the buffer is updatable
  85068. */
  85069. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85070. /**
  85071. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85072. * or just falling back on setUniformXXX calls.
  85073. */
  85074. get useUbo(): boolean;
  85075. /**
  85076. * Indicates if the WebGL underlying uniform buffer is in sync
  85077. * with the javascript cache data.
  85078. */
  85079. get isSync(): boolean;
  85080. /**
  85081. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85082. * Also, a dynamic UniformBuffer will disable cache verification and always
  85083. * update the underlying WebGL uniform buffer to the GPU.
  85084. * @returns if Dynamic, otherwise false
  85085. */
  85086. isDynamic(): boolean;
  85087. /**
  85088. * The data cache on JS side.
  85089. * @returns the underlying data as a float array
  85090. */
  85091. getData(): Float32Array;
  85092. /**
  85093. * The underlying WebGL Uniform buffer.
  85094. * @returns the webgl buffer
  85095. */
  85096. getBuffer(): Nullable<DataBuffer>;
  85097. /**
  85098. * std140 layout specifies how to align data within an UBO structure.
  85099. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85100. * for specs.
  85101. */
  85102. private _fillAlignment;
  85103. /**
  85104. * Adds an uniform in the buffer.
  85105. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85106. * for the layout to be correct !
  85107. * @param name Name of the uniform, as used in the uniform block in the shader.
  85108. * @param size Data size, or data directly.
  85109. */
  85110. addUniform(name: string, size: number | number[]): void;
  85111. /**
  85112. * Adds a Matrix 4x4 to the uniform buffer.
  85113. * @param name Name of the uniform, as used in the uniform block in the shader.
  85114. * @param mat A 4x4 matrix.
  85115. */
  85116. addMatrix(name: string, mat: Matrix): void;
  85117. /**
  85118. * Adds a vec2 to the uniform buffer.
  85119. * @param name Name of the uniform, as used in the uniform block in the shader.
  85120. * @param x Define the x component value of the vec2
  85121. * @param y Define the y component value of the vec2
  85122. */
  85123. addFloat2(name: string, x: number, y: number): void;
  85124. /**
  85125. * Adds a vec3 to the uniform buffer.
  85126. * @param name Name of the uniform, as used in the uniform block in the shader.
  85127. * @param x Define the x component value of the vec3
  85128. * @param y Define the y component value of the vec3
  85129. * @param z Define the z component value of the vec3
  85130. */
  85131. addFloat3(name: string, x: number, y: number, z: number): void;
  85132. /**
  85133. * Adds a vec3 to the uniform buffer.
  85134. * @param name Name of the uniform, as used in the uniform block in the shader.
  85135. * @param color Define the vec3 from a Color
  85136. */
  85137. addColor3(name: string, color: Color3): void;
  85138. /**
  85139. * Adds a vec4 to the uniform buffer.
  85140. * @param name Name of the uniform, as used in the uniform block in the shader.
  85141. * @param color Define the rgb components from a Color
  85142. * @param alpha Define the a component of the vec4
  85143. */
  85144. addColor4(name: string, color: Color3, alpha: number): void;
  85145. /**
  85146. * Adds a vec3 to the uniform buffer.
  85147. * @param name Name of the uniform, as used in the uniform block in the shader.
  85148. * @param vector Define the vec3 components from a Vector
  85149. */
  85150. addVector3(name: string, vector: Vector3): void;
  85151. /**
  85152. * Adds a Matrix 3x3 to the uniform buffer.
  85153. * @param name Name of the uniform, as used in the uniform block in the shader.
  85154. */
  85155. addMatrix3x3(name: string): void;
  85156. /**
  85157. * Adds a Matrix 2x2 to the uniform buffer.
  85158. * @param name Name of the uniform, as used in the uniform block in the shader.
  85159. */
  85160. addMatrix2x2(name: string): void;
  85161. /**
  85162. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85163. */
  85164. create(): void;
  85165. /** @hidden */
  85166. _rebuild(): void;
  85167. /**
  85168. * Updates the WebGL Uniform Buffer on the GPU.
  85169. * If the `dynamic` flag is set to true, no cache comparison is done.
  85170. * Otherwise, the buffer will be updated only if the cache differs.
  85171. */
  85172. update(): void;
  85173. /**
  85174. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85175. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85176. * @param data Define the flattened data
  85177. * @param size Define the size of the data.
  85178. */
  85179. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85180. private _valueCache;
  85181. private _cacheMatrix;
  85182. private _updateMatrix3x3ForUniform;
  85183. private _updateMatrix3x3ForEffect;
  85184. private _updateMatrix2x2ForEffect;
  85185. private _updateMatrix2x2ForUniform;
  85186. private _updateFloatForEffect;
  85187. private _updateFloatForUniform;
  85188. private _updateFloat2ForEffect;
  85189. private _updateFloat2ForUniform;
  85190. private _updateFloat3ForEffect;
  85191. private _updateFloat3ForUniform;
  85192. private _updateFloat4ForEffect;
  85193. private _updateFloat4ForUniform;
  85194. private _updateMatrixForEffect;
  85195. private _updateMatrixForUniform;
  85196. private _updateVector3ForEffect;
  85197. private _updateVector3ForUniform;
  85198. private _updateVector4ForEffect;
  85199. private _updateVector4ForUniform;
  85200. private _updateColor3ForEffect;
  85201. private _updateColor3ForUniform;
  85202. private _updateColor4ForEffect;
  85203. private _updateColor4ForUniform;
  85204. /**
  85205. * Sets a sampler uniform on the effect.
  85206. * @param name Define the name of the sampler.
  85207. * @param texture Define the texture to set in the sampler
  85208. */
  85209. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85210. /**
  85211. * Directly updates the value of the uniform in the cache AND on the GPU.
  85212. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85213. * @param data Define the flattened data
  85214. */
  85215. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85216. /**
  85217. * Binds this uniform buffer to an effect.
  85218. * @param effect Define the effect to bind the buffer to
  85219. * @param name Name of the uniform block in the shader.
  85220. */
  85221. bindToEffect(effect: Effect, name: string): void;
  85222. /**
  85223. * Disposes the uniform buffer.
  85224. */
  85225. dispose(): void;
  85226. }
  85227. }
  85228. declare module BABYLON {
  85229. /**
  85230. * Enum that determines the text-wrapping mode to use.
  85231. */
  85232. export enum InspectableType {
  85233. /**
  85234. * Checkbox for booleans
  85235. */
  85236. Checkbox = 0,
  85237. /**
  85238. * Sliders for numbers
  85239. */
  85240. Slider = 1,
  85241. /**
  85242. * Vector3
  85243. */
  85244. Vector3 = 2,
  85245. /**
  85246. * Quaternions
  85247. */
  85248. Quaternion = 3,
  85249. /**
  85250. * Color3
  85251. */
  85252. Color3 = 4,
  85253. /**
  85254. * String
  85255. */
  85256. String = 5
  85257. }
  85258. /**
  85259. * Interface used to define custom inspectable properties.
  85260. * This interface is used by the inspector to display custom property grids
  85261. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85262. */
  85263. export interface IInspectable {
  85264. /**
  85265. * Gets the label to display
  85266. */
  85267. label: string;
  85268. /**
  85269. * Gets the name of the property to edit
  85270. */
  85271. propertyName: string;
  85272. /**
  85273. * Gets the type of the editor to use
  85274. */
  85275. type: InspectableType;
  85276. /**
  85277. * Gets the minimum value of the property when using in "slider" mode
  85278. */
  85279. min?: number;
  85280. /**
  85281. * Gets the maximum value of the property when using in "slider" mode
  85282. */
  85283. max?: number;
  85284. /**
  85285. * Gets the setp to use when using in "slider" mode
  85286. */
  85287. step?: number;
  85288. }
  85289. }
  85290. declare module BABYLON {
  85291. /**
  85292. * Class used to provide helper for timing
  85293. */
  85294. export class TimingTools {
  85295. /**
  85296. * Polyfill for setImmediate
  85297. * @param action defines the action to execute after the current execution block
  85298. */
  85299. static SetImmediate(action: () => void): void;
  85300. }
  85301. }
  85302. declare module BABYLON {
  85303. /**
  85304. * Class used to enable instatition of objects by class name
  85305. */
  85306. export class InstantiationTools {
  85307. /**
  85308. * Use this object to register external classes like custom textures or material
  85309. * to allow the laoders to instantiate them
  85310. */
  85311. static RegisteredExternalClasses: {
  85312. [key: string]: Object;
  85313. };
  85314. /**
  85315. * Tries to instantiate a new object from a given class name
  85316. * @param className defines the class name to instantiate
  85317. * @returns the new object or null if the system was not able to do the instantiation
  85318. */
  85319. static Instantiate(className: string): any;
  85320. }
  85321. }
  85322. declare module BABYLON {
  85323. /**
  85324. * Define options used to create a depth texture
  85325. */
  85326. export class DepthTextureCreationOptions {
  85327. /** Specifies whether or not a stencil should be allocated in the texture */
  85328. generateStencil?: boolean;
  85329. /** Specifies whether or not bilinear filtering is enable on the texture */
  85330. bilinearFiltering?: boolean;
  85331. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85332. comparisonFunction?: number;
  85333. /** Specifies if the created texture is a cube texture */
  85334. isCube?: boolean;
  85335. }
  85336. }
  85337. declare module BABYLON {
  85338. interface ThinEngine {
  85339. /**
  85340. * Creates a depth stencil cube texture.
  85341. * This is only available in WebGL 2.
  85342. * @param size The size of face edge in the cube texture.
  85343. * @param options The options defining the cube texture.
  85344. * @returns The cube texture
  85345. */
  85346. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  85347. /**
  85348. * Creates a cube texture
  85349. * @param rootUrl defines the url where the files to load is located
  85350. * @param scene defines the current scene
  85351. * @param files defines the list of files to load (1 per face)
  85352. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85353. * @param onLoad defines an optional callback raised when the texture is loaded
  85354. * @param onError defines an optional callback raised if there is an issue to load the texture
  85355. * @param format defines the format of the data
  85356. * @param forcedExtension defines the extension to use to pick the right loader
  85357. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85358. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85359. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85360. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85361. * @returns the cube texture as an InternalTexture
  85362. */
  85363. 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;
  85364. /**
  85365. * Creates a cube texture
  85366. * @param rootUrl defines the url where the files to load is located
  85367. * @param scene defines the current scene
  85368. * @param files defines the list of files to load (1 per face)
  85369. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85370. * @param onLoad defines an optional callback raised when the texture is loaded
  85371. * @param onError defines an optional callback raised if there is an issue to load the texture
  85372. * @param format defines the format of the data
  85373. * @param forcedExtension defines the extension to use to pick the right loader
  85374. * @returns the cube texture as an InternalTexture
  85375. */
  85376. 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;
  85377. /**
  85378. * Creates a cube texture
  85379. * @param rootUrl defines the url where the files to load is located
  85380. * @param scene defines the current scene
  85381. * @param files defines the list of files to load (1 per face)
  85382. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85383. * @param onLoad defines an optional callback raised when the texture is loaded
  85384. * @param onError defines an optional callback raised if there is an issue to load the texture
  85385. * @param format defines the format of the data
  85386. * @param forcedExtension defines the extension to use to pick the right loader
  85387. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85388. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85389. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85390. * @returns the cube texture as an InternalTexture
  85391. */
  85392. 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;
  85393. /** @hidden */
  85394. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  85395. /** @hidden */
  85396. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  85397. /** @hidden */
  85398. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85399. /** @hidden */
  85400. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85401. /**
  85402. * @hidden
  85403. */
  85404. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85405. }
  85406. }
  85407. declare module BABYLON {
  85408. /**
  85409. * Class for creating a cube texture
  85410. */
  85411. export class CubeTexture extends BaseTexture {
  85412. private _delayedOnLoad;
  85413. /**
  85414. * Observable triggered once the texture has been loaded.
  85415. */
  85416. onLoadObservable: Observable<CubeTexture>;
  85417. /**
  85418. * The url of the texture
  85419. */
  85420. url: string;
  85421. /**
  85422. * Gets or sets the center of the bounding box associated with the cube texture.
  85423. * It must define where the camera used to render the texture was set
  85424. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85425. */
  85426. boundingBoxPosition: Vector3;
  85427. private _boundingBoxSize;
  85428. /**
  85429. * Gets or sets the size of the bounding box associated with the cube texture
  85430. * When defined, the cubemap will switch to local mode
  85431. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85432. * @example https://www.babylonjs-playground.com/#RNASML
  85433. */
  85434. set boundingBoxSize(value: Vector3);
  85435. /**
  85436. * Returns the bounding box size
  85437. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85438. */
  85439. get boundingBoxSize(): Vector3;
  85440. protected _rotationY: number;
  85441. /**
  85442. * Sets texture matrix rotation angle around Y axis in radians.
  85443. */
  85444. set rotationY(value: number);
  85445. /**
  85446. * Gets texture matrix rotation angle around Y axis radians.
  85447. */
  85448. get rotationY(): number;
  85449. /**
  85450. * Are mip maps generated for this texture or not.
  85451. */
  85452. get noMipmap(): boolean;
  85453. private _noMipmap;
  85454. private _files;
  85455. protected _forcedExtension: Nullable<string>;
  85456. private _extensions;
  85457. private _textureMatrix;
  85458. private _format;
  85459. private _createPolynomials;
  85460. /**
  85461. * Creates a cube texture from an array of image urls
  85462. * @param files defines an array of image urls
  85463. * @param scene defines the hosting scene
  85464. * @param noMipmap specifies if mip maps are not used
  85465. * @returns a cube texture
  85466. */
  85467. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85468. /**
  85469. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  85470. * @param url defines the url of the prefiltered texture
  85471. * @param scene defines the scene the texture is attached to
  85472. * @param forcedExtension defines the extension of the file if different from the url
  85473. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85474. * @return the prefiltered texture
  85475. */
  85476. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  85477. /**
  85478. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  85479. * as prefiltered data.
  85480. * @param rootUrl defines the url of the texture or the root name of the six images
  85481. * @param null defines the scene or engine the texture is attached to
  85482. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  85483. * @param noMipmap defines if mipmaps should be created or not
  85484. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  85485. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  85486. * @param onError defines a callback triggered in case of error during load
  85487. * @param format defines the internal format to use for the texture once loaded
  85488. * @param prefiltered defines whether or not the texture is created from prefiltered data
  85489. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  85490. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85491. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85492. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85493. * @return the cube texture
  85494. */
  85495. 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);
  85496. /**
  85497. * Get the current class name of the texture useful for serialization or dynamic coding.
  85498. * @returns "CubeTexture"
  85499. */
  85500. getClassName(): string;
  85501. /**
  85502. * Update the url (and optional buffer) of this texture if url was null during construction.
  85503. * @param url the url of the texture
  85504. * @param forcedExtension defines the extension to use
  85505. * @param onLoad callback called when the texture is loaded (defaults to null)
  85506. * @param prefiltered Defines whether the updated texture is prefiltered or not
  85507. */
  85508. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  85509. /**
  85510. * Delays loading of the cube texture
  85511. * @param forcedExtension defines the extension to use
  85512. */
  85513. delayLoad(forcedExtension?: string): void;
  85514. /**
  85515. * Returns the reflection texture matrix
  85516. * @returns the reflection texture matrix
  85517. */
  85518. getReflectionTextureMatrix(): Matrix;
  85519. /**
  85520. * Sets the reflection texture matrix
  85521. * @param value Reflection texture matrix
  85522. */
  85523. setReflectionTextureMatrix(value: Matrix): void;
  85524. /**
  85525. * Parses text to create a cube texture
  85526. * @param parsedTexture define the serialized text to read from
  85527. * @param scene defines the hosting scene
  85528. * @param rootUrl defines the root url of the cube texture
  85529. * @returns a cube texture
  85530. */
  85531. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  85532. /**
  85533. * Makes a clone, or deep copy, of the cube texture
  85534. * @returns a new cube texture
  85535. */
  85536. clone(): CubeTexture;
  85537. }
  85538. }
  85539. declare module BABYLON {
  85540. /**
  85541. * Manages the defines for the Material
  85542. */
  85543. export class MaterialDefines {
  85544. /** @hidden */
  85545. protected _keys: string[];
  85546. private _isDirty;
  85547. /** @hidden */
  85548. _renderId: number;
  85549. /** @hidden */
  85550. _areLightsDirty: boolean;
  85551. /** @hidden */
  85552. _areLightsDisposed: boolean;
  85553. /** @hidden */
  85554. _areAttributesDirty: boolean;
  85555. /** @hidden */
  85556. _areTexturesDirty: boolean;
  85557. /** @hidden */
  85558. _areFresnelDirty: boolean;
  85559. /** @hidden */
  85560. _areMiscDirty: boolean;
  85561. /** @hidden */
  85562. _areImageProcessingDirty: boolean;
  85563. /** @hidden */
  85564. _normals: boolean;
  85565. /** @hidden */
  85566. _uvs: boolean;
  85567. /** @hidden */
  85568. _needNormals: boolean;
  85569. /** @hidden */
  85570. _needUVs: boolean;
  85571. [id: string]: any;
  85572. /**
  85573. * Specifies if the material needs to be re-calculated
  85574. */
  85575. get isDirty(): boolean;
  85576. /**
  85577. * Marks the material to indicate that it has been re-calculated
  85578. */
  85579. markAsProcessed(): void;
  85580. /**
  85581. * Marks the material to indicate that it needs to be re-calculated
  85582. */
  85583. markAsUnprocessed(): void;
  85584. /**
  85585. * Marks the material to indicate all of its defines need to be re-calculated
  85586. */
  85587. markAllAsDirty(): void;
  85588. /**
  85589. * Marks the material to indicate that image processing needs to be re-calculated
  85590. */
  85591. markAsImageProcessingDirty(): void;
  85592. /**
  85593. * Marks the material to indicate the lights need to be re-calculated
  85594. * @param disposed Defines whether the light is dirty due to dispose or not
  85595. */
  85596. markAsLightDirty(disposed?: boolean): void;
  85597. /**
  85598. * Marks the attribute state as changed
  85599. */
  85600. markAsAttributesDirty(): void;
  85601. /**
  85602. * Marks the texture state as changed
  85603. */
  85604. markAsTexturesDirty(): void;
  85605. /**
  85606. * Marks the fresnel state as changed
  85607. */
  85608. markAsFresnelDirty(): void;
  85609. /**
  85610. * Marks the misc state as changed
  85611. */
  85612. markAsMiscDirty(): void;
  85613. /**
  85614. * Rebuilds the material defines
  85615. */
  85616. rebuild(): void;
  85617. /**
  85618. * Specifies if two material defines are equal
  85619. * @param other - A material define instance to compare to
  85620. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  85621. */
  85622. isEqual(other: MaterialDefines): boolean;
  85623. /**
  85624. * Clones this instance's defines to another instance
  85625. * @param other - material defines to clone values to
  85626. */
  85627. cloneTo(other: MaterialDefines): void;
  85628. /**
  85629. * Resets the material define values
  85630. */
  85631. reset(): void;
  85632. /**
  85633. * Converts the material define values to a string
  85634. * @returns - String of material define information
  85635. */
  85636. toString(): string;
  85637. }
  85638. }
  85639. declare module BABYLON {
  85640. /**
  85641. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85642. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85643. * 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;
  85644. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85645. */
  85646. export class ColorCurves {
  85647. private _dirty;
  85648. private _tempColor;
  85649. private _globalCurve;
  85650. private _highlightsCurve;
  85651. private _midtonesCurve;
  85652. private _shadowsCurve;
  85653. private _positiveCurve;
  85654. private _negativeCurve;
  85655. private _globalHue;
  85656. private _globalDensity;
  85657. private _globalSaturation;
  85658. private _globalExposure;
  85659. /**
  85660. * Gets the global Hue value.
  85661. * 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).
  85662. */
  85663. get globalHue(): number;
  85664. /**
  85665. * Sets the global Hue value.
  85666. * 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).
  85667. */
  85668. set globalHue(value: number);
  85669. /**
  85670. * Gets the global Density value.
  85671. * 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.
  85672. * Values less than zero provide a filter of opposite hue.
  85673. */
  85674. get globalDensity(): number;
  85675. /**
  85676. * Sets the global Density value.
  85677. * 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.
  85678. * Values less than zero provide a filter of opposite hue.
  85679. */
  85680. set globalDensity(value: number);
  85681. /**
  85682. * Gets the global Saturation value.
  85683. * 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.
  85684. */
  85685. get globalSaturation(): number;
  85686. /**
  85687. * Sets the global Saturation value.
  85688. * 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.
  85689. */
  85690. set globalSaturation(value: number);
  85691. /**
  85692. * Gets the global Exposure value.
  85693. * 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.
  85694. */
  85695. get globalExposure(): number;
  85696. /**
  85697. * Sets the global Exposure value.
  85698. * 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.
  85699. */
  85700. set globalExposure(value: number);
  85701. private _highlightsHue;
  85702. private _highlightsDensity;
  85703. private _highlightsSaturation;
  85704. private _highlightsExposure;
  85705. /**
  85706. * Gets the highlights Hue value.
  85707. * 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).
  85708. */
  85709. get highlightsHue(): number;
  85710. /**
  85711. * Sets the highlights Hue value.
  85712. * 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).
  85713. */
  85714. set highlightsHue(value: number);
  85715. /**
  85716. * Gets the highlights Density value.
  85717. * 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.
  85718. * Values less than zero provide a filter of opposite hue.
  85719. */
  85720. get highlightsDensity(): number;
  85721. /**
  85722. * Sets the highlights Density value.
  85723. * 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.
  85724. * Values less than zero provide a filter of opposite hue.
  85725. */
  85726. set highlightsDensity(value: number);
  85727. /**
  85728. * Gets the highlights Saturation value.
  85729. * 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.
  85730. */
  85731. get highlightsSaturation(): number;
  85732. /**
  85733. * Sets the highlights Saturation value.
  85734. * 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.
  85735. */
  85736. set highlightsSaturation(value: number);
  85737. /**
  85738. * Gets the highlights Exposure value.
  85739. * 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.
  85740. */
  85741. get highlightsExposure(): number;
  85742. /**
  85743. * Sets the highlights Exposure value.
  85744. * 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.
  85745. */
  85746. set highlightsExposure(value: number);
  85747. private _midtonesHue;
  85748. private _midtonesDensity;
  85749. private _midtonesSaturation;
  85750. private _midtonesExposure;
  85751. /**
  85752. * Gets the midtones Hue value.
  85753. * 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).
  85754. */
  85755. get midtonesHue(): number;
  85756. /**
  85757. * Sets the midtones Hue value.
  85758. * 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).
  85759. */
  85760. set midtonesHue(value: number);
  85761. /**
  85762. * Gets the midtones Density value.
  85763. * 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.
  85764. * Values less than zero provide a filter of opposite hue.
  85765. */
  85766. get midtonesDensity(): number;
  85767. /**
  85768. * Sets the midtones Density value.
  85769. * 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.
  85770. * Values less than zero provide a filter of opposite hue.
  85771. */
  85772. set midtonesDensity(value: number);
  85773. /**
  85774. * Gets the midtones Saturation value.
  85775. * 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.
  85776. */
  85777. get midtonesSaturation(): number;
  85778. /**
  85779. * Sets the midtones Saturation value.
  85780. * 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.
  85781. */
  85782. set midtonesSaturation(value: number);
  85783. /**
  85784. * Gets the midtones Exposure value.
  85785. * 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.
  85786. */
  85787. get midtonesExposure(): number;
  85788. /**
  85789. * Sets the midtones Exposure value.
  85790. * 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.
  85791. */
  85792. set midtonesExposure(value: number);
  85793. private _shadowsHue;
  85794. private _shadowsDensity;
  85795. private _shadowsSaturation;
  85796. private _shadowsExposure;
  85797. /**
  85798. * Gets the shadows Hue value.
  85799. * 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).
  85800. */
  85801. get shadowsHue(): number;
  85802. /**
  85803. * Sets the shadows Hue value.
  85804. * 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).
  85805. */
  85806. set shadowsHue(value: number);
  85807. /**
  85808. * Gets the shadows Density value.
  85809. * 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.
  85810. * Values less than zero provide a filter of opposite hue.
  85811. */
  85812. get shadowsDensity(): number;
  85813. /**
  85814. * Sets the shadows Density value.
  85815. * 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.
  85816. * Values less than zero provide a filter of opposite hue.
  85817. */
  85818. set shadowsDensity(value: number);
  85819. /**
  85820. * Gets the shadows Saturation value.
  85821. * 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.
  85822. */
  85823. get shadowsSaturation(): number;
  85824. /**
  85825. * Sets the shadows Saturation value.
  85826. * 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.
  85827. */
  85828. set shadowsSaturation(value: number);
  85829. /**
  85830. * Gets the shadows Exposure value.
  85831. * 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.
  85832. */
  85833. get shadowsExposure(): number;
  85834. /**
  85835. * Sets the shadows Exposure value.
  85836. * 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.
  85837. */
  85838. set shadowsExposure(value: number);
  85839. /**
  85840. * Returns the class name
  85841. * @returns The class name
  85842. */
  85843. getClassName(): string;
  85844. /**
  85845. * Binds the color curves to the shader.
  85846. * @param colorCurves The color curve to bind
  85847. * @param effect The effect to bind to
  85848. * @param positiveUniform The positive uniform shader parameter
  85849. * @param neutralUniform The neutral uniform shader parameter
  85850. * @param negativeUniform The negative uniform shader parameter
  85851. */
  85852. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85853. /**
  85854. * Prepare the list of uniforms associated with the ColorCurves effects.
  85855. * @param uniformsList The list of uniforms used in the effect
  85856. */
  85857. static PrepareUniforms(uniformsList: string[]): void;
  85858. /**
  85859. * Returns color grading data based on a hue, density, saturation and exposure value.
  85860. * @param filterHue The hue of the color filter.
  85861. * @param filterDensity The density of the color filter.
  85862. * @param saturation The saturation.
  85863. * @param exposure The exposure.
  85864. * @param result The result data container.
  85865. */
  85866. private getColorGradingDataToRef;
  85867. /**
  85868. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85869. * @param value The input slider value in range [-100,100].
  85870. * @returns Adjusted value.
  85871. */
  85872. private static applyColorGradingSliderNonlinear;
  85873. /**
  85874. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85875. * @param hue The hue (H) input.
  85876. * @param saturation The saturation (S) input.
  85877. * @param brightness The brightness (B) input.
  85878. * @result An RGBA color represented as Vector4.
  85879. */
  85880. private static fromHSBToRef;
  85881. /**
  85882. * Returns a value clamped between min and max
  85883. * @param value The value to clamp
  85884. * @param min The minimum of value
  85885. * @param max The maximum of value
  85886. * @returns The clamped value.
  85887. */
  85888. private static clamp;
  85889. /**
  85890. * Clones the current color curve instance.
  85891. * @return The cloned curves
  85892. */
  85893. clone(): ColorCurves;
  85894. /**
  85895. * Serializes the current color curve instance to a json representation.
  85896. * @return a JSON representation
  85897. */
  85898. serialize(): any;
  85899. /**
  85900. * Parses the color curve from a json representation.
  85901. * @param source the JSON source to parse
  85902. * @return The parsed curves
  85903. */
  85904. static Parse(source: any): ColorCurves;
  85905. }
  85906. }
  85907. declare module BABYLON {
  85908. /**
  85909. * Interface to follow in your material defines to integrate easily the
  85910. * Image proccessing functions.
  85911. * @hidden
  85912. */
  85913. export interface IImageProcessingConfigurationDefines {
  85914. IMAGEPROCESSING: boolean;
  85915. VIGNETTE: boolean;
  85916. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85917. VIGNETTEBLENDMODEOPAQUE: boolean;
  85918. TONEMAPPING: boolean;
  85919. TONEMAPPING_ACES: boolean;
  85920. CONTRAST: boolean;
  85921. EXPOSURE: boolean;
  85922. COLORCURVES: boolean;
  85923. COLORGRADING: boolean;
  85924. COLORGRADING3D: boolean;
  85925. SAMPLER3DGREENDEPTH: boolean;
  85926. SAMPLER3DBGRMAP: boolean;
  85927. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85928. }
  85929. /**
  85930. * @hidden
  85931. */
  85932. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85933. IMAGEPROCESSING: boolean;
  85934. VIGNETTE: boolean;
  85935. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85936. VIGNETTEBLENDMODEOPAQUE: boolean;
  85937. TONEMAPPING: boolean;
  85938. TONEMAPPING_ACES: boolean;
  85939. CONTRAST: boolean;
  85940. COLORCURVES: boolean;
  85941. COLORGRADING: boolean;
  85942. COLORGRADING3D: boolean;
  85943. SAMPLER3DGREENDEPTH: boolean;
  85944. SAMPLER3DBGRMAP: boolean;
  85945. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85946. EXPOSURE: boolean;
  85947. constructor();
  85948. }
  85949. /**
  85950. * This groups together the common properties used for image processing either in direct forward pass
  85951. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85952. * or not.
  85953. */
  85954. export class ImageProcessingConfiguration {
  85955. /**
  85956. * Default tone mapping applied in BabylonJS.
  85957. */
  85958. static readonly TONEMAPPING_STANDARD: number;
  85959. /**
  85960. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85961. * to other engines rendering to increase portability.
  85962. */
  85963. static readonly TONEMAPPING_ACES: number;
  85964. /**
  85965. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85966. */
  85967. colorCurves: Nullable<ColorCurves>;
  85968. private _colorCurvesEnabled;
  85969. /**
  85970. * Gets wether the color curves effect is enabled.
  85971. */
  85972. get colorCurvesEnabled(): boolean;
  85973. /**
  85974. * Sets wether the color curves effect is enabled.
  85975. */
  85976. set colorCurvesEnabled(value: boolean);
  85977. private _colorGradingTexture;
  85978. /**
  85979. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85980. */
  85981. get colorGradingTexture(): Nullable<BaseTexture>;
  85982. /**
  85983. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85984. */
  85985. set colorGradingTexture(value: Nullable<BaseTexture>);
  85986. private _colorGradingEnabled;
  85987. /**
  85988. * Gets wether the color grading effect is enabled.
  85989. */
  85990. get colorGradingEnabled(): boolean;
  85991. /**
  85992. * Sets wether the color grading effect is enabled.
  85993. */
  85994. set colorGradingEnabled(value: boolean);
  85995. private _colorGradingWithGreenDepth;
  85996. /**
  85997. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85998. */
  85999. get colorGradingWithGreenDepth(): boolean;
  86000. /**
  86001. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86002. */
  86003. set colorGradingWithGreenDepth(value: boolean);
  86004. private _colorGradingBGR;
  86005. /**
  86006. * Gets wether the color grading texture contains BGR values.
  86007. */
  86008. get colorGradingBGR(): boolean;
  86009. /**
  86010. * Sets wether the color grading texture contains BGR values.
  86011. */
  86012. set colorGradingBGR(value: boolean);
  86013. /** @hidden */
  86014. _exposure: number;
  86015. /**
  86016. * Gets the Exposure used in the effect.
  86017. */
  86018. get exposure(): number;
  86019. /**
  86020. * Sets the Exposure used in the effect.
  86021. */
  86022. set exposure(value: number);
  86023. private _toneMappingEnabled;
  86024. /**
  86025. * Gets wether the tone mapping effect is enabled.
  86026. */
  86027. get toneMappingEnabled(): boolean;
  86028. /**
  86029. * Sets wether the tone mapping effect is enabled.
  86030. */
  86031. set toneMappingEnabled(value: boolean);
  86032. private _toneMappingType;
  86033. /**
  86034. * Gets the type of tone mapping effect.
  86035. */
  86036. get toneMappingType(): number;
  86037. /**
  86038. * Sets the type of tone mapping effect used in BabylonJS.
  86039. */
  86040. set toneMappingType(value: number);
  86041. protected _contrast: number;
  86042. /**
  86043. * Gets the contrast used in the effect.
  86044. */
  86045. get contrast(): number;
  86046. /**
  86047. * Sets the contrast used in the effect.
  86048. */
  86049. set contrast(value: number);
  86050. /**
  86051. * Vignette stretch size.
  86052. */
  86053. vignetteStretch: number;
  86054. /**
  86055. * Vignette centre X Offset.
  86056. */
  86057. vignetteCentreX: number;
  86058. /**
  86059. * Vignette centre Y Offset.
  86060. */
  86061. vignetteCentreY: number;
  86062. /**
  86063. * Vignette weight or intensity of the vignette effect.
  86064. */
  86065. vignetteWeight: number;
  86066. /**
  86067. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86068. * if vignetteEnabled is set to true.
  86069. */
  86070. vignetteColor: Color4;
  86071. /**
  86072. * Camera field of view used by the Vignette effect.
  86073. */
  86074. vignetteCameraFov: number;
  86075. private _vignetteBlendMode;
  86076. /**
  86077. * Gets the vignette blend mode allowing different kind of effect.
  86078. */
  86079. get vignetteBlendMode(): number;
  86080. /**
  86081. * Sets the vignette blend mode allowing different kind of effect.
  86082. */
  86083. set vignetteBlendMode(value: number);
  86084. private _vignetteEnabled;
  86085. /**
  86086. * Gets wether the vignette effect is enabled.
  86087. */
  86088. get vignetteEnabled(): boolean;
  86089. /**
  86090. * Sets wether the vignette effect is enabled.
  86091. */
  86092. set vignetteEnabled(value: boolean);
  86093. private _applyByPostProcess;
  86094. /**
  86095. * Gets wether the image processing is applied through a post process or not.
  86096. */
  86097. get applyByPostProcess(): boolean;
  86098. /**
  86099. * Sets wether the image processing is applied through a post process or not.
  86100. */
  86101. set applyByPostProcess(value: boolean);
  86102. private _isEnabled;
  86103. /**
  86104. * Gets wether the image processing is enabled or not.
  86105. */
  86106. get isEnabled(): boolean;
  86107. /**
  86108. * Sets wether the image processing is enabled or not.
  86109. */
  86110. set isEnabled(value: boolean);
  86111. /**
  86112. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86113. */
  86114. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86115. /**
  86116. * Method called each time the image processing information changes requires to recompile the effect.
  86117. */
  86118. protected _updateParameters(): void;
  86119. /**
  86120. * Gets the current class name.
  86121. * @return "ImageProcessingConfiguration"
  86122. */
  86123. getClassName(): string;
  86124. /**
  86125. * Prepare the list of uniforms associated with the Image Processing effects.
  86126. * @param uniforms The list of uniforms used in the effect
  86127. * @param defines the list of defines currently in use
  86128. */
  86129. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86130. /**
  86131. * Prepare the list of samplers associated with the Image Processing effects.
  86132. * @param samplersList The list of uniforms used in the effect
  86133. * @param defines the list of defines currently in use
  86134. */
  86135. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86136. /**
  86137. * Prepare the list of defines associated to the shader.
  86138. * @param defines the list of defines to complete
  86139. * @param forPostProcess Define if we are currently in post process mode or not
  86140. */
  86141. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86142. /**
  86143. * Returns true if all the image processing information are ready.
  86144. * @returns True if ready, otherwise, false
  86145. */
  86146. isReady(): boolean;
  86147. /**
  86148. * Binds the image processing to the shader.
  86149. * @param effect The effect to bind to
  86150. * @param overrideAspectRatio Override the aspect ratio of the effect
  86151. */
  86152. bind(effect: Effect, overrideAspectRatio?: number): void;
  86153. /**
  86154. * Clones the current image processing instance.
  86155. * @return The cloned image processing
  86156. */
  86157. clone(): ImageProcessingConfiguration;
  86158. /**
  86159. * Serializes the current image processing instance to a json representation.
  86160. * @return a JSON representation
  86161. */
  86162. serialize(): any;
  86163. /**
  86164. * Parses the image processing from a json representation.
  86165. * @param source the JSON source to parse
  86166. * @return The parsed image processing
  86167. */
  86168. static Parse(source: any): ImageProcessingConfiguration;
  86169. private static _VIGNETTEMODE_MULTIPLY;
  86170. private static _VIGNETTEMODE_OPAQUE;
  86171. /**
  86172. * Used to apply the vignette as a mix with the pixel color.
  86173. */
  86174. static get VIGNETTEMODE_MULTIPLY(): number;
  86175. /**
  86176. * Used to apply the vignette as a replacement of the pixel color.
  86177. */
  86178. static get VIGNETTEMODE_OPAQUE(): number;
  86179. }
  86180. }
  86181. declare module BABYLON {
  86182. /** @hidden */
  86183. export var postprocessVertexShader: {
  86184. name: string;
  86185. shader: string;
  86186. };
  86187. }
  86188. declare module BABYLON {
  86189. interface ThinEngine {
  86190. /**
  86191. * Creates a new render target texture
  86192. * @param size defines the size of the texture
  86193. * @param options defines the options used to create the texture
  86194. * @returns a new render target texture stored in an InternalTexture
  86195. */
  86196. createRenderTargetTexture(size: number | {
  86197. width: number;
  86198. height: number;
  86199. layers?: number;
  86200. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86201. /**
  86202. * Creates a depth stencil texture.
  86203. * This is only available in WebGL 2 or with the depth texture extension available.
  86204. * @param size The size of face edge in the texture.
  86205. * @param options The options defining the texture.
  86206. * @returns The texture
  86207. */
  86208. createDepthStencilTexture(size: number | {
  86209. width: number;
  86210. height: number;
  86211. layers?: number;
  86212. }, options: DepthTextureCreationOptions): InternalTexture;
  86213. /** @hidden */
  86214. _createDepthStencilTexture(size: number | {
  86215. width: number;
  86216. height: number;
  86217. layers?: number;
  86218. }, options: DepthTextureCreationOptions): InternalTexture;
  86219. }
  86220. }
  86221. declare module BABYLON {
  86222. /**
  86223. * Defines the kind of connection point for node based material
  86224. */
  86225. export enum NodeMaterialBlockConnectionPointTypes {
  86226. /** Float */
  86227. Float = 1,
  86228. /** Int */
  86229. Int = 2,
  86230. /** Vector2 */
  86231. Vector2 = 4,
  86232. /** Vector3 */
  86233. Vector3 = 8,
  86234. /** Vector4 */
  86235. Vector4 = 16,
  86236. /** Color3 */
  86237. Color3 = 32,
  86238. /** Color4 */
  86239. Color4 = 64,
  86240. /** Matrix */
  86241. Matrix = 128,
  86242. /** Custom object */
  86243. Object = 256,
  86244. /** Detect type based on connection */
  86245. AutoDetect = 1024,
  86246. /** Output type that will be defined by input type */
  86247. BasedOnInput = 2048
  86248. }
  86249. }
  86250. declare module BABYLON {
  86251. /**
  86252. * Enum used to define the target of a block
  86253. */
  86254. export enum NodeMaterialBlockTargets {
  86255. /** Vertex shader */
  86256. Vertex = 1,
  86257. /** Fragment shader */
  86258. Fragment = 2,
  86259. /** Neutral */
  86260. Neutral = 4,
  86261. /** Vertex and Fragment */
  86262. VertexAndFragment = 3
  86263. }
  86264. }
  86265. declare module BABYLON {
  86266. /**
  86267. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86268. */
  86269. export enum NodeMaterialBlockConnectionPointMode {
  86270. /** Value is an uniform */
  86271. Uniform = 0,
  86272. /** Value is a mesh attribute */
  86273. Attribute = 1,
  86274. /** Value is a varying between vertex and fragment shaders */
  86275. Varying = 2,
  86276. /** Mode is undefined */
  86277. Undefined = 3
  86278. }
  86279. }
  86280. declare module BABYLON {
  86281. /**
  86282. * Enum used to define system values e.g. values automatically provided by the system
  86283. */
  86284. export enum NodeMaterialSystemValues {
  86285. /** World */
  86286. World = 1,
  86287. /** View */
  86288. View = 2,
  86289. /** Projection */
  86290. Projection = 3,
  86291. /** ViewProjection */
  86292. ViewProjection = 4,
  86293. /** WorldView */
  86294. WorldView = 5,
  86295. /** WorldViewProjection */
  86296. WorldViewProjection = 6,
  86297. /** CameraPosition */
  86298. CameraPosition = 7,
  86299. /** Fog Color */
  86300. FogColor = 8,
  86301. /** Delta time */
  86302. DeltaTime = 9
  86303. }
  86304. }
  86305. declare module BABYLON {
  86306. /** Defines supported spaces */
  86307. export enum Space {
  86308. /** Local (object) space */
  86309. LOCAL = 0,
  86310. /** World space */
  86311. WORLD = 1,
  86312. /** Bone space */
  86313. BONE = 2
  86314. }
  86315. /** Defines the 3 main axes */
  86316. export class Axis {
  86317. /** X axis */
  86318. static X: Vector3;
  86319. /** Y axis */
  86320. static Y: Vector3;
  86321. /** Z axis */
  86322. static Z: Vector3;
  86323. }
  86324. }
  86325. declare module BABYLON {
  86326. /**
  86327. * Represents a camera frustum
  86328. */
  86329. export class Frustum {
  86330. /**
  86331. * Gets the planes representing the frustum
  86332. * @param transform matrix to be applied to the returned planes
  86333. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86334. */
  86335. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86336. /**
  86337. * Gets the near frustum plane transformed by the transform matrix
  86338. * @param transform transformation matrix to be applied to the resulting frustum plane
  86339. * @param frustumPlane the resuling frustum plane
  86340. */
  86341. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86342. /**
  86343. * Gets the far frustum plane transformed by the transform matrix
  86344. * @param transform transformation matrix to be applied to the resulting frustum plane
  86345. * @param frustumPlane the resuling frustum plane
  86346. */
  86347. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86348. /**
  86349. * Gets the left frustum plane transformed by the transform matrix
  86350. * @param transform transformation matrix to be applied to the resulting frustum plane
  86351. * @param frustumPlane the resuling frustum plane
  86352. */
  86353. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86354. /**
  86355. * Gets the right frustum plane transformed by the transform matrix
  86356. * @param transform transformation matrix to be applied to the resulting frustum plane
  86357. * @param frustumPlane the resuling frustum plane
  86358. */
  86359. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86360. /**
  86361. * Gets the top frustum plane transformed by the transform matrix
  86362. * @param transform transformation matrix to be applied to the resulting frustum plane
  86363. * @param frustumPlane the resuling frustum plane
  86364. */
  86365. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86366. /**
  86367. * Gets the bottom frustum plane transformed by the transform matrix
  86368. * @param transform transformation matrix to be applied to the resulting frustum plane
  86369. * @param frustumPlane the resuling frustum plane
  86370. */
  86371. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86372. /**
  86373. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86374. * @param transform transformation matrix to be applied to the resulting frustum planes
  86375. * @param frustumPlanes the resuling frustum planes
  86376. */
  86377. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86378. }
  86379. }
  86380. declare module BABYLON {
  86381. /**
  86382. * Interface for the size containing width and height
  86383. */
  86384. export interface ISize {
  86385. /**
  86386. * Width
  86387. */
  86388. width: number;
  86389. /**
  86390. * Heighht
  86391. */
  86392. height: number;
  86393. }
  86394. /**
  86395. * Size containing widht and height
  86396. */
  86397. export class Size implements ISize {
  86398. /**
  86399. * Width
  86400. */
  86401. width: number;
  86402. /**
  86403. * Height
  86404. */
  86405. height: number;
  86406. /**
  86407. * Creates a Size object from the given width and height (floats).
  86408. * @param width width of the new size
  86409. * @param height height of the new size
  86410. */
  86411. constructor(width: number, height: number);
  86412. /**
  86413. * Returns a string with the Size width and height
  86414. * @returns a string with the Size width and height
  86415. */
  86416. toString(): string;
  86417. /**
  86418. * "Size"
  86419. * @returns the string "Size"
  86420. */
  86421. getClassName(): string;
  86422. /**
  86423. * Returns the Size hash code.
  86424. * @returns a hash code for a unique width and height
  86425. */
  86426. getHashCode(): number;
  86427. /**
  86428. * Updates the current size from the given one.
  86429. * @param src the given size
  86430. */
  86431. copyFrom(src: Size): void;
  86432. /**
  86433. * Updates in place the current Size from the given floats.
  86434. * @param width width of the new size
  86435. * @param height height of the new size
  86436. * @returns the updated Size.
  86437. */
  86438. copyFromFloats(width: number, height: number): Size;
  86439. /**
  86440. * Updates in place the current Size from the given floats.
  86441. * @param width width to set
  86442. * @param height height to set
  86443. * @returns the updated Size.
  86444. */
  86445. set(width: number, height: number): Size;
  86446. /**
  86447. * Multiplies the width and height by numbers
  86448. * @param w factor to multiple the width by
  86449. * @param h factor to multiple the height by
  86450. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86451. */
  86452. multiplyByFloats(w: number, h: number): Size;
  86453. /**
  86454. * Clones the size
  86455. * @returns a new Size copied from the given one.
  86456. */
  86457. clone(): Size;
  86458. /**
  86459. * True if the current Size and the given one width and height are strictly equal.
  86460. * @param other the other size to compare against
  86461. * @returns True if the current Size and the given one width and height are strictly equal.
  86462. */
  86463. equals(other: Size): boolean;
  86464. /**
  86465. * The surface of the Size : width * height (float).
  86466. */
  86467. get surface(): number;
  86468. /**
  86469. * Create a new size of zero
  86470. * @returns a new Size set to (0.0, 0.0)
  86471. */
  86472. static Zero(): Size;
  86473. /**
  86474. * Sums the width and height of two sizes
  86475. * @param otherSize size to add to this size
  86476. * @returns a new Size set as the addition result of the current Size and the given one.
  86477. */
  86478. add(otherSize: Size): Size;
  86479. /**
  86480. * Subtracts the width and height of two
  86481. * @param otherSize size to subtract to this size
  86482. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86483. */
  86484. subtract(otherSize: Size): Size;
  86485. /**
  86486. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86487. * @param start starting size to lerp between
  86488. * @param end end size to lerp between
  86489. * @param amount amount to lerp between the start and end values
  86490. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86491. */
  86492. static Lerp(start: Size, end: Size, amount: number): Size;
  86493. }
  86494. }
  86495. declare module BABYLON {
  86496. /**
  86497. * Contains position and normal vectors for a vertex
  86498. */
  86499. export class PositionNormalVertex {
  86500. /** the position of the vertex (defaut: 0,0,0) */
  86501. position: Vector3;
  86502. /** the normal of the vertex (defaut: 0,1,0) */
  86503. normal: Vector3;
  86504. /**
  86505. * Creates a PositionNormalVertex
  86506. * @param position the position of the vertex (defaut: 0,0,0)
  86507. * @param normal the normal of the vertex (defaut: 0,1,0)
  86508. */
  86509. constructor(
  86510. /** the position of the vertex (defaut: 0,0,0) */
  86511. position?: Vector3,
  86512. /** the normal of the vertex (defaut: 0,1,0) */
  86513. normal?: Vector3);
  86514. /**
  86515. * Clones the PositionNormalVertex
  86516. * @returns the cloned PositionNormalVertex
  86517. */
  86518. clone(): PositionNormalVertex;
  86519. }
  86520. /**
  86521. * Contains position, normal and uv vectors for a vertex
  86522. */
  86523. export class PositionNormalTextureVertex {
  86524. /** the position of the vertex (defaut: 0,0,0) */
  86525. position: Vector3;
  86526. /** the normal of the vertex (defaut: 0,1,0) */
  86527. normal: Vector3;
  86528. /** the uv of the vertex (default: 0,0) */
  86529. uv: Vector2;
  86530. /**
  86531. * Creates a PositionNormalTextureVertex
  86532. * @param position the position of the vertex (defaut: 0,0,0)
  86533. * @param normal the normal of the vertex (defaut: 0,1,0)
  86534. * @param uv the uv of the vertex (default: 0,0)
  86535. */
  86536. constructor(
  86537. /** the position of the vertex (defaut: 0,0,0) */
  86538. position?: Vector3,
  86539. /** the normal of the vertex (defaut: 0,1,0) */
  86540. normal?: Vector3,
  86541. /** the uv of the vertex (default: 0,0) */
  86542. uv?: Vector2);
  86543. /**
  86544. * Clones the PositionNormalTextureVertex
  86545. * @returns the cloned PositionNormalTextureVertex
  86546. */
  86547. clone(): PositionNormalTextureVertex;
  86548. }
  86549. }
  86550. declare module BABYLON {
  86551. /**
  86552. * Enum defining the type of animations supported by InputBlock
  86553. */
  86554. export enum AnimatedInputBlockTypes {
  86555. /** No animation */
  86556. None = 0,
  86557. /** Time based animation. Will only work for floats */
  86558. Time = 1
  86559. }
  86560. }
  86561. declare module BABYLON {
  86562. /**
  86563. * Interface describing all the common properties and methods a shadow light needs to implement.
  86564. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  86565. * as well as binding the different shadow properties to the effects.
  86566. */
  86567. export interface IShadowLight extends Light {
  86568. /**
  86569. * The light id in the scene (used in scene.findLighById for instance)
  86570. */
  86571. id: string;
  86572. /**
  86573. * The position the shdow will be casted from.
  86574. */
  86575. position: Vector3;
  86576. /**
  86577. * In 2d mode (needCube being false), the direction used to cast the shadow.
  86578. */
  86579. direction: Vector3;
  86580. /**
  86581. * The transformed position. Position of the light in world space taking parenting in account.
  86582. */
  86583. transformedPosition: Vector3;
  86584. /**
  86585. * The transformed direction. Direction of the light in world space taking parenting in account.
  86586. */
  86587. transformedDirection: Vector3;
  86588. /**
  86589. * The friendly name of the light in the scene.
  86590. */
  86591. name: string;
  86592. /**
  86593. * Defines the shadow projection clipping minimum z value.
  86594. */
  86595. shadowMinZ: number;
  86596. /**
  86597. * Defines the shadow projection clipping maximum z value.
  86598. */
  86599. shadowMaxZ: number;
  86600. /**
  86601. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86602. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86603. */
  86604. computeTransformedInformation(): boolean;
  86605. /**
  86606. * Gets the scene the light belongs to.
  86607. * @returns The scene
  86608. */
  86609. getScene(): Scene;
  86610. /**
  86611. * Callback defining a custom Projection Matrix Builder.
  86612. * This can be used to override the default projection matrix computation.
  86613. */
  86614. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86615. /**
  86616. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86617. * @param matrix The materix to updated with the projection information
  86618. * @param viewMatrix The transform matrix of the light
  86619. * @param renderList The list of mesh to render in the map
  86620. * @returns The current light
  86621. */
  86622. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86623. /**
  86624. * Gets the current depth scale used in ESM.
  86625. * @returns The scale
  86626. */
  86627. getDepthScale(): number;
  86628. /**
  86629. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86630. * @returns true if a cube texture needs to be use
  86631. */
  86632. needCube(): boolean;
  86633. /**
  86634. * Detects if the projection matrix requires to be recomputed this frame.
  86635. * @returns true if it requires to be recomputed otherwise, false.
  86636. */
  86637. needProjectionMatrixCompute(): boolean;
  86638. /**
  86639. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86640. */
  86641. forceProjectionMatrixCompute(): void;
  86642. /**
  86643. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86644. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86645. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86646. */
  86647. getShadowDirection(faceIndex?: number): Vector3;
  86648. /**
  86649. * Gets the minZ used for shadow according to both the scene and the light.
  86650. * @param activeCamera The camera we are returning the min for
  86651. * @returns the depth min z
  86652. */
  86653. getDepthMinZ(activeCamera: Camera): number;
  86654. /**
  86655. * Gets the maxZ used for shadow according to both the scene and the light.
  86656. * @param activeCamera The camera we are returning the max for
  86657. * @returns the depth max z
  86658. */
  86659. getDepthMaxZ(activeCamera: Camera): number;
  86660. }
  86661. /**
  86662. * Base implementation IShadowLight
  86663. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  86664. */
  86665. export abstract class ShadowLight extends Light implements IShadowLight {
  86666. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  86667. protected _position: Vector3;
  86668. protected _setPosition(value: Vector3): void;
  86669. /**
  86670. * Sets the position the shadow will be casted from. Also use as the light position for both
  86671. * point and spot lights.
  86672. */
  86673. get position(): Vector3;
  86674. /**
  86675. * Sets the position the shadow will be casted from. Also use as the light position for both
  86676. * point and spot lights.
  86677. */
  86678. set position(value: Vector3);
  86679. protected _direction: Vector3;
  86680. protected _setDirection(value: Vector3): void;
  86681. /**
  86682. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  86683. * Also use as the light direction on spot and directional lights.
  86684. */
  86685. get direction(): Vector3;
  86686. /**
  86687. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  86688. * Also use as the light direction on spot and directional lights.
  86689. */
  86690. set direction(value: Vector3);
  86691. protected _shadowMinZ: number;
  86692. /**
  86693. * Gets the shadow projection clipping minimum z value.
  86694. */
  86695. get shadowMinZ(): number;
  86696. /**
  86697. * Sets the shadow projection clipping minimum z value.
  86698. */
  86699. set shadowMinZ(value: number);
  86700. protected _shadowMaxZ: number;
  86701. /**
  86702. * Sets the shadow projection clipping maximum z value.
  86703. */
  86704. get shadowMaxZ(): number;
  86705. /**
  86706. * Gets the shadow projection clipping maximum z value.
  86707. */
  86708. set shadowMaxZ(value: number);
  86709. /**
  86710. * Callback defining a custom Projection Matrix Builder.
  86711. * This can be used to override the default projection matrix computation.
  86712. */
  86713. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86714. /**
  86715. * The transformed position. Position of the light in world space taking parenting in account.
  86716. */
  86717. transformedPosition: Vector3;
  86718. /**
  86719. * The transformed direction. Direction of the light in world space taking parenting in account.
  86720. */
  86721. transformedDirection: Vector3;
  86722. private _needProjectionMatrixCompute;
  86723. /**
  86724. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86725. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86726. */
  86727. computeTransformedInformation(): boolean;
  86728. /**
  86729. * Return the depth scale used for the shadow map.
  86730. * @returns the depth scale.
  86731. */
  86732. getDepthScale(): number;
  86733. /**
  86734. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86735. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86736. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86737. */
  86738. getShadowDirection(faceIndex?: number): Vector3;
  86739. /**
  86740. * Returns the ShadowLight absolute position in the World.
  86741. * @returns the position vector in world space
  86742. */
  86743. getAbsolutePosition(): Vector3;
  86744. /**
  86745. * Sets the ShadowLight direction toward the passed target.
  86746. * @param target The point to target in local space
  86747. * @returns the updated ShadowLight direction
  86748. */
  86749. setDirectionToTarget(target: Vector3): Vector3;
  86750. /**
  86751. * Returns the light rotation in euler definition.
  86752. * @returns the x y z rotation in local space.
  86753. */
  86754. getRotation(): Vector3;
  86755. /**
  86756. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86757. * @returns true if a cube texture needs to be use
  86758. */
  86759. needCube(): boolean;
  86760. /**
  86761. * Detects if the projection matrix requires to be recomputed this frame.
  86762. * @returns true if it requires to be recomputed otherwise, false.
  86763. */
  86764. needProjectionMatrixCompute(): boolean;
  86765. /**
  86766. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86767. */
  86768. forceProjectionMatrixCompute(): void;
  86769. /** @hidden */
  86770. _initCache(): void;
  86771. /** @hidden */
  86772. _isSynchronized(): boolean;
  86773. /**
  86774. * Computes the world matrix of the node
  86775. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86776. * @returns the world matrix
  86777. */
  86778. computeWorldMatrix(force?: boolean): Matrix;
  86779. /**
  86780. * Gets the minZ used for shadow according to both the scene and the light.
  86781. * @param activeCamera The camera we are returning the min for
  86782. * @returns the depth min z
  86783. */
  86784. getDepthMinZ(activeCamera: Camera): number;
  86785. /**
  86786. * Gets the maxZ used for shadow according to both the scene and the light.
  86787. * @param activeCamera The camera we are returning the max for
  86788. * @returns the depth max z
  86789. */
  86790. getDepthMaxZ(activeCamera: Camera): number;
  86791. /**
  86792. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86793. * @param matrix The materix to updated with the projection information
  86794. * @param viewMatrix The transform matrix of the light
  86795. * @param renderList The list of mesh to render in the map
  86796. * @returns The current light
  86797. */
  86798. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86799. }
  86800. }
  86801. declare module BABYLON {
  86802. /** @hidden */
  86803. export var packingFunctions: {
  86804. name: string;
  86805. shader: string;
  86806. };
  86807. }
  86808. declare module BABYLON {
  86809. /** @hidden */
  86810. export var bayerDitherFunctions: {
  86811. name: string;
  86812. shader: string;
  86813. };
  86814. }
  86815. declare module BABYLON {
  86816. /** @hidden */
  86817. export var shadowMapFragmentDeclaration: {
  86818. name: string;
  86819. shader: string;
  86820. };
  86821. }
  86822. declare module BABYLON {
  86823. /** @hidden */
  86824. export var clipPlaneFragmentDeclaration: {
  86825. name: string;
  86826. shader: string;
  86827. };
  86828. }
  86829. declare module BABYLON {
  86830. /** @hidden */
  86831. export var clipPlaneFragment: {
  86832. name: string;
  86833. shader: string;
  86834. };
  86835. }
  86836. declare module BABYLON {
  86837. /** @hidden */
  86838. export var shadowMapFragment: {
  86839. name: string;
  86840. shader: string;
  86841. };
  86842. }
  86843. declare module BABYLON {
  86844. /** @hidden */
  86845. export var shadowMapPixelShader: {
  86846. name: string;
  86847. shader: string;
  86848. };
  86849. }
  86850. declare module BABYLON {
  86851. /** @hidden */
  86852. export var bonesDeclaration: {
  86853. name: string;
  86854. shader: string;
  86855. };
  86856. }
  86857. declare module BABYLON {
  86858. /** @hidden */
  86859. export var morphTargetsVertexGlobalDeclaration: {
  86860. name: string;
  86861. shader: string;
  86862. };
  86863. }
  86864. declare module BABYLON {
  86865. /** @hidden */
  86866. export var morphTargetsVertexDeclaration: {
  86867. name: string;
  86868. shader: string;
  86869. };
  86870. }
  86871. declare module BABYLON {
  86872. /** @hidden */
  86873. export var instancesDeclaration: {
  86874. name: string;
  86875. shader: string;
  86876. };
  86877. }
  86878. declare module BABYLON {
  86879. /** @hidden */
  86880. export var helperFunctions: {
  86881. name: string;
  86882. shader: string;
  86883. };
  86884. }
  86885. declare module BABYLON {
  86886. /** @hidden */
  86887. export var shadowMapVertexDeclaration: {
  86888. name: string;
  86889. shader: string;
  86890. };
  86891. }
  86892. declare module BABYLON {
  86893. /** @hidden */
  86894. export var clipPlaneVertexDeclaration: {
  86895. name: string;
  86896. shader: string;
  86897. };
  86898. }
  86899. declare module BABYLON {
  86900. /** @hidden */
  86901. export var morphTargetsVertex: {
  86902. name: string;
  86903. shader: string;
  86904. };
  86905. }
  86906. declare module BABYLON {
  86907. /** @hidden */
  86908. export var instancesVertex: {
  86909. name: string;
  86910. shader: string;
  86911. };
  86912. }
  86913. declare module BABYLON {
  86914. /** @hidden */
  86915. export var bonesVertex: {
  86916. name: string;
  86917. shader: string;
  86918. };
  86919. }
  86920. declare module BABYLON {
  86921. /** @hidden */
  86922. export var shadowMapVertexNormalBias: {
  86923. name: string;
  86924. shader: string;
  86925. };
  86926. }
  86927. declare module BABYLON {
  86928. /** @hidden */
  86929. export var shadowMapVertexMetric: {
  86930. name: string;
  86931. shader: string;
  86932. };
  86933. }
  86934. declare module BABYLON {
  86935. /** @hidden */
  86936. export var clipPlaneVertex: {
  86937. name: string;
  86938. shader: string;
  86939. };
  86940. }
  86941. declare module BABYLON {
  86942. /** @hidden */
  86943. export var shadowMapVertexShader: {
  86944. name: string;
  86945. shader: string;
  86946. };
  86947. }
  86948. declare module BABYLON {
  86949. /** @hidden */
  86950. export var depthBoxBlurPixelShader: {
  86951. name: string;
  86952. shader: string;
  86953. };
  86954. }
  86955. declare module BABYLON {
  86956. /** @hidden */
  86957. export var shadowMapFragmentSoftTransparentShadow: {
  86958. name: string;
  86959. shader: string;
  86960. };
  86961. }
  86962. declare module BABYLON {
  86963. /**
  86964. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86965. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86966. */
  86967. export class EffectFallbacks implements IEffectFallbacks {
  86968. private _defines;
  86969. private _currentRank;
  86970. private _maxRank;
  86971. private _mesh;
  86972. /**
  86973. * Removes the fallback from the bound mesh.
  86974. */
  86975. unBindMesh(): void;
  86976. /**
  86977. * Adds a fallback on the specified property.
  86978. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86979. * @param define The name of the define in the shader
  86980. */
  86981. addFallback(rank: number, define: string): void;
  86982. /**
  86983. * Sets the mesh to use CPU skinning when needing to fallback.
  86984. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86985. * @param mesh The mesh to use the fallbacks.
  86986. */
  86987. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86988. /**
  86989. * Checks to see if more fallbacks are still availible.
  86990. */
  86991. get hasMoreFallbacks(): boolean;
  86992. /**
  86993. * Removes the defines that should be removed when falling back.
  86994. * @param currentDefines defines the current define statements for the shader.
  86995. * @param effect defines the current effect we try to compile
  86996. * @returns The resulting defines with defines of the current rank removed.
  86997. */
  86998. reduce(currentDefines: string, effect: Effect): string;
  86999. }
  87000. }
  87001. declare module BABYLON {
  87002. /**
  87003. * Interface used to define Action
  87004. */
  87005. export interface IAction {
  87006. /**
  87007. * Trigger for the action
  87008. */
  87009. trigger: number;
  87010. /** Options of the trigger */
  87011. triggerOptions: any;
  87012. /**
  87013. * Gets the trigger parameters
  87014. * @returns the trigger parameters
  87015. */
  87016. getTriggerParameter(): any;
  87017. /**
  87018. * Internal only - executes current action event
  87019. * @hidden
  87020. */
  87021. _executeCurrent(evt?: ActionEvent): void;
  87022. /**
  87023. * Serialize placeholder for child classes
  87024. * @param parent of child
  87025. * @returns the serialized object
  87026. */
  87027. serialize(parent: any): any;
  87028. /**
  87029. * Internal only
  87030. * @hidden
  87031. */
  87032. _prepare(): void;
  87033. /**
  87034. * Internal only - manager for action
  87035. * @hidden
  87036. */
  87037. _actionManager: AbstractActionManager;
  87038. /**
  87039. * Adds action to chain of actions, may be a DoNothingAction
  87040. * @param action defines the next action to execute
  87041. * @returns The action passed in
  87042. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87043. */
  87044. then(action: IAction): IAction;
  87045. }
  87046. /**
  87047. * The action to be carried out following a trigger
  87048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87049. */
  87050. export class Action implements IAction {
  87051. /** the trigger, with or without parameters, for the action */
  87052. triggerOptions: any;
  87053. /**
  87054. * Trigger for the action
  87055. */
  87056. trigger: number;
  87057. /**
  87058. * Internal only - manager for action
  87059. * @hidden
  87060. */
  87061. _actionManager: ActionManager;
  87062. private _nextActiveAction;
  87063. private _child;
  87064. private _condition?;
  87065. private _triggerParameter;
  87066. /**
  87067. * An event triggered prior to action being executed.
  87068. */
  87069. onBeforeExecuteObservable: Observable<Action>;
  87070. /**
  87071. * Creates a new Action
  87072. * @param triggerOptions the trigger, with or without parameters, for the action
  87073. * @param condition an optional determinant of action
  87074. */
  87075. constructor(
  87076. /** the trigger, with or without parameters, for the action */
  87077. triggerOptions: any, condition?: Condition);
  87078. /**
  87079. * Internal only
  87080. * @hidden
  87081. */
  87082. _prepare(): void;
  87083. /**
  87084. * Gets the trigger parameters
  87085. * @returns the trigger parameters
  87086. */
  87087. getTriggerParameter(): any;
  87088. /**
  87089. * Internal only - executes current action event
  87090. * @hidden
  87091. */
  87092. _executeCurrent(evt?: ActionEvent): void;
  87093. /**
  87094. * Execute placeholder for child classes
  87095. * @param evt optional action event
  87096. */
  87097. execute(evt?: ActionEvent): void;
  87098. /**
  87099. * Skips to next active action
  87100. */
  87101. skipToNextActiveAction(): void;
  87102. /**
  87103. * Adds action to chain of actions, may be a DoNothingAction
  87104. * @param action defines the next action to execute
  87105. * @returns The action passed in
  87106. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87107. */
  87108. then(action: Action): Action;
  87109. /**
  87110. * Internal only
  87111. * @hidden
  87112. */
  87113. _getProperty(propertyPath: string): string;
  87114. /**
  87115. * Internal only
  87116. * @hidden
  87117. */
  87118. _getEffectiveTarget(target: any, propertyPath: string): any;
  87119. /**
  87120. * Serialize placeholder for child classes
  87121. * @param parent of child
  87122. * @returns the serialized object
  87123. */
  87124. serialize(parent: any): any;
  87125. /**
  87126. * Internal only called by serialize
  87127. * @hidden
  87128. */
  87129. protected _serialize(serializedAction: any, parent?: any): any;
  87130. /**
  87131. * Internal only
  87132. * @hidden
  87133. */
  87134. static _SerializeValueAsString: (value: any) => string;
  87135. /**
  87136. * Internal only
  87137. * @hidden
  87138. */
  87139. static _GetTargetProperty: (target: Node | Scene) => {
  87140. name: string;
  87141. targetType: string;
  87142. value: string;
  87143. };
  87144. }
  87145. }
  87146. declare module BABYLON {
  87147. /**
  87148. * A Condition applied to an Action
  87149. */
  87150. export class Condition {
  87151. /**
  87152. * Internal only - manager for action
  87153. * @hidden
  87154. */
  87155. _actionManager: ActionManager;
  87156. /**
  87157. * Internal only
  87158. * @hidden
  87159. */
  87160. _evaluationId: number;
  87161. /**
  87162. * Internal only
  87163. * @hidden
  87164. */
  87165. _currentResult: boolean;
  87166. /**
  87167. * Creates a new Condition
  87168. * @param actionManager the manager of the action the condition is applied to
  87169. */
  87170. constructor(actionManager: ActionManager);
  87171. /**
  87172. * Check if the current condition is valid
  87173. * @returns a boolean
  87174. */
  87175. isValid(): boolean;
  87176. /**
  87177. * Internal only
  87178. * @hidden
  87179. */
  87180. _getProperty(propertyPath: string): string;
  87181. /**
  87182. * Internal only
  87183. * @hidden
  87184. */
  87185. _getEffectiveTarget(target: any, propertyPath: string): any;
  87186. /**
  87187. * Serialize placeholder for child classes
  87188. * @returns the serialized object
  87189. */
  87190. serialize(): any;
  87191. /**
  87192. * Internal only
  87193. * @hidden
  87194. */
  87195. protected _serialize(serializedCondition: any): any;
  87196. }
  87197. /**
  87198. * Defines specific conditional operators as extensions of Condition
  87199. */
  87200. export class ValueCondition extends Condition {
  87201. /** path to specify the property of the target the conditional operator uses */
  87202. propertyPath: string;
  87203. /** the value compared by the conditional operator against the current value of the property */
  87204. value: any;
  87205. /** the conditional operator, default ValueCondition.IsEqual */
  87206. operator: number;
  87207. /**
  87208. * Internal only
  87209. * @hidden
  87210. */
  87211. private static _IsEqual;
  87212. /**
  87213. * Internal only
  87214. * @hidden
  87215. */
  87216. private static _IsDifferent;
  87217. /**
  87218. * Internal only
  87219. * @hidden
  87220. */
  87221. private static _IsGreater;
  87222. /**
  87223. * Internal only
  87224. * @hidden
  87225. */
  87226. private static _IsLesser;
  87227. /**
  87228. * returns the number for IsEqual
  87229. */
  87230. static get IsEqual(): number;
  87231. /**
  87232. * Returns the number for IsDifferent
  87233. */
  87234. static get IsDifferent(): number;
  87235. /**
  87236. * Returns the number for IsGreater
  87237. */
  87238. static get IsGreater(): number;
  87239. /**
  87240. * Returns the number for IsLesser
  87241. */
  87242. static get IsLesser(): number;
  87243. /**
  87244. * Internal only The action manager for the condition
  87245. * @hidden
  87246. */
  87247. _actionManager: ActionManager;
  87248. /**
  87249. * Internal only
  87250. * @hidden
  87251. */
  87252. private _target;
  87253. /**
  87254. * Internal only
  87255. * @hidden
  87256. */
  87257. private _effectiveTarget;
  87258. /**
  87259. * Internal only
  87260. * @hidden
  87261. */
  87262. private _property;
  87263. /**
  87264. * Creates a new ValueCondition
  87265. * @param actionManager manager for the action the condition applies to
  87266. * @param target for the action
  87267. * @param propertyPath path to specify the property of the target the conditional operator uses
  87268. * @param value the value compared by the conditional operator against the current value of the property
  87269. * @param operator the conditional operator, default ValueCondition.IsEqual
  87270. */
  87271. constructor(actionManager: ActionManager, target: any,
  87272. /** path to specify the property of the target the conditional operator uses */
  87273. propertyPath: string,
  87274. /** the value compared by the conditional operator against the current value of the property */
  87275. value: any,
  87276. /** the conditional operator, default ValueCondition.IsEqual */
  87277. operator?: number);
  87278. /**
  87279. * Compares the given value with the property value for the specified conditional operator
  87280. * @returns the result of the comparison
  87281. */
  87282. isValid(): boolean;
  87283. /**
  87284. * Serialize the ValueCondition into a JSON compatible object
  87285. * @returns serialization object
  87286. */
  87287. serialize(): any;
  87288. /**
  87289. * Gets the name of the conditional operator for the ValueCondition
  87290. * @param operator the conditional operator
  87291. * @returns the name
  87292. */
  87293. static GetOperatorName(operator: number): string;
  87294. }
  87295. /**
  87296. * Defines a predicate condition as an extension of Condition
  87297. */
  87298. export class PredicateCondition extends Condition {
  87299. /** defines the predicate function used to validate the condition */
  87300. predicate: () => boolean;
  87301. /**
  87302. * Internal only - manager for action
  87303. * @hidden
  87304. */
  87305. _actionManager: ActionManager;
  87306. /**
  87307. * Creates a new PredicateCondition
  87308. * @param actionManager manager for the action the condition applies to
  87309. * @param predicate defines the predicate function used to validate the condition
  87310. */
  87311. constructor(actionManager: ActionManager,
  87312. /** defines the predicate function used to validate the condition */
  87313. predicate: () => boolean);
  87314. /**
  87315. * @returns the validity of the predicate condition
  87316. */
  87317. isValid(): boolean;
  87318. }
  87319. /**
  87320. * Defines a state condition as an extension of Condition
  87321. */
  87322. export class StateCondition extends Condition {
  87323. /** Value to compare with target state */
  87324. value: string;
  87325. /**
  87326. * Internal only - manager for action
  87327. * @hidden
  87328. */
  87329. _actionManager: ActionManager;
  87330. /**
  87331. * Internal only
  87332. * @hidden
  87333. */
  87334. private _target;
  87335. /**
  87336. * Creates a new StateCondition
  87337. * @param actionManager manager for the action the condition applies to
  87338. * @param target of the condition
  87339. * @param value to compare with target state
  87340. */
  87341. constructor(actionManager: ActionManager, target: any,
  87342. /** Value to compare with target state */
  87343. value: string);
  87344. /**
  87345. * Gets a boolean indicating if the current condition is met
  87346. * @returns the validity of the state
  87347. */
  87348. isValid(): boolean;
  87349. /**
  87350. * Serialize the StateCondition into a JSON compatible object
  87351. * @returns serialization object
  87352. */
  87353. serialize(): any;
  87354. }
  87355. }
  87356. declare module BABYLON {
  87357. /**
  87358. * This defines an action responsible to toggle a boolean once triggered.
  87359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87360. */
  87361. export class SwitchBooleanAction extends Action {
  87362. /**
  87363. * The path to the boolean property in the target object
  87364. */
  87365. propertyPath: string;
  87366. private _target;
  87367. private _effectiveTarget;
  87368. private _property;
  87369. /**
  87370. * Instantiate the action
  87371. * @param triggerOptions defines the trigger options
  87372. * @param target defines the object containing the boolean
  87373. * @param propertyPath defines the path to the boolean property in the target object
  87374. * @param condition defines the trigger related conditions
  87375. */
  87376. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  87377. /** @hidden */
  87378. _prepare(): void;
  87379. /**
  87380. * Execute the action toggle the boolean value.
  87381. */
  87382. execute(): void;
  87383. /**
  87384. * Serializes the actions and its related information.
  87385. * @param parent defines the object to serialize in
  87386. * @returns the serialized object
  87387. */
  87388. serialize(parent: any): any;
  87389. }
  87390. /**
  87391. * This defines an action responsible to set a the state field of the target
  87392. * to a desired value once triggered.
  87393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87394. */
  87395. export class SetStateAction extends Action {
  87396. /**
  87397. * The value to store in the state field.
  87398. */
  87399. value: string;
  87400. private _target;
  87401. /**
  87402. * Instantiate the action
  87403. * @param triggerOptions defines the trigger options
  87404. * @param target defines the object containing the state property
  87405. * @param value defines the value to store in the state field
  87406. * @param condition defines the trigger related conditions
  87407. */
  87408. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  87409. /**
  87410. * Execute the action and store the value on the target state property.
  87411. */
  87412. execute(): void;
  87413. /**
  87414. * Serializes the actions and its related information.
  87415. * @param parent defines the object to serialize in
  87416. * @returns the serialized object
  87417. */
  87418. serialize(parent: any): any;
  87419. }
  87420. /**
  87421. * This defines an action responsible to set a property of the target
  87422. * to a desired value once triggered.
  87423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87424. */
  87425. export class SetValueAction extends Action {
  87426. /**
  87427. * The path of the property to set in the target.
  87428. */
  87429. propertyPath: string;
  87430. /**
  87431. * The value to set in the property
  87432. */
  87433. value: any;
  87434. private _target;
  87435. private _effectiveTarget;
  87436. private _property;
  87437. /**
  87438. * Instantiate the action
  87439. * @param triggerOptions defines the trigger options
  87440. * @param target defines the object containing the property
  87441. * @param propertyPath defines the path of the property to set in the target
  87442. * @param value defines the value to set in the property
  87443. * @param condition defines the trigger related conditions
  87444. */
  87445. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87446. /** @hidden */
  87447. _prepare(): void;
  87448. /**
  87449. * Execute the action and set the targetted property to the desired value.
  87450. */
  87451. execute(): void;
  87452. /**
  87453. * Serializes the actions and its related information.
  87454. * @param parent defines the object to serialize in
  87455. * @returns the serialized object
  87456. */
  87457. serialize(parent: any): any;
  87458. }
  87459. /**
  87460. * This defines an action responsible to increment the target value
  87461. * to a desired value once triggered.
  87462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87463. */
  87464. export class IncrementValueAction extends Action {
  87465. /**
  87466. * The path of the property to increment in the target.
  87467. */
  87468. propertyPath: string;
  87469. /**
  87470. * The value we should increment the property by.
  87471. */
  87472. value: any;
  87473. private _target;
  87474. private _effectiveTarget;
  87475. private _property;
  87476. /**
  87477. * Instantiate the action
  87478. * @param triggerOptions defines the trigger options
  87479. * @param target defines the object containing the property
  87480. * @param propertyPath defines the path of the property to increment in the target
  87481. * @param value defines the value value we should increment the property by
  87482. * @param condition defines the trigger related conditions
  87483. */
  87484. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87485. /** @hidden */
  87486. _prepare(): void;
  87487. /**
  87488. * Execute the action and increment the target of the value amount.
  87489. */
  87490. execute(): void;
  87491. /**
  87492. * Serializes the actions and its related information.
  87493. * @param parent defines the object to serialize in
  87494. * @returns the serialized object
  87495. */
  87496. serialize(parent: any): any;
  87497. }
  87498. /**
  87499. * This defines an action responsible to start an animation once triggered.
  87500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87501. */
  87502. export class PlayAnimationAction extends Action {
  87503. /**
  87504. * Where the animation should start (animation frame)
  87505. */
  87506. from: number;
  87507. /**
  87508. * Where the animation should stop (animation frame)
  87509. */
  87510. to: number;
  87511. /**
  87512. * Define if the animation should loop or stop after the first play.
  87513. */
  87514. loop?: boolean;
  87515. private _target;
  87516. /**
  87517. * Instantiate the action
  87518. * @param triggerOptions defines the trigger options
  87519. * @param target defines the target animation or animation name
  87520. * @param from defines from where the animation should start (animation frame)
  87521. * @param end defines where the animation should stop (animation frame)
  87522. * @param loop defines if the animation should loop or stop after the first play
  87523. * @param condition defines the trigger related conditions
  87524. */
  87525. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  87526. /** @hidden */
  87527. _prepare(): void;
  87528. /**
  87529. * Execute the action and play the animation.
  87530. */
  87531. execute(): void;
  87532. /**
  87533. * Serializes the actions and its related information.
  87534. * @param parent defines the object to serialize in
  87535. * @returns the serialized object
  87536. */
  87537. serialize(parent: any): any;
  87538. }
  87539. /**
  87540. * This defines an action responsible to stop an animation once triggered.
  87541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87542. */
  87543. export class StopAnimationAction extends Action {
  87544. private _target;
  87545. /**
  87546. * Instantiate the action
  87547. * @param triggerOptions defines the trigger options
  87548. * @param target defines the target animation or animation name
  87549. * @param condition defines the trigger related conditions
  87550. */
  87551. constructor(triggerOptions: any, target: any, condition?: Condition);
  87552. /** @hidden */
  87553. _prepare(): void;
  87554. /**
  87555. * Execute the action and stop the animation.
  87556. */
  87557. execute(): void;
  87558. /**
  87559. * Serializes the actions and its related information.
  87560. * @param parent defines the object to serialize in
  87561. * @returns the serialized object
  87562. */
  87563. serialize(parent: any): any;
  87564. }
  87565. /**
  87566. * This defines an action responsible that does nothing once triggered.
  87567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87568. */
  87569. export class DoNothingAction extends Action {
  87570. /**
  87571. * Instantiate the action
  87572. * @param triggerOptions defines the trigger options
  87573. * @param condition defines the trigger related conditions
  87574. */
  87575. constructor(triggerOptions?: any, condition?: Condition);
  87576. /**
  87577. * Execute the action and do nothing.
  87578. */
  87579. execute(): void;
  87580. /**
  87581. * Serializes the actions and its related information.
  87582. * @param parent defines the object to serialize in
  87583. * @returns the serialized object
  87584. */
  87585. serialize(parent: any): any;
  87586. }
  87587. /**
  87588. * This defines an action responsible to trigger several actions once triggered.
  87589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87590. */
  87591. export class CombineAction extends Action {
  87592. /**
  87593. * The list of aggregated animations to run.
  87594. */
  87595. children: Action[];
  87596. /**
  87597. * Instantiate the action
  87598. * @param triggerOptions defines the trigger options
  87599. * @param children defines the list of aggregated animations to run
  87600. * @param condition defines the trigger related conditions
  87601. */
  87602. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  87603. /** @hidden */
  87604. _prepare(): void;
  87605. /**
  87606. * Execute the action and executes all the aggregated actions.
  87607. */
  87608. execute(evt: ActionEvent): void;
  87609. /**
  87610. * Serializes the actions and its related information.
  87611. * @param parent defines the object to serialize in
  87612. * @returns the serialized object
  87613. */
  87614. serialize(parent: any): any;
  87615. }
  87616. /**
  87617. * This defines an action responsible to run code (external event) once triggered.
  87618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87619. */
  87620. export class ExecuteCodeAction extends Action {
  87621. /**
  87622. * The callback function to run.
  87623. */
  87624. func: (evt: ActionEvent) => void;
  87625. /**
  87626. * Instantiate the action
  87627. * @param triggerOptions defines the trigger options
  87628. * @param func defines the callback function to run
  87629. * @param condition defines the trigger related conditions
  87630. */
  87631. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  87632. /**
  87633. * Execute the action and run the attached code.
  87634. */
  87635. execute(evt: ActionEvent): void;
  87636. }
  87637. /**
  87638. * This defines an action responsible to set the parent property of the target once triggered.
  87639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87640. */
  87641. export class SetParentAction extends Action {
  87642. private _parent;
  87643. private _target;
  87644. /**
  87645. * Instantiate the action
  87646. * @param triggerOptions defines the trigger options
  87647. * @param target defines the target containing the parent property
  87648. * @param parent defines from where the animation should start (animation frame)
  87649. * @param condition defines the trigger related conditions
  87650. */
  87651. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  87652. /** @hidden */
  87653. _prepare(): void;
  87654. /**
  87655. * Execute the action and set the parent property.
  87656. */
  87657. execute(): void;
  87658. /**
  87659. * Serializes the actions and its related information.
  87660. * @param parent defines the object to serialize in
  87661. * @returns the serialized object
  87662. */
  87663. serialize(parent: any): any;
  87664. }
  87665. }
  87666. declare module BABYLON {
  87667. /**
  87668. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  87669. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  87670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87671. */
  87672. export class ActionManager extends AbstractActionManager {
  87673. /**
  87674. * Nothing
  87675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87676. */
  87677. static readonly NothingTrigger: number;
  87678. /**
  87679. * On pick
  87680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87681. */
  87682. static readonly OnPickTrigger: number;
  87683. /**
  87684. * On left pick
  87685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87686. */
  87687. static readonly OnLeftPickTrigger: number;
  87688. /**
  87689. * On right pick
  87690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87691. */
  87692. static readonly OnRightPickTrigger: number;
  87693. /**
  87694. * On center pick
  87695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87696. */
  87697. static readonly OnCenterPickTrigger: number;
  87698. /**
  87699. * On pick down
  87700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87701. */
  87702. static readonly OnPickDownTrigger: number;
  87703. /**
  87704. * On double pick
  87705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87706. */
  87707. static readonly OnDoublePickTrigger: number;
  87708. /**
  87709. * On pick up
  87710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87711. */
  87712. static readonly OnPickUpTrigger: number;
  87713. /**
  87714. * On pick out.
  87715. * This trigger will only be raised if you also declared a OnPickDown
  87716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87717. */
  87718. static readonly OnPickOutTrigger: number;
  87719. /**
  87720. * On long press
  87721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87722. */
  87723. static readonly OnLongPressTrigger: number;
  87724. /**
  87725. * On pointer over
  87726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87727. */
  87728. static readonly OnPointerOverTrigger: number;
  87729. /**
  87730. * On pointer out
  87731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87732. */
  87733. static readonly OnPointerOutTrigger: number;
  87734. /**
  87735. * On every frame
  87736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87737. */
  87738. static readonly OnEveryFrameTrigger: number;
  87739. /**
  87740. * On intersection enter
  87741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87742. */
  87743. static readonly OnIntersectionEnterTrigger: number;
  87744. /**
  87745. * On intersection exit
  87746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87747. */
  87748. static readonly OnIntersectionExitTrigger: number;
  87749. /**
  87750. * On key down
  87751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87752. */
  87753. static readonly OnKeyDownTrigger: number;
  87754. /**
  87755. * On key up
  87756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87757. */
  87758. static readonly OnKeyUpTrigger: number;
  87759. private _scene;
  87760. /**
  87761. * Creates a new action manager
  87762. * @param scene defines the hosting scene
  87763. */
  87764. constructor(scene: Scene);
  87765. /**
  87766. * Releases all associated resources
  87767. */
  87768. dispose(): void;
  87769. /**
  87770. * Gets hosting scene
  87771. * @returns the hosting scene
  87772. */
  87773. getScene(): Scene;
  87774. /**
  87775. * Does this action manager handles actions of any of the given triggers
  87776. * @param triggers defines the triggers to be tested
  87777. * @return a boolean indicating whether one (or more) of the triggers is handled
  87778. */
  87779. hasSpecificTriggers(triggers: number[]): boolean;
  87780. /**
  87781. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87782. * speed.
  87783. * @param triggerA defines the trigger to be tested
  87784. * @param triggerB defines the trigger to be tested
  87785. * @return a boolean indicating whether one (or more) of the triggers is handled
  87786. */
  87787. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87788. /**
  87789. * Does this action manager handles actions of a given trigger
  87790. * @param trigger defines the trigger to be tested
  87791. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87792. * @return whether the trigger is handled
  87793. */
  87794. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87795. /**
  87796. * Does this action manager has pointer triggers
  87797. */
  87798. get hasPointerTriggers(): boolean;
  87799. /**
  87800. * Does this action manager has pick triggers
  87801. */
  87802. get hasPickTriggers(): boolean;
  87803. /**
  87804. * Registers an action to this action manager
  87805. * @param action defines the action to be registered
  87806. * @return the action amended (prepared) after registration
  87807. */
  87808. registerAction(action: IAction): Nullable<IAction>;
  87809. /**
  87810. * Unregisters an action to this action manager
  87811. * @param action defines the action to be unregistered
  87812. * @return a boolean indicating whether the action has been unregistered
  87813. */
  87814. unregisterAction(action: IAction): Boolean;
  87815. /**
  87816. * Process a specific trigger
  87817. * @param trigger defines the trigger to process
  87818. * @param evt defines the event details to be processed
  87819. */
  87820. processTrigger(trigger: number, evt?: IActionEvent): void;
  87821. /** @hidden */
  87822. _getEffectiveTarget(target: any, propertyPath: string): any;
  87823. /** @hidden */
  87824. _getProperty(propertyPath: string): string;
  87825. /**
  87826. * Serialize this manager to a JSON object
  87827. * @param name defines the property name to store this manager
  87828. * @returns a JSON representation of this manager
  87829. */
  87830. serialize(name: string): any;
  87831. /**
  87832. * Creates a new ActionManager from a JSON data
  87833. * @param parsedActions defines the JSON data to read from
  87834. * @param object defines the hosting mesh
  87835. * @param scene defines the hosting scene
  87836. */
  87837. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87838. /**
  87839. * Get a trigger name by index
  87840. * @param trigger defines the trigger index
  87841. * @returns a trigger name
  87842. */
  87843. static GetTriggerName(trigger: number): string;
  87844. }
  87845. }
  87846. declare module BABYLON {
  87847. /**
  87848. * Class used to represent a sprite
  87849. * @see http://doc.babylonjs.com/babylon101/sprites
  87850. */
  87851. export class Sprite implements IAnimatable {
  87852. /** defines the name */
  87853. name: string;
  87854. /** Gets or sets the current world position */
  87855. position: Vector3;
  87856. /** Gets or sets the main color */
  87857. color: Color4;
  87858. /** Gets or sets the width */
  87859. width: number;
  87860. /** Gets or sets the height */
  87861. height: number;
  87862. /** Gets or sets rotation angle */
  87863. angle: number;
  87864. /** Gets or sets the cell index in the sprite sheet */
  87865. cellIndex: number;
  87866. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  87867. cellRef: string;
  87868. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  87869. invertU: boolean;
  87870. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  87871. invertV: boolean;
  87872. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  87873. disposeWhenFinishedAnimating: boolean;
  87874. /** Gets the list of attached animations */
  87875. animations: Nullable<Array<Animation>>;
  87876. /** Gets or sets a boolean indicating if the sprite can be picked */
  87877. isPickable: boolean;
  87878. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  87879. useAlphaForPicking: boolean;
  87880. /** @hidden */
  87881. _xOffset: number;
  87882. /** @hidden */
  87883. _yOffset: number;
  87884. /** @hidden */
  87885. _xSize: number;
  87886. /** @hidden */
  87887. _ySize: number;
  87888. /**
  87889. * Gets or sets the associated action manager
  87890. */
  87891. actionManager: Nullable<ActionManager>;
  87892. /**
  87893. * An event triggered when the control has been disposed
  87894. */
  87895. onDisposeObservable: Observable<Sprite>;
  87896. private _animationStarted;
  87897. private _loopAnimation;
  87898. private _fromIndex;
  87899. private _toIndex;
  87900. private _delay;
  87901. private _direction;
  87902. private _manager;
  87903. private _time;
  87904. private _onAnimationEnd;
  87905. /**
  87906. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  87907. */
  87908. isVisible: boolean;
  87909. /**
  87910. * Gets or sets the sprite size
  87911. */
  87912. get size(): number;
  87913. set size(value: number);
  87914. /**
  87915. * Returns a boolean indicating if the animation is started
  87916. */
  87917. get animationStarted(): boolean;
  87918. /**
  87919. * Gets or sets the unique id of the sprite
  87920. */
  87921. uniqueId: number;
  87922. /**
  87923. * Gets the manager of this sprite
  87924. */
  87925. get manager(): ISpriteManager;
  87926. /**
  87927. * Creates a new Sprite
  87928. * @param name defines the name
  87929. * @param manager defines the manager
  87930. */
  87931. constructor(
  87932. /** defines the name */
  87933. name: string, manager: ISpriteManager);
  87934. /**
  87935. * Returns the string "Sprite"
  87936. * @returns "Sprite"
  87937. */
  87938. getClassName(): string;
  87939. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  87940. get fromIndex(): number;
  87941. set fromIndex(value: number);
  87942. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  87943. get toIndex(): number;
  87944. set toIndex(value: number);
  87945. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  87946. get loopAnimation(): boolean;
  87947. set loopAnimation(value: boolean);
  87948. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  87949. get delay(): number;
  87950. set delay(value: number);
  87951. /**
  87952. * Starts an animation
  87953. * @param from defines the initial key
  87954. * @param to defines the end key
  87955. * @param loop defines if the animation must loop
  87956. * @param delay defines the start delay (in ms)
  87957. * @param onAnimationEnd defines a callback to call when animation ends
  87958. */
  87959. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  87960. /** Stops current animation (if any) */
  87961. stopAnimation(): void;
  87962. /** @hidden */
  87963. _animate(deltaTime: number): void;
  87964. /** Release associated resources */
  87965. dispose(): void;
  87966. /**
  87967. * Serializes the sprite to a JSON object
  87968. * @returns the JSON object
  87969. */
  87970. serialize(): any;
  87971. /**
  87972. * Parses a JSON object to create a new sprite
  87973. * @param parsedSprite The JSON object to parse
  87974. * @param manager defines the hosting manager
  87975. * @returns the new sprite
  87976. */
  87977. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  87978. }
  87979. }
  87980. declare module BABYLON {
  87981. /**
  87982. * Information about the result of picking within a scene
  87983. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  87984. */
  87985. export class PickingInfo {
  87986. /** @hidden */
  87987. _pickingUnavailable: boolean;
  87988. /**
  87989. * If the pick collided with an object
  87990. */
  87991. hit: boolean;
  87992. /**
  87993. * Distance away where the pick collided
  87994. */
  87995. distance: number;
  87996. /**
  87997. * The location of pick collision
  87998. */
  87999. pickedPoint: Nullable<Vector3>;
  88000. /**
  88001. * The mesh corresponding the the pick collision
  88002. */
  88003. pickedMesh: Nullable<AbstractMesh>;
  88004. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88005. bu: number;
  88006. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88007. bv: number;
  88008. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88009. faceId: number;
  88010. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88011. subMeshFaceId: number;
  88012. /** Id of the the submesh that was picked */
  88013. subMeshId: number;
  88014. /** If a sprite was picked, this will be the sprite the pick collided with */
  88015. pickedSprite: Nullable<Sprite>;
  88016. /**
  88017. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88018. */
  88019. originMesh: Nullable<AbstractMesh>;
  88020. /**
  88021. * The ray that was used to perform the picking.
  88022. */
  88023. ray: Nullable<Ray>;
  88024. /**
  88025. * Gets the normal correspodning to the face the pick collided with
  88026. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88027. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88028. * @returns The normal correspodning to the face the pick collided with
  88029. */
  88030. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88031. /**
  88032. * Gets the texture coordinates of where the pick occured
  88033. * @returns the vector containing the coordnates of the texture
  88034. */
  88035. getTextureCoordinates(): Nullable<Vector2>;
  88036. }
  88037. }
  88038. declare module BABYLON {
  88039. /**
  88040. * Class representing a ray with position and direction
  88041. */
  88042. export class Ray {
  88043. /** origin point */
  88044. origin: Vector3;
  88045. /** direction */
  88046. direction: Vector3;
  88047. /** length of the ray */
  88048. length: number;
  88049. private static readonly TmpVector3;
  88050. private _tmpRay;
  88051. /**
  88052. * Creates a new ray
  88053. * @param origin origin point
  88054. * @param direction direction
  88055. * @param length length of the ray
  88056. */
  88057. constructor(
  88058. /** origin point */
  88059. origin: Vector3,
  88060. /** direction */
  88061. direction: Vector3,
  88062. /** length of the ray */
  88063. length?: number);
  88064. /**
  88065. * Checks if the ray intersects a box
  88066. * This does not account for the ray lenght by design to improve perfs.
  88067. * @param minimum bound of the box
  88068. * @param maximum bound of the box
  88069. * @param intersectionTreshold extra extend to be added to the box in all direction
  88070. * @returns if the box was hit
  88071. */
  88072. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88073. /**
  88074. * Checks if the ray intersects a box
  88075. * This does not account for the ray lenght by design to improve perfs.
  88076. * @param box the bounding box to check
  88077. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88078. * @returns if the box was hit
  88079. */
  88080. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88081. /**
  88082. * If the ray hits a sphere
  88083. * @param sphere the bounding sphere to check
  88084. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88085. * @returns true if it hits the sphere
  88086. */
  88087. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88088. /**
  88089. * If the ray hits a triange
  88090. * @param vertex0 triangle vertex
  88091. * @param vertex1 triangle vertex
  88092. * @param vertex2 triangle vertex
  88093. * @returns intersection information if hit
  88094. */
  88095. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88096. /**
  88097. * Checks if ray intersects a plane
  88098. * @param plane the plane to check
  88099. * @returns the distance away it was hit
  88100. */
  88101. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88102. /**
  88103. * Calculate the intercept of a ray on a given axis
  88104. * @param axis to check 'x' | 'y' | 'z'
  88105. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88106. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88107. */
  88108. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88109. /**
  88110. * Checks if ray intersects a mesh
  88111. * @param mesh the mesh to check
  88112. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88113. * @returns picking info of the intersecton
  88114. */
  88115. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88116. /**
  88117. * Checks if ray intersects a mesh
  88118. * @param meshes the meshes to check
  88119. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88120. * @param results array to store result in
  88121. * @returns Array of picking infos
  88122. */
  88123. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88124. private _comparePickingInfo;
  88125. private static smallnum;
  88126. private static rayl;
  88127. /**
  88128. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88129. * @param sega the first point of the segment to test the intersection against
  88130. * @param segb the second point of the segment to test the intersection against
  88131. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88132. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88133. */
  88134. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88135. /**
  88136. * Update the ray from viewport position
  88137. * @param x position
  88138. * @param y y position
  88139. * @param viewportWidth viewport width
  88140. * @param viewportHeight viewport height
  88141. * @param world world matrix
  88142. * @param view view matrix
  88143. * @param projection projection matrix
  88144. * @returns this ray updated
  88145. */
  88146. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88147. /**
  88148. * Creates a ray with origin and direction of 0,0,0
  88149. * @returns the new ray
  88150. */
  88151. static Zero(): Ray;
  88152. /**
  88153. * Creates a new ray from screen space and viewport
  88154. * @param x position
  88155. * @param y y position
  88156. * @param viewportWidth viewport width
  88157. * @param viewportHeight viewport height
  88158. * @param world world matrix
  88159. * @param view view matrix
  88160. * @param projection projection matrix
  88161. * @returns new ray
  88162. */
  88163. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88164. /**
  88165. * 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
  88166. * transformed to the given world matrix.
  88167. * @param origin The origin point
  88168. * @param end The end point
  88169. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88170. * @returns the new ray
  88171. */
  88172. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  88173. /**
  88174. * Transforms a ray by a matrix
  88175. * @param ray ray to transform
  88176. * @param matrix matrix to apply
  88177. * @returns the resulting new ray
  88178. */
  88179. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88180. /**
  88181. * Transforms a ray by a matrix
  88182. * @param ray ray to transform
  88183. * @param matrix matrix to apply
  88184. * @param result ray to store result in
  88185. */
  88186. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88187. /**
  88188. * Unproject a ray from screen space to object space
  88189. * @param sourceX defines the screen space x coordinate to use
  88190. * @param sourceY defines the screen space y coordinate to use
  88191. * @param viewportWidth defines the current width of the viewport
  88192. * @param viewportHeight defines the current height of the viewport
  88193. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88194. * @param view defines the view matrix to use
  88195. * @param projection defines the projection matrix to use
  88196. */
  88197. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88198. }
  88199. /**
  88200. * Type used to define predicate used to select faces when a mesh intersection is detected
  88201. */
  88202. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88203. interface Scene {
  88204. /** @hidden */
  88205. _tempPickingRay: Nullable<Ray>;
  88206. /** @hidden */
  88207. _cachedRayForTransform: Ray;
  88208. /** @hidden */
  88209. _pickWithRayInverseMatrix: Matrix;
  88210. /** @hidden */
  88211. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88212. /** @hidden */
  88213. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88214. }
  88215. }
  88216. declare module BABYLON {
  88217. /**
  88218. * Groups all the scene component constants in one place to ease maintenance.
  88219. * @hidden
  88220. */
  88221. export class SceneComponentConstants {
  88222. static readonly NAME_EFFECTLAYER: string;
  88223. static readonly NAME_LAYER: string;
  88224. static readonly NAME_LENSFLARESYSTEM: string;
  88225. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88226. static readonly NAME_PARTICLESYSTEM: string;
  88227. static readonly NAME_GAMEPAD: string;
  88228. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88229. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88230. static readonly NAME_DEPTHRENDERER: string;
  88231. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88232. static readonly NAME_SPRITE: string;
  88233. static readonly NAME_OUTLINERENDERER: string;
  88234. static readonly NAME_PROCEDURALTEXTURE: string;
  88235. static readonly NAME_SHADOWGENERATOR: string;
  88236. static readonly NAME_OCTREE: string;
  88237. static readonly NAME_PHYSICSENGINE: string;
  88238. static readonly NAME_AUDIO: string;
  88239. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88240. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88241. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88242. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88243. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88244. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88245. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88246. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88247. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88248. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88249. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88250. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88251. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88252. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88253. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88254. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88255. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88256. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88257. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88258. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88259. static readonly STEP_AFTERRENDER_AUDIO: number;
  88260. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88261. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88262. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88263. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88264. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88265. static readonly STEP_POINTERMOVE_SPRITE: number;
  88266. static readonly STEP_POINTERDOWN_SPRITE: number;
  88267. static readonly STEP_POINTERUP_SPRITE: number;
  88268. }
  88269. /**
  88270. * This represents a scene component.
  88271. *
  88272. * This is used to decouple the dependency the scene is having on the different workloads like
  88273. * layers, post processes...
  88274. */
  88275. export interface ISceneComponent {
  88276. /**
  88277. * The name of the component. Each component must have a unique name.
  88278. */
  88279. name: string;
  88280. /**
  88281. * The scene the component belongs to.
  88282. */
  88283. scene: Scene;
  88284. /**
  88285. * Register the component to one instance of a scene.
  88286. */
  88287. register(): void;
  88288. /**
  88289. * Rebuilds the elements related to this component in case of
  88290. * context lost for instance.
  88291. */
  88292. rebuild(): void;
  88293. /**
  88294. * Disposes the component and the associated ressources.
  88295. */
  88296. dispose(): void;
  88297. }
  88298. /**
  88299. * This represents a SERIALIZABLE scene component.
  88300. *
  88301. * This extends Scene Component to add Serialization methods on top.
  88302. */
  88303. export interface ISceneSerializableComponent extends ISceneComponent {
  88304. /**
  88305. * Adds all the elements from the container to the scene
  88306. * @param container the container holding the elements
  88307. */
  88308. addFromContainer(container: AbstractScene): void;
  88309. /**
  88310. * Removes all the elements in the container from the scene
  88311. * @param container contains the elements to remove
  88312. * @param dispose if the removed element should be disposed (default: false)
  88313. */
  88314. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88315. /**
  88316. * Serializes the component data to the specified json object
  88317. * @param serializationObject The object to serialize to
  88318. */
  88319. serialize(serializationObject: any): void;
  88320. }
  88321. /**
  88322. * Strong typing of a Mesh related stage step action
  88323. */
  88324. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  88325. /**
  88326. * Strong typing of a Evaluate Sub Mesh related stage step action
  88327. */
  88328. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  88329. /**
  88330. * Strong typing of a Active Mesh related stage step action
  88331. */
  88332. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  88333. /**
  88334. * Strong typing of a Camera related stage step action
  88335. */
  88336. export type CameraStageAction = (camera: Camera) => void;
  88337. /**
  88338. * Strong typing of a Camera Frame buffer related stage step action
  88339. */
  88340. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  88341. /**
  88342. * Strong typing of a Render Target related stage step action
  88343. */
  88344. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  88345. /**
  88346. * Strong typing of a RenderingGroup related stage step action
  88347. */
  88348. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  88349. /**
  88350. * Strong typing of a Mesh Render related stage step action
  88351. */
  88352. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  88353. /**
  88354. * Strong typing of a simple stage step action
  88355. */
  88356. export type SimpleStageAction = () => void;
  88357. /**
  88358. * Strong typing of a render target action.
  88359. */
  88360. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  88361. /**
  88362. * Strong typing of a pointer move action.
  88363. */
  88364. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  88365. /**
  88366. * Strong typing of a pointer up/down action.
  88367. */
  88368. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  88369. /**
  88370. * Representation of a stage in the scene (Basically a list of ordered steps)
  88371. * @hidden
  88372. */
  88373. export class Stage<T extends Function> extends Array<{
  88374. index: number;
  88375. component: ISceneComponent;
  88376. action: T;
  88377. }> {
  88378. /**
  88379. * Hide ctor from the rest of the world.
  88380. * @param items The items to add.
  88381. */
  88382. private constructor();
  88383. /**
  88384. * Creates a new Stage.
  88385. * @returns A new instance of a Stage
  88386. */
  88387. static Create<T extends Function>(): Stage<T>;
  88388. /**
  88389. * Registers a step in an ordered way in the targeted stage.
  88390. * @param index Defines the position to register the step in
  88391. * @param component Defines the component attached to the step
  88392. * @param action Defines the action to launch during the step
  88393. */
  88394. registerStep(index: number, component: ISceneComponent, action: T): void;
  88395. /**
  88396. * Clears all the steps from the stage.
  88397. */
  88398. clear(): void;
  88399. }
  88400. }
  88401. declare module BABYLON {
  88402. interface Scene {
  88403. /** @hidden */
  88404. _pointerOverSprite: Nullable<Sprite>;
  88405. /** @hidden */
  88406. _pickedDownSprite: Nullable<Sprite>;
  88407. /** @hidden */
  88408. _tempSpritePickingRay: Nullable<Ray>;
  88409. /**
  88410. * All of the sprite managers added to this scene
  88411. * @see http://doc.babylonjs.com/babylon101/sprites
  88412. */
  88413. spriteManagers: Array<ISpriteManager>;
  88414. /**
  88415. * An event triggered when sprites rendering is about to start
  88416. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88417. */
  88418. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88419. /**
  88420. * An event triggered when sprites rendering is done
  88421. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88422. */
  88423. onAfterSpritesRenderingObservable: Observable<Scene>;
  88424. /** @hidden */
  88425. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88426. /** Launch a ray to try to pick a sprite in the scene
  88427. * @param x position on screen
  88428. * @param y position on screen
  88429. * @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
  88430. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88431. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88432. * @returns a PickingInfo
  88433. */
  88434. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88435. /** Use the given ray to pick a sprite in the scene
  88436. * @param ray The ray (in world space) to use to pick meshes
  88437. * @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
  88438. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88439. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88440. * @returns a PickingInfo
  88441. */
  88442. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88443. /** @hidden */
  88444. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88445. /** Launch a ray to try to pick sprites in the scene
  88446. * @param x position on screen
  88447. * @param y position on screen
  88448. * @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
  88449. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88450. * @returns a PickingInfo array
  88451. */
  88452. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88453. /** Use the given ray to pick sprites in the scene
  88454. * @param ray The ray (in world space) to use to pick meshes
  88455. * @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
  88456. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88457. * @returns a PickingInfo array
  88458. */
  88459. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88460. /**
  88461. * Force the sprite under the pointer
  88462. * @param sprite defines the sprite to use
  88463. */
  88464. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  88465. /**
  88466. * Gets the sprite under the pointer
  88467. * @returns a Sprite or null if no sprite is under the pointer
  88468. */
  88469. getPointerOverSprite(): Nullable<Sprite>;
  88470. }
  88471. /**
  88472. * Defines the sprite scene component responsible to manage sprites
  88473. * in a given scene.
  88474. */
  88475. export class SpriteSceneComponent implements ISceneComponent {
  88476. /**
  88477. * The component name helpfull to identify the component in the list of scene components.
  88478. */
  88479. readonly name: string;
  88480. /**
  88481. * The scene the component belongs to.
  88482. */
  88483. scene: Scene;
  88484. /** @hidden */
  88485. private _spritePredicate;
  88486. /**
  88487. * Creates a new instance of the component for the given scene
  88488. * @param scene Defines the scene to register the component in
  88489. */
  88490. constructor(scene: Scene);
  88491. /**
  88492. * Registers the component in a given scene
  88493. */
  88494. register(): void;
  88495. /**
  88496. * Rebuilds the elements related to this component in case of
  88497. * context lost for instance.
  88498. */
  88499. rebuild(): void;
  88500. /**
  88501. * Disposes the component and the associated ressources.
  88502. */
  88503. dispose(): void;
  88504. private _pickSpriteButKeepRay;
  88505. private _pointerMove;
  88506. private _pointerDown;
  88507. private _pointerUp;
  88508. }
  88509. }
  88510. declare module BABYLON {
  88511. /** @hidden */
  88512. export var fogFragmentDeclaration: {
  88513. name: string;
  88514. shader: string;
  88515. };
  88516. }
  88517. declare module BABYLON {
  88518. /** @hidden */
  88519. export var fogFragment: {
  88520. name: string;
  88521. shader: string;
  88522. };
  88523. }
  88524. declare module BABYLON {
  88525. /** @hidden */
  88526. export var spritesPixelShader: {
  88527. name: string;
  88528. shader: string;
  88529. };
  88530. }
  88531. declare module BABYLON {
  88532. /** @hidden */
  88533. export var fogVertexDeclaration: {
  88534. name: string;
  88535. shader: string;
  88536. };
  88537. }
  88538. declare module BABYLON {
  88539. /** @hidden */
  88540. export var spritesVertexShader: {
  88541. name: string;
  88542. shader: string;
  88543. };
  88544. }
  88545. declare module BABYLON {
  88546. /**
  88547. * Defines the minimum interface to fullfil in order to be a sprite manager.
  88548. */
  88549. export interface ISpriteManager extends IDisposable {
  88550. /**
  88551. * Gets manager's name
  88552. */
  88553. name: string;
  88554. /**
  88555. * Restricts the camera to viewing objects with the same layerMask.
  88556. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  88557. */
  88558. layerMask: number;
  88559. /**
  88560. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  88561. */
  88562. isPickable: boolean;
  88563. /**
  88564. * Gets the hosting scene
  88565. */
  88566. scene: Scene;
  88567. /**
  88568. * Specifies the rendering group id for this mesh (0 by default)
  88569. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  88570. */
  88571. renderingGroupId: number;
  88572. /**
  88573. * Defines the list of sprites managed by the manager.
  88574. */
  88575. sprites: Array<Sprite>;
  88576. /**
  88577. * Gets or sets the spritesheet texture
  88578. */
  88579. texture: Texture;
  88580. /** Defines the default width of a cell in the spritesheet */
  88581. cellWidth: number;
  88582. /** Defines the default height of a cell in the spritesheet */
  88583. cellHeight: number;
  88584. /**
  88585. * Tests the intersection of a sprite with a specific ray.
  88586. * @param ray The ray we are sending to test the collision
  88587. * @param camera The camera space we are sending rays in
  88588. * @param predicate A predicate allowing excluding sprites from the list of object to test
  88589. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88590. * @returns picking info or null.
  88591. */
  88592. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88593. /**
  88594. * Intersects the sprites with a ray
  88595. * @param ray defines the ray to intersect with
  88596. * @param camera defines the current active camera
  88597. * @param predicate defines a predicate used to select candidate sprites
  88598. * @returns null if no hit or a PickingInfo array
  88599. */
  88600. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88601. /**
  88602. * Renders the list of sprites on screen.
  88603. */
  88604. render(): void;
  88605. }
  88606. /**
  88607. * Class used to manage multiple sprites on the same spritesheet
  88608. * @see http://doc.babylonjs.com/babylon101/sprites
  88609. */
  88610. export class SpriteManager implements ISpriteManager {
  88611. /** defines the manager's name */
  88612. name: string;
  88613. /** Define the Url to load snippets */
  88614. static SnippetUrl: string;
  88615. /** Snippet ID if the manager was created from the snippet server */
  88616. snippetId: string;
  88617. /** Gets the list of sprites */
  88618. sprites: Sprite[];
  88619. /** Gets or sets the rendering group id (0 by default) */
  88620. renderingGroupId: number;
  88621. /** Gets or sets camera layer mask */
  88622. layerMask: number;
  88623. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  88624. fogEnabled: boolean;
  88625. /** Gets or sets a boolean indicating if the sprites are pickable */
  88626. isPickable: boolean;
  88627. /** Defines the default width of a cell in the spritesheet */
  88628. cellWidth: number;
  88629. /** Defines the default height of a cell in the spritesheet */
  88630. cellHeight: number;
  88631. /** Associative array from JSON sprite data file */
  88632. private _cellData;
  88633. /** Array of sprite names from JSON sprite data file */
  88634. private _spriteMap;
  88635. /** True when packed cell data from JSON file is ready*/
  88636. private _packedAndReady;
  88637. private _textureContent;
  88638. /**
  88639. * An event triggered when the manager is disposed.
  88640. */
  88641. onDisposeObservable: Observable<SpriteManager>;
  88642. private _onDisposeObserver;
  88643. /**
  88644. * Callback called when the manager is disposed
  88645. */
  88646. set onDispose(callback: () => void);
  88647. private _capacity;
  88648. private _fromPacked;
  88649. private _spriteTexture;
  88650. private _epsilon;
  88651. private _scene;
  88652. private _vertexData;
  88653. private _buffer;
  88654. private _vertexBuffers;
  88655. private _indexBuffer;
  88656. private _effectBase;
  88657. private _effectFog;
  88658. /**
  88659. * Gets or sets the unique id of the sprite
  88660. */
  88661. uniqueId: number;
  88662. /**
  88663. * Gets the array of sprites
  88664. */
  88665. get children(): Sprite[];
  88666. /**
  88667. * Gets the hosting scene
  88668. */
  88669. get scene(): Scene;
  88670. /**
  88671. * Gets the capacity of the manager
  88672. */
  88673. get capacity(): number;
  88674. /**
  88675. * Gets or sets the spritesheet texture
  88676. */
  88677. get texture(): Texture;
  88678. set texture(value: Texture);
  88679. private _blendMode;
  88680. /**
  88681. * Blend mode use to render the particle, it can be any of
  88682. * the static Constants.ALPHA_x properties provided in this class.
  88683. * Default value is Constants.ALPHA_COMBINE
  88684. */
  88685. get blendMode(): number;
  88686. set blendMode(blendMode: number);
  88687. /** Disables writing to the depth buffer when rendering the sprites.
  88688. * It can be handy to disable depth writing when using textures without alpha channel
  88689. * and setting some specific blend modes.
  88690. */
  88691. disableDepthWrite: boolean;
  88692. /**
  88693. * Creates a new sprite manager
  88694. * @param name defines the manager's name
  88695. * @param imgUrl defines the sprite sheet url
  88696. * @param capacity defines the maximum allowed number of sprites
  88697. * @param cellSize defines the size of a sprite cell
  88698. * @param scene defines the hosting scene
  88699. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  88700. * @param samplingMode defines the smapling mode to use with spritesheet
  88701. * @param fromPacked set to false; do not alter
  88702. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  88703. */
  88704. constructor(
  88705. /** defines the manager's name */
  88706. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  88707. /**
  88708. * Returns the string "SpriteManager"
  88709. * @returns "SpriteManager"
  88710. */
  88711. getClassName(): string;
  88712. private _makePacked;
  88713. private _appendSpriteVertex;
  88714. private _checkTextureAlpha;
  88715. /**
  88716. * Intersects the sprites with a ray
  88717. * @param ray defines the ray to intersect with
  88718. * @param camera defines the current active camera
  88719. * @param predicate defines a predicate used to select candidate sprites
  88720. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  88721. * @returns null if no hit or a PickingInfo
  88722. */
  88723. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88724. /**
  88725. * Intersects the sprites with a ray
  88726. * @param ray defines the ray to intersect with
  88727. * @param camera defines the current active camera
  88728. * @param predicate defines a predicate used to select candidate sprites
  88729. * @returns null if no hit or a PickingInfo array
  88730. */
  88731. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88732. /**
  88733. * Render all child sprites
  88734. */
  88735. render(): void;
  88736. /**
  88737. * Release associated resources
  88738. */
  88739. dispose(): void;
  88740. /**
  88741. * Serializes the sprite manager to a JSON object
  88742. * @param serializeTexture defines if the texture must be serialized as well
  88743. * @returns the JSON object
  88744. */
  88745. serialize(serializeTexture?: boolean): any;
  88746. /**
  88747. * Parses a JSON object to create a new sprite manager.
  88748. * @param parsedManager The JSON object to parse
  88749. * @param scene The scene to create the sprite managerin
  88750. * @param rootUrl The root url to use to load external dependencies like texture
  88751. * @returns the new sprite manager
  88752. */
  88753. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  88754. /**
  88755. * Creates a sprite manager from a snippet saved in a remote file
  88756. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  88757. * @param url defines the url to load from
  88758. * @param scene defines the hosting scene
  88759. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88760. * @returns a promise that will resolve to the new sprite manager
  88761. */
  88762. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88763. /**
  88764. * Creates a sprite manager from a snippet saved by the sprite editor
  88765. * @param snippetId defines the snippet to load
  88766. * @param scene defines the hosting scene
  88767. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88768. * @returns a promise that will resolve to the new sprite manager
  88769. */
  88770. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88771. }
  88772. }
  88773. declare module BABYLON {
  88774. /** Interface used by value gradients (color, factor, ...) */
  88775. export interface IValueGradient {
  88776. /**
  88777. * Gets or sets the gradient value (between 0 and 1)
  88778. */
  88779. gradient: number;
  88780. }
  88781. /** Class used to store color4 gradient */
  88782. export class ColorGradient implements IValueGradient {
  88783. /**
  88784. * Gets or sets the gradient value (between 0 and 1)
  88785. */
  88786. gradient: number;
  88787. /**
  88788. * Gets or sets first associated color
  88789. */
  88790. color1: Color4;
  88791. /**
  88792. * Gets or sets second associated color
  88793. */
  88794. color2?: Color4 | undefined;
  88795. /**
  88796. * Creates a new color4 gradient
  88797. * @param gradient gets or sets the gradient value (between 0 and 1)
  88798. * @param color1 gets or sets first associated color
  88799. * @param color2 gets or sets first second color
  88800. */
  88801. constructor(
  88802. /**
  88803. * Gets or sets the gradient value (between 0 and 1)
  88804. */
  88805. gradient: number,
  88806. /**
  88807. * Gets or sets first associated color
  88808. */
  88809. color1: Color4,
  88810. /**
  88811. * Gets or sets second associated color
  88812. */
  88813. color2?: Color4 | undefined);
  88814. /**
  88815. * Will get a color picked randomly between color1 and color2.
  88816. * If color2 is undefined then color1 will be used
  88817. * @param result defines the target Color4 to store the result in
  88818. */
  88819. getColorToRef(result: Color4): void;
  88820. }
  88821. /** Class used to store color 3 gradient */
  88822. export class Color3Gradient implements IValueGradient {
  88823. /**
  88824. * Gets or sets the gradient value (between 0 and 1)
  88825. */
  88826. gradient: number;
  88827. /**
  88828. * Gets or sets the associated color
  88829. */
  88830. color: Color3;
  88831. /**
  88832. * Creates a new color3 gradient
  88833. * @param gradient gets or sets the gradient value (between 0 and 1)
  88834. * @param color gets or sets associated color
  88835. */
  88836. constructor(
  88837. /**
  88838. * Gets or sets the gradient value (between 0 and 1)
  88839. */
  88840. gradient: number,
  88841. /**
  88842. * Gets or sets the associated color
  88843. */
  88844. color: Color3);
  88845. }
  88846. /** Class used to store factor gradient */
  88847. export class FactorGradient implements IValueGradient {
  88848. /**
  88849. * Gets or sets the gradient value (between 0 and 1)
  88850. */
  88851. gradient: number;
  88852. /**
  88853. * Gets or sets first associated factor
  88854. */
  88855. factor1: number;
  88856. /**
  88857. * Gets or sets second associated factor
  88858. */
  88859. factor2?: number | undefined;
  88860. /**
  88861. * Creates a new factor gradient
  88862. * @param gradient gets or sets the gradient value (between 0 and 1)
  88863. * @param factor1 gets or sets first associated factor
  88864. * @param factor2 gets or sets second associated factor
  88865. */
  88866. constructor(
  88867. /**
  88868. * Gets or sets the gradient value (between 0 and 1)
  88869. */
  88870. gradient: number,
  88871. /**
  88872. * Gets or sets first associated factor
  88873. */
  88874. factor1: number,
  88875. /**
  88876. * Gets or sets second associated factor
  88877. */
  88878. factor2?: number | undefined);
  88879. /**
  88880. * Will get a number picked randomly between factor1 and factor2.
  88881. * If factor2 is undefined then factor1 will be used
  88882. * @returns the picked number
  88883. */
  88884. getFactor(): number;
  88885. }
  88886. /**
  88887. * Helper used to simplify some generic gradient tasks
  88888. */
  88889. export class GradientHelper {
  88890. /**
  88891. * Gets the current gradient from an array of IValueGradient
  88892. * @param ratio defines the current ratio to get
  88893. * @param gradients defines the array of IValueGradient
  88894. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88895. */
  88896. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88897. }
  88898. }
  88899. declare module BABYLON {
  88900. interface ThinEngine {
  88901. /**
  88902. * Creates a dynamic texture
  88903. * @param width defines the width of the texture
  88904. * @param height defines the height of the texture
  88905. * @param generateMipMaps defines if the engine should generate the mip levels
  88906. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88907. * @returns the dynamic texture inside an InternalTexture
  88908. */
  88909. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88910. /**
  88911. * Update the content of a dynamic texture
  88912. * @param texture defines the texture to update
  88913. * @param canvas defines the canvas containing the source
  88914. * @param invertY defines if data must be stored with Y axis inverted
  88915. * @param premulAlpha defines if alpha is stored as premultiplied
  88916. * @param format defines the format of the data
  88917. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88918. */
  88919. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88920. }
  88921. }
  88922. declare module BABYLON {
  88923. /**
  88924. * Helper class used to generate a canvas to manipulate images
  88925. */
  88926. export class CanvasGenerator {
  88927. /**
  88928. * Create a new canvas (or offscreen canvas depending on the context)
  88929. * @param width defines the expected width
  88930. * @param height defines the expected height
  88931. * @return a new canvas or offscreen canvas
  88932. */
  88933. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  88934. }
  88935. }
  88936. declare module BABYLON {
  88937. /**
  88938. * A class extending Texture allowing drawing on a texture
  88939. * @see http://doc.babylonjs.com/how_to/dynamictexture
  88940. */
  88941. export class DynamicTexture extends Texture {
  88942. private _generateMipMaps;
  88943. private _canvas;
  88944. private _context;
  88945. /**
  88946. * Creates a DynamicTexture
  88947. * @param name defines the name of the texture
  88948. * @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
  88949. * @param scene defines the scene where you want the texture
  88950. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  88951. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  88952. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  88953. */
  88954. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  88955. /**
  88956. * Get the current class name of the texture useful for serialization or dynamic coding.
  88957. * @returns "DynamicTexture"
  88958. */
  88959. getClassName(): string;
  88960. /**
  88961. * Gets the current state of canRescale
  88962. */
  88963. get canRescale(): boolean;
  88964. private _recreate;
  88965. /**
  88966. * Scales the texture
  88967. * @param ratio the scale factor to apply to both width and height
  88968. */
  88969. scale(ratio: number): void;
  88970. /**
  88971. * Resizes the texture
  88972. * @param width the new width
  88973. * @param height the new height
  88974. */
  88975. scaleTo(width: number, height: number): void;
  88976. /**
  88977. * Gets the context of the canvas used by the texture
  88978. * @returns the canvas context of the dynamic texture
  88979. */
  88980. getContext(): CanvasRenderingContext2D;
  88981. /**
  88982. * Clears the texture
  88983. */
  88984. clear(): void;
  88985. /**
  88986. * Updates the texture
  88987. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  88988. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  88989. */
  88990. update(invertY?: boolean, premulAlpha?: boolean): void;
  88991. /**
  88992. * Draws text onto the texture
  88993. * @param text defines the text to be drawn
  88994. * @param x defines the placement of the text from the left
  88995. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  88996. * @param font defines the font to be used with font-style, font-size, font-name
  88997. * @param color defines the color used for the text
  88998. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  88999. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  89000. * @param update defines whether texture is immediately update (default is true)
  89001. */
  89002. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  89003. /**
  89004. * Clones the texture
  89005. * @returns the clone of the texture.
  89006. */
  89007. clone(): DynamicTexture;
  89008. /**
  89009. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  89010. * @returns a serialized dynamic texture object
  89011. */
  89012. serialize(): any;
  89013. private _IsCanvasElement;
  89014. /** @hidden */
  89015. _rebuild(): void;
  89016. }
  89017. }
  89018. declare module BABYLON {
  89019. interface ThinEngine {
  89020. /**
  89021. * Creates a raw texture
  89022. * @param data defines the data to store in the texture
  89023. * @param width defines the width of the texture
  89024. * @param height defines the height of the texture
  89025. * @param format defines the format of the data
  89026. * @param generateMipMaps defines if the engine should generate the mip levels
  89027. * @param invertY defines if data must be stored with Y axis inverted
  89028. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89029. * @param compression defines the compression used (null by default)
  89030. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89031. * @returns the raw texture inside an InternalTexture
  89032. */
  89033. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89034. /**
  89035. * Update a raw texture
  89036. * @param texture defines the texture to update
  89037. * @param data defines the data to store in the texture
  89038. * @param format defines the format of the data
  89039. * @param invertY defines if data must be stored with Y axis inverted
  89040. */
  89041. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89042. /**
  89043. * Update a raw texture
  89044. * @param texture defines the texture to update
  89045. * @param data defines the data to store in the texture
  89046. * @param format defines the format of the data
  89047. * @param invertY defines if data must be stored with Y axis inverted
  89048. * @param compression defines the compression used (null by default)
  89049. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89050. */
  89051. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89052. /**
  89053. * Creates a new raw cube texture
  89054. * @param data defines the array of data to use to create each face
  89055. * @param size defines the size of the textures
  89056. * @param format defines the format of the data
  89057. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89058. * @param generateMipMaps defines if the engine should generate the mip levels
  89059. * @param invertY defines if data must be stored with Y axis inverted
  89060. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89061. * @param compression defines the compression used (null by default)
  89062. * @returns the cube texture as an InternalTexture
  89063. */
  89064. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89065. /**
  89066. * Update a raw cube texture
  89067. * @param texture defines the texture to udpdate
  89068. * @param data defines the data to store
  89069. * @param format defines the data format
  89070. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89071. * @param invertY defines if data must be stored with Y axis inverted
  89072. */
  89073. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  89074. /**
  89075. * Update a raw cube texture
  89076. * @param texture defines the texture to udpdate
  89077. * @param data defines the data to store
  89078. * @param format defines the data format
  89079. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89080. * @param invertY defines if data must be stored with Y axis inverted
  89081. * @param compression defines the compression used (null by default)
  89082. */
  89083. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89084. /**
  89085. * Update a raw cube texture
  89086. * @param texture defines the texture to udpdate
  89087. * @param data defines the data to store
  89088. * @param format defines the data format
  89089. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89090. * @param invertY defines if data must be stored with Y axis inverted
  89091. * @param compression defines the compression used (null by default)
  89092. * @param level defines which level of the texture to update
  89093. */
  89094. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89095. /**
  89096. * Creates a new raw cube texture from a specified url
  89097. * @param url defines the url where the data is located
  89098. * @param scene defines the current scene
  89099. * @param size defines the size of the textures
  89100. * @param format defines the format of the data
  89101. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89102. * @param noMipmap defines if the engine should avoid generating the mip levels
  89103. * @param callback defines a callback used to extract texture data from loaded data
  89104. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89105. * @param onLoad defines a callback called when texture is loaded
  89106. * @param onError defines a callback called if there is an error
  89107. * @returns the cube texture as an InternalTexture
  89108. */
  89109. 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;
  89110. /**
  89111. * Creates a new raw cube texture from a specified url
  89112. * @param url defines the url where the data is located
  89113. * @param scene defines the current scene
  89114. * @param size defines the size of the textures
  89115. * @param format defines the format of the data
  89116. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89117. * @param noMipmap defines if the engine should avoid generating the mip levels
  89118. * @param callback defines a callback used to extract texture data from loaded data
  89119. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89120. * @param onLoad defines a callback called when texture is loaded
  89121. * @param onError defines a callback called if there is an error
  89122. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89123. * @param invertY defines if data must be stored with Y axis inverted
  89124. * @returns the cube texture as an InternalTexture
  89125. */
  89126. 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;
  89127. /**
  89128. * Creates a new raw 3D texture
  89129. * @param data defines the data used to create the texture
  89130. * @param width defines the width of the texture
  89131. * @param height defines the height of the texture
  89132. * @param depth defines the depth of the texture
  89133. * @param format defines the format of the texture
  89134. * @param generateMipMaps defines if the engine must generate mip levels
  89135. * @param invertY defines if data must be stored with Y axis inverted
  89136. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89137. * @param compression defines the compressed used (can be null)
  89138. * @param textureType defines the compressed used (can be null)
  89139. * @returns a new raw 3D texture (stored in an InternalTexture)
  89140. */
  89141. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89142. /**
  89143. * Update a raw 3D texture
  89144. * @param texture defines the texture to update
  89145. * @param data defines the data to store
  89146. * @param format defines the data format
  89147. * @param invertY defines if data must be stored with Y axis inverted
  89148. */
  89149. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89150. /**
  89151. * Update a raw 3D texture
  89152. * @param texture defines the texture to update
  89153. * @param data defines the data to store
  89154. * @param format defines the data format
  89155. * @param invertY defines if data must be stored with Y axis inverted
  89156. * @param compression defines the used compression (can be null)
  89157. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89158. */
  89159. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89160. /**
  89161. * Creates a new raw 2D array texture
  89162. * @param data defines the data used to create the texture
  89163. * @param width defines the width of the texture
  89164. * @param height defines the height of the texture
  89165. * @param depth defines the number of layers of the texture
  89166. * @param format defines the format of the texture
  89167. * @param generateMipMaps defines if the engine must generate mip levels
  89168. * @param invertY defines if data must be stored with Y axis inverted
  89169. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89170. * @param compression defines the compressed used (can be null)
  89171. * @param textureType defines the compressed used (can be null)
  89172. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89173. */
  89174. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89175. /**
  89176. * Update a raw 2D array texture
  89177. * @param texture defines the texture to update
  89178. * @param data defines the data to store
  89179. * @param format defines the data format
  89180. * @param invertY defines if data must be stored with Y axis inverted
  89181. */
  89182. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89183. /**
  89184. * Update a raw 2D array texture
  89185. * @param texture defines the texture to update
  89186. * @param data defines the data to store
  89187. * @param format defines the data format
  89188. * @param invertY defines if data must be stored with Y axis inverted
  89189. * @param compression defines the used compression (can be null)
  89190. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89191. */
  89192. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89193. }
  89194. }
  89195. declare module BABYLON {
  89196. /**
  89197. * Raw texture can help creating a texture directly from an array of data.
  89198. * This can be super useful if you either get the data from an uncompressed source or
  89199. * if you wish to create your texture pixel by pixel.
  89200. */
  89201. export class RawTexture extends Texture {
  89202. /**
  89203. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89204. */
  89205. format: number;
  89206. /**
  89207. * Instantiates a new RawTexture.
  89208. * Raw texture can help creating a texture directly from an array of data.
  89209. * This can be super useful if you either get the data from an uncompressed source or
  89210. * if you wish to create your texture pixel by pixel.
  89211. * @param data define the array of data to use to create the texture
  89212. * @param width define the width of the texture
  89213. * @param height define the height of the texture
  89214. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89215. * @param scene define the scene the texture belongs to
  89216. * @param generateMipMaps define whether mip maps should be generated or not
  89217. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89218. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89219. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89220. */
  89221. constructor(data: ArrayBufferView, width: number, height: number,
  89222. /**
  89223. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89224. */
  89225. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89226. /**
  89227. * Updates the texture underlying data.
  89228. * @param data Define the new data of the texture
  89229. */
  89230. update(data: ArrayBufferView): void;
  89231. /**
  89232. * Creates a luminance texture from some data.
  89233. * @param data Define the texture data
  89234. * @param width Define the width of the texture
  89235. * @param height Define the height of the texture
  89236. * @param scene Define the scene the texture belongs to
  89237. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89238. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89239. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89240. * @returns the luminance texture
  89241. */
  89242. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89243. /**
  89244. * Creates a luminance alpha texture from some data.
  89245. * @param data Define the texture data
  89246. * @param width Define the width of the texture
  89247. * @param height Define the height of the texture
  89248. * @param scene Define the scene the texture belongs to
  89249. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89250. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89251. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89252. * @returns the luminance alpha texture
  89253. */
  89254. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89255. /**
  89256. * Creates an alpha texture from some data.
  89257. * @param data Define the texture data
  89258. * @param width Define the width of the texture
  89259. * @param height Define the height of the texture
  89260. * @param scene Define the scene the texture belongs to
  89261. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89262. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89263. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89264. * @returns the alpha texture
  89265. */
  89266. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89267. /**
  89268. * Creates a RGB texture from some data.
  89269. * @param data Define the texture data
  89270. * @param width Define the width of the texture
  89271. * @param height Define the height of the texture
  89272. * @param scene Define the scene the texture belongs to
  89273. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89274. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89275. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89276. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89277. * @returns the RGB alpha texture
  89278. */
  89279. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89280. /**
  89281. * Creates a RGBA texture from some data.
  89282. * @param data Define the texture data
  89283. * @param width Define the width of the texture
  89284. * @param height Define the height of the texture
  89285. * @param scene Define the scene the texture belongs to
  89286. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89287. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89288. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89289. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89290. * @returns the RGBA texture
  89291. */
  89292. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89293. /**
  89294. * Creates a R texture from some data.
  89295. * @param data Define the texture data
  89296. * @param width Define the width of the texture
  89297. * @param height Define the height of the texture
  89298. * @param scene Define the scene the texture belongs to
  89299. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89300. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89301. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89302. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89303. * @returns the R texture
  89304. */
  89305. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89306. }
  89307. }
  89308. declare module BABYLON {
  89309. interface AbstractScene {
  89310. /**
  89311. * The list of procedural textures added to the scene
  89312. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89313. */
  89314. proceduralTextures: Array<ProceduralTexture>;
  89315. }
  89316. /**
  89317. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89318. * in a given scene.
  89319. */
  89320. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89321. /**
  89322. * The component name helpfull to identify the component in the list of scene components.
  89323. */
  89324. readonly name: string;
  89325. /**
  89326. * The scene the component belongs to.
  89327. */
  89328. scene: Scene;
  89329. /**
  89330. * Creates a new instance of the component for the given scene
  89331. * @param scene Defines the scene to register the component in
  89332. */
  89333. constructor(scene: Scene);
  89334. /**
  89335. * Registers the component in a given scene
  89336. */
  89337. register(): void;
  89338. /**
  89339. * Rebuilds the elements related to this component in case of
  89340. * context lost for instance.
  89341. */
  89342. rebuild(): void;
  89343. /**
  89344. * Disposes the component and the associated ressources.
  89345. */
  89346. dispose(): void;
  89347. private _beforeClear;
  89348. }
  89349. }
  89350. declare module BABYLON {
  89351. interface ThinEngine {
  89352. /**
  89353. * Creates a new render target cube texture
  89354. * @param size defines the size of the texture
  89355. * @param options defines the options used to create the texture
  89356. * @returns a new render target cube texture stored in an InternalTexture
  89357. */
  89358. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89359. }
  89360. }
  89361. declare module BABYLON {
  89362. /** @hidden */
  89363. export var proceduralVertexShader: {
  89364. name: string;
  89365. shader: string;
  89366. };
  89367. }
  89368. declare module BABYLON {
  89369. /**
  89370. * 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.
  89371. * This is the base class of any Procedural texture and contains most of the shareable code.
  89372. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89373. */
  89374. export class ProceduralTexture extends Texture {
  89375. isCube: boolean;
  89376. /**
  89377. * Define if the texture is enabled or not (disabled texture will not render)
  89378. */
  89379. isEnabled: boolean;
  89380. /**
  89381. * Define if the texture must be cleared before rendering (default is true)
  89382. */
  89383. autoClear: boolean;
  89384. /**
  89385. * Callback called when the texture is generated
  89386. */
  89387. onGenerated: () => void;
  89388. /**
  89389. * Event raised when the texture is generated
  89390. */
  89391. onGeneratedObservable: Observable<ProceduralTexture>;
  89392. /** @hidden */
  89393. _generateMipMaps: boolean;
  89394. /** @hidden **/
  89395. _effect: Effect;
  89396. /** @hidden */
  89397. _textures: {
  89398. [key: string]: Texture;
  89399. };
  89400. /** @hidden */
  89401. protected _fallbackTexture: Nullable<Texture>;
  89402. private _size;
  89403. private _currentRefreshId;
  89404. private _frameId;
  89405. private _refreshRate;
  89406. private _vertexBuffers;
  89407. private _indexBuffer;
  89408. private _uniforms;
  89409. private _samplers;
  89410. private _fragment;
  89411. private _floats;
  89412. private _ints;
  89413. private _floatsArrays;
  89414. private _colors3;
  89415. private _colors4;
  89416. private _vectors2;
  89417. private _vectors3;
  89418. private _matrices;
  89419. private _fallbackTextureUsed;
  89420. private _fullEngine;
  89421. private _cachedDefines;
  89422. private _contentUpdateId;
  89423. private _contentData;
  89424. /**
  89425. * Instantiates a new procedural texture.
  89426. * 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.
  89427. * This is the base class of any Procedural texture and contains most of the shareable code.
  89428. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89429. * @param name Define the name of the texture
  89430. * @param size Define the size of the texture to create
  89431. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89432. * @param scene Define the scene the texture belongs to
  89433. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89434. * @param generateMipMaps Define if the texture should creates mip maps or not
  89435. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89436. */
  89437. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89438. /**
  89439. * The effect that is created when initializing the post process.
  89440. * @returns The created effect corresponding the the postprocess.
  89441. */
  89442. getEffect(): Effect;
  89443. /**
  89444. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89445. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89446. */
  89447. getContent(): Nullable<ArrayBufferView>;
  89448. private _createIndexBuffer;
  89449. /** @hidden */
  89450. _rebuild(): void;
  89451. /**
  89452. * Resets the texture in order to recreate its associated resources.
  89453. * This can be called in case of context loss
  89454. */
  89455. reset(): void;
  89456. protected _getDefines(): string;
  89457. /**
  89458. * Is the texture ready to be used ? (rendered at least once)
  89459. * @returns true if ready, otherwise, false.
  89460. */
  89461. isReady(): boolean;
  89462. /**
  89463. * Resets the refresh counter of the texture and start bak from scratch.
  89464. * Could be useful to regenerate the texture if it is setup to render only once.
  89465. */
  89466. resetRefreshCounter(): void;
  89467. /**
  89468. * Set the fragment shader to use in order to render the texture.
  89469. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89470. */
  89471. setFragment(fragment: any): void;
  89472. /**
  89473. * Define the refresh rate of the texture or the rendering frequency.
  89474. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89475. */
  89476. get refreshRate(): number;
  89477. set refreshRate(value: number);
  89478. /** @hidden */
  89479. _shouldRender(): boolean;
  89480. /**
  89481. * Get the size the texture is rendering at.
  89482. * @returns the size (texture is always squared)
  89483. */
  89484. getRenderSize(): number;
  89485. /**
  89486. * Resize the texture to new value.
  89487. * @param size Define the new size the texture should have
  89488. * @param generateMipMaps Define whether the new texture should create mip maps
  89489. */
  89490. resize(size: number, generateMipMaps: boolean): void;
  89491. private _checkUniform;
  89492. /**
  89493. * Set a texture in the shader program used to render.
  89494. * @param name Define the name of the uniform samplers as defined in the shader
  89495. * @param texture Define the texture to bind to this sampler
  89496. * @return the texture itself allowing "fluent" like uniform updates
  89497. */
  89498. setTexture(name: string, texture: Texture): ProceduralTexture;
  89499. /**
  89500. * Set a float in the shader.
  89501. * @param name Define the name of the uniform as defined in the shader
  89502. * @param value Define the value to give to the uniform
  89503. * @return the texture itself allowing "fluent" like uniform updates
  89504. */
  89505. setFloat(name: string, value: number): ProceduralTexture;
  89506. /**
  89507. * Set a int in the shader.
  89508. * @param name Define the name of the uniform as defined in the shader
  89509. * @param value Define the value to give to the uniform
  89510. * @return the texture itself allowing "fluent" like uniform updates
  89511. */
  89512. setInt(name: string, value: number): ProceduralTexture;
  89513. /**
  89514. * Set an array of floats in the shader.
  89515. * @param name Define the name of the uniform as defined in the shader
  89516. * @param value Define the value to give to the uniform
  89517. * @return the texture itself allowing "fluent" like uniform updates
  89518. */
  89519. setFloats(name: string, value: number[]): ProceduralTexture;
  89520. /**
  89521. * Set a vec3 in the shader from a Color3.
  89522. * @param name Define the name of the uniform as defined in the shader
  89523. * @param value Define the value to give to the uniform
  89524. * @return the texture itself allowing "fluent" like uniform updates
  89525. */
  89526. setColor3(name: string, value: Color3): ProceduralTexture;
  89527. /**
  89528. * Set a vec4 in the shader from a Color4.
  89529. * @param name Define the name of the uniform as defined in the shader
  89530. * @param value Define the value to give to the uniform
  89531. * @return the texture itself allowing "fluent" like uniform updates
  89532. */
  89533. setColor4(name: string, value: Color4): ProceduralTexture;
  89534. /**
  89535. * Set a vec2 in the shader from a Vector2.
  89536. * @param name Define the name of the uniform as defined in the shader
  89537. * @param value Define the value to give to the uniform
  89538. * @return the texture itself allowing "fluent" like uniform updates
  89539. */
  89540. setVector2(name: string, value: Vector2): ProceduralTexture;
  89541. /**
  89542. * Set a vec3 in the shader from a Vector3.
  89543. * @param name Define the name of the uniform as defined in the shader
  89544. * @param value Define the value to give to the uniform
  89545. * @return the texture itself allowing "fluent" like uniform updates
  89546. */
  89547. setVector3(name: string, value: Vector3): ProceduralTexture;
  89548. /**
  89549. * Set a mat4 in the shader from a MAtrix.
  89550. * @param name Define the name of the uniform as defined in the shader
  89551. * @param value Define the value to give to the uniform
  89552. * @return the texture itself allowing "fluent" like uniform updates
  89553. */
  89554. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89555. /**
  89556. * Render the texture to its associated render target.
  89557. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89558. */
  89559. render(useCameraPostProcess?: boolean): void;
  89560. /**
  89561. * Clone the texture.
  89562. * @returns the cloned texture
  89563. */
  89564. clone(): ProceduralTexture;
  89565. /**
  89566. * Dispose the texture and release its asoociated resources.
  89567. */
  89568. dispose(): void;
  89569. }
  89570. }
  89571. declare module BABYLON {
  89572. /**
  89573. * This represents the base class for particle system in Babylon.
  89574. * 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.
  89575. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89576. * @example https://doc.babylonjs.com/babylon101/particles
  89577. */
  89578. export class BaseParticleSystem {
  89579. /**
  89580. * Source color is added to the destination color without alpha affecting the result
  89581. */
  89582. static BLENDMODE_ONEONE: number;
  89583. /**
  89584. * Blend current color and particle color using particle’s alpha
  89585. */
  89586. static BLENDMODE_STANDARD: number;
  89587. /**
  89588. * Add current color and particle color multiplied by particle’s alpha
  89589. */
  89590. static BLENDMODE_ADD: number;
  89591. /**
  89592. * Multiply current color with particle color
  89593. */
  89594. static BLENDMODE_MULTIPLY: number;
  89595. /**
  89596. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89597. */
  89598. static BLENDMODE_MULTIPLYADD: number;
  89599. /**
  89600. * List of animations used by the particle system.
  89601. */
  89602. animations: Animation[];
  89603. /**
  89604. * Gets or sets the unique id of the particle system
  89605. */
  89606. uniqueId: number;
  89607. /**
  89608. * The id of the Particle system.
  89609. */
  89610. id: string;
  89611. /**
  89612. * The friendly name of the Particle system.
  89613. */
  89614. name: string;
  89615. /**
  89616. * Snippet ID if the particle system was created from the snippet server
  89617. */
  89618. snippetId: string;
  89619. /**
  89620. * The rendering group used by the Particle system to chose when to render.
  89621. */
  89622. renderingGroupId: number;
  89623. /**
  89624. * The emitter represents the Mesh or position we are attaching the particle system to.
  89625. */
  89626. emitter: Nullable<AbstractMesh | Vector3>;
  89627. /**
  89628. * The maximum number of particles to emit per frame
  89629. */
  89630. emitRate: number;
  89631. /**
  89632. * If you want to launch only a few particles at once, that can be done, as well.
  89633. */
  89634. manualEmitCount: number;
  89635. /**
  89636. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89637. */
  89638. updateSpeed: number;
  89639. /**
  89640. * The amount of time the particle system is running (depends of the overall update speed).
  89641. */
  89642. targetStopDuration: number;
  89643. /**
  89644. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89645. */
  89646. disposeOnStop: boolean;
  89647. /**
  89648. * Minimum power of emitting particles.
  89649. */
  89650. minEmitPower: number;
  89651. /**
  89652. * Maximum power of emitting particles.
  89653. */
  89654. maxEmitPower: number;
  89655. /**
  89656. * Minimum life time of emitting particles.
  89657. */
  89658. minLifeTime: number;
  89659. /**
  89660. * Maximum life time of emitting particles.
  89661. */
  89662. maxLifeTime: number;
  89663. /**
  89664. * Minimum Size of emitting particles.
  89665. */
  89666. minSize: number;
  89667. /**
  89668. * Maximum Size of emitting particles.
  89669. */
  89670. maxSize: number;
  89671. /**
  89672. * Minimum scale of emitting particles on X axis.
  89673. */
  89674. minScaleX: number;
  89675. /**
  89676. * Maximum scale of emitting particles on X axis.
  89677. */
  89678. maxScaleX: number;
  89679. /**
  89680. * Minimum scale of emitting particles on Y axis.
  89681. */
  89682. minScaleY: number;
  89683. /**
  89684. * Maximum scale of emitting particles on Y axis.
  89685. */
  89686. maxScaleY: number;
  89687. /**
  89688. * Gets or sets the minimal initial rotation in radians.
  89689. */
  89690. minInitialRotation: number;
  89691. /**
  89692. * Gets or sets the maximal initial rotation in radians.
  89693. */
  89694. maxInitialRotation: number;
  89695. /**
  89696. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89697. */
  89698. minAngularSpeed: number;
  89699. /**
  89700. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89701. */
  89702. maxAngularSpeed: number;
  89703. /**
  89704. * The texture used to render each particle. (this can be a spritesheet)
  89705. */
  89706. particleTexture: Nullable<Texture>;
  89707. /**
  89708. * The layer mask we are rendering the particles through.
  89709. */
  89710. layerMask: number;
  89711. /**
  89712. * This can help using your own shader to render the particle system.
  89713. * The according effect will be created
  89714. */
  89715. customShader: any;
  89716. /**
  89717. * By default particle system starts as soon as they are created. This prevents the
  89718. * automatic start to happen and let you decide when to start emitting particles.
  89719. */
  89720. preventAutoStart: boolean;
  89721. private _noiseTexture;
  89722. /**
  89723. * Gets or sets a texture used to add random noise to particle positions
  89724. */
  89725. get noiseTexture(): Nullable<ProceduralTexture>;
  89726. set noiseTexture(value: Nullable<ProceduralTexture>);
  89727. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89728. noiseStrength: Vector3;
  89729. /**
  89730. * Callback triggered when the particle animation is ending.
  89731. */
  89732. onAnimationEnd: Nullable<() => void>;
  89733. /**
  89734. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89735. */
  89736. blendMode: number;
  89737. /**
  89738. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89739. * to override the particles.
  89740. */
  89741. forceDepthWrite: boolean;
  89742. /** 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 */
  89743. preWarmCycles: number;
  89744. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89745. preWarmStepOffset: number;
  89746. /**
  89747. * 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)
  89748. */
  89749. spriteCellChangeSpeed: number;
  89750. /**
  89751. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89752. */
  89753. startSpriteCellID: number;
  89754. /**
  89755. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89756. */
  89757. endSpriteCellID: number;
  89758. /**
  89759. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89760. */
  89761. spriteCellWidth: number;
  89762. /**
  89763. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89764. */
  89765. spriteCellHeight: number;
  89766. /**
  89767. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89768. */
  89769. spriteRandomStartCell: boolean;
  89770. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89771. translationPivot: Vector2;
  89772. /** @hidden */
  89773. protected _isAnimationSheetEnabled: boolean;
  89774. /**
  89775. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89776. */
  89777. beginAnimationOnStart: boolean;
  89778. /**
  89779. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89780. */
  89781. beginAnimationFrom: number;
  89782. /**
  89783. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89784. */
  89785. beginAnimationTo: number;
  89786. /**
  89787. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89788. */
  89789. beginAnimationLoop: boolean;
  89790. /**
  89791. * Gets or sets a world offset applied to all particles
  89792. */
  89793. worldOffset: Vector3;
  89794. /**
  89795. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89796. */
  89797. get isAnimationSheetEnabled(): boolean;
  89798. set isAnimationSheetEnabled(value: boolean);
  89799. /**
  89800. * Get hosting scene
  89801. * @returns the scene
  89802. */
  89803. getScene(): Scene;
  89804. /**
  89805. * You can use gravity if you want to give an orientation to your particles.
  89806. */
  89807. gravity: Vector3;
  89808. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89809. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89810. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89811. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89812. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89813. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89814. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89815. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89816. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89817. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89818. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89819. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89820. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89821. /**
  89822. * Defines the delay in milliseconds before starting the system (0 by default)
  89823. */
  89824. startDelay: number;
  89825. /**
  89826. * Gets the current list of drag gradients.
  89827. * You must use addDragGradient and removeDragGradient to udpate this list
  89828. * @returns the list of drag gradients
  89829. */
  89830. getDragGradients(): Nullable<Array<FactorGradient>>;
  89831. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89832. limitVelocityDamping: number;
  89833. /**
  89834. * Gets the current list of limit velocity gradients.
  89835. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89836. * @returns the list of limit velocity gradients
  89837. */
  89838. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89839. /**
  89840. * Gets the current list of color gradients.
  89841. * You must use addColorGradient and removeColorGradient to udpate this list
  89842. * @returns the list of color gradients
  89843. */
  89844. getColorGradients(): Nullable<Array<ColorGradient>>;
  89845. /**
  89846. * Gets the current list of size gradients.
  89847. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89848. * @returns the list of size gradients
  89849. */
  89850. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89851. /**
  89852. * Gets the current list of color remap gradients.
  89853. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89854. * @returns the list of color remap gradients
  89855. */
  89856. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89857. /**
  89858. * Gets the current list of alpha remap gradients.
  89859. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89860. * @returns the list of alpha remap gradients
  89861. */
  89862. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89863. /**
  89864. * Gets the current list of life time gradients.
  89865. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89866. * @returns the list of life time gradients
  89867. */
  89868. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89869. /**
  89870. * Gets the current list of angular speed gradients.
  89871. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89872. * @returns the list of angular speed gradients
  89873. */
  89874. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89875. /**
  89876. * Gets the current list of velocity gradients.
  89877. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89878. * @returns the list of velocity gradients
  89879. */
  89880. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89881. /**
  89882. * Gets the current list of start size gradients.
  89883. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89884. * @returns the list of start size gradients
  89885. */
  89886. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89887. /**
  89888. * Gets the current list of emit rate gradients.
  89889. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89890. * @returns the list of emit rate gradients
  89891. */
  89892. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89893. /**
  89894. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89895. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89896. */
  89897. get direction1(): Vector3;
  89898. set direction1(value: Vector3);
  89899. /**
  89900. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89901. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89902. */
  89903. get direction2(): Vector3;
  89904. set direction2(value: Vector3);
  89905. /**
  89906. * 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.
  89907. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89908. */
  89909. get minEmitBox(): Vector3;
  89910. set minEmitBox(value: Vector3);
  89911. /**
  89912. * 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.
  89913. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89914. */
  89915. get maxEmitBox(): Vector3;
  89916. set maxEmitBox(value: Vector3);
  89917. /**
  89918. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89919. */
  89920. color1: Color4;
  89921. /**
  89922. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89923. */
  89924. color2: Color4;
  89925. /**
  89926. * Color the particle will have at the end of its lifetime
  89927. */
  89928. colorDead: Color4;
  89929. /**
  89930. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89931. */
  89932. textureMask: Color4;
  89933. /**
  89934. * The particle emitter type defines the emitter used by the particle system.
  89935. * It can be for example box, sphere, or cone...
  89936. */
  89937. particleEmitterType: IParticleEmitterType;
  89938. /** @hidden */
  89939. _isSubEmitter: boolean;
  89940. /**
  89941. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89942. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89943. */
  89944. billboardMode: number;
  89945. protected _isBillboardBased: boolean;
  89946. /**
  89947. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89948. */
  89949. get isBillboardBased(): boolean;
  89950. set isBillboardBased(value: boolean);
  89951. /**
  89952. * The scene the particle system belongs to.
  89953. */
  89954. protected _scene: Scene;
  89955. /**
  89956. * Local cache of defines for image processing.
  89957. */
  89958. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89959. /**
  89960. * Default configuration related to image processing available in the standard Material.
  89961. */
  89962. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89963. /**
  89964. * Gets the image processing configuration used either in this material.
  89965. */
  89966. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89967. /**
  89968. * Sets the Default image processing configuration used either in the this material.
  89969. *
  89970. * If sets to null, the scene one is in use.
  89971. */
  89972. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89973. /**
  89974. * Attaches a new image processing configuration to the Standard Material.
  89975. * @param configuration
  89976. */
  89977. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89978. /** @hidden */
  89979. protected _reset(): void;
  89980. /** @hidden */
  89981. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89982. /**
  89983. * Instantiates a particle system.
  89984. * 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.
  89985. * @param name The name of the particle system
  89986. */
  89987. constructor(name: string);
  89988. /**
  89989. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89990. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89991. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89992. * @returns the emitter
  89993. */
  89994. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89995. /**
  89996. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89997. * @param radius The radius of the hemisphere to emit from
  89998. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89999. * @returns the emitter
  90000. */
  90001. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90002. /**
  90003. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90004. * @param radius The radius of the sphere to emit from
  90005. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90006. * @returns the emitter
  90007. */
  90008. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90009. /**
  90010. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90011. * @param radius The radius of the sphere to emit from
  90012. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90013. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90014. * @returns the emitter
  90015. */
  90016. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90017. /**
  90018. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90019. * @param radius The radius of the emission cylinder
  90020. * @param height The height of the emission cylinder
  90021. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90022. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90023. * @returns the emitter
  90024. */
  90025. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90026. /**
  90027. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90028. * @param radius The radius of the cylinder to emit from
  90029. * @param height The height of the emission cylinder
  90030. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90031. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90032. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90033. * @returns the emitter
  90034. */
  90035. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90036. /**
  90037. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90038. * @param radius The radius of the cone to emit from
  90039. * @param angle The base angle of the cone
  90040. * @returns the emitter
  90041. */
  90042. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90043. /**
  90044. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90045. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90046. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90047. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90048. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90049. * @returns the emitter
  90050. */
  90051. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90052. }
  90053. }
  90054. declare module BABYLON {
  90055. /**
  90056. * Type of sub emitter
  90057. */
  90058. export enum SubEmitterType {
  90059. /**
  90060. * Attached to the particle over it's lifetime
  90061. */
  90062. ATTACHED = 0,
  90063. /**
  90064. * Created when the particle dies
  90065. */
  90066. END = 1
  90067. }
  90068. /**
  90069. * Sub emitter class used to emit particles from an existing particle
  90070. */
  90071. export class SubEmitter {
  90072. /**
  90073. * the particle system to be used by the sub emitter
  90074. */
  90075. particleSystem: ParticleSystem;
  90076. /**
  90077. * Type of the submitter (Default: END)
  90078. */
  90079. type: SubEmitterType;
  90080. /**
  90081. * 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)
  90082. * Note: This only is supported when using an emitter of type Mesh
  90083. */
  90084. inheritDirection: boolean;
  90085. /**
  90086. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90087. */
  90088. inheritedVelocityAmount: number;
  90089. /**
  90090. * Creates a sub emitter
  90091. * @param particleSystem the particle system to be used by the sub emitter
  90092. */
  90093. constructor(
  90094. /**
  90095. * the particle system to be used by the sub emitter
  90096. */
  90097. particleSystem: ParticleSystem);
  90098. /**
  90099. * Clones the sub emitter
  90100. * @returns the cloned sub emitter
  90101. */
  90102. clone(): SubEmitter;
  90103. /**
  90104. * Serialize current object to a JSON object
  90105. * @returns the serialized object
  90106. */
  90107. serialize(): any;
  90108. /** @hidden */
  90109. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90110. /**
  90111. * Creates a new SubEmitter from a serialized JSON version
  90112. * @param serializationObject defines the JSON object to read from
  90113. * @param scene defines the hosting scene
  90114. * @param rootUrl defines the rootUrl for data loading
  90115. * @returns a new SubEmitter
  90116. */
  90117. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90118. /** Release associated resources */
  90119. dispose(): void;
  90120. }
  90121. }
  90122. declare module BABYLON {
  90123. /** @hidden */
  90124. export var imageProcessingDeclaration: {
  90125. name: string;
  90126. shader: string;
  90127. };
  90128. }
  90129. declare module BABYLON {
  90130. /** @hidden */
  90131. export var imageProcessingFunctions: {
  90132. name: string;
  90133. shader: string;
  90134. };
  90135. }
  90136. declare module BABYLON {
  90137. /** @hidden */
  90138. export var particlesPixelShader: {
  90139. name: string;
  90140. shader: string;
  90141. };
  90142. }
  90143. declare module BABYLON {
  90144. /** @hidden */
  90145. export var particlesVertexShader: {
  90146. name: string;
  90147. shader: string;
  90148. };
  90149. }
  90150. declare module BABYLON {
  90151. /**
  90152. * This represents a particle system in Babylon.
  90153. * 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.
  90154. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90155. * @example https://doc.babylonjs.com/babylon101/particles
  90156. */
  90157. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90158. /**
  90159. * Billboard mode will only apply to Y axis
  90160. */
  90161. static readonly BILLBOARDMODE_Y: number;
  90162. /**
  90163. * Billboard mode will apply to all axes
  90164. */
  90165. static readonly BILLBOARDMODE_ALL: number;
  90166. /**
  90167. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90168. */
  90169. static readonly BILLBOARDMODE_STRETCHED: number;
  90170. /**
  90171. * This function can be defined to provide custom update for active particles.
  90172. * This function will be called instead of regular update (age, position, color, etc.).
  90173. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90174. */
  90175. updateFunction: (particles: Particle[]) => void;
  90176. private _emitterWorldMatrix;
  90177. /**
  90178. * This function can be defined to specify initial direction for every new particle.
  90179. * It by default use the emitterType defined function
  90180. */
  90181. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90182. /**
  90183. * This function can be defined to specify initial position for every new particle.
  90184. * It by default use the emitterType defined function
  90185. */
  90186. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90187. /**
  90188. * @hidden
  90189. */
  90190. _inheritedVelocityOffset: Vector3;
  90191. /**
  90192. * An event triggered when the system is disposed
  90193. */
  90194. onDisposeObservable: Observable<IParticleSystem>;
  90195. private _onDisposeObserver;
  90196. /**
  90197. * Sets a callback that will be triggered when the system is disposed
  90198. */
  90199. set onDispose(callback: () => void);
  90200. private _particles;
  90201. private _epsilon;
  90202. private _capacity;
  90203. private _stockParticles;
  90204. private _newPartsExcess;
  90205. private _vertexData;
  90206. private _vertexBuffer;
  90207. private _vertexBuffers;
  90208. private _spriteBuffer;
  90209. private _indexBuffer;
  90210. private _effect;
  90211. private _customEffect;
  90212. private _cachedDefines;
  90213. private _scaledColorStep;
  90214. private _colorDiff;
  90215. private _scaledDirection;
  90216. private _scaledGravity;
  90217. private _currentRenderId;
  90218. private _alive;
  90219. private _useInstancing;
  90220. private _started;
  90221. private _stopped;
  90222. private _actualFrame;
  90223. private _scaledUpdateSpeed;
  90224. private _vertexBufferSize;
  90225. /** @hidden */
  90226. _currentEmitRateGradient: Nullable<FactorGradient>;
  90227. /** @hidden */
  90228. _currentEmitRate1: number;
  90229. /** @hidden */
  90230. _currentEmitRate2: number;
  90231. /** @hidden */
  90232. _currentStartSizeGradient: Nullable<FactorGradient>;
  90233. /** @hidden */
  90234. _currentStartSize1: number;
  90235. /** @hidden */
  90236. _currentStartSize2: number;
  90237. private readonly _rawTextureWidth;
  90238. private _rampGradientsTexture;
  90239. private _useRampGradients;
  90240. /** Gets or sets a boolean indicating that ramp gradients must be used
  90241. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90242. */
  90243. get useRampGradients(): boolean;
  90244. set useRampGradients(value: boolean);
  90245. /**
  90246. * 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.
  90247. * 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: [])
  90248. */
  90249. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90250. private _subEmitters;
  90251. /**
  90252. * @hidden
  90253. * If the particle systems emitter should be disposed when the particle system is disposed
  90254. */
  90255. _disposeEmitterOnDispose: boolean;
  90256. /**
  90257. * The current active Sub-systems, this property is used by the root particle system only.
  90258. */
  90259. activeSubSystems: Array<ParticleSystem>;
  90260. /**
  90261. * Specifies if the particles are updated in emitter local space or world space
  90262. */
  90263. isLocal: boolean;
  90264. private _rootParticleSystem;
  90265. /**
  90266. * Gets the current list of active particles
  90267. */
  90268. get particles(): Particle[];
  90269. /**
  90270. * Gets the number of particles active at the same time.
  90271. * @returns The number of active particles.
  90272. */
  90273. getActiveCount(): number;
  90274. /**
  90275. * Returns the string "ParticleSystem"
  90276. * @returns a string containing the class name
  90277. */
  90278. getClassName(): string;
  90279. /**
  90280. * Gets a boolean indicating that the system is stopping
  90281. * @returns true if the system is currently stopping
  90282. */
  90283. isStopping(): boolean;
  90284. /**
  90285. * Gets the custom effect used to render the particles
  90286. * @param blendMode Blend mode for which the effect should be retrieved
  90287. * @returns The effect
  90288. */
  90289. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90290. /**
  90291. * Sets the custom effect used to render the particles
  90292. * @param effect The effect to set
  90293. * @param blendMode Blend mode for which the effect should be set
  90294. */
  90295. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90296. /** @hidden */
  90297. private _onBeforeDrawParticlesObservable;
  90298. /**
  90299. * Observable that will be called just before the particles are drawn
  90300. */
  90301. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90302. /**
  90303. * Gets the name of the particle vertex shader
  90304. */
  90305. get vertexShaderName(): string;
  90306. /**
  90307. * Instantiates a particle system.
  90308. * 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.
  90309. * @param name The name of the particle system
  90310. * @param capacity The max number of particles alive at the same time
  90311. * @param scene The scene the particle system belongs to
  90312. * @param customEffect a custom effect used to change the way particles are rendered by default
  90313. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90314. * @param epsilon Offset used to render the particles
  90315. */
  90316. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90317. private _addFactorGradient;
  90318. private _removeFactorGradient;
  90319. /**
  90320. * Adds a new life time gradient
  90321. * @param gradient defines the gradient to use (between 0 and 1)
  90322. * @param factor defines the life time factor to affect to the specified gradient
  90323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90324. * @returns the current particle system
  90325. */
  90326. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90327. /**
  90328. * Remove a specific life time gradient
  90329. * @param gradient defines the gradient to remove
  90330. * @returns the current particle system
  90331. */
  90332. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90333. /**
  90334. * Adds a new size gradient
  90335. * @param gradient defines the gradient to use (between 0 and 1)
  90336. * @param factor defines the size factor to affect to the specified gradient
  90337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90338. * @returns the current particle system
  90339. */
  90340. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90341. /**
  90342. * Remove a specific size gradient
  90343. * @param gradient defines the gradient to remove
  90344. * @returns the current particle system
  90345. */
  90346. removeSizeGradient(gradient: number): IParticleSystem;
  90347. /**
  90348. * Adds a new color remap gradient
  90349. * @param gradient defines the gradient to use (between 0 and 1)
  90350. * @param min defines the color remap minimal range
  90351. * @param max defines the color remap maximal range
  90352. * @returns the current particle system
  90353. */
  90354. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90355. /**
  90356. * Remove a specific color remap gradient
  90357. * @param gradient defines the gradient to remove
  90358. * @returns the current particle system
  90359. */
  90360. removeColorRemapGradient(gradient: number): IParticleSystem;
  90361. /**
  90362. * Adds a new alpha remap gradient
  90363. * @param gradient defines the gradient to use (between 0 and 1)
  90364. * @param min defines the alpha remap minimal range
  90365. * @param max defines the alpha remap maximal range
  90366. * @returns the current particle system
  90367. */
  90368. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90369. /**
  90370. * Remove a specific alpha remap gradient
  90371. * @param gradient defines the gradient to remove
  90372. * @returns the current particle system
  90373. */
  90374. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90375. /**
  90376. * Adds a new angular speed gradient
  90377. * @param gradient defines the gradient to use (between 0 and 1)
  90378. * @param factor defines the angular speed to affect to the specified gradient
  90379. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90380. * @returns the current particle system
  90381. */
  90382. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90383. /**
  90384. * Remove a specific angular speed gradient
  90385. * @param gradient defines the gradient to remove
  90386. * @returns the current particle system
  90387. */
  90388. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90389. /**
  90390. * Adds a new velocity gradient
  90391. * @param gradient defines the gradient to use (between 0 and 1)
  90392. * @param factor defines the velocity to affect to the specified gradient
  90393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90394. * @returns the current particle system
  90395. */
  90396. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90397. /**
  90398. * Remove a specific velocity gradient
  90399. * @param gradient defines the gradient to remove
  90400. * @returns the current particle system
  90401. */
  90402. removeVelocityGradient(gradient: number): IParticleSystem;
  90403. /**
  90404. * Adds a new limit velocity gradient
  90405. * @param gradient defines the gradient to use (between 0 and 1)
  90406. * @param factor defines the limit velocity value to affect to the specified gradient
  90407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90408. * @returns the current particle system
  90409. */
  90410. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90411. /**
  90412. * Remove a specific limit velocity gradient
  90413. * @param gradient defines the gradient to remove
  90414. * @returns the current particle system
  90415. */
  90416. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90417. /**
  90418. * Adds a new drag gradient
  90419. * @param gradient defines the gradient to use (between 0 and 1)
  90420. * @param factor defines the drag value to affect to the specified gradient
  90421. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90422. * @returns the current particle system
  90423. */
  90424. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90425. /**
  90426. * Remove a specific drag gradient
  90427. * @param gradient defines the gradient to remove
  90428. * @returns the current particle system
  90429. */
  90430. removeDragGradient(gradient: number): IParticleSystem;
  90431. /**
  90432. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90433. * @param gradient defines the gradient to use (between 0 and 1)
  90434. * @param factor defines the emit rate value to affect to the specified gradient
  90435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90436. * @returns the current particle system
  90437. */
  90438. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90439. /**
  90440. * Remove a specific emit rate gradient
  90441. * @param gradient defines the gradient to remove
  90442. * @returns the current particle system
  90443. */
  90444. removeEmitRateGradient(gradient: number): IParticleSystem;
  90445. /**
  90446. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90447. * @param gradient defines the gradient to use (between 0 and 1)
  90448. * @param factor defines the start size value to affect to the specified gradient
  90449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90450. * @returns the current particle system
  90451. */
  90452. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90453. /**
  90454. * Remove a specific start size gradient
  90455. * @param gradient defines the gradient to remove
  90456. * @returns the current particle system
  90457. */
  90458. removeStartSizeGradient(gradient: number): IParticleSystem;
  90459. private _createRampGradientTexture;
  90460. /**
  90461. * Gets the current list of ramp gradients.
  90462. * You must use addRampGradient and removeRampGradient to udpate this list
  90463. * @returns the list of ramp gradients
  90464. */
  90465. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90466. /** Force the system to rebuild all gradients that need to be resync */
  90467. forceRefreshGradients(): void;
  90468. private _syncRampGradientTexture;
  90469. /**
  90470. * Adds a new ramp gradient used to remap particle colors
  90471. * @param gradient defines the gradient to use (between 0 and 1)
  90472. * @param color defines the color to affect to the specified gradient
  90473. * @returns the current particle system
  90474. */
  90475. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90476. /**
  90477. * Remove a specific ramp gradient
  90478. * @param gradient defines the gradient to remove
  90479. * @returns the current particle system
  90480. */
  90481. removeRampGradient(gradient: number): ParticleSystem;
  90482. /**
  90483. * Adds a new color gradient
  90484. * @param gradient defines the gradient to use (between 0 and 1)
  90485. * @param color1 defines the color to affect to the specified gradient
  90486. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90487. * @returns this particle system
  90488. */
  90489. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90490. /**
  90491. * Remove a specific color gradient
  90492. * @param gradient defines the gradient to remove
  90493. * @returns this particle system
  90494. */
  90495. removeColorGradient(gradient: number): IParticleSystem;
  90496. private _fetchR;
  90497. protected _reset(): void;
  90498. private _resetEffect;
  90499. private _createVertexBuffers;
  90500. private _createIndexBuffer;
  90501. /**
  90502. * Gets the maximum number of particles active at the same time.
  90503. * @returns The max number of active particles.
  90504. */
  90505. getCapacity(): number;
  90506. /**
  90507. * Gets whether there are still active particles in the system.
  90508. * @returns True if it is alive, otherwise false.
  90509. */
  90510. isAlive(): boolean;
  90511. /**
  90512. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90513. * @returns True if it has been started, otherwise false.
  90514. */
  90515. isStarted(): boolean;
  90516. private _prepareSubEmitterInternalArray;
  90517. /**
  90518. * Starts the particle system and begins to emit
  90519. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90520. */
  90521. start(delay?: number): void;
  90522. /**
  90523. * Stops the particle system.
  90524. * @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.
  90525. */
  90526. stop(stopSubEmitters?: boolean): void;
  90527. /**
  90528. * Remove all active particles
  90529. */
  90530. reset(): void;
  90531. /**
  90532. * @hidden (for internal use only)
  90533. */
  90534. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90535. /**
  90536. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90537. * Its lifetime will start back at 0.
  90538. */
  90539. recycleParticle: (particle: Particle) => void;
  90540. private _stopSubEmitters;
  90541. private _createParticle;
  90542. private _removeFromRoot;
  90543. private _emitFromParticle;
  90544. private _update;
  90545. /** @hidden */
  90546. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90547. /** @hidden */
  90548. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90549. /**
  90550. * Fill the defines array according to the current settings of the particle system
  90551. * @param defines Array to be updated
  90552. * @param blendMode blend mode to take into account when updating the array
  90553. */
  90554. fillDefines(defines: Array<string>, blendMode: number): void;
  90555. /**
  90556. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90557. * @param uniforms Uniforms array to fill
  90558. * @param attributes Attributes array to fill
  90559. * @param samplers Samplers array to fill
  90560. */
  90561. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90562. /** @hidden */
  90563. private _getEffect;
  90564. /**
  90565. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90566. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90567. */
  90568. animate(preWarmOnly?: boolean): void;
  90569. private _appendParticleVertices;
  90570. /**
  90571. * Rebuilds the particle system.
  90572. */
  90573. rebuild(): void;
  90574. /**
  90575. * Is this system ready to be used/rendered
  90576. * @return true if the system is ready
  90577. */
  90578. isReady(): boolean;
  90579. private _render;
  90580. /**
  90581. * Renders the particle system in its current state.
  90582. * @returns the current number of particles
  90583. */
  90584. render(): number;
  90585. /**
  90586. * Disposes the particle system and free the associated resources
  90587. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90588. */
  90589. dispose(disposeTexture?: boolean): void;
  90590. /**
  90591. * Clones the particle system.
  90592. * @param name The name of the cloned object
  90593. * @param newEmitter The new emitter to use
  90594. * @returns the cloned particle system
  90595. */
  90596. clone(name: string, newEmitter: any): ParticleSystem;
  90597. /**
  90598. * Serializes the particle system to a JSON object
  90599. * @param serializeTexture defines if the texture must be serialized as well
  90600. * @returns the JSON object
  90601. */
  90602. serialize(serializeTexture?: boolean): any;
  90603. /** @hidden */
  90604. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  90605. /** @hidden */
  90606. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90607. /**
  90608. * Parses a JSON object to create a particle system.
  90609. * @param parsedParticleSystem The JSON object to parse
  90610. * @param scene The scene to create the particle system in
  90611. * @param rootUrl The root url to use to load external dependencies like texture
  90612. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90613. * @returns the Parsed particle system
  90614. */
  90615. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90616. }
  90617. }
  90618. declare module BABYLON {
  90619. /**
  90620. * A particle represents one of the element emitted by a particle system.
  90621. * This is mainly define by its coordinates, direction, velocity and age.
  90622. */
  90623. export class Particle {
  90624. /**
  90625. * The particle system the particle belongs to.
  90626. */
  90627. particleSystem: ParticleSystem;
  90628. private static _Count;
  90629. /**
  90630. * Unique ID of the particle
  90631. */
  90632. id: number;
  90633. /**
  90634. * The world position of the particle in the scene.
  90635. */
  90636. position: Vector3;
  90637. /**
  90638. * The world direction of the particle in the scene.
  90639. */
  90640. direction: Vector3;
  90641. /**
  90642. * The color of the particle.
  90643. */
  90644. color: Color4;
  90645. /**
  90646. * The color change of the particle per step.
  90647. */
  90648. colorStep: Color4;
  90649. /**
  90650. * Defines how long will the life of the particle be.
  90651. */
  90652. lifeTime: number;
  90653. /**
  90654. * The current age of the particle.
  90655. */
  90656. age: number;
  90657. /**
  90658. * The current size of the particle.
  90659. */
  90660. size: number;
  90661. /**
  90662. * The current scale of the particle.
  90663. */
  90664. scale: Vector2;
  90665. /**
  90666. * The current angle of the particle.
  90667. */
  90668. angle: number;
  90669. /**
  90670. * Defines how fast is the angle changing.
  90671. */
  90672. angularSpeed: number;
  90673. /**
  90674. * Defines the cell index used by the particle to be rendered from a sprite.
  90675. */
  90676. cellIndex: number;
  90677. /**
  90678. * The information required to support color remapping
  90679. */
  90680. remapData: Vector4;
  90681. /** @hidden */
  90682. _randomCellOffset?: number;
  90683. /** @hidden */
  90684. _initialDirection: Nullable<Vector3>;
  90685. /** @hidden */
  90686. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90687. /** @hidden */
  90688. _initialStartSpriteCellID: number;
  90689. /** @hidden */
  90690. _initialEndSpriteCellID: number;
  90691. /** @hidden */
  90692. _currentColorGradient: Nullable<ColorGradient>;
  90693. /** @hidden */
  90694. _currentColor1: Color4;
  90695. /** @hidden */
  90696. _currentColor2: Color4;
  90697. /** @hidden */
  90698. _currentSizeGradient: Nullable<FactorGradient>;
  90699. /** @hidden */
  90700. _currentSize1: number;
  90701. /** @hidden */
  90702. _currentSize2: number;
  90703. /** @hidden */
  90704. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90705. /** @hidden */
  90706. _currentAngularSpeed1: number;
  90707. /** @hidden */
  90708. _currentAngularSpeed2: number;
  90709. /** @hidden */
  90710. _currentVelocityGradient: Nullable<FactorGradient>;
  90711. /** @hidden */
  90712. _currentVelocity1: number;
  90713. /** @hidden */
  90714. _currentVelocity2: number;
  90715. /** @hidden */
  90716. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90717. /** @hidden */
  90718. _currentLimitVelocity1: number;
  90719. /** @hidden */
  90720. _currentLimitVelocity2: number;
  90721. /** @hidden */
  90722. _currentDragGradient: Nullable<FactorGradient>;
  90723. /** @hidden */
  90724. _currentDrag1: number;
  90725. /** @hidden */
  90726. _currentDrag2: number;
  90727. /** @hidden */
  90728. _randomNoiseCoordinates1: Vector3;
  90729. /** @hidden */
  90730. _randomNoiseCoordinates2: Vector3;
  90731. /** @hidden */
  90732. _localPosition?: Vector3;
  90733. /**
  90734. * Creates a new instance Particle
  90735. * @param particleSystem the particle system the particle belongs to
  90736. */
  90737. constructor(
  90738. /**
  90739. * The particle system the particle belongs to.
  90740. */
  90741. particleSystem: ParticleSystem);
  90742. private updateCellInfoFromSystem;
  90743. /**
  90744. * Defines how the sprite cell index is updated for the particle
  90745. */
  90746. updateCellIndex(): void;
  90747. /** @hidden */
  90748. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90749. /** @hidden */
  90750. _inheritParticleInfoToSubEmitters(): void;
  90751. /** @hidden */
  90752. _reset(): void;
  90753. /**
  90754. * Copy the properties of particle to another one.
  90755. * @param other the particle to copy the information to.
  90756. */
  90757. copyTo(other: Particle): void;
  90758. }
  90759. }
  90760. declare module BABYLON {
  90761. /**
  90762. * Particle emitter represents a volume emitting particles.
  90763. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90764. */
  90765. export interface IParticleEmitterType {
  90766. /**
  90767. * Called by the particle System when the direction is computed for the created particle.
  90768. * @param worldMatrix is the world matrix of the particle system
  90769. * @param directionToUpdate is the direction vector to update with the result
  90770. * @param particle is the particle we are computed the direction for
  90771. * @param isLocal defines if the direction should be set in local space
  90772. */
  90773. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90774. /**
  90775. * Called by the particle System when the position is computed for the created particle.
  90776. * @param worldMatrix is the world matrix of the particle system
  90777. * @param positionToUpdate is the position vector to update with the result
  90778. * @param particle is the particle we are computed the position for
  90779. * @param isLocal defines if the position should be set in local space
  90780. */
  90781. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90782. /**
  90783. * Clones the current emitter and returns a copy of it
  90784. * @returns the new emitter
  90785. */
  90786. clone(): IParticleEmitterType;
  90787. /**
  90788. * Called by the GPUParticleSystem to setup the update shader
  90789. * @param effect defines the update shader
  90790. */
  90791. applyToShader(effect: Effect): void;
  90792. /**
  90793. * Returns a string to use to update the GPU particles update shader
  90794. * @returns the effect defines string
  90795. */
  90796. getEffectDefines(): string;
  90797. /**
  90798. * Returns a string representing the class name
  90799. * @returns a string containing the class name
  90800. */
  90801. getClassName(): string;
  90802. /**
  90803. * Serializes the particle system to a JSON object.
  90804. * @returns the JSON object
  90805. */
  90806. serialize(): any;
  90807. /**
  90808. * Parse properties from a JSON object
  90809. * @param serializationObject defines the JSON object
  90810. * @param scene defines the hosting scene
  90811. */
  90812. parse(serializationObject: any, scene: Scene): void;
  90813. }
  90814. }
  90815. declare module BABYLON {
  90816. /**
  90817. * Particle emitter emitting particles from the inside of a box.
  90818. * It emits the particles randomly between 2 given directions.
  90819. */
  90820. export class BoxParticleEmitter implements IParticleEmitterType {
  90821. /**
  90822. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90823. */
  90824. direction1: Vector3;
  90825. /**
  90826. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90827. */
  90828. direction2: Vector3;
  90829. /**
  90830. * 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.
  90831. */
  90832. minEmitBox: Vector3;
  90833. /**
  90834. * 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.
  90835. */
  90836. maxEmitBox: Vector3;
  90837. /**
  90838. * Creates a new instance BoxParticleEmitter
  90839. */
  90840. constructor();
  90841. /**
  90842. * Called by the particle System when the direction is computed for the created particle.
  90843. * @param worldMatrix is the world matrix of the particle system
  90844. * @param directionToUpdate is the direction vector to update with the result
  90845. * @param particle is the particle we are computed the direction for
  90846. * @param isLocal defines if the direction should be set in local space
  90847. */
  90848. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90849. /**
  90850. * Called by the particle System when the position is computed for the created particle.
  90851. * @param worldMatrix is the world matrix of the particle system
  90852. * @param positionToUpdate is the position vector to update with the result
  90853. * @param particle is the particle we are computed the position for
  90854. * @param isLocal defines if the position should be set in local space
  90855. */
  90856. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90857. /**
  90858. * Clones the current emitter and returns a copy of it
  90859. * @returns the new emitter
  90860. */
  90861. clone(): BoxParticleEmitter;
  90862. /**
  90863. * Called by the GPUParticleSystem to setup the update shader
  90864. * @param effect defines the update shader
  90865. */
  90866. applyToShader(effect: Effect): void;
  90867. /**
  90868. * Returns a string to use to update the GPU particles update shader
  90869. * @returns a string containng the defines string
  90870. */
  90871. getEffectDefines(): string;
  90872. /**
  90873. * Returns the string "BoxParticleEmitter"
  90874. * @returns a string containing the class name
  90875. */
  90876. getClassName(): string;
  90877. /**
  90878. * Serializes the particle system to a JSON object.
  90879. * @returns the JSON object
  90880. */
  90881. serialize(): any;
  90882. /**
  90883. * Parse properties from a JSON object
  90884. * @param serializationObject defines the JSON object
  90885. */
  90886. parse(serializationObject: any): void;
  90887. }
  90888. }
  90889. declare module BABYLON {
  90890. /**
  90891. * Particle emitter emitting particles from the inside of a cone.
  90892. * It emits the particles alongside the cone volume from the base to the particle.
  90893. * The emission direction might be randomized.
  90894. */
  90895. export class ConeParticleEmitter implements IParticleEmitterType {
  90896. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90897. directionRandomizer: number;
  90898. private _radius;
  90899. private _angle;
  90900. private _height;
  90901. /**
  90902. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90903. */
  90904. radiusRange: number;
  90905. /**
  90906. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90907. */
  90908. heightRange: number;
  90909. /**
  90910. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90911. */
  90912. emitFromSpawnPointOnly: boolean;
  90913. /**
  90914. * Gets or sets the radius of the emission cone
  90915. */
  90916. get radius(): number;
  90917. set radius(value: number);
  90918. /**
  90919. * Gets or sets the angle of the emission cone
  90920. */
  90921. get angle(): number;
  90922. set angle(value: number);
  90923. private _buildHeight;
  90924. /**
  90925. * Creates a new instance ConeParticleEmitter
  90926. * @param radius the radius of the emission cone (1 by default)
  90927. * @param angle the cone base angle (PI by default)
  90928. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90929. */
  90930. constructor(radius?: number, angle?: number,
  90931. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90932. directionRandomizer?: number);
  90933. /**
  90934. * Called by the particle System when the direction is computed for the created particle.
  90935. * @param worldMatrix is the world matrix of the particle system
  90936. * @param directionToUpdate is the direction vector to update with the result
  90937. * @param particle is the particle we are computed the direction for
  90938. * @param isLocal defines if the direction should be set in local space
  90939. */
  90940. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90941. /**
  90942. * Called by the particle System when the position is computed for the created particle.
  90943. * @param worldMatrix is the world matrix of the particle system
  90944. * @param positionToUpdate is the position vector to update with the result
  90945. * @param particle is the particle we are computed the position for
  90946. * @param isLocal defines if the position should be set in local space
  90947. */
  90948. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90949. /**
  90950. * Clones the current emitter and returns a copy of it
  90951. * @returns the new emitter
  90952. */
  90953. clone(): ConeParticleEmitter;
  90954. /**
  90955. * Called by the GPUParticleSystem to setup the update shader
  90956. * @param effect defines the update shader
  90957. */
  90958. applyToShader(effect: Effect): void;
  90959. /**
  90960. * Returns a string to use to update the GPU particles update shader
  90961. * @returns a string containng the defines string
  90962. */
  90963. getEffectDefines(): string;
  90964. /**
  90965. * Returns the string "ConeParticleEmitter"
  90966. * @returns a string containing the class name
  90967. */
  90968. getClassName(): string;
  90969. /**
  90970. * Serializes the particle system to a JSON object.
  90971. * @returns the JSON object
  90972. */
  90973. serialize(): any;
  90974. /**
  90975. * Parse properties from a JSON object
  90976. * @param serializationObject defines the JSON object
  90977. */
  90978. parse(serializationObject: any): void;
  90979. }
  90980. }
  90981. declare module BABYLON {
  90982. /**
  90983. * Particle emitter emitting particles from the inside of a cylinder.
  90984. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90985. */
  90986. export class CylinderParticleEmitter implements IParticleEmitterType {
  90987. /**
  90988. * The radius of the emission cylinder.
  90989. */
  90990. radius: number;
  90991. /**
  90992. * The height of the emission cylinder.
  90993. */
  90994. height: number;
  90995. /**
  90996. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90997. */
  90998. radiusRange: number;
  90999. /**
  91000. * How much to randomize the particle direction [0-1].
  91001. */
  91002. directionRandomizer: number;
  91003. /**
  91004. * Creates a new instance CylinderParticleEmitter
  91005. * @param radius the radius of the emission cylinder (1 by default)
  91006. * @param height the height of the emission cylinder (1 by default)
  91007. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91008. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91009. */
  91010. constructor(
  91011. /**
  91012. * The radius of the emission cylinder.
  91013. */
  91014. radius?: number,
  91015. /**
  91016. * The height of the emission cylinder.
  91017. */
  91018. height?: number,
  91019. /**
  91020. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91021. */
  91022. radiusRange?: number,
  91023. /**
  91024. * How much to randomize the particle direction [0-1].
  91025. */
  91026. directionRandomizer?: number);
  91027. /**
  91028. * Called by the particle System when the direction is computed for the created particle.
  91029. * @param worldMatrix is the world matrix of the particle system
  91030. * @param directionToUpdate is the direction vector to update with the result
  91031. * @param particle is the particle we are computed the direction for
  91032. * @param isLocal defines if the direction should be set in local space
  91033. */
  91034. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91035. /**
  91036. * Called by the particle System when the position is computed for the created particle.
  91037. * @param worldMatrix is the world matrix of the particle system
  91038. * @param positionToUpdate is the position vector to update with the result
  91039. * @param particle is the particle we are computed the position for
  91040. * @param isLocal defines if the position should be set in local space
  91041. */
  91042. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91043. /**
  91044. * Clones the current emitter and returns a copy of it
  91045. * @returns the new emitter
  91046. */
  91047. clone(): CylinderParticleEmitter;
  91048. /**
  91049. * Called by the GPUParticleSystem to setup the update shader
  91050. * @param effect defines the update shader
  91051. */
  91052. applyToShader(effect: Effect): void;
  91053. /**
  91054. * Returns a string to use to update the GPU particles update shader
  91055. * @returns a string containng the defines string
  91056. */
  91057. getEffectDefines(): string;
  91058. /**
  91059. * Returns the string "CylinderParticleEmitter"
  91060. * @returns a string containing the class name
  91061. */
  91062. getClassName(): string;
  91063. /**
  91064. * Serializes the particle system to a JSON object.
  91065. * @returns the JSON object
  91066. */
  91067. serialize(): any;
  91068. /**
  91069. * Parse properties from a JSON object
  91070. * @param serializationObject defines the JSON object
  91071. */
  91072. parse(serializationObject: any): void;
  91073. }
  91074. /**
  91075. * Particle emitter emitting particles from the inside of a cylinder.
  91076. * It emits the particles randomly between two vectors.
  91077. */
  91078. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91079. /**
  91080. * The min limit of the emission direction.
  91081. */
  91082. direction1: Vector3;
  91083. /**
  91084. * The max limit of the emission direction.
  91085. */
  91086. direction2: Vector3;
  91087. /**
  91088. * Creates a new instance CylinderDirectedParticleEmitter
  91089. * @param radius the radius of the emission cylinder (1 by default)
  91090. * @param height the height of the emission cylinder (1 by default)
  91091. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91092. * @param direction1 the min limit of the emission direction (up vector by default)
  91093. * @param direction2 the max limit of the emission direction (up vector by default)
  91094. */
  91095. constructor(radius?: number, height?: number, radiusRange?: number,
  91096. /**
  91097. * The min limit of the emission direction.
  91098. */
  91099. direction1?: Vector3,
  91100. /**
  91101. * The max limit of the emission direction.
  91102. */
  91103. direction2?: Vector3);
  91104. /**
  91105. * Called by the particle System when the direction is computed for the created particle.
  91106. * @param worldMatrix is the world matrix of the particle system
  91107. * @param directionToUpdate is the direction vector to update with the result
  91108. * @param particle is the particle we are computed the direction for
  91109. */
  91110. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91111. /**
  91112. * Clones the current emitter and returns a copy of it
  91113. * @returns the new emitter
  91114. */
  91115. clone(): CylinderDirectedParticleEmitter;
  91116. /**
  91117. * Called by the GPUParticleSystem to setup the update shader
  91118. * @param effect defines the update shader
  91119. */
  91120. applyToShader(effect: Effect): void;
  91121. /**
  91122. * Returns a string to use to update the GPU particles update shader
  91123. * @returns a string containng the defines string
  91124. */
  91125. getEffectDefines(): string;
  91126. /**
  91127. * Returns the string "CylinderDirectedParticleEmitter"
  91128. * @returns a string containing the class name
  91129. */
  91130. getClassName(): string;
  91131. /**
  91132. * Serializes the particle system to a JSON object.
  91133. * @returns the JSON object
  91134. */
  91135. serialize(): any;
  91136. /**
  91137. * Parse properties from a JSON object
  91138. * @param serializationObject defines the JSON object
  91139. */
  91140. parse(serializationObject: any): void;
  91141. }
  91142. }
  91143. declare module BABYLON {
  91144. /**
  91145. * Particle emitter emitting particles from the inside of a hemisphere.
  91146. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91147. */
  91148. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91149. /**
  91150. * The radius of the emission hemisphere.
  91151. */
  91152. radius: number;
  91153. /**
  91154. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91155. */
  91156. radiusRange: number;
  91157. /**
  91158. * How much to randomize the particle direction [0-1].
  91159. */
  91160. directionRandomizer: number;
  91161. /**
  91162. * Creates a new instance HemisphericParticleEmitter
  91163. * @param radius the radius of the emission hemisphere (1 by default)
  91164. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91165. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91166. */
  91167. constructor(
  91168. /**
  91169. * The radius of the emission hemisphere.
  91170. */
  91171. radius?: number,
  91172. /**
  91173. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91174. */
  91175. radiusRange?: number,
  91176. /**
  91177. * How much to randomize the particle direction [0-1].
  91178. */
  91179. directionRandomizer?: number);
  91180. /**
  91181. * Called by the particle System when the direction is computed for the created particle.
  91182. * @param worldMatrix is the world matrix of the particle system
  91183. * @param directionToUpdate is the direction vector to update with the result
  91184. * @param particle is the particle we are computed the direction for
  91185. * @param isLocal defines if the direction should be set in local space
  91186. */
  91187. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91188. /**
  91189. * Called by the particle System when the position is computed for the created particle.
  91190. * @param worldMatrix is the world matrix of the particle system
  91191. * @param positionToUpdate is the position vector to update with the result
  91192. * @param particle is the particle we are computed the position for
  91193. * @param isLocal defines if the position should be set in local space
  91194. */
  91195. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91196. /**
  91197. * Clones the current emitter and returns a copy of it
  91198. * @returns the new emitter
  91199. */
  91200. clone(): HemisphericParticleEmitter;
  91201. /**
  91202. * Called by the GPUParticleSystem to setup the update shader
  91203. * @param effect defines the update shader
  91204. */
  91205. applyToShader(effect: Effect): void;
  91206. /**
  91207. * Returns a string to use to update the GPU particles update shader
  91208. * @returns a string containng the defines string
  91209. */
  91210. getEffectDefines(): string;
  91211. /**
  91212. * Returns the string "HemisphericParticleEmitter"
  91213. * @returns a string containing the class name
  91214. */
  91215. getClassName(): string;
  91216. /**
  91217. * Serializes the particle system to a JSON object.
  91218. * @returns the JSON object
  91219. */
  91220. serialize(): any;
  91221. /**
  91222. * Parse properties from a JSON object
  91223. * @param serializationObject defines the JSON object
  91224. */
  91225. parse(serializationObject: any): void;
  91226. }
  91227. }
  91228. declare module BABYLON {
  91229. /**
  91230. * Particle emitter emitting particles from a point.
  91231. * It emits the particles randomly between 2 given directions.
  91232. */
  91233. export class PointParticleEmitter implements IParticleEmitterType {
  91234. /**
  91235. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91236. */
  91237. direction1: Vector3;
  91238. /**
  91239. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91240. */
  91241. direction2: Vector3;
  91242. /**
  91243. * Creates a new instance PointParticleEmitter
  91244. */
  91245. constructor();
  91246. /**
  91247. * Called by the particle System when the direction is computed for the created particle.
  91248. * @param worldMatrix is the world matrix of the particle system
  91249. * @param directionToUpdate is the direction vector to update with the result
  91250. * @param particle is the particle we are computed the direction for
  91251. * @param isLocal defines if the direction should be set in local space
  91252. */
  91253. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91254. /**
  91255. * Called by the particle System when the position is computed for the created particle.
  91256. * @param worldMatrix is the world matrix of the particle system
  91257. * @param positionToUpdate is the position vector to update with the result
  91258. * @param particle is the particle we are computed the position for
  91259. * @param isLocal defines if the position should be set in local space
  91260. */
  91261. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91262. /**
  91263. * Clones the current emitter and returns a copy of it
  91264. * @returns the new emitter
  91265. */
  91266. clone(): PointParticleEmitter;
  91267. /**
  91268. * Called by the GPUParticleSystem to setup the update shader
  91269. * @param effect defines the update shader
  91270. */
  91271. applyToShader(effect: Effect): void;
  91272. /**
  91273. * Returns a string to use to update the GPU particles update shader
  91274. * @returns a string containng the defines string
  91275. */
  91276. getEffectDefines(): string;
  91277. /**
  91278. * Returns the string "PointParticleEmitter"
  91279. * @returns a string containing the class name
  91280. */
  91281. getClassName(): string;
  91282. /**
  91283. * Serializes the particle system to a JSON object.
  91284. * @returns the JSON object
  91285. */
  91286. serialize(): any;
  91287. /**
  91288. * Parse properties from a JSON object
  91289. * @param serializationObject defines the JSON object
  91290. */
  91291. parse(serializationObject: any): void;
  91292. }
  91293. }
  91294. declare module BABYLON {
  91295. /**
  91296. * Particle emitter emitting particles from the inside of a sphere.
  91297. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91298. */
  91299. export class SphereParticleEmitter implements IParticleEmitterType {
  91300. /**
  91301. * The radius of the emission sphere.
  91302. */
  91303. radius: number;
  91304. /**
  91305. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91306. */
  91307. radiusRange: number;
  91308. /**
  91309. * How much to randomize the particle direction [0-1].
  91310. */
  91311. directionRandomizer: number;
  91312. /**
  91313. * Creates a new instance SphereParticleEmitter
  91314. * @param radius the radius of the emission sphere (1 by default)
  91315. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91316. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91317. */
  91318. constructor(
  91319. /**
  91320. * The radius of the emission sphere.
  91321. */
  91322. radius?: number,
  91323. /**
  91324. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91325. */
  91326. radiusRange?: number,
  91327. /**
  91328. * How much to randomize the particle direction [0-1].
  91329. */
  91330. directionRandomizer?: number);
  91331. /**
  91332. * Called by the particle System when the direction is computed for the created particle.
  91333. * @param worldMatrix is the world matrix of the particle system
  91334. * @param directionToUpdate is the direction vector to update with the result
  91335. * @param particle is the particle we are computed the direction for
  91336. * @param isLocal defines if the direction should be set in local space
  91337. */
  91338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91339. /**
  91340. * Called by the particle System when the position is computed for the created particle.
  91341. * @param worldMatrix is the world matrix of the particle system
  91342. * @param positionToUpdate is the position vector to update with the result
  91343. * @param particle is the particle we are computed the position for
  91344. * @param isLocal defines if the position should be set in local space
  91345. */
  91346. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91347. /**
  91348. * Clones the current emitter and returns a copy of it
  91349. * @returns the new emitter
  91350. */
  91351. clone(): SphereParticleEmitter;
  91352. /**
  91353. * Called by the GPUParticleSystem to setup the update shader
  91354. * @param effect defines the update shader
  91355. */
  91356. applyToShader(effect: Effect): void;
  91357. /**
  91358. * Returns a string to use to update the GPU particles update shader
  91359. * @returns a string containng the defines string
  91360. */
  91361. getEffectDefines(): string;
  91362. /**
  91363. * Returns the string "SphereParticleEmitter"
  91364. * @returns a string containing the class name
  91365. */
  91366. getClassName(): string;
  91367. /**
  91368. * Serializes the particle system to a JSON object.
  91369. * @returns the JSON object
  91370. */
  91371. serialize(): any;
  91372. /**
  91373. * Parse properties from a JSON object
  91374. * @param serializationObject defines the JSON object
  91375. */
  91376. parse(serializationObject: any): void;
  91377. }
  91378. /**
  91379. * Particle emitter emitting particles from the inside of a sphere.
  91380. * It emits the particles randomly between two vectors.
  91381. */
  91382. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91383. /**
  91384. * The min limit of the emission direction.
  91385. */
  91386. direction1: Vector3;
  91387. /**
  91388. * The max limit of the emission direction.
  91389. */
  91390. direction2: Vector3;
  91391. /**
  91392. * Creates a new instance SphereDirectedParticleEmitter
  91393. * @param radius the radius of the emission sphere (1 by default)
  91394. * @param direction1 the min limit of the emission direction (up vector by default)
  91395. * @param direction2 the max limit of the emission direction (up vector by default)
  91396. */
  91397. constructor(radius?: number,
  91398. /**
  91399. * The min limit of the emission direction.
  91400. */
  91401. direction1?: Vector3,
  91402. /**
  91403. * The max limit of the emission direction.
  91404. */
  91405. direction2?: Vector3);
  91406. /**
  91407. * Called by the particle System when the direction is computed for the created particle.
  91408. * @param worldMatrix is the world matrix of the particle system
  91409. * @param directionToUpdate is the direction vector to update with the result
  91410. * @param particle is the particle we are computed the direction for
  91411. */
  91412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91413. /**
  91414. * Clones the current emitter and returns a copy of it
  91415. * @returns the new emitter
  91416. */
  91417. clone(): SphereDirectedParticleEmitter;
  91418. /**
  91419. * Called by the GPUParticleSystem to setup the update shader
  91420. * @param effect defines the update shader
  91421. */
  91422. applyToShader(effect: Effect): void;
  91423. /**
  91424. * Returns a string to use to update the GPU particles update shader
  91425. * @returns a string containng the defines string
  91426. */
  91427. getEffectDefines(): string;
  91428. /**
  91429. * Returns the string "SphereDirectedParticleEmitter"
  91430. * @returns a string containing the class name
  91431. */
  91432. getClassName(): string;
  91433. /**
  91434. * Serializes the particle system to a JSON object.
  91435. * @returns the JSON object
  91436. */
  91437. serialize(): any;
  91438. /**
  91439. * Parse properties from a JSON object
  91440. * @param serializationObject defines the JSON object
  91441. */
  91442. parse(serializationObject: any): void;
  91443. }
  91444. }
  91445. declare module BABYLON {
  91446. /**
  91447. * Particle emitter emitting particles from a custom list of positions.
  91448. */
  91449. export class CustomParticleEmitter implements IParticleEmitterType {
  91450. /**
  91451. * Gets or sets the position generator that will create the inital position of each particle.
  91452. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91453. */
  91454. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91455. /**
  91456. * Gets or sets the destination generator that will create the final destination of each particle.
  91457. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91458. */
  91459. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91460. /**
  91461. * Creates a new instance CustomParticleEmitter
  91462. */
  91463. constructor();
  91464. /**
  91465. * Called by the particle System when the direction is computed for the created particle.
  91466. * @param worldMatrix is the world matrix of the particle system
  91467. * @param directionToUpdate is the direction vector to update with the result
  91468. * @param particle is the particle we are computed the direction for
  91469. * @param isLocal defines if the direction should be set in local space
  91470. */
  91471. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91472. /**
  91473. * Called by the particle System when the position is computed for the created particle.
  91474. * @param worldMatrix is the world matrix of the particle system
  91475. * @param positionToUpdate is the position vector to update with the result
  91476. * @param particle is the particle we are computed the position for
  91477. * @param isLocal defines if the position should be set in local space
  91478. */
  91479. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91480. /**
  91481. * Clones the current emitter and returns a copy of it
  91482. * @returns the new emitter
  91483. */
  91484. clone(): CustomParticleEmitter;
  91485. /**
  91486. * Called by the GPUParticleSystem to setup the update shader
  91487. * @param effect defines the update shader
  91488. */
  91489. applyToShader(effect: Effect): void;
  91490. /**
  91491. * Returns a string to use to update the GPU particles update shader
  91492. * @returns a string containng the defines string
  91493. */
  91494. getEffectDefines(): string;
  91495. /**
  91496. * Returns the string "PointParticleEmitter"
  91497. * @returns a string containing the class name
  91498. */
  91499. getClassName(): string;
  91500. /**
  91501. * Serializes the particle system to a JSON object.
  91502. * @returns the JSON object
  91503. */
  91504. serialize(): any;
  91505. /**
  91506. * Parse properties from a JSON object
  91507. * @param serializationObject defines the JSON object
  91508. */
  91509. parse(serializationObject: any): void;
  91510. }
  91511. }
  91512. declare module BABYLON {
  91513. /**
  91514. * Particle emitter emitting particles from the inside of a box.
  91515. * It emits the particles randomly between 2 given directions.
  91516. */
  91517. export class MeshParticleEmitter implements IParticleEmitterType {
  91518. private _indices;
  91519. private _positions;
  91520. private _normals;
  91521. private _storedNormal;
  91522. private _mesh;
  91523. /**
  91524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91525. */
  91526. direction1: Vector3;
  91527. /**
  91528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91529. */
  91530. direction2: Vector3;
  91531. /**
  91532. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91533. */
  91534. useMeshNormalsForDirection: boolean;
  91535. /** Defines the mesh to use as source */
  91536. get mesh(): Nullable<AbstractMesh>;
  91537. set mesh(value: Nullable<AbstractMesh>);
  91538. /**
  91539. * Creates a new instance MeshParticleEmitter
  91540. * @param mesh defines the mesh to use as source
  91541. */
  91542. constructor(mesh?: Nullable<AbstractMesh>);
  91543. /**
  91544. * Called by the particle System when the direction is computed for the created particle.
  91545. * @param worldMatrix is the world matrix of the particle system
  91546. * @param directionToUpdate is the direction vector to update with the result
  91547. * @param particle is the particle we are computed the direction for
  91548. * @param isLocal defines if the direction should be set in local space
  91549. */
  91550. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91551. /**
  91552. * Called by the particle System when the position is computed for the created particle.
  91553. * @param worldMatrix is the world matrix of the particle system
  91554. * @param positionToUpdate is the position vector to update with the result
  91555. * @param particle is the particle we are computed the position for
  91556. * @param isLocal defines if the position should be set in local space
  91557. */
  91558. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91559. /**
  91560. * Clones the current emitter and returns a copy of it
  91561. * @returns the new emitter
  91562. */
  91563. clone(): MeshParticleEmitter;
  91564. /**
  91565. * Called by the GPUParticleSystem to setup the update shader
  91566. * @param effect defines the update shader
  91567. */
  91568. applyToShader(effect: Effect): void;
  91569. /**
  91570. * Returns a string to use to update the GPU particles update shader
  91571. * @returns a string containng the defines string
  91572. */
  91573. getEffectDefines(): string;
  91574. /**
  91575. * Returns the string "BoxParticleEmitter"
  91576. * @returns a string containing the class name
  91577. */
  91578. getClassName(): string;
  91579. /**
  91580. * Serializes the particle system to a JSON object.
  91581. * @returns the JSON object
  91582. */
  91583. serialize(): any;
  91584. /**
  91585. * Parse properties from a JSON object
  91586. * @param serializationObject defines the JSON object
  91587. * @param scene defines the hosting scene
  91588. */
  91589. parse(serializationObject: any, scene: Scene): void;
  91590. }
  91591. }
  91592. declare module BABYLON {
  91593. /**
  91594. * Interface representing a particle system in Babylon.js.
  91595. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91596. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91597. */
  91598. export interface IParticleSystem {
  91599. /**
  91600. * List of animations used by the particle system.
  91601. */
  91602. animations: Animation[];
  91603. /**
  91604. * The id of the Particle system.
  91605. */
  91606. id: string;
  91607. /**
  91608. * The name of the Particle system.
  91609. */
  91610. name: string;
  91611. /**
  91612. * The emitter represents the Mesh or position we are attaching the particle system to.
  91613. */
  91614. emitter: Nullable<AbstractMesh | Vector3>;
  91615. /**
  91616. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91617. */
  91618. isBillboardBased: boolean;
  91619. /**
  91620. * The rendering group used by the Particle system to chose when to render.
  91621. */
  91622. renderingGroupId: number;
  91623. /**
  91624. * The layer mask we are rendering the particles through.
  91625. */
  91626. layerMask: number;
  91627. /**
  91628. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91629. */
  91630. updateSpeed: number;
  91631. /**
  91632. * The amount of time the particle system is running (depends of the overall update speed).
  91633. */
  91634. targetStopDuration: number;
  91635. /**
  91636. * The texture used to render each particle. (this can be a spritesheet)
  91637. */
  91638. particleTexture: Nullable<Texture>;
  91639. /**
  91640. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91641. */
  91642. blendMode: number;
  91643. /**
  91644. * Minimum life time of emitting particles.
  91645. */
  91646. minLifeTime: number;
  91647. /**
  91648. * Maximum life time of emitting particles.
  91649. */
  91650. maxLifeTime: number;
  91651. /**
  91652. * Minimum Size of emitting particles.
  91653. */
  91654. minSize: number;
  91655. /**
  91656. * Maximum Size of emitting particles.
  91657. */
  91658. maxSize: number;
  91659. /**
  91660. * Minimum scale of emitting particles on X axis.
  91661. */
  91662. minScaleX: number;
  91663. /**
  91664. * Maximum scale of emitting particles on X axis.
  91665. */
  91666. maxScaleX: number;
  91667. /**
  91668. * Minimum scale of emitting particles on Y axis.
  91669. */
  91670. minScaleY: number;
  91671. /**
  91672. * Maximum scale of emitting particles on Y axis.
  91673. */
  91674. maxScaleY: number;
  91675. /**
  91676. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91677. */
  91678. color1: Color4;
  91679. /**
  91680. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91681. */
  91682. color2: Color4;
  91683. /**
  91684. * Color the particle will have at the end of its lifetime.
  91685. */
  91686. colorDead: Color4;
  91687. /**
  91688. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91689. */
  91690. emitRate: number;
  91691. /**
  91692. * You can use gravity if you want to give an orientation to your particles.
  91693. */
  91694. gravity: Vector3;
  91695. /**
  91696. * Minimum power of emitting particles.
  91697. */
  91698. minEmitPower: number;
  91699. /**
  91700. * Maximum power of emitting particles.
  91701. */
  91702. maxEmitPower: number;
  91703. /**
  91704. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91705. */
  91706. minAngularSpeed: number;
  91707. /**
  91708. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91709. */
  91710. maxAngularSpeed: number;
  91711. /**
  91712. * Gets or sets the minimal initial rotation in radians.
  91713. */
  91714. minInitialRotation: number;
  91715. /**
  91716. * Gets or sets the maximal initial rotation in radians.
  91717. */
  91718. maxInitialRotation: number;
  91719. /**
  91720. * The particle emitter type defines the emitter used by the particle system.
  91721. * It can be for example box, sphere, or cone...
  91722. */
  91723. particleEmitterType: Nullable<IParticleEmitterType>;
  91724. /**
  91725. * Defines the delay in milliseconds before starting the system (0 by default)
  91726. */
  91727. startDelay: number;
  91728. /**
  91729. * 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
  91730. */
  91731. preWarmCycles: number;
  91732. /**
  91733. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91734. */
  91735. preWarmStepOffset: number;
  91736. /**
  91737. * 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)
  91738. */
  91739. spriteCellChangeSpeed: number;
  91740. /**
  91741. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91742. */
  91743. startSpriteCellID: number;
  91744. /**
  91745. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91746. */
  91747. endSpriteCellID: number;
  91748. /**
  91749. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91750. */
  91751. spriteCellWidth: number;
  91752. /**
  91753. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91754. */
  91755. spriteCellHeight: number;
  91756. /**
  91757. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91758. */
  91759. spriteRandomStartCell: boolean;
  91760. /**
  91761. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91762. */
  91763. isAnimationSheetEnabled: boolean;
  91764. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91765. translationPivot: Vector2;
  91766. /**
  91767. * Gets or sets a texture used to add random noise to particle positions
  91768. */
  91769. noiseTexture: Nullable<BaseTexture>;
  91770. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91771. noiseStrength: Vector3;
  91772. /**
  91773. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91774. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91775. */
  91776. billboardMode: number;
  91777. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91778. limitVelocityDamping: number;
  91779. /**
  91780. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91781. */
  91782. beginAnimationOnStart: boolean;
  91783. /**
  91784. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91785. */
  91786. beginAnimationFrom: number;
  91787. /**
  91788. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91789. */
  91790. beginAnimationTo: number;
  91791. /**
  91792. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91793. */
  91794. beginAnimationLoop: boolean;
  91795. /**
  91796. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91797. */
  91798. disposeOnStop: boolean;
  91799. /**
  91800. * Specifies if the particles are updated in emitter local space or world space
  91801. */
  91802. isLocal: boolean;
  91803. /** Snippet ID if the particle system was created from the snippet server */
  91804. snippetId: string;
  91805. /**
  91806. * Gets the maximum number of particles active at the same time.
  91807. * @returns The max number of active particles.
  91808. */
  91809. getCapacity(): number;
  91810. /**
  91811. * Gets the number of particles active at the same time.
  91812. * @returns The number of active particles.
  91813. */
  91814. getActiveCount(): number;
  91815. /**
  91816. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91817. * @returns True if it has been started, otherwise false.
  91818. */
  91819. isStarted(): boolean;
  91820. /**
  91821. * Animates the particle system for this frame.
  91822. */
  91823. animate(): void;
  91824. /**
  91825. * Renders the particle system in its current state.
  91826. * @returns the current number of particles
  91827. */
  91828. render(): number;
  91829. /**
  91830. * Dispose the particle system and frees its associated resources.
  91831. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91832. */
  91833. dispose(disposeTexture?: boolean): void;
  91834. /**
  91835. * An event triggered when the system is disposed
  91836. */
  91837. onDisposeObservable: Observable<IParticleSystem>;
  91838. /**
  91839. * Clones the particle system.
  91840. * @param name The name of the cloned object
  91841. * @param newEmitter The new emitter to use
  91842. * @returns the cloned particle system
  91843. */
  91844. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91845. /**
  91846. * Serializes the particle system to a JSON object
  91847. * @param serializeTexture defines if the texture must be serialized as well
  91848. * @returns the JSON object
  91849. */
  91850. serialize(serializeTexture: boolean): any;
  91851. /**
  91852. * Rebuild the particle system
  91853. */
  91854. rebuild(): void;
  91855. /** Force the system to rebuild all gradients that need to be resync */
  91856. forceRefreshGradients(): void;
  91857. /**
  91858. * Starts the particle system and begins to emit
  91859. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91860. */
  91861. start(delay?: number): void;
  91862. /**
  91863. * Stops the particle system.
  91864. */
  91865. stop(): void;
  91866. /**
  91867. * Remove all active particles
  91868. */
  91869. reset(): void;
  91870. /**
  91871. * Gets a boolean indicating that the system is stopping
  91872. * @returns true if the system is currently stopping
  91873. */
  91874. isStopping(): boolean;
  91875. /**
  91876. * Is this system ready to be used/rendered
  91877. * @return true if the system is ready
  91878. */
  91879. isReady(): boolean;
  91880. /**
  91881. * Returns the string "ParticleSystem"
  91882. * @returns a string containing the class name
  91883. */
  91884. getClassName(): string;
  91885. /**
  91886. * Gets the custom effect used to render the particles
  91887. * @param blendMode Blend mode for which the effect should be retrieved
  91888. * @returns The effect
  91889. */
  91890. getCustomEffect(blendMode: number): Nullable<Effect>;
  91891. /**
  91892. * Sets the custom effect used to render the particles
  91893. * @param effect The effect to set
  91894. * @param blendMode Blend mode for which the effect should be set
  91895. */
  91896. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91897. /**
  91898. * Fill the defines array according to the current settings of the particle system
  91899. * @param defines Array to be updated
  91900. * @param blendMode blend mode to take into account when updating the array
  91901. */
  91902. fillDefines(defines: Array<string>, blendMode: number): void;
  91903. /**
  91904. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91905. * @param uniforms Uniforms array to fill
  91906. * @param attributes Attributes array to fill
  91907. * @param samplers Samplers array to fill
  91908. */
  91909. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91910. /**
  91911. * Observable that will be called just before the particles are drawn
  91912. */
  91913. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91914. /**
  91915. * Gets the name of the particle vertex shader
  91916. */
  91917. vertexShaderName: string;
  91918. /**
  91919. * Adds a new color gradient
  91920. * @param gradient defines the gradient to use (between 0 and 1)
  91921. * @param color1 defines the color to affect to the specified gradient
  91922. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91923. * @returns the current particle system
  91924. */
  91925. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91926. /**
  91927. * Remove a specific color gradient
  91928. * @param gradient defines the gradient to remove
  91929. * @returns the current particle system
  91930. */
  91931. removeColorGradient(gradient: number): IParticleSystem;
  91932. /**
  91933. * Adds a new size gradient
  91934. * @param gradient defines the gradient to use (between 0 and 1)
  91935. * @param factor defines the size factor to affect to the specified gradient
  91936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91937. * @returns the current particle system
  91938. */
  91939. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91940. /**
  91941. * Remove a specific size gradient
  91942. * @param gradient defines the gradient to remove
  91943. * @returns the current particle system
  91944. */
  91945. removeSizeGradient(gradient: number): IParticleSystem;
  91946. /**
  91947. * Gets the current list of color gradients.
  91948. * You must use addColorGradient and removeColorGradient to udpate this list
  91949. * @returns the list of color gradients
  91950. */
  91951. getColorGradients(): Nullable<Array<ColorGradient>>;
  91952. /**
  91953. * Gets the current list of size gradients.
  91954. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91955. * @returns the list of size gradients
  91956. */
  91957. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91958. /**
  91959. * Gets the current list of angular speed gradients.
  91960. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91961. * @returns the list of angular speed gradients
  91962. */
  91963. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91964. /**
  91965. * Adds a new angular speed gradient
  91966. * @param gradient defines the gradient to use (between 0 and 1)
  91967. * @param factor defines the angular speed to affect to the specified gradient
  91968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91969. * @returns the current particle system
  91970. */
  91971. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91972. /**
  91973. * Remove a specific angular speed gradient
  91974. * @param gradient defines the gradient to remove
  91975. * @returns the current particle system
  91976. */
  91977. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91978. /**
  91979. * Gets the current list of velocity gradients.
  91980. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91981. * @returns the list of velocity gradients
  91982. */
  91983. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91984. /**
  91985. * Adds a new velocity gradient
  91986. * @param gradient defines the gradient to use (between 0 and 1)
  91987. * @param factor defines the velocity to affect to the specified gradient
  91988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91989. * @returns the current particle system
  91990. */
  91991. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91992. /**
  91993. * Remove a specific velocity gradient
  91994. * @param gradient defines the gradient to remove
  91995. * @returns the current particle system
  91996. */
  91997. removeVelocityGradient(gradient: number): IParticleSystem;
  91998. /**
  91999. * Gets the current list of limit velocity gradients.
  92000. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92001. * @returns the list of limit velocity gradients
  92002. */
  92003. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92004. /**
  92005. * Adds a new limit velocity gradient
  92006. * @param gradient defines the gradient to use (between 0 and 1)
  92007. * @param factor defines the limit velocity to affect to the specified gradient
  92008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92009. * @returns the current particle system
  92010. */
  92011. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92012. /**
  92013. * Remove a specific limit velocity gradient
  92014. * @param gradient defines the gradient to remove
  92015. * @returns the current particle system
  92016. */
  92017. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92018. /**
  92019. * Adds a new drag gradient
  92020. * @param gradient defines the gradient to use (between 0 and 1)
  92021. * @param factor defines the drag to affect to the specified gradient
  92022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92023. * @returns the current particle system
  92024. */
  92025. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92026. /**
  92027. * Remove a specific drag gradient
  92028. * @param gradient defines the gradient to remove
  92029. * @returns the current particle system
  92030. */
  92031. removeDragGradient(gradient: number): IParticleSystem;
  92032. /**
  92033. * Gets the current list of drag gradients.
  92034. * You must use addDragGradient and removeDragGradient to udpate this list
  92035. * @returns the list of drag gradients
  92036. */
  92037. getDragGradients(): Nullable<Array<FactorGradient>>;
  92038. /**
  92039. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92040. * @param gradient defines the gradient to use (between 0 and 1)
  92041. * @param factor defines the emit rate to affect to the specified gradient
  92042. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92043. * @returns the current particle system
  92044. */
  92045. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92046. /**
  92047. * Remove a specific emit rate gradient
  92048. * @param gradient defines the gradient to remove
  92049. * @returns the current particle system
  92050. */
  92051. removeEmitRateGradient(gradient: number): IParticleSystem;
  92052. /**
  92053. * Gets the current list of emit rate gradients.
  92054. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92055. * @returns the list of emit rate gradients
  92056. */
  92057. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92058. /**
  92059. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92060. * @param gradient defines the gradient to use (between 0 and 1)
  92061. * @param factor defines the start size to affect to the specified gradient
  92062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92063. * @returns the current particle system
  92064. */
  92065. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92066. /**
  92067. * Remove a specific start size gradient
  92068. * @param gradient defines the gradient to remove
  92069. * @returns the current particle system
  92070. */
  92071. removeStartSizeGradient(gradient: number): IParticleSystem;
  92072. /**
  92073. * Gets the current list of start size gradients.
  92074. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92075. * @returns the list of start size gradients
  92076. */
  92077. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92078. /**
  92079. * Adds a new life time gradient
  92080. * @param gradient defines the gradient to use (between 0 and 1)
  92081. * @param factor defines the life time factor to affect to the specified gradient
  92082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92083. * @returns the current particle system
  92084. */
  92085. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92086. /**
  92087. * Remove a specific life time gradient
  92088. * @param gradient defines the gradient to remove
  92089. * @returns the current particle system
  92090. */
  92091. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92092. /**
  92093. * Gets the current list of life time gradients.
  92094. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92095. * @returns the list of life time gradients
  92096. */
  92097. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92098. /**
  92099. * Gets the current list of color gradients.
  92100. * You must use addColorGradient and removeColorGradient to udpate this list
  92101. * @returns the list of color gradients
  92102. */
  92103. getColorGradients(): Nullable<Array<ColorGradient>>;
  92104. /**
  92105. * Adds a new ramp gradient used to remap particle colors
  92106. * @param gradient defines the gradient to use (between 0 and 1)
  92107. * @param color defines the color to affect to the specified gradient
  92108. * @returns the current particle system
  92109. */
  92110. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92111. /**
  92112. * Gets the current list of ramp gradients.
  92113. * You must use addRampGradient and removeRampGradient to udpate this list
  92114. * @returns the list of ramp gradients
  92115. */
  92116. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92117. /** Gets or sets a boolean indicating that ramp gradients must be used
  92118. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92119. */
  92120. useRampGradients: boolean;
  92121. /**
  92122. * Adds a new color remap gradient
  92123. * @param gradient defines the gradient to use (between 0 and 1)
  92124. * @param min defines the color remap minimal range
  92125. * @param max defines the color remap maximal range
  92126. * @returns the current particle system
  92127. */
  92128. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92129. /**
  92130. * Gets the current list of color remap gradients.
  92131. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92132. * @returns the list of color remap gradients
  92133. */
  92134. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92135. /**
  92136. * Adds a new alpha remap gradient
  92137. * @param gradient defines the gradient to use (between 0 and 1)
  92138. * @param min defines the alpha remap minimal range
  92139. * @param max defines the alpha remap maximal range
  92140. * @returns the current particle system
  92141. */
  92142. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92143. /**
  92144. * Gets the current list of alpha remap gradients.
  92145. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92146. * @returns the list of alpha remap gradients
  92147. */
  92148. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92149. /**
  92150. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92151. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92152. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92153. * @returns the emitter
  92154. */
  92155. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92156. /**
  92157. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92158. * @param radius The radius of the hemisphere to emit from
  92159. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92160. * @returns the emitter
  92161. */
  92162. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92163. /**
  92164. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92165. * @param radius The radius of the sphere to emit from
  92166. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92167. * @returns the emitter
  92168. */
  92169. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92170. /**
  92171. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92172. * @param radius The radius of the sphere to emit from
  92173. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92174. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92175. * @returns the emitter
  92176. */
  92177. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92178. /**
  92179. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92180. * @param radius The radius of the emission cylinder
  92181. * @param height The height of the emission cylinder
  92182. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92183. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92184. * @returns the emitter
  92185. */
  92186. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92187. /**
  92188. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92189. * @param radius The radius of the cylinder to emit from
  92190. * @param height The height of the emission cylinder
  92191. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92192. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92193. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92194. * @returns the emitter
  92195. */
  92196. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92197. /**
  92198. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92199. * @param radius The radius of the cone to emit from
  92200. * @param angle The base angle of the cone
  92201. * @returns the emitter
  92202. */
  92203. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92204. /**
  92205. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92206. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92207. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92208. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92209. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92210. * @returns the emitter
  92211. */
  92212. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92213. /**
  92214. * Get hosting scene
  92215. * @returns the scene
  92216. */
  92217. getScene(): Scene;
  92218. }
  92219. }
  92220. declare module BABYLON {
  92221. /**
  92222. * 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.
  92223. * @see https://doc.babylonjs.com/how_to/transformnode
  92224. */
  92225. export class TransformNode extends Node {
  92226. /**
  92227. * Object will not rotate to face the camera
  92228. */
  92229. static BILLBOARDMODE_NONE: number;
  92230. /**
  92231. * Object will rotate to face the camera but only on the x axis
  92232. */
  92233. static BILLBOARDMODE_X: number;
  92234. /**
  92235. * Object will rotate to face the camera but only on the y axis
  92236. */
  92237. static BILLBOARDMODE_Y: number;
  92238. /**
  92239. * Object will rotate to face the camera but only on the z axis
  92240. */
  92241. static BILLBOARDMODE_Z: number;
  92242. /**
  92243. * Object will rotate to face the camera
  92244. */
  92245. static BILLBOARDMODE_ALL: number;
  92246. /**
  92247. * Object will rotate to face the camera's position instead of orientation
  92248. */
  92249. static BILLBOARDMODE_USE_POSITION: number;
  92250. private static _TmpRotation;
  92251. private static _TmpScaling;
  92252. private static _TmpTranslation;
  92253. private _forward;
  92254. private _forwardInverted;
  92255. private _up;
  92256. private _right;
  92257. private _rightInverted;
  92258. private _position;
  92259. private _rotation;
  92260. private _rotationQuaternion;
  92261. protected _scaling: Vector3;
  92262. protected _isDirty: boolean;
  92263. private _transformToBoneReferal;
  92264. private _isAbsoluteSynced;
  92265. private _billboardMode;
  92266. /**
  92267. * Gets or sets the billboard mode. Default is 0.
  92268. *
  92269. * | Value | Type | Description |
  92270. * | --- | --- | --- |
  92271. * | 0 | BILLBOARDMODE_NONE | |
  92272. * | 1 | BILLBOARDMODE_X | |
  92273. * | 2 | BILLBOARDMODE_Y | |
  92274. * | 4 | BILLBOARDMODE_Z | |
  92275. * | 7 | BILLBOARDMODE_ALL | |
  92276. *
  92277. */
  92278. get billboardMode(): number;
  92279. set billboardMode(value: number);
  92280. private _preserveParentRotationForBillboard;
  92281. /**
  92282. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92283. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92284. */
  92285. get preserveParentRotationForBillboard(): boolean;
  92286. set preserveParentRotationForBillboard(value: boolean);
  92287. /**
  92288. * 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
  92289. */
  92290. scalingDeterminant: number;
  92291. private _infiniteDistance;
  92292. /**
  92293. * Gets or sets the distance of the object to max, often used by skybox
  92294. */
  92295. get infiniteDistance(): boolean;
  92296. set infiniteDistance(value: boolean);
  92297. /**
  92298. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92299. * By default the system will update normals to compensate
  92300. */
  92301. ignoreNonUniformScaling: boolean;
  92302. /**
  92303. * 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
  92304. */
  92305. reIntegrateRotationIntoRotationQuaternion: boolean;
  92306. /** @hidden */
  92307. _poseMatrix: Nullable<Matrix>;
  92308. /** @hidden */
  92309. _localMatrix: Matrix;
  92310. private _usePivotMatrix;
  92311. private _absolutePosition;
  92312. private _absoluteScaling;
  92313. private _absoluteRotationQuaternion;
  92314. private _pivotMatrix;
  92315. private _pivotMatrixInverse;
  92316. protected _postMultiplyPivotMatrix: boolean;
  92317. protected _isWorldMatrixFrozen: boolean;
  92318. /** @hidden */
  92319. _indexInSceneTransformNodesArray: number;
  92320. /**
  92321. * An event triggered after the world matrix is updated
  92322. */
  92323. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92324. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92325. /**
  92326. * Gets a string identifying the name of the class
  92327. * @returns "TransformNode" string
  92328. */
  92329. getClassName(): string;
  92330. /**
  92331. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92332. */
  92333. get position(): Vector3;
  92334. set position(newPosition: Vector3);
  92335. /**
  92336. * 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)).
  92337. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92338. */
  92339. get rotation(): Vector3;
  92340. set rotation(newRotation: Vector3);
  92341. /**
  92342. * 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)).
  92343. */
  92344. get scaling(): Vector3;
  92345. set scaling(newScaling: Vector3);
  92346. /**
  92347. * 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).
  92348. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92349. */
  92350. get rotationQuaternion(): Nullable<Quaternion>;
  92351. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92352. /**
  92353. * The forward direction of that transform in world space.
  92354. */
  92355. get forward(): Vector3;
  92356. /**
  92357. * The up direction of that transform in world space.
  92358. */
  92359. get up(): Vector3;
  92360. /**
  92361. * The right direction of that transform in world space.
  92362. */
  92363. get right(): Vector3;
  92364. /**
  92365. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92366. * @param matrix the matrix to copy the pose from
  92367. * @returns this TransformNode.
  92368. */
  92369. updatePoseMatrix(matrix: Matrix): TransformNode;
  92370. /**
  92371. * Returns the mesh Pose matrix.
  92372. * @returns the pose matrix
  92373. */
  92374. getPoseMatrix(): Matrix;
  92375. /** @hidden */
  92376. _isSynchronized(): boolean;
  92377. /** @hidden */
  92378. _initCache(): void;
  92379. /**
  92380. * Flag the transform node as dirty (Forcing it to update everything)
  92381. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92382. * @returns this transform node
  92383. */
  92384. markAsDirty(property: string): TransformNode;
  92385. /**
  92386. * Returns the current mesh absolute position.
  92387. * Returns a Vector3.
  92388. */
  92389. get absolutePosition(): Vector3;
  92390. /**
  92391. * Returns the current mesh absolute scaling.
  92392. * Returns a Vector3.
  92393. */
  92394. get absoluteScaling(): Vector3;
  92395. /**
  92396. * Returns the current mesh absolute rotation.
  92397. * Returns a Quaternion.
  92398. */
  92399. get absoluteRotationQuaternion(): Quaternion;
  92400. /**
  92401. * Sets a new matrix to apply before all other transformation
  92402. * @param matrix defines the transform matrix
  92403. * @returns the current TransformNode
  92404. */
  92405. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92406. /**
  92407. * Sets a new pivot matrix to the current node
  92408. * @param matrix defines the new pivot matrix to use
  92409. * @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
  92410. * @returns the current TransformNode
  92411. */
  92412. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92413. /**
  92414. * Returns the mesh pivot matrix.
  92415. * Default : Identity.
  92416. * @returns the matrix
  92417. */
  92418. getPivotMatrix(): Matrix;
  92419. /**
  92420. * Instantiate (when possible) or clone that node with its hierarchy
  92421. * @param newParent defines the new parent to use for the instance (or clone)
  92422. * @param options defines options to configure how copy is done
  92423. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92424. * @returns an instance (or a clone) of the current node with its hiearchy
  92425. */
  92426. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92427. doNotInstantiate: boolean;
  92428. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92429. /**
  92430. * Prevents the World matrix to be computed any longer
  92431. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92432. * @returns the TransformNode.
  92433. */
  92434. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92435. /**
  92436. * Allows back the World matrix computation.
  92437. * @returns the TransformNode.
  92438. */
  92439. unfreezeWorldMatrix(): this;
  92440. /**
  92441. * True if the World matrix has been frozen.
  92442. */
  92443. get isWorldMatrixFrozen(): boolean;
  92444. /**
  92445. * Retuns the mesh absolute position in the World.
  92446. * @returns a Vector3.
  92447. */
  92448. getAbsolutePosition(): Vector3;
  92449. /**
  92450. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92451. * @param absolutePosition the absolute position to set
  92452. * @returns the TransformNode.
  92453. */
  92454. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92455. /**
  92456. * Sets the mesh position in its local space.
  92457. * @param vector3 the position to set in localspace
  92458. * @returns the TransformNode.
  92459. */
  92460. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92461. /**
  92462. * Returns the mesh position in the local space from the current World matrix values.
  92463. * @returns a new Vector3.
  92464. */
  92465. getPositionExpressedInLocalSpace(): Vector3;
  92466. /**
  92467. * Translates the mesh along the passed Vector3 in its local space.
  92468. * @param vector3 the distance to translate in localspace
  92469. * @returns the TransformNode.
  92470. */
  92471. locallyTranslate(vector3: Vector3): TransformNode;
  92472. private static _lookAtVectorCache;
  92473. /**
  92474. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92475. * @param targetPoint the position (must be in same space as current mesh) to look at
  92476. * @param yawCor optional yaw (y-axis) correction in radians
  92477. * @param pitchCor optional pitch (x-axis) correction in radians
  92478. * @param rollCor optional roll (z-axis) correction in radians
  92479. * @param space the choosen space of the target
  92480. * @returns the TransformNode.
  92481. */
  92482. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92483. /**
  92484. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92485. * This Vector3 is expressed in the World space.
  92486. * @param localAxis axis to rotate
  92487. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92488. */
  92489. getDirection(localAxis: Vector3): Vector3;
  92490. /**
  92491. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92492. * localAxis is expressed in the mesh local space.
  92493. * result is computed in the Wordl space from the mesh World matrix.
  92494. * @param localAxis axis to rotate
  92495. * @param result the resulting transformnode
  92496. * @returns this TransformNode.
  92497. */
  92498. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92499. /**
  92500. * Sets this transform node rotation to the given local axis.
  92501. * @param localAxis the axis in local space
  92502. * @param yawCor optional yaw (y-axis) correction in radians
  92503. * @param pitchCor optional pitch (x-axis) correction in radians
  92504. * @param rollCor optional roll (z-axis) correction in radians
  92505. * @returns this TransformNode
  92506. */
  92507. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92508. /**
  92509. * Sets a new pivot point to the current node
  92510. * @param point defines the new pivot point to use
  92511. * @param space defines if the point is in world or local space (local by default)
  92512. * @returns the current TransformNode
  92513. */
  92514. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92515. /**
  92516. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92517. * @returns the pivot point
  92518. */
  92519. getPivotPoint(): Vector3;
  92520. /**
  92521. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92522. * @param result the vector3 to store the result
  92523. * @returns this TransformNode.
  92524. */
  92525. getPivotPointToRef(result: Vector3): TransformNode;
  92526. /**
  92527. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92528. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92529. */
  92530. getAbsolutePivotPoint(): Vector3;
  92531. /**
  92532. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92533. * @param result vector3 to store the result
  92534. * @returns this TransformNode.
  92535. */
  92536. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92537. /**
  92538. * Defines the passed node as the parent of the current node.
  92539. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92540. * @see https://doc.babylonjs.com/how_to/parenting
  92541. * @param node the node ot set as the parent
  92542. * @returns this TransformNode.
  92543. */
  92544. setParent(node: Nullable<Node>): TransformNode;
  92545. private _nonUniformScaling;
  92546. /**
  92547. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92548. */
  92549. get nonUniformScaling(): boolean;
  92550. /** @hidden */
  92551. _updateNonUniformScalingState(value: boolean): boolean;
  92552. /**
  92553. * Attach the current TransformNode to another TransformNode associated with a bone
  92554. * @param bone Bone affecting the TransformNode
  92555. * @param affectedTransformNode TransformNode associated with the bone
  92556. * @returns this object
  92557. */
  92558. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92559. /**
  92560. * Detach the transform node if its associated with a bone
  92561. * @returns this object
  92562. */
  92563. detachFromBone(): TransformNode;
  92564. private static _rotationAxisCache;
  92565. /**
  92566. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92567. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92568. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92569. * The passed axis is also normalized.
  92570. * @param axis the axis to rotate around
  92571. * @param amount the amount to rotate in radians
  92572. * @param space Space to rotate in (Default: local)
  92573. * @returns the TransformNode.
  92574. */
  92575. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92576. /**
  92577. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92578. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92579. * The passed axis is also normalized. .
  92580. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92581. * @param point the point to rotate around
  92582. * @param axis the axis to rotate around
  92583. * @param amount the amount to rotate in radians
  92584. * @returns the TransformNode
  92585. */
  92586. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92587. /**
  92588. * Translates the mesh along the axis vector for the passed distance in the given space.
  92589. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92590. * @param axis the axis to translate in
  92591. * @param distance the distance to translate
  92592. * @param space Space to rotate in (Default: local)
  92593. * @returns the TransformNode.
  92594. */
  92595. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92596. /**
  92597. * Adds a rotation step to the mesh current rotation.
  92598. * x, y, z are Euler angles expressed in radians.
  92599. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92600. * This means this rotation is made in the mesh local space only.
  92601. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92602. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92603. * ```javascript
  92604. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92605. * ```
  92606. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92607. * 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.
  92608. * @param x Rotation to add
  92609. * @param y Rotation to add
  92610. * @param z Rotation to add
  92611. * @returns the TransformNode.
  92612. */
  92613. addRotation(x: number, y: number, z: number): TransformNode;
  92614. /**
  92615. * @hidden
  92616. */
  92617. protected _getEffectiveParent(): Nullable<Node>;
  92618. /**
  92619. * Computes the world matrix of the node
  92620. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92621. * @returns the world matrix
  92622. */
  92623. computeWorldMatrix(force?: boolean): Matrix;
  92624. /**
  92625. * Resets this nodeTransform's local matrix to Matrix.Identity().
  92626. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  92627. */
  92628. resetLocalMatrix(independentOfChildren?: boolean): void;
  92629. protected _afterComputeWorldMatrix(): void;
  92630. /**
  92631. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  92632. * @param func callback function to add
  92633. *
  92634. * @returns the TransformNode.
  92635. */
  92636. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92637. /**
  92638. * Removes a registered callback function.
  92639. * @param func callback function to remove
  92640. * @returns the TransformNode.
  92641. */
  92642. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92643. /**
  92644. * Gets the position of the current mesh in camera space
  92645. * @param camera defines the camera to use
  92646. * @returns a position
  92647. */
  92648. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  92649. /**
  92650. * Returns the distance from the mesh to the active camera
  92651. * @param camera defines the camera to use
  92652. * @returns the distance
  92653. */
  92654. getDistanceToCamera(camera?: Nullable<Camera>): number;
  92655. /**
  92656. * Clone the current transform node
  92657. * @param name Name of the new clone
  92658. * @param newParent New parent for the clone
  92659. * @param doNotCloneChildren Do not clone children hierarchy
  92660. * @returns the new transform node
  92661. */
  92662. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  92663. /**
  92664. * Serializes the objects information.
  92665. * @param currentSerializationObject defines the object to serialize in
  92666. * @returns the serialized object
  92667. */
  92668. serialize(currentSerializationObject?: any): any;
  92669. /**
  92670. * Returns a new TransformNode object parsed from the source provided.
  92671. * @param parsedTransformNode is the source.
  92672. * @param scene the scne the object belongs to
  92673. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  92674. * @returns a new TransformNode object parsed from the source provided.
  92675. */
  92676. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  92677. /**
  92678. * Get all child-transformNodes of this node
  92679. * @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
  92680. * @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
  92681. * @returns an array of TransformNode
  92682. */
  92683. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  92684. /**
  92685. * Releases resources associated with this transform node.
  92686. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92687. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92688. */
  92689. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92690. /**
  92691. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92692. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92693. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92694. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92695. * @returns the current mesh
  92696. */
  92697. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  92698. private _syncAbsoluteScalingAndRotation;
  92699. }
  92700. }
  92701. declare module BABYLON {
  92702. /**
  92703. * Class used to override all child animations of a given target
  92704. */
  92705. export class AnimationPropertiesOverride {
  92706. /**
  92707. * Gets or sets a value indicating if animation blending must be used
  92708. */
  92709. enableBlending: boolean;
  92710. /**
  92711. * Gets or sets the blending speed to use when enableBlending is true
  92712. */
  92713. blendingSpeed: number;
  92714. /**
  92715. * Gets or sets the default loop mode to use
  92716. */
  92717. loopMode: number;
  92718. }
  92719. }
  92720. declare module BABYLON {
  92721. /**
  92722. * Class used to store bone information
  92723. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92724. */
  92725. export class Bone extends Node {
  92726. /**
  92727. * defines the bone name
  92728. */
  92729. name: string;
  92730. private static _tmpVecs;
  92731. private static _tmpQuat;
  92732. private static _tmpMats;
  92733. /**
  92734. * Gets the list of child bones
  92735. */
  92736. children: Bone[];
  92737. /** Gets the animations associated with this bone */
  92738. animations: Animation[];
  92739. /**
  92740. * Gets or sets bone length
  92741. */
  92742. length: number;
  92743. /**
  92744. * @hidden Internal only
  92745. * Set this value to map this bone to a different index in the transform matrices
  92746. * Set this value to -1 to exclude the bone from the transform matrices
  92747. */
  92748. _index: Nullable<number>;
  92749. private _skeleton;
  92750. private _localMatrix;
  92751. private _restPose;
  92752. private _baseMatrix;
  92753. private _absoluteTransform;
  92754. private _invertedAbsoluteTransform;
  92755. private _parent;
  92756. private _scalingDeterminant;
  92757. private _worldTransform;
  92758. private _localScaling;
  92759. private _localRotation;
  92760. private _localPosition;
  92761. private _needToDecompose;
  92762. private _needToCompose;
  92763. /** @hidden */
  92764. _linkedTransformNode: Nullable<TransformNode>;
  92765. /** @hidden */
  92766. _waitingTransformNodeId: Nullable<string>;
  92767. /** @hidden */
  92768. get _matrix(): Matrix;
  92769. /** @hidden */
  92770. set _matrix(value: Matrix);
  92771. /**
  92772. * Create a new bone
  92773. * @param name defines the bone name
  92774. * @param skeleton defines the parent skeleton
  92775. * @param parentBone defines the parent (can be null if the bone is the root)
  92776. * @param localMatrix defines the local matrix
  92777. * @param restPose defines the rest pose matrix
  92778. * @param baseMatrix defines the base matrix
  92779. * @param index defines index of the bone in the hiearchy
  92780. */
  92781. constructor(
  92782. /**
  92783. * defines the bone name
  92784. */
  92785. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  92786. /**
  92787. * Gets the current object class name.
  92788. * @return the class name
  92789. */
  92790. getClassName(): string;
  92791. /**
  92792. * Gets the parent skeleton
  92793. * @returns a skeleton
  92794. */
  92795. getSkeleton(): Skeleton;
  92796. /**
  92797. * Gets parent bone
  92798. * @returns a bone or null if the bone is the root of the bone hierarchy
  92799. */
  92800. getParent(): Nullable<Bone>;
  92801. /**
  92802. * Returns an array containing the root bones
  92803. * @returns an array containing the root bones
  92804. */
  92805. getChildren(): Array<Bone>;
  92806. /**
  92807. * Gets the node index in matrix array generated for rendering
  92808. * @returns the node index
  92809. */
  92810. getIndex(): number;
  92811. /**
  92812. * Sets the parent bone
  92813. * @param parent defines the parent (can be null if the bone is the root)
  92814. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92815. */
  92816. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  92817. /**
  92818. * Gets the local matrix
  92819. * @returns a matrix
  92820. */
  92821. getLocalMatrix(): Matrix;
  92822. /**
  92823. * Gets the base matrix (initial matrix which remains unchanged)
  92824. * @returns a matrix
  92825. */
  92826. getBaseMatrix(): Matrix;
  92827. /**
  92828. * Gets the rest pose matrix
  92829. * @returns a matrix
  92830. */
  92831. getRestPose(): Matrix;
  92832. /**
  92833. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92834. */
  92835. getWorldMatrix(): Matrix;
  92836. /**
  92837. * Sets the local matrix to rest pose matrix
  92838. */
  92839. returnToRest(): void;
  92840. /**
  92841. * Gets the inverse of the absolute transform matrix.
  92842. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92843. * @returns a matrix
  92844. */
  92845. getInvertedAbsoluteTransform(): Matrix;
  92846. /**
  92847. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92848. * @returns a matrix
  92849. */
  92850. getAbsoluteTransform(): Matrix;
  92851. /**
  92852. * Links with the given transform node.
  92853. * The local matrix of this bone is copied from the transform node every frame.
  92854. * @param transformNode defines the transform node to link to
  92855. */
  92856. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92857. /**
  92858. * Gets the node used to drive the bone's transformation
  92859. * @returns a transform node or null
  92860. */
  92861. getTransformNode(): Nullable<TransformNode>;
  92862. /** Gets or sets current position (in local space) */
  92863. get position(): Vector3;
  92864. set position(newPosition: Vector3);
  92865. /** Gets or sets current rotation (in local space) */
  92866. get rotation(): Vector3;
  92867. set rotation(newRotation: Vector3);
  92868. /** Gets or sets current rotation quaternion (in local space) */
  92869. get rotationQuaternion(): Quaternion;
  92870. set rotationQuaternion(newRotation: Quaternion);
  92871. /** Gets or sets current scaling (in local space) */
  92872. get scaling(): Vector3;
  92873. set scaling(newScaling: Vector3);
  92874. /**
  92875. * Gets the animation properties override
  92876. */
  92877. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92878. private _decompose;
  92879. private _compose;
  92880. /**
  92881. * Update the base and local matrices
  92882. * @param matrix defines the new base or local matrix
  92883. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92884. * @param updateLocalMatrix defines if the local matrix should be updated
  92885. */
  92886. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92887. /** @hidden */
  92888. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92889. /**
  92890. * Flag the bone as dirty (Forcing it to update everything)
  92891. */
  92892. markAsDirty(): void;
  92893. /** @hidden */
  92894. _markAsDirtyAndCompose(): void;
  92895. private _markAsDirtyAndDecompose;
  92896. /**
  92897. * Translate the bone in local or world space
  92898. * @param vec The amount to translate the bone
  92899. * @param space The space that the translation is in
  92900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92901. */
  92902. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92903. /**
  92904. * Set the postion of the bone in local or world space
  92905. * @param position The position to set the bone
  92906. * @param space The space that the position is in
  92907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92908. */
  92909. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92910. /**
  92911. * Set the absolute position of the bone (world space)
  92912. * @param position The position to set the bone
  92913. * @param mesh The mesh that this bone is attached to
  92914. */
  92915. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92916. /**
  92917. * Scale the bone on the x, y and z axes (in local space)
  92918. * @param x The amount to scale the bone on the x axis
  92919. * @param y The amount to scale the bone on the y axis
  92920. * @param z The amount to scale the bone on the z axis
  92921. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92922. */
  92923. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92924. /**
  92925. * Set the bone scaling in local space
  92926. * @param scale defines the scaling vector
  92927. */
  92928. setScale(scale: Vector3): void;
  92929. /**
  92930. * Gets the current scaling in local space
  92931. * @returns the current scaling vector
  92932. */
  92933. getScale(): Vector3;
  92934. /**
  92935. * Gets the current scaling in local space and stores it in a target vector
  92936. * @param result defines the target vector
  92937. */
  92938. getScaleToRef(result: Vector3): void;
  92939. /**
  92940. * Set the yaw, pitch, and roll of the bone in local or world space
  92941. * @param yaw The rotation of the bone on the y axis
  92942. * @param pitch The rotation of the bone on the x axis
  92943. * @param roll The rotation of the bone on the z axis
  92944. * @param space The space that the axes of rotation are in
  92945. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92946. */
  92947. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92948. /**
  92949. * Add a rotation to the bone on an axis in local or world space
  92950. * @param axis The axis to rotate the bone on
  92951. * @param amount The amount to rotate the bone
  92952. * @param space The space that the axis is in
  92953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92954. */
  92955. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92956. /**
  92957. * Set the rotation of the bone to a particular axis angle in local or world space
  92958. * @param axis The axis to rotate the bone on
  92959. * @param angle The angle that the bone should be rotated to
  92960. * @param space The space that the axis is in
  92961. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92962. */
  92963. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92964. /**
  92965. * Set the euler rotation of the bone in local of world space
  92966. * @param rotation The euler rotation that the bone should be set to
  92967. * @param space The space that the rotation is in
  92968. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92969. */
  92970. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92971. /**
  92972. * Set the quaternion rotation of the bone in local of world space
  92973. * @param quat The quaternion rotation that the bone should be set to
  92974. * @param space The space that the rotation is in
  92975. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92976. */
  92977. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  92978. /**
  92979. * Set the rotation matrix of the bone in local of world space
  92980. * @param rotMat The rotation matrix that the bone should be set to
  92981. * @param space The space that the rotation is in
  92982. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92983. */
  92984. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  92985. private _rotateWithMatrix;
  92986. private _getNegativeRotationToRef;
  92987. /**
  92988. * Get the position of the bone in local or world space
  92989. * @param space The space that the returned position is in
  92990. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92991. * @returns The position of the bone
  92992. */
  92993. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92994. /**
  92995. * Copy the position of the bone to a vector3 in local or world space
  92996. * @param space The space that the returned position is in
  92997. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92998. * @param result The vector3 to copy the position to
  92999. */
  93000. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93001. /**
  93002. * Get the absolute position of the bone (world space)
  93003. * @param mesh The mesh that this bone is attached to
  93004. * @returns The absolute position of the bone
  93005. */
  93006. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93007. /**
  93008. * Copy the absolute position of the bone (world space) to the result param
  93009. * @param mesh The mesh that this bone is attached to
  93010. * @param result The vector3 to copy the absolute position to
  93011. */
  93012. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93013. /**
  93014. * Compute the absolute transforms of this bone and its children
  93015. */
  93016. computeAbsoluteTransforms(): void;
  93017. /**
  93018. * Get the world direction from an axis that is in the local space of the bone
  93019. * @param localAxis The local direction that is used to compute the world direction
  93020. * @param mesh The mesh that this bone is attached to
  93021. * @returns The world direction
  93022. */
  93023. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93024. /**
  93025. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93026. * @param localAxis The local direction that is used to compute the world direction
  93027. * @param mesh The mesh that this bone is attached to
  93028. * @param result The vector3 that the world direction will be copied to
  93029. */
  93030. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93031. /**
  93032. * Get the euler rotation of the bone in local or world space
  93033. * @param space The space that the rotation should be in
  93034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93035. * @returns The euler rotation
  93036. */
  93037. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93038. /**
  93039. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93040. * @param space The space that the rotation should be in
  93041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93042. * @param result The vector3 that the rotation should be copied to
  93043. */
  93044. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93045. /**
  93046. * Get the quaternion rotation of the bone in either local or world space
  93047. * @param space The space that the rotation should be in
  93048. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93049. * @returns The quaternion rotation
  93050. */
  93051. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93052. /**
  93053. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93054. * @param space The space that the rotation should be in
  93055. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93056. * @param result The quaternion that the rotation should be copied to
  93057. */
  93058. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93059. /**
  93060. * Get the rotation matrix of the bone in local or world space
  93061. * @param space The space that the rotation should be in
  93062. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93063. * @returns The rotation matrix
  93064. */
  93065. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93066. /**
  93067. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93068. * @param space The space that the rotation should be in
  93069. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93070. * @param result The quaternion that the rotation should be copied to
  93071. */
  93072. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93073. /**
  93074. * Get the world position of a point that is in the local space of the bone
  93075. * @param position The local position
  93076. * @param mesh The mesh that this bone is attached to
  93077. * @returns The world position
  93078. */
  93079. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93080. /**
  93081. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93082. * @param position The local position
  93083. * @param mesh The mesh that this bone is attached to
  93084. * @param result The vector3 that the world position should be copied to
  93085. */
  93086. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93087. /**
  93088. * Get the local position of a point that is in world space
  93089. * @param position The world position
  93090. * @param mesh The mesh that this bone is attached to
  93091. * @returns The local position
  93092. */
  93093. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93094. /**
  93095. * Get the local position of a point that is in world space and copy it to the result param
  93096. * @param position The world position
  93097. * @param mesh The mesh that this bone is attached to
  93098. * @param result The vector3 that the local position should be copied to
  93099. */
  93100. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93101. }
  93102. }
  93103. declare module BABYLON {
  93104. /**
  93105. * Defines a runtime animation
  93106. */
  93107. export class RuntimeAnimation {
  93108. private _events;
  93109. /**
  93110. * The current frame of the runtime animation
  93111. */
  93112. private _currentFrame;
  93113. /**
  93114. * The animation used by the runtime animation
  93115. */
  93116. private _animation;
  93117. /**
  93118. * The target of the runtime animation
  93119. */
  93120. private _target;
  93121. /**
  93122. * The initiating animatable
  93123. */
  93124. private _host;
  93125. /**
  93126. * The original value of the runtime animation
  93127. */
  93128. private _originalValue;
  93129. /**
  93130. * The original blend value of the runtime animation
  93131. */
  93132. private _originalBlendValue;
  93133. /**
  93134. * The offsets cache of the runtime animation
  93135. */
  93136. private _offsetsCache;
  93137. /**
  93138. * The high limits cache of the runtime animation
  93139. */
  93140. private _highLimitsCache;
  93141. /**
  93142. * Specifies if the runtime animation has been stopped
  93143. */
  93144. private _stopped;
  93145. /**
  93146. * The blending factor of the runtime animation
  93147. */
  93148. private _blendingFactor;
  93149. /**
  93150. * The BabylonJS scene
  93151. */
  93152. private _scene;
  93153. /**
  93154. * The current value of the runtime animation
  93155. */
  93156. private _currentValue;
  93157. /** @hidden */
  93158. _animationState: _IAnimationState;
  93159. /**
  93160. * The active target of the runtime animation
  93161. */
  93162. private _activeTargets;
  93163. private _currentActiveTarget;
  93164. private _directTarget;
  93165. /**
  93166. * The target path of the runtime animation
  93167. */
  93168. private _targetPath;
  93169. /**
  93170. * The weight of the runtime animation
  93171. */
  93172. private _weight;
  93173. /**
  93174. * The ratio offset of the runtime animation
  93175. */
  93176. private _ratioOffset;
  93177. /**
  93178. * The previous delay of the runtime animation
  93179. */
  93180. private _previousDelay;
  93181. /**
  93182. * The previous ratio of the runtime animation
  93183. */
  93184. private _previousRatio;
  93185. private _enableBlending;
  93186. private _keys;
  93187. private _minFrame;
  93188. private _maxFrame;
  93189. private _minValue;
  93190. private _maxValue;
  93191. private _targetIsArray;
  93192. /**
  93193. * Gets the current frame of the runtime animation
  93194. */
  93195. get currentFrame(): number;
  93196. /**
  93197. * Gets the weight of the runtime animation
  93198. */
  93199. get weight(): number;
  93200. /**
  93201. * Gets the current value of the runtime animation
  93202. */
  93203. get currentValue(): any;
  93204. /**
  93205. * Gets the target path of the runtime animation
  93206. */
  93207. get targetPath(): string;
  93208. /**
  93209. * Gets the actual target of the runtime animation
  93210. */
  93211. get target(): any;
  93212. /**
  93213. * Gets the additive state of the runtime animation
  93214. */
  93215. get isAdditive(): boolean;
  93216. /** @hidden */
  93217. _onLoop: () => void;
  93218. /**
  93219. * Create a new RuntimeAnimation object
  93220. * @param target defines the target of the animation
  93221. * @param animation defines the source animation object
  93222. * @param scene defines the hosting scene
  93223. * @param host defines the initiating Animatable
  93224. */
  93225. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93226. private _preparePath;
  93227. /**
  93228. * Gets the animation from the runtime animation
  93229. */
  93230. get animation(): Animation;
  93231. /**
  93232. * Resets the runtime animation to the beginning
  93233. * @param restoreOriginal defines whether to restore the target property to the original value
  93234. */
  93235. reset(restoreOriginal?: boolean): void;
  93236. /**
  93237. * Specifies if the runtime animation is stopped
  93238. * @returns Boolean specifying if the runtime animation is stopped
  93239. */
  93240. isStopped(): boolean;
  93241. /**
  93242. * Disposes of the runtime animation
  93243. */
  93244. dispose(): void;
  93245. /**
  93246. * Apply the interpolated value to the target
  93247. * @param currentValue defines the value computed by the animation
  93248. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93249. */
  93250. setValue(currentValue: any, weight: number): void;
  93251. private _getOriginalValues;
  93252. private _setValue;
  93253. /**
  93254. * Gets the loop pmode of the runtime animation
  93255. * @returns Loop Mode
  93256. */
  93257. private _getCorrectLoopMode;
  93258. /**
  93259. * Move the current animation to a given frame
  93260. * @param frame defines the frame to move to
  93261. */
  93262. goToFrame(frame: number): void;
  93263. /**
  93264. * @hidden Internal use only
  93265. */
  93266. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93267. /**
  93268. * Execute the current animation
  93269. * @param delay defines the delay to add to the current frame
  93270. * @param from defines the lower bound of the animation range
  93271. * @param to defines the upper bound of the animation range
  93272. * @param loop defines if the current animation must loop
  93273. * @param speedRatio defines the current speed ratio
  93274. * @param weight defines the weight of the animation (default is -1 so no weight)
  93275. * @param onLoop optional callback called when animation loops
  93276. * @returns a boolean indicating if the animation is running
  93277. */
  93278. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93279. }
  93280. }
  93281. declare module BABYLON {
  93282. /**
  93283. * Class used to store an actual running animation
  93284. */
  93285. export class Animatable {
  93286. /** defines the target object */
  93287. target: any;
  93288. /** defines the starting frame number (default is 0) */
  93289. fromFrame: number;
  93290. /** defines the ending frame number (default is 100) */
  93291. toFrame: number;
  93292. /** defines if the animation must loop (default is false) */
  93293. loopAnimation: boolean;
  93294. /** defines a callback to call when animation ends if it is not looping */
  93295. onAnimationEnd?: (() => void) | null | undefined;
  93296. /** defines a callback to call when animation loops */
  93297. onAnimationLoop?: (() => void) | null | undefined;
  93298. /** defines whether the animation should be evaluated additively */
  93299. isAdditive: boolean;
  93300. private _localDelayOffset;
  93301. private _pausedDelay;
  93302. private _runtimeAnimations;
  93303. private _paused;
  93304. private _scene;
  93305. private _speedRatio;
  93306. private _weight;
  93307. private _syncRoot;
  93308. /**
  93309. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93310. * This will only apply for non looping animation (default is true)
  93311. */
  93312. disposeOnEnd: boolean;
  93313. /**
  93314. * Gets a boolean indicating if the animation has started
  93315. */
  93316. animationStarted: boolean;
  93317. /**
  93318. * Observer raised when the animation ends
  93319. */
  93320. onAnimationEndObservable: Observable<Animatable>;
  93321. /**
  93322. * Observer raised when the animation loops
  93323. */
  93324. onAnimationLoopObservable: Observable<Animatable>;
  93325. /**
  93326. * Gets the root Animatable used to synchronize and normalize animations
  93327. */
  93328. get syncRoot(): Nullable<Animatable>;
  93329. /**
  93330. * Gets the current frame of the first RuntimeAnimation
  93331. * Used to synchronize Animatables
  93332. */
  93333. get masterFrame(): number;
  93334. /**
  93335. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93336. */
  93337. get weight(): number;
  93338. set weight(value: number);
  93339. /**
  93340. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93341. */
  93342. get speedRatio(): number;
  93343. set speedRatio(value: number);
  93344. /**
  93345. * Creates a new Animatable
  93346. * @param scene defines the hosting scene
  93347. * @param target defines the target object
  93348. * @param fromFrame defines the starting frame number (default is 0)
  93349. * @param toFrame defines the ending frame number (default is 100)
  93350. * @param loopAnimation defines if the animation must loop (default is false)
  93351. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93352. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93353. * @param animations defines a group of animation to add to the new Animatable
  93354. * @param onAnimationLoop defines a callback to call when animation loops
  93355. * @param isAdditive defines whether the animation should be evaluated additively
  93356. */
  93357. constructor(scene: Scene,
  93358. /** defines the target object */
  93359. target: any,
  93360. /** defines the starting frame number (default is 0) */
  93361. fromFrame?: number,
  93362. /** defines the ending frame number (default is 100) */
  93363. toFrame?: number,
  93364. /** defines if the animation must loop (default is false) */
  93365. loopAnimation?: boolean, speedRatio?: number,
  93366. /** defines a callback to call when animation ends if it is not looping */
  93367. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93368. /** defines a callback to call when animation loops */
  93369. onAnimationLoop?: (() => void) | null | undefined,
  93370. /** defines whether the animation should be evaluated additively */
  93371. isAdditive?: boolean);
  93372. /**
  93373. * Synchronize and normalize current Animatable with a source Animatable
  93374. * This is useful when using animation weights and when animations are not of the same length
  93375. * @param root defines the root Animatable to synchronize with
  93376. * @returns the current Animatable
  93377. */
  93378. syncWith(root: Animatable): Animatable;
  93379. /**
  93380. * Gets the list of runtime animations
  93381. * @returns an array of RuntimeAnimation
  93382. */
  93383. getAnimations(): RuntimeAnimation[];
  93384. /**
  93385. * Adds more animations to the current animatable
  93386. * @param target defines the target of the animations
  93387. * @param animations defines the new animations to add
  93388. */
  93389. appendAnimations(target: any, animations: Animation[]): void;
  93390. /**
  93391. * Gets the source animation for a specific property
  93392. * @param property defines the propertyu to look for
  93393. * @returns null or the source animation for the given property
  93394. */
  93395. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93396. /**
  93397. * Gets the runtime animation for a specific property
  93398. * @param property defines the propertyu to look for
  93399. * @returns null or the runtime animation for the given property
  93400. */
  93401. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93402. /**
  93403. * Resets the animatable to its original state
  93404. */
  93405. reset(): void;
  93406. /**
  93407. * Allows the animatable to blend with current running animations
  93408. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93409. * @param blendingSpeed defines the blending speed to use
  93410. */
  93411. enableBlending(blendingSpeed: number): void;
  93412. /**
  93413. * Disable animation blending
  93414. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93415. */
  93416. disableBlending(): void;
  93417. /**
  93418. * Jump directly to a given frame
  93419. * @param frame defines the frame to jump to
  93420. */
  93421. goToFrame(frame: number): void;
  93422. /**
  93423. * Pause the animation
  93424. */
  93425. pause(): void;
  93426. /**
  93427. * Restart the animation
  93428. */
  93429. restart(): void;
  93430. private _raiseOnAnimationEnd;
  93431. /**
  93432. * Stop and delete the current animation
  93433. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93434. * @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)
  93435. */
  93436. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93437. /**
  93438. * Wait asynchronously for the animation to end
  93439. * @returns a promise which will be fullfilled when the animation ends
  93440. */
  93441. waitAsync(): Promise<Animatable>;
  93442. /** @hidden */
  93443. _animate(delay: number): boolean;
  93444. }
  93445. interface Scene {
  93446. /** @hidden */
  93447. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93448. /** @hidden */
  93449. _processLateAnimationBindingsForMatrices(holder: {
  93450. totalWeight: number;
  93451. totalAdditiveWeight: number;
  93452. animations: RuntimeAnimation[];
  93453. additiveAnimations: RuntimeAnimation[];
  93454. originalValue: Matrix;
  93455. }): any;
  93456. /** @hidden */
  93457. _processLateAnimationBindingsForQuaternions(holder: {
  93458. totalWeight: number;
  93459. totalAdditiveWeight: number;
  93460. animations: RuntimeAnimation[];
  93461. additiveAnimations: RuntimeAnimation[];
  93462. originalValue: Quaternion;
  93463. }, refQuaternion: Quaternion): Quaternion;
  93464. /** @hidden */
  93465. _processLateAnimationBindings(): void;
  93466. /**
  93467. * Will start the animation sequence of a given target
  93468. * @param target defines the target
  93469. * @param from defines from which frame should animation start
  93470. * @param to defines until which frame should animation run.
  93471. * @param weight defines the weight to apply to the animation (1.0 by default)
  93472. * @param loop defines if the animation loops
  93473. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93474. * @param onAnimationEnd defines the function to be executed when the animation ends
  93475. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93476. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93477. * @param onAnimationLoop defines the callback to call when an animation loops
  93478. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93479. * @returns the animatable object created for this animation
  93480. */
  93481. 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;
  93482. /**
  93483. * Will start the animation sequence of a given target
  93484. * @param target defines the target
  93485. * @param from defines from which frame should animation start
  93486. * @param to defines until which frame should animation run.
  93487. * @param loop defines if the animation loops
  93488. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93489. * @param onAnimationEnd defines the function to be executed when the animation ends
  93490. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93491. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93492. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93493. * @param onAnimationLoop defines the callback to call when an animation loops
  93494. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93495. * @returns the animatable object created for this animation
  93496. */
  93497. 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;
  93498. /**
  93499. * Will start the animation sequence of a given target and its hierarchy
  93500. * @param target defines the target
  93501. * @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.
  93502. * @param from defines from which frame should animation start
  93503. * @param to defines until which frame should animation run.
  93504. * @param loop defines if the animation loops
  93505. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93506. * @param onAnimationEnd defines the function to be executed when the animation ends
  93507. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93508. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93509. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93510. * @param onAnimationLoop defines the callback to call when an animation loops
  93511. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93512. * @returns the list of created animatables
  93513. */
  93514. 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[];
  93515. /**
  93516. * Begin a new animation on a given node
  93517. * @param target defines the target where the animation will take place
  93518. * @param animations defines the list of animations to start
  93519. * @param from defines the initial value
  93520. * @param to defines the final value
  93521. * @param loop defines if you want animation to loop (off by default)
  93522. * @param speedRatio defines the speed ratio to apply to all animations
  93523. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93524. * @param onAnimationLoop defines the callback to call when an animation loops
  93525. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93526. * @returns the list of created animatables
  93527. */
  93528. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93529. /**
  93530. * Begin a new animation on a given node and its hierarchy
  93531. * @param target defines the root node where the animation will take place
  93532. * @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.
  93533. * @param animations defines the list of animations to start
  93534. * @param from defines the initial value
  93535. * @param to defines the final value
  93536. * @param loop defines if you want animation to loop (off by default)
  93537. * @param speedRatio defines the speed ratio to apply to all animations
  93538. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93539. * @param onAnimationLoop defines the callback to call when an animation loops
  93540. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93541. * @returns the list of animatables created for all nodes
  93542. */
  93543. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93544. /**
  93545. * Gets the animatable associated with a specific target
  93546. * @param target defines the target of the animatable
  93547. * @returns the required animatable if found
  93548. */
  93549. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93550. /**
  93551. * Gets all animatables associated with a given target
  93552. * @param target defines the target to look animatables for
  93553. * @returns an array of Animatables
  93554. */
  93555. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93556. /**
  93557. * Stops and removes all animations that have been applied to the scene
  93558. */
  93559. stopAllAnimations(): void;
  93560. /**
  93561. * Gets the current delta time used by animation engine
  93562. */
  93563. deltaTime: number;
  93564. }
  93565. interface Bone {
  93566. /**
  93567. * Copy an animation range from another bone
  93568. * @param source defines the source bone
  93569. * @param rangeName defines the range name to copy
  93570. * @param frameOffset defines the frame offset
  93571. * @param rescaleAsRequired defines if rescaling must be applied if required
  93572. * @param skelDimensionsRatio defines the scaling ratio
  93573. * @returns true if operation was successful
  93574. */
  93575. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93576. }
  93577. }
  93578. declare module BABYLON {
  93579. /**
  93580. * Class used to handle skinning animations
  93581. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93582. */
  93583. export class Skeleton implements IAnimatable {
  93584. /** defines the skeleton name */
  93585. name: string;
  93586. /** defines the skeleton Id */
  93587. id: string;
  93588. /**
  93589. * Defines the list of child bones
  93590. */
  93591. bones: Bone[];
  93592. /**
  93593. * Defines an estimate of the dimension of the skeleton at rest
  93594. */
  93595. dimensionsAtRest: Vector3;
  93596. /**
  93597. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  93598. */
  93599. needInitialSkinMatrix: boolean;
  93600. /**
  93601. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  93602. */
  93603. overrideMesh: Nullable<AbstractMesh>;
  93604. /**
  93605. * Gets the list of animations attached to this skeleton
  93606. */
  93607. animations: Array<Animation>;
  93608. private _scene;
  93609. private _isDirty;
  93610. private _transformMatrices;
  93611. private _transformMatrixTexture;
  93612. private _meshesWithPoseMatrix;
  93613. private _animatables;
  93614. private _identity;
  93615. private _synchronizedWithMesh;
  93616. private _ranges;
  93617. private _lastAbsoluteTransformsUpdateId;
  93618. private _canUseTextureForBones;
  93619. private _uniqueId;
  93620. /** @hidden */
  93621. _numBonesWithLinkedTransformNode: number;
  93622. /** @hidden */
  93623. _hasWaitingData: Nullable<boolean>;
  93624. /**
  93625. * Specifies if the skeleton should be serialized
  93626. */
  93627. doNotSerialize: boolean;
  93628. private _useTextureToStoreBoneMatrices;
  93629. /**
  93630. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  93631. * Please note that this option is not available if the hardware does not support it
  93632. */
  93633. get useTextureToStoreBoneMatrices(): boolean;
  93634. set useTextureToStoreBoneMatrices(value: boolean);
  93635. private _animationPropertiesOverride;
  93636. /**
  93637. * Gets or sets the animation properties override
  93638. */
  93639. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93640. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93641. /**
  93642. * List of inspectable custom properties (used by the Inspector)
  93643. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93644. */
  93645. inspectableCustomProperties: IInspectable[];
  93646. /**
  93647. * An observable triggered before computing the skeleton's matrices
  93648. */
  93649. onBeforeComputeObservable: Observable<Skeleton>;
  93650. /**
  93651. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  93652. */
  93653. get isUsingTextureForMatrices(): boolean;
  93654. /**
  93655. * Gets the unique ID of this skeleton
  93656. */
  93657. get uniqueId(): number;
  93658. /**
  93659. * Creates a new skeleton
  93660. * @param name defines the skeleton name
  93661. * @param id defines the skeleton Id
  93662. * @param scene defines the hosting scene
  93663. */
  93664. constructor(
  93665. /** defines the skeleton name */
  93666. name: string,
  93667. /** defines the skeleton Id */
  93668. id: string, scene: Scene);
  93669. /**
  93670. * Gets the current object class name.
  93671. * @return the class name
  93672. */
  93673. getClassName(): string;
  93674. /**
  93675. * Returns an array containing the root bones
  93676. * @returns an array containing the root bones
  93677. */
  93678. getChildren(): Array<Bone>;
  93679. /**
  93680. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  93681. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93682. * @returns a Float32Array containing matrices data
  93683. */
  93684. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  93685. /**
  93686. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  93687. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93688. * @returns a raw texture containing the data
  93689. */
  93690. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  93691. /**
  93692. * Gets the current hosting scene
  93693. * @returns a scene object
  93694. */
  93695. getScene(): Scene;
  93696. /**
  93697. * Gets a string representing the current skeleton data
  93698. * @param fullDetails defines a boolean indicating if we want a verbose version
  93699. * @returns a string representing the current skeleton data
  93700. */
  93701. toString(fullDetails?: boolean): string;
  93702. /**
  93703. * Get bone's index searching by name
  93704. * @param name defines bone's name to search for
  93705. * @return the indice of the bone. Returns -1 if not found
  93706. */
  93707. getBoneIndexByName(name: string): number;
  93708. /**
  93709. * Creater a new animation range
  93710. * @param name defines the name of the range
  93711. * @param from defines the start key
  93712. * @param to defines the end key
  93713. */
  93714. createAnimationRange(name: string, from: number, to: number): void;
  93715. /**
  93716. * Delete a specific animation range
  93717. * @param name defines the name of the range
  93718. * @param deleteFrames defines if frames must be removed as well
  93719. */
  93720. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93721. /**
  93722. * Gets a specific animation range
  93723. * @param name defines the name of the range to look for
  93724. * @returns the requested animation range or null if not found
  93725. */
  93726. getAnimationRange(name: string): Nullable<AnimationRange>;
  93727. /**
  93728. * Gets the list of all animation ranges defined on this skeleton
  93729. * @returns an array
  93730. */
  93731. getAnimationRanges(): Nullable<AnimationRange>[];
  93732. /**
  93733. * Copy animation range from a source skeleton.
  93734. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  93735. * @param source defines the source skeleton
  93736. * @param name defines the name of the range to copy
  93737. * @param rescaleAsRequired defines if rescaling must be applied if required
  93738. * @returns true if operation was successful
  93739. */
  93740. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  93741. /**
  93742. * Forces the skeleton to go to rest pose
  93743. */
  93744. returnToRest(): void;
  93745. private _getHighestAnimationFrame;
  93746. /**
  93747. * Begin a specific animation range
  93748. * @param name defines the name of the range to start
  93749. * @param loop defines if looping must be turned on (false by default)
  93750. * @param speedRatio defines the speed ratio to apply (1 by default)
  93751. * @param onAnimationEnd defines a callback which will be called when animation will end
  93752. * @returns a new animatable
  93753. */
  93754. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93755. /**
  93756. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  93757. * @param skeleton defines the Skeleton containing the animation range to convert
  93758. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  93759. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  93760. * @returns the original skeleton
  93761. */
  93762. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  93763. /** @hidden */
  93764. _markAsDirty(): void;
  93765. /** @hidden */
  93766. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93767. /** @hidden */
  93768. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93769. private _computeTransformMatrices;
  93770. /**
  93771. * Build all resources required to render a skeleton
  93772. */
  93773. prepare(): void;
  93774. /**
  93775. * Gets the list of animatables currently running for this skeleton
  93776. * @returns an array of animatables
  93777. */
  93778. getAnimatables(): IAnimatable[];
  93779. /**
  93780. * Clone the current skeleton
  93781. * @param name defines the name of the new skeleton
  93782. * @param id defines the id of the new skeleton
  93783. * @returns the new skeleton
  93784. */
  93785. clone(name: string, id?: string): Skeleton;
  93786. /**
  93787. * Enable animation blending for this skeleton
  93788. * @param blendingSpeed defines the blending speed to apply
  93789. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93790. */
  93791. enableBlending(blendingSpeed?: number): void;
  93792. /**
  93793. * Releases all resources associated with the current skeleton
  93794. */
  93795. dispose(): void;
  93796. /**
  93797. * Serialize the skeleton in a JSON object
  93798. * @returns a JSON object
  93799. */
  93800. serialize(): any;
  93801. /**
  93802. * Creates a new skeleton from serialized data
  93803. * @param parsedSkeleton defines the serialized data
  93804. * @param scene defines the hosting scene
  93805. * @returns a new skeleton
  93806. */
  93807. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  93808. /**
  93809. * Compute all node absolute transforms
  93810. * @param forceUpdate defines if computation must be done even if cache is up to date
  93811. */
  93812. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  93813. /**
  93814. * Gets the root pose matrix
  93815. * @returns a matrix
  93816. */
  93817. getPoseMatrix(): Nullable<Matrix>;
  93818. /**
  93819. * Sorts bones per internal index
  93820. */
  93821. sortBones(): void;
  93822. private _sortBones;
  93823. }
  93824. }
  93825. declare module BABYLON {
  93826. /**
  93827. * Creates an instance based on a source mesh.
  93828. */
  93829. export class InstancedMesh extends AbstractMesh {
  93830. private _sourceMesh;
  93831. private _currentLOD;
  93832. /** @hidden */
  93833. _indexInSourceMeshInstanceArray: number;
  93834. constructor(name: string, source: Mesh);
  93835. /**
  93836. * Returns the string "InstancedMesh".
  93837. */
  93838. getClassName(): string;
  93839. /** Gets the list of lights affecting that mesh */
  93840. get lightSources(): Light[];
  93841. _resyncLightSources(): void;
  93842. _resyncLightSource(light: Light): void;
  93843. _removeLightSource(light: Light, dispose: boolean): void;
  93844. /**
  93845. * If the source mesh receives shadows
  93846. */
  93847. get receiveShadows(): boolean;
  93848. /**
  93849. * The material of the source mesh
  93850. */
  93851. get material(): Nullable<Material>;
  93852. /**
  93853. * Visibility of the source mesh
  93854. */
  93855. get visibility(): number;
  93856. /**
  93857. * Skeleton of the source mesh
  93858. */
  93859. get skeleton(): Nullable<Skeleton>;
  93860. /**
  93861. * Rendering ground id of the source mesh
  93862. */
  93863. get renderingGroupId(): number;
  93864. set renderingGroupId(value: number);
  93865. /**
  93866. * Returns the total number of vertices (integer).
  93867. */
  93868. getTotalVertices(): number;
  93869. /**
  93870. * Returns a positive integer : the total number of indices in this mesh geometry.
  93871. * @returns the numner of indices or zero if the mesh has no geometry.
  93872. */
  93873. getTotalIndices(): number;
  93874. /**
  93875. * The source mesh of the instance
  93876. */
  93877. get sourceMesh(): Mesh;
  93878. /**
  93879. * Creates a new InstancedMesh object from the mesh model.
  93880. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93881. * @param name defines the name of the new instance
  93882. * @returns a new InstancedMesh
  93883. */
  93884. createInstance(name: string): InstancedMesh;
  93885. /**
  93886. * Is this node ready to be used/rendered
  93887. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93888. * @return {boolean} is it ready
  93889. */
  93890. isReady(completeCheck?: boolean): boolean;
  93891. /**
  93892. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93893. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93894. * @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.
  93895. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93896. */
  93897. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93898. /**
  93899. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93900. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93901. * The `data` are either a numeric array either a Float32Array.
  93902. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93903. * 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).
  93904. * Note that a new underlying VertexBuffer object is created each call.
  93905. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93906. *
  93907. * Possible `kind` values :
  93908. * - VertexBuffer.PositionKind
  93909. * - VertexBuffer.UVKind
  93910. * - VertexBuffer.UV2Kind
  93911. * - VertexBuffer.UV3Kind
  93912. * - VertexBuffer.UV4Kind
  93913. * - VertexBuffer.UV5Kind
  93914. * - VertexBuffer.UV6Kind
  93915. * - VertexBuffer.ColorKind
  93916. * - VertexBuffer.MatricesIndicesKind
  93917. * - VertexBuffer.MatricesIndicesExtraKind
  93918. * - VertexBuffer.MatricesWeightsKind
  93919. * - VertexBuffer.MatricesWeightsExtraKind
  93920. *
  93921. * Returns the Mesh.
  93922. */
  93923. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93924. /**
  93925. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93926. * If the mesh has no geometry, it is simply returned as it is.
  93927. * The `data` are either a numeric array either a Float32Array.
  93928. * No new underlying VertexBuffer object is created.
  93929. * 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.
  93930. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93931. *
  93932. * Possible `kind` values :
  93933. * - VertexBuffer.PositionKind
  93934. * - VertexBuffer.UVKind
  93935. * - VertexBuffer.UV2Kind
  93936. * - VertexBuffer.UV3Kind
  93937. * - VertexBuffer.UV4Kind
  93938. * - VertexBuffer.UV5Kind
  93939. * - VertexBuffer.UV6Kind
  93940. * - VertexBuffer.ColorKind
  93941. * - VertexBuffer.MatricesIndicesKind
  93942. * - VertexBuffer.MatricesIndicesExtraKind
  93943. * - VertexBuffer.MatricesWeightsKind
  93944. * - VertexBuffer.MatricesWeightsExtraKind
  93945. *
  93946. * Returns the Mesh.
  93947. */
  93948. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93949. /**
  93950. * Sets the mesh indices.
  93951. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93952. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93953. * This method creates a new index buffer each call.
  93954. * Returns the Mesh.
  93955. */
  93956. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93957. /**
  93958. * Boolean : True if the mesh owns the requested kind of data.
  93959. */
  93960. isVerticesDataPresent(kind: string): boolean;
  93961. /**
  93962. * Returns an array of indices (IndicesArray).
  93963. */
  93964. getIndices(): Nullable<IndicesArray>;
  93965. get _positions(): Nullable<Vector3[]>;
  93966. /**
  93967. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93968. * This means the mesh underlying bounding box and sphere are recomputed.
  93969. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93970. * @returns the current mesh
  93971. */
  93972. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93973. /** @hidden */
  93974. _preActivate(): InstancedMesh;
  93975. /** @hidden */
  93976. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93977. /** @hidden */
  93978. _postActivate(): void;
  93979. getWorldMatrix(): Matrix;
  93980. get isAnInstance(): boolean;
  93981. /**
  93982. * Returns the current associated LOD AbstractMesh.
  93983. */
  93984. getLOD(camera: Camera): AbstractMesh;
  93985. /** @hidden */
  93986. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93987. /** @hidden */
  93988. _syncSubMeshes(): InstancedMesh;
  93989. /** @hidden */
  93990. _generatePointsArray(): boolean;
  93991. /**
  93992. * Creates a new InstancedMesh from the current mesh.
  93993. * - name (string) : the cloned mesh name
  93994. * - newParent (optional Node) : the optional Node to parent the clone to.
  93995. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  93996. *
  93997. * Returns the clone.
  93998. */
  93999. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94000. /**
  94001. * Disposes the InstancedMesh.
  94002. * Returns nothing.
  94003. */
  94004. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94005. }
  94006. interface Mesh {
  94007. /**
  94008. * Register a custom buffer that will be instanced
  94009. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94010. * @param kind defines the buffer kind
  94011. * @param stride defines the stride in floats
  94012. */
  94013. registerInstancedBuffer(kind: string, stride: number): void;
  94014. /**
  94015. * true to use the edge renderer for all instances of this mesh
  94016. */
  94017. edgesShareWithInstances: boolean;
  94018. /** @hidden */
  94019. _userInstancedBuffersStorage: {
  94020. data: {
  94021. [key: string]: Float32Array;
  94022. };
  94023. sizes: {
  94024. [key: string]: number;
  94025. };
  94026. vertexBuffers: {
  94027. [key: string]: Nullable<VertexBuffer>;
  94028. };
  94029. strides: {
  94030. [key: string]: number;
  94031. };
  94032. };
  94033. }
  94034. interface AbstractMesh {
  94035. /**
  94036. * Object used to store instanced buffers defined by user
  94037. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94038. */
  94039. instancedBuffers: {
  94040. [key: string]: any;
  94041. };
  94042. }
  94043. }
  94044. declare module BABYLON {
  94045. /**
  94046. * Defines the options associated with the creation of a shader material.
  94047. */
  94048. export interface IShaderMaterialOptions {
  94049. /**
  94050. * Does the material work in alpha blend mode
  94051. */
  94052. needAlphaBlending: boolean;
  94053. /**
  94054. * Does the material work in alpha test mode
  94055. */
  94056. needAlphaTesting: boolean;
  94057. /**
  94058. * The list of attribute names used in the shader
  94059. */
  94060. attributes: string[];
  94061. /**
  94062. * The list of unifrom names used in the shader
  94063. */
  94064. uniforms: string[];
  94065. /**
  94066. * The list of UBO names used in the shader
  94067. */
  94068. uniformBuffers: string[];
  94069. /**
  94070. * The list of sampler names used in the shader
  94071. */
  94072. samplers: string[];
  94073. /**
  94074. * The list of defines used in the shader
  94075. */
  94076. defines: string[];
  94077. }
  94078. /**
  94079. * 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.
  94080. *
  94081. * This returned material effects how the mesh will look based on the code in the shaders.
  94082. *
  94083. * @see http://doc.babylonjs.com/how_to/shader_material
  94084. */
  94085. export class ShaderMaterial extends Material {
  94086. private _shaderPath;
  94087. private _options;
  94088. private _textures;
  94089. private _textureArrays;
  94090. private _floats;
  94091. private _ints;
  94092. private _floatsArrays;
  94093. private _colors3;
  94094. private _colors3Arrays;
  94095. private _colors4;
  94096. private _colors4Arrays;
  94097. private _vectors2;
  94098. private _vectors3;
  94099. private _vectors4;
  94100. private _matrices;
  94101. private _matrixArrays;
  94102. private _matrices3x3;
  94103. private _matrices2x2;
  94104. private _vectors2Arrays;
  94105. private _vectors3Arrays;
  94106. private _vectors4Arrays;
  94107. private _cachedWorldViewMatrix;
  94108. private _cachedWorldViewProjectionMatrix;
  94109. private _renderId;
  94110. private _multiview;
  94111. private _cachedDefines;
  94112. /** Define the Url to load snippets */
  94113. static SnippetUrl: string;
  94114. /** Snippet ID if the material was created from the snippet server */
  94115. snippetId: string;
  94116. /**
  94117. * Instantiate a new shader material.
  94118. * 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.
  94119. * This returned material effects how the mesh will look based on the code in the shaders.
  94120. * @see http://doc.babylonjs.com/how_to/shader_material
  94121. * @param name Define the name of the material in the scene
  94122. * @param scene Define the scene the material belongs to
  94123. * @param shaderPath Defines the route to the shader code in one of three ways:
  94124. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94125. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94126. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94127. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94128. * @param options Define the options used to create the shader
  94129. */
  94130. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94131. /**
  94132. * Gets the shader path used to define the shader code
  94133. * It can be modified to trigger a new compilation
  94134. */
  94135. get shaderPath(): any;
  94136. /**
  94137. * Sets the shader path used to define the shader code
  94138. * It can be modified to trigger a new compilation
  94139. */
  94140. set shaderPath(shaderPath: any);
  94141. /**
  94142. * Gets the options used to compile the shader.
  94143. * They can be modified to trigger a new compilation
  94144. */
  94145. get options(): IShaderMaterialOptions;
  94146. /**
  94147. * Gets the current class name of the material e.g. "ShaderMaterial"
  94148. * Mainly use in serialization.
  94149. * @returns the class name
  94150. */
  94151. getClassName(): string;
  94152. /**
  94153. * Specifies if the material will require alpha blending
  94154. * @returns a boolean specifying if alpha blending is needed
  94155. */
  94156. needAlphaBlending(): boolean;
  94157. /**
  94158. * Specifies if this material should be rendered in alpha test mode
  94159. * @returns a boolean specifying if an alpha test is needed.
  94160. */
  94161. needAlphaTesting(): boolean;
  94162. private _checkUniform;
  94163. /**
  94164. * Set a texture in the shader.
  94165. * @param name Define the name of the uniform samplers as defined in the shader
  94166. * @param texture Define the texture to bind to this sampler
  94167. * @return the material itself allowing "fluent" like uniform updates
  94168. */
  94169. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94170. /**
  94171. * Set a texture array in the shader.
  94172. * @param name Define the name of the uniform sampler array as defined in the shader
  94173. * @param textures Define the list of textures to bind to this sampler
  94174. * @return the material itself allowing "fluent" like uniform updates
  94175. */
  94176. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94177. /**
  94178. * Set a float in the shader.
  94179. * @param name Define the name of the uniform as defined in the shader
  94180. * @param value Define the value to give to the uniform
  94181. * @return the material itself allowing "fluent" like uniform updates
  94182. */
  94183. setFloat(name: string, value: number): ShaderMaterial;
  94184. /**
  94185. * Set a int in the shader.
  94186. * @param name Define the name of the uniform as defined in the shader
  94187. * @param value Define the value to give to the uniform
  94188. * @return the material itself allowing "fluent" like uniform updates
  94189. */
  94190. setInt(name: string, value: number): ShaderMaterial;
  94191. /**
  94192. * Set an array of floats in the shader.
  94193. * @param name Define the name of the uniform as defined in the shader
  94194. * @param value Define the value to give to the uniform
  94195. * @return the material itself allowing "fluent" like uniform updates
  94196. */
  94197. setFloats(name: string, value: number[]): ShaderMaterial;
  94198. /**
  94199. * Set a vec3 in the shader from a Color3.
  94200. * @param name Define the name of the uniform as defined in the shader
  94201. * @param value Define the value to give to the uniform
  94202. * @return the material itself allowing "fluent" like uniform updates
  94203. */
  94204. setColor3(name: string, value: Color3): ShaderMaterial;
  94205. /**
  94206. * Set a vec3 array in the shader from a Color3 array.
  94207. * @param name Define the name of the uniform as defined in the shader
  94208. * @param value Define the value to give to the uniform
  94209. * @return the material itself allowing "fluent" like uniform updates
  94210. */
  94211. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94212. /**
  94213. * Set a vec4 in the shader from a Color4.
  94214. * @param name Define the name of the uniform as defined in the shader
  94215. * @param value Define the value to give to the uniform
  94216. * @return the material itself allowing "fluent" like uniform updates
  94217. */
  94218. setColor4(name: string, value: Color4): ShaderMaterial;
  94219. /**
  94220. * Set a vec4 array in the shader from a Color4 array.
  94221. * @param name Define the name of the uniform as defined in the shader
  94222. * @param value Define the value to give to the uniform
  94223. * @return the material itself allowing "fluent" like uniform updates
  94224. */
  94225. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94226. /**
  94227. * Set a vec2 in the shader from a Vector2.
  94228. * @param name Define the name of the uniform as defined in the shader
  94229. * @param value Define the value to give to the uniform
  94230. * @return the material itself allowing "fluent" like uniform updates
  94231. */
  94232. setVector2(name: string, value: Vector2): ShaderMaterial;
  94233. /**
  94234. * Set a vec3 in the shader from a Vector3.
  94235. * @param name Define the name of the uniform as defined in the shader
  94236. * @param value Define the value to give to the uniform
  94237. * @return the material itself allowing "fluent" like uniform updates
  94238. */
  94239. setVector3(name: string, value: Vector3): ShaderMaterial;
  94240. /**
  94241. * Set a vec4 in the shader from a Vector4.
  94242. * @param name Define the name of the uniform as defined in the shader
  94243. * @param value Define the value to give to the uniform
  94244. * @return the material itself allowing "fluent" like uniform updates
  94245. */
  94246. setVector4(name: string, value: Vector4): ShaderMaterial;
  94247. /**
  94248. * Set a mat4 in the shader from a Matrix.
  94249. * @param name Define the name of the uniform as defined in the shader
  94250. * @param value Define the value to give to the uniform
  94251. * @return the material itself allowing "fluent" like uniform updates
  94252. */
  94253. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94254. /**
  94255. * Set a float32Array in the shader from a matrix array.
  94256. * @param name Define the name of the uniform as defined in the shader
  94257. * @param value Define the value to give to the uniform
  94258. * @return the material itself allowing "fluent" like uniform updates
  94259. */
  94260. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94261. /**
  94262. * Set a mat3 in the shader from a Float32Array.
  94263. * @param name Define the name of the uniform as defined in the shader
  94264. * @param value Define the value to give to the uniform
  94265. * @return the material itself allowing "fluent" like uniform updates
  94266. */
  94267. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94268. /**
  94269. * Set a mat2 in the shader from a Float32Array.
  94270. * @param name Define the name of the uniform as defined in the shader
  94271. * @param value Define the value to give to the uniform
  94272. * @return the material itself allowing "fluent" like uniform updates
  94273. */
  94274. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94275. /**
  94276. * Set a vec2 array in the shader from a number array.
  94277. * @param name Define the name of the uniform as defined in the shader
  94278. * @param value Define the value to give to the uniform
  94279. * @return the material itself allowing "fluent" like uniform updates
  94280. */
  94281. setArray2(name: string, value: number[]): ShaderMaterial;
  94282. /**
  94283. * Set a vec3 array in the shader from a number array.
  94284. * @param name Define the name of the uniform as defined in the shader
  94285. * @param value Define the value to give to the uniform
  94286. * @return the material itself allowing "fluent" like uniform updates
  94287. */
  94288. setArray3(name: string, value: number[]): ShaderMaterial;
  94289. /**
  94290. * Set a vec4 array in the shader from a number array.
  94291. * @param name Define the name of the uniform as defined in the shader
  94292. * @param value Define the value to give to the uniform
  94293. * @return the material itself allowing "fluent" like uniform updates
  94294. */
  94295. setArray4(name: string, value: number[]): ShaderMaterial;
  94296. private _checkCache;
  94297. /**
  94298. * Specifies that the submesh is ready to be used
  94299. * @param mesh defines the mesh to check
  94300. * @param subMesh defines which submesh to check
  94301. * @param useInstances specifies that instances should be used
  94302. * @returns a boolean indicating that the submesh is ready or not
  94303. */
  94304. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94305. /**
  94306. * Checks if the material is ready to render the requested mesh
  94307. * @param mesh Define the mesh to render
  94308. * @param useInstances Define whether or not the material is used with instances
  94309. * @returns true if ready, otherwise false
  94310. */
  94311. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94312. /**
  94313. * Binds the world matrix to the material
  94314. * @param world defines the world transformation matrix
  94315. * @param effectOverride - If provided, use this effect instead of internal effect
  94316. */
  94317. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94318. /**
  94319. * Binds the submesh to this material by preparing the effect and shader to draw
  94320. * @param world defines the world transformation matrix
  94321. * @param mesh defines the mesh containing the submesh
  94322. * @param subMesh defines the submesh to bind the material to
  94323. */
  94324. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94325. /**
  94326. * Binds the material to the mesh
  94327. * @param world defines the world transformation matrix
  94328. * @param mesh defines the mesh to bind the material to
  94329. * @param effectOverride - If provided, use this effect instead of internal effect
  94330. */
  94331. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94332. protected _afterBind(mesh?: Mesh): void;
  94333. /**
  94334. * Gets the active textures from the material
  94335. * @returns an array of textures
  94336. */
  94337. getActiveTextures(): BaseTexture[];
  94338. /**
  94339. * Specifies if the material uses a texture
  94340. * @param texture defines the texture to check against the material
  94341. * @returns a boolean specifying if the material uses the texture
  94342. */
  94343. hasTexture(texture: BaseTexture): boolean;
  94344. /**
  94345. * Makes a duplicate of the material, and gives it a new name
  94346. * @param name defines the new name for the duplicated material
  94347. * @returns the cloned material
  94348. */
  94349. clone(name: string): ShaderMaterial;
  94350. /**
  94351. * Disposes the material
  94352. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94353. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94354. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94355. */
  94356. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94357. /**
  94358. * Serializes this material in a JSON representation
  94359. * @returns the serialized material object
  94360. */
  94361. serialize(): any;
  94362. /**
  94363. * Creates a shader material from parsed shader material data
  94364. * @param source defines the JSON represnetation of the material
  94365. * @param scene defines the hosting scene
  94366. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94367. * @returns a new material
  94368. */
  94369. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94370. /**
  94371. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94372. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94373. * @param url defines the url to load from
  94374. * @param scene defines the hosting scene
  94375. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94376. * @returns a promise that will resolve to the new ShaderMaterial
  94377. */
  94378. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94379. /**
  94380. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94381. * @param snippetId defines the snippet to load
  94382. * @param scene defines the hosting scene
  94383. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94384. * @returns a promise that will resolve to the new ShaderMaterial
  94385. */
  94386. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94387. }
  94388. }
  94389. declare module BABYLON {
  94390. /** @hidden */
  94391. export var colorPixelShader: {
  94392. name: string;
  94393. shader: string;
  94394. };
  94395. }
  94396. declare module BABYLON {
  94397. /** @hidden */
  94398. export var colorVertexShader: {
  94399. name: string;
  94400. shader: string;
  94401. };
  94402. }
  94403. declare module BABYLON {
  94404. /**
  94405. * Line mesh
  94406. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94407. */
  94408. export class LinesMesh extends Mesh {
  94409. /**
  94410. * If vertex color should be applied to the mesh
  94411. */
  94412. readonly useVertexColor?: boolean | undefined;
  94413. /**
  94414. * If vertex alpha should be applied to the mesh
  94415. */
  94416. readonly useVertexAlpha?: boolean | undefined;
  94417. /**
  94418. * Color of the line (Default: White)
  94419. */
  94420. color: Color3;
  94421. /**
  94422. * Alpha of the line (Default: 1)
  94423. */
  94424. alpha: number;
  94425. /**
  94426. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94427. * This margin is expressed in world space coordinates, so its value may vary.
  94428. * Default value is 0.1
  94429. */
  94430. intersectionThreshold: number;
  94431. private _colorShader;
  94432. private color4;
  94433. /**
  94434. * Creates a new LinesMesh
  94435. * @param name defines the name
  94436. * @param scene defines the hosting scene
  94437. * @param parent defines the parent mesh if any
  94438. * @param source defines the optional source LinesMesh used to clone data from
  94439. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94440. * When false, achieved by calling a clone(), also passing False.
  94441. * This will make creation of children, recursive.
  94442. * @param useVertexColor defines if this LinesMesh supports vertex color
  94443. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94444. */
  94445. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94446. /**
  94447. * If vertex color should be applied to the mesh
  94448. */
  94449. useVertexColor?: boolean | undefined,
  94450. /**
  94451. * If vertex alpha should be applied to the mesh
  94452. */
  94453. useVertexAlpha?: boolean | undefined);
  94454. private _addClipPlaneDefine;
  94455. private _removeClipPlaneDefine;
  94456. isReady(): boolean;
  94457. /**
  94458. * Returns the string "LineMesh"
  94459. */
  94460. getClassName(): string;
  94461. /**
  94462. * @hidden
  94463. */
  94464. get material(): Material;
  94465. /**
  94466. * @hidden
  94467. */
  94468. set material(value: Material);
  94469. /**
  94470. * @hidden
  94471. */
  94472. get checkCollisions(): boolean;
  94473. /** @hidden */
  94474. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94475. /** @hidden */
  94476. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94477. /**
  94478. * Disposes of the line mesh
  94479. * @param doNotRecurse If children should be disposed
  94480. */
  94481. dispose(doNotRecurse?: boolean): void;
  94482. /**
  94483. * Returns a new LineMesh object cloned from the current one.
  94484. */
  94485. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94486. /**
  94487. * Creates a new InstancedLinesMesh object from the mesh model.
  94488. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94489. * @param name defines the name of the new instance
  94490. * @returns a new InstancedLinesMesh
  94491. */
  94492. createInstance(name: string): InstancedLinesMesh;
  94493. }
  94494. /**
  94495. * Creates an instance based on a source LinesMesh
  94496. */
  94497. export class InstancedLinesMesh extends InstancedMesh {
  94498. /**
  94499. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94500. * This margin is expressed in world space coordinates, so its value may vary.
  94501. * Initilized with the intersectionThreshold value of the source LinesMesh
  94502. */
  94503. intersectionThreshold: number;
  94504. constructor(name: string, source: LinesMesh);
  94505. /**
  94506. * Returns the string "InstancedLinesMesh".
  94507. */
  94508. getClassName(): string;
  94509. }
  94510. }
  94511. declare module BABYLON {
  94512. /** @hidden */
  94513. export var linePixelShader: {
  94514. name: string;
  94515. shader: string;
  94516. };
  94517. }
  94518. declare module BABYLON {
  94519. /** @hidden */
  94520. export var lineVertexShader: {
  94521. name: string;
  94522. shader: string;
  94523. };
  94524. }
  94525. declare module BABYLON {
  94526. interface Scene {
  94527. /** @hidden */
  94528. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  94529. }
  94530. interface AbstractMesh {
  94531. /**
  94532. * Gets the edgesRenderer associated with the mesh
  94533. */
  94534. edgesRenderer: Nullable<EdgesRenderer>;
  94535. }
  94536. interface LinesMesh {
  94537. /**
  94538. * Enables the edge rendering mode on the mesh.
  94539. * This mode makes the mesh edges visible
  94540. * @param epsilon defines the maximal distance between two angles to detect a face
  94541. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94542. * @returns the currentAbstractMesh
  94543. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94544. */
  94545. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94546. }
  94547. interface InstancedLinesMesh {
  94548. /**
  94549. * Enables the edge rendering mode on the mesh.
  94550. * This mode makes the mesh edges visible
  94551. * @param epsilon defines the maximal distance between two angles to detect a face
  94552. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94553. * @returns the current InstancedLinesMesh
  94554. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94555. */
  94556. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94557. }
  94558. /**
  94559. * Defines the minimum contract an Edges renderer should follow.
  94560. */
  94561. export interface IEdgesRenderer extends IDisposable {
  94562. /**
  94563. * Gets or sets a boolean indicating if the edgesRenderer is active
  94564. */
  94565. isEnabled: boolean;
  94566. /**
  94567. * Renders the edges of the attached mesh,
  94568. */
  94569. render(): void;
  94570. /**
  94571. * Checks wether or not the edges renderer is ready to render.
  94572. * @return true if ready, otherwise false.
  94573. */
  94574. isReady(): boolean;
  94575. /**
  94576. * List of instances to render in case the source mesh has instances
  94577. */
  94578. customInstances: SmartArray<Matrix>;
  94579. }
  94580. /**
  94581. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94582. */
  94583. export class EdgesRenderer implements IEdgesRenderer {
  94584. /**
  94585. * Define the size of the edges with an orthographic camera
  94586. */
  94587. edgesWidthScalerForOrthographic: number;
  94588. /**
  94589. * Define the size of the edges with a perspective camera
  94590. */
  94591. edgesWidthScalerForPerspective: number;
  94592. protected _source: AbstractMesh;
  94593. protected _linesPositions: number[];
  94594. protected _linesNormals: number[];
  94595. protected _linesIndices: number[];
  94596. protected _epsilon: number;
  94597. protected _indicesCount: number;
  94598. protected _lineShader: ShaderMaterial;
  94599. protected _ib: DataBuffer;
  94600. protected _buffers: {
  94601. [key: string]: Nullable<VertexBuffer>;
  94602. };
  94603. protected _buffersForInstances: {
  94604. [key: string]: Nullable<VertexBuffer>;
  94605. };
  94606. protected _checkVerticesInsteadOfIndices: boolean;
  94607. private _meshRebuildObserver;
  94608. private _meshDisposeObserver;
  94609. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  94610. isEnabled: boolean;
  94611. /**
  94612. * List of instances to render in case the source mesh has instances
  94613. */
  94614. customInstances: SmartArray<Matrix>;
  94615. private static GetShader;
  94616. /**
  94617. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  94618. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  94619. * @param source Mesh used to create edges
  94620. * @param epsilon sum of angles in adjacency to check for edge
  94621. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  94622. * @param generateEdgesLines - should generate Lines or only prepare resources.
  94623. */
  94624. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  94625. protected _prepareRessources(): void;
  94626. /** @hidden */
  94627. _rebuild(): void;
  94628. /**
  94629. * Releases the required resources for the edges renderer
  94630. */
  94631. dispose(): void;
  94632. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  94633. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  94634. /**
  94635. * Checks if the pair of p0 and p1 is en edge
  94636. * @param faceIndex
  94637. * @param edge
  94638. * @param faceNormals
  94639. * @param p0
  94640. * @param p1
  94641. * @private
  94642. */
  94643. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  94644. /**
  94645. * push line into the position, normal and index buffer
  94646. * @protected
  94647. */
  94648. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  94649. /**
  94650. * Generates lines edges from adjacencjes
  94651. * @private
  94652. */
  94653. _generateEdgesLines(): void;
  94654. /**
  94655. * Checks wether or not the edges renderer is ready to render.
  94656. * @return true if ready, otherwise false.
  94657. */
  94658. isReady(): boolean;
  94659. /**
  94660. * Renders the edges of the attached mesh,
  94661. */
  94662. render(): void;
  94663. }
  94664. /**
  94665. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  94666. */
  94667. export class LineEdgesRenderer extends EdgesRenderer {
  94668. /**
  94669. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  94670. * @param source LineMesh used to generate edges
  94671. * @param epsilon not important (specified angle for edge detection)
  94672. * @param checkVerticesInsteadOfIndices not important for LineMesh
  94673. */
  94674. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  94675. /**
  94676. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  94677. */
  94678. _generateEdgesLines(): void;
  94679. }
  94680. }
  94681. declare module BABYLON {
  94682. /**
  94683. * This represents the object necessary to create a rendering group.
  94684. * This is exclusively used and created by the rendering manager.
  94685. * To modify the behavior, you use the available helpers in your scene or meshes.
  94686. * @hidden
  94687. */
  94688. export class RenderingGroup {
  94689. index: number;
  94690. private static _zeroVector;
  94691. private _scene;
  94692. private _opaqueSubMeshes;
  94693. private _transparentSubMeshes;
  94694. private _alphaTestSubMeshes;
  94695. private _depthOnlySubMeshes;
  94696. private _particleSystems;
  94697. private _spriteManagers;
  94698. private _opaqueSortCompareFn;
  94699. private _alphaTestSortCompareFn;
  94700. private _transparentSortCompareFn;
  94701. private _renderOpaque;
  94702. private _renderAlphaTest;
  94703. private _renderTransparent;
  94704. /** @hidden */
  94705. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  94706. onBeforeTransparentRendering: () => void;
  94707. /**
  94708. * Set the opaque sort comparison function.
  94709. * If null the sub meshes will be render in the order they were created
  94710. */
  94711. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94712. /**
  94713. * Set the alpha test sort comparison function.
  94714. * If null the sub meshes will be render in the order they were created
  94715. */
  94716. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94717. /**
  94718. * Set the transparent sort comparison function.
  94719. * If null the sub meshes will be render in the order they were created
  94720. */
  94721. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94722. /**
  94723. * Creates a new rendering group.
  94724. * @param index The rendering group index
  94725. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  94726. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  94727. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  94728. */
  94729. 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>);
  94730. /**
  94731. * Render all the sub meshes contained in the group.
  94732. * @param customRenderFunction Used to override the default render behaviour of the group.
  94733. * @returns true if rendered some submeshes.
  94734. */
  94735. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  94736. /**
  94737. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  94738. * @param subMeshes The submeshes to render
  94739. */
  94740. private renderOpaqueSorted;
  94741. /**
  94742. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  94743. * @param subMeshes The submeshes to render
  94744. */
  94745. private renderAlphaTestSorted;
  94746. /**
  94747. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  94748. * @param subMeshes The submeshes to render
  94749. */
  94750. private renderTransparentSorted;
  94751. /**
  94752. * Renders the submeshes in a specified order.
  94753. * @param subMeshes The submeshes to sort before render
  94754. * @param sortCompareFn The comparison function use to sort
  94755. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  94756. * @param transparent Specifies to activate blending if true
  94757. */
  94758. private static renderSorted;
  94759. /**
  94760. * Renders the submeshes in the order they were dispatched (no sort applied).
  94761. * @param subMeshes The submeshes to render
  94762. */
  94763. private static renderUnsorted;
  94764. /**
  94765. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94766. * are rendered back to front if in the same alpha index.
  94767. *
  94768. * @param a The first submesh
  94769. * @param b The second submesh
  94770. * @returns The result of the comparison
  94771. */
  94772. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  94773. /**
  94774. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94775. * are rendered back to front.
  94776. *
  94777. * @param a The first submesh
  94778. * @param b The second submesh
  94779. * @returns The result of the comparison
  94780. */
  94781. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  94782. /**
  94783. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94784. * are rendered front to back (prevent overdraw).
  94785. *
  94786. * @param a The first submesh
  94787. * @param b The second submesh
  94788. * @returns The result of the comparison
  94789. */
  94790. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  94791. /**
  94792. * Resets the different lists of submeshes to prepare a new frame.
  94793. */
  94794. prepare(): void;
  94795. dispose(): void;
  94796. /**
  94797. * Inserts the submesh in its correct queue depending on its material.
  94798. * @param subMesh The submesh to dispatch
  94799. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94800. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94801. */
  94802. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94803. dispatchSprites(spriteManager: ISpriteManager): void;
  94804. dispatchParticles(particleSystem: IParticleSystem): void;
  94805. private _renderParticles;
  94806. private _renderSprites;
  94807. }
  94808. }
  94809. declare module BABYLON {
  94810. /**
  94811. * Interface describing the different options available in the rendering manager
  94812. * regarding Auto Clear between groups.
  94813. */
  94814. export interface IRenderingManagerAutoClearSetup {
  94815. /**
  94816. * Defines whether or not autoclear is enable.
  94817. */
  94818. autoClear: boolean;
  94819. /**
  94820. * Defines whether or not to autoclear the depth buffer.
  94821. */
  94822. depth: boolean;
  94823. /**
  94824. * Defines whether or not to autoclear the stencil buffer.
  94825. */
  94826. stencil: boolean;
  94827. }
  94828. /**
  94829. * This class is used by the onRenderingGroupObservable
  94830. */
  94831. export class RenderingGroupInfo {
  94832. /**
  94833. * The Scene that being rendered
  94834. */
  94835. scene: Scene;
  94836. /**
  94837. * The camera currently used for the rendering pass
  94838. */
  94839. camera: Nullable<Camera>;
  94840. /**
  94841. * The ID of the renderingGroup being processed
  94842. */
  94843. renderingGroupId: number;
  94844. }
  94845. /**
  94846. * This is the manager responsible of all the rendering for meshes sprites and particles.
  94847. * It is enable to manage the different groups as well as the different necessary sort functions.
  94848. * This should not be used directly aside of the few static configurations
  94849. */
  94850. export class RenderingManager {
  94851. /**
  94852. * The max id used for rendering groups (not included)
  94853. */
  94854. static MAX_RENDERINGGROUPS: number;
  94855. /**
  94856. * The min id used for rendering groups (included)
  94857. */
  94858. static MIN_RENDERINGGROUPS: number;
  94859. /**
  94860. * Used to globally prevent autoclearing scenes.
  94861. */
  94862. static AUTOCLEAR: boolean;
  94863. /**
  94864. * @hidden
  94865. */
  94866. _useSceneAutoClearSetup: boolean;
  94867. private _scene;
  94868. private _renderingGroups;
  94869. private _depthStencilBufferAlreadyCleaned;
  94870. private _autoClearDepthStencil;
  94871. private _customOpaqueSortCompareFn;
  94872. private _customAlphaTestSortCompareFn;
  94873. private _customTransparentSortCompareFn;
  94874. private _renderingGroupInfo;
  94875. /**
  94876. * Instantiates a new rendering group for a particular scene
  94877. * @param scene Defines the scene the groups belongs to
  94878. */
  94879. constructor(scene: Scene);
  94880. private _clearDepthStencilBuffer;
  94881. /**
  94882. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94883. * @hidden
  94884. */
  94885. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94886. /**
  94887. * Resets the different information of the group to prepare a new frame
  94888. * @hidden
  94889. */
  94890. reset(): void;
  94891. /**
  94892. * Dispose and release the group and its associated resources.
  94893. * @hidden
  94894. */
  94895. dispose(): void;
  94896. /**
  94897. * Clear the info related to rendering groups preventing retention points during dispose.
  94898. */
  94899. freeRenderingGroups(): void;
  94900. private _prepareRenderingGroup;
  94901. /**
  94902. * Add a sprite manager to the rendering manager in order to render it this frame.
  94903. * @param spriteManager Define the sprite manager to render
  94904. */
  94905. dispatchSprites(spriteManager: ISpriteManager): void;
  94906. /**
  94907. * Add a particle system to the rendering manager in order to render it this frame.
  94908. * @param particleSystem Define the particle system to render
  94909. */
  94910. dispatchParticles(particleSystem: IParticleSystem): void;
  94911. /**
  94912. * Add a submesh to the manager in order to render it this frame
  94913. * @param subMesh The submesh to dispatch
  94914. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94915. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94916. */
  94917. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94918. /**
  94919. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94920. * This allowed control for front to back rendering or reversly depending of the special needs.
  94921. *
  94922. * @param renderingGroupId The rendering group id corresponding to its index
  94923. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94924. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94925. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94926. */
  94927. 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;
  94928. /**
  94929. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94930. *
  94931. * @param renderingGroupId The rendering group id corresponding to its index
  94932. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94933. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94934. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94935. */
  94936. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94937. /**
  94938. * Gets the current auto clear configuration for one rendering group of the rendering
  94939. * manager.
  94940. * @param index the rendering group index to get the information for
  94941. * @returns The auto clear setup for the requested rendering group
  94942. */
  94943. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94944. }
  94945. }
  94946. declare module BABYLON {
  94947. /**
  94948. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94949. */
  94950. export interface ICustomShaderOptions {
  94951. /**
  94952. * Gets or sets the custom shader name to use
  94953. */
  94954. shaderName: string;
  94955. /**
  94956. * The list of attribute names used in the shader
  94957. */
  94958. attributes?: string[];
  94959. /**
  94960. * The list of unifrom names used in the shader
  94961. */
  94962. uniforms?: string[];
  94963. /**
  94964. * The list of sampler names used in the shader
  94965. */
  94966. samplers?: string[];
  94967. /**
  94968. * The list of defines used in the shader
  94969. */
  94970. defines?: string[];
  94971. }
  94972. /**
  94973. * Interface to implement to create a shadow generator compatible with BJS.
  94974. */
  94975. export interface IShadowGenerator {
  94976. /**
  94977. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94978. * @returns The render target texture if present otherwise, null
  94979. */
  94980. getShadowMap(): Nullable<RenderTargetTexture>;
  94981. /**
  94982. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94983. * @param subMesh The submesh we want to render in the shadow map
  94984. * @param useInstances Defines wether will draw in the map using instances
  94985. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94986. * @returns true if ready otherwise, false
  94987. */
  94988. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94989. /**
  94990. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94991. * @param defines Defines of the material we want to update
  94992. * @param lightIndex Index of the light in the enabled light list of the material
  94993. */
  94994. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  94995. /**
  94996. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94997. * defined in the generator but impacting the effect).
  94998. * It implies the unifroms available on the materials are the standard BJS ones.
  94999. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95000. * @param effect The effect we are binfing the information for
  95001. */
  95002. bindShadowLight(lightIndex: string, effect: Effect): void;
  95003. /**
  95004. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95005. * (eq to shadow prjection matrix * light transform matrix)
  95006. * @returns The transform matrix used to create the shadow map
  95007. */
  95008. getTransformMatrix(): Matrix;
  95009. /**
  95010. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95011. * Cube and 2D textures for instance.
  95012. */
  95013. recreateShadowMap(): void;
  95014. /**
  95015. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95016. * @param onCompiled Callback triggered at the and of the effects compilation
  95017. * @param options Sets of optional options forcing the compilation with different modes
  95018. */
  95019. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95020. useInstances: boolean;
  95021. }>): void;
  95022. /**
  95023. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95024. * @param options Sets of optional options forcing the compilation with different modes
  95025. * @returns A promise that resolves when the compilation completes
  95026. */
  95027. forceCompilationAsync(options?: Partial<{
  95028. useInstances: boolean;
  95029. }>): Promise<void>;
  95030. /**
  95031. * Serializes the shadow generator setup to a json object.
  95032. * @returns The serialized JSON object
  95033. */
  95034. serialize(): any;
  95035. /**
  95036. * Disposes the Shadow map and related Textures and effects.
  95037. */
  95038. dispose(): void;
  95039. }
  95040. /**
  95041. * Default implementation IShadowGenerator.
  95042. * This is the main object responsible of generating shadows in the framework.
  95043. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95044. */
  95045. export class ShadowGenerator implements IShadowGenerator {
  95046. /**
  95047. * Name of the shadow generator class
  95048. */
  95049. static CLASSNAME: string;
  95050. /**
  95051. * Shadow generator mode None: no filtering applied.
  95052. */
  95053. static readonly FILTER_NONE: number;
  95054. /**
  95055. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95056. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95057. */
  95058. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95059. /**
  95060. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95061. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95062. */
  95063. static readonly FILTER_POISSONSAMPLING: number;
  95064. /**
  95065. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95066. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95067. */
  95068. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95069. /**
  95070. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95071. * edge artifacts on steep falloff.
  95072. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95073. */
  95074. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95075. /**
  95076. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95077. * edge artifacts on steep falloff.
  95078. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95079. */
  95080. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95081. /**
  95082. * Shadow generator mode PCF: Percentage Closer Filtering
  95083. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95084. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95085. */
  95086. static readonly FILTER_PCF: number;
  95087. /**
  95088. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95089. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95090. * Contact Hardening
  95091. */
  95092. static readonly FILTER_PCSS: number;
  95093. /**
  95094. * Reserved for PCF and PCSS
  95095. * Highest Quality.
  95096. *
  95097. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95098. *
  95099. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95100. */
  95101. static readonly QUALITY_HIGH: number;
  95102. /**
  95103. * Reserved for PCF and PCSS
  95104. * Good tradeoff for quality/perf cross devices
  95105. *
  95106. * Execute PCF on a 3*3 kernel.
  95107. *
  95108. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95109. */
  95110. static readonly QUALITY_MEDIUM: number;
  95111. /**
  95112. * Reserved for PCF and PCSS
  95113. * The lowest quality but the fastest.
  95114. *
  95115. * Execute PCF on a 1*1 kernel.
  95116. *
  95117. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95118. */
  95119. static readonly QUALITY_LOW: number;
  95120. /** Gets or sets the custom shader name to use */
  95121. customShaderOptions: ICustomShaderOptions;
  95122. /**
  95123. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95124. */
  95125. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95126. /**
  95127. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95128. */
  95129. onAfterShadowMapRenderObservable: Observable<Effect>;
  95130. /**
  95131. * Observable triggered before a mesh is rendered in the shadow map.
  95132. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95133. */
  95134. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95135. /**
  95136. * Observable triggered after a mesh is rendered in the shadow map.
  95137. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95138. */
  95139. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95140. protected _bias: number;
  95141. /**
  95142. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95143. */
  95144. get bias(): number;
  95145. /**
  95146. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95147. */
  95148. set bias(bias: number);
  95149. protected _normalBias: number;
  95150. /**
  95151. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95152. */
  95153. get normalBias(): number;
  95154. /**
  95155. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95156. */
  95157. set normalBias(normalBias: number);
  95158. protected _blurBoxOffset: number;
  95159. /**
  95160. * Gets the blur box offset: offset applied during the blur pass.
  95161. * Only useful if useKernelBlur = false
  95162. */
  95163. get blurBoxOffset(): number;
  95164. /**
  95165. * Sets the blur box offset: offset applied during the blur pass.
  95166. * Only useful if useKernelBlur = false
  95167. */
  95168. set blurBoxOffset(value: number);
  95169. protected _blurScale: number;
  95170. /**
  95171. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95172. * 2 means half of the size.
  95173. */
  95174. get blurScale(): number;
  95175. /**
  95176. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95177. * 2 means half of the size.
  95178. */
  95179. set blurScale(value: number);
  95180. protected _blurKernel: number;
  95181. /**
  95182. * Gets the blur kernel: kernel size of the blur pass.
  95183. * Only useful if useKernelBlur = true
  95184. */
  95185. get blurKernel(): number;
  95186. /**
  95187. * Sets the blur kernel: kernel size of the blur pass.
  95188. * Only useful if useKernelBlur = true
  95189. */
  95190. set blurKernel(value: number);
  95191. protected _useKernelBlur: boolean;
  95192. /**
  95193. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95194. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95195. */
  95196. get useKernelBlur(): boolean;
  95197. /**
  95198. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95199. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95200. */
  95201. set useKernelBlur(value: boolean);
  95202. protected _depthScale: number;
  95203. /**
  95204. * Gets the depth scale used in ESM mode.
  95205. */
  95206. get depthScale(): number;
  95207. /**
  95208. * Sets the depth scale used in ESM mode.
  95209. * This can override the scale stored on the light.
  95210. */
  95211. set depthScale(value: number);
  95212. protected _validateFilter(filter: number): number;
  95213. protected _filter: number;
  95214. /**
  95215. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95216. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95217. */
  95218. get filter(): number;
  95219. /**
  95220. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95221. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95222. */
  95223. set filter(value: number);
  95224. /**
  95225. * Gets if the current filter is set to Poisson Sampling.
  95226. */
  95227. get usePoissonSampling(): boolean;
  95228. /**
  95229. * Sets the current filter to Poisson Sampling.
  95230. */
  95231. set usePoissonSampling(value: boolean);
  95232. /**
  95233. * Gets if the current filter is set to ESM.
  95234. */
  95235. get useExponentialShadowMap(): boolean;
  95236. /**
  95237. * Sets the current filter is to ESM.
  95238. */
  95239. set useExponentialShadowMap(value: boolean);
  95240. /**
  95241. * Gets if the current filter is set to filtered ESM.
  95242. */
  95243. get useBlurExponentialShadowMap(): boolean;
  95244. /**
  95245. * Gets if the current filter is set to filtered ESM.
  95246. */
  95247. set useBlurExponentialShadowMap(value: boolean);
  95248. /**
  95249. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95250. * exponential to prevent steep falloff artifacts).
  95251. */
  95252. get useCloseExponentialShadowMap(): boolean;
  95253. /**
  95254. * Sets the current filter to "close ESM" (using the inverse of the
  95255. * exponential to prevent steep falloff artifacts).
  95256. */
  95257. set useCloseExponentialShadowMap(value: boolean);
  95258. /**
  95259. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95260. * exponential to prevent steep falloff artifacts).
  95261. */
  95262. get useBlurCloseExponentialShadowMap(): boolean;
  95263. /**
  95264. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95265. * exponential to prevent steep falloff artifacts).
  95266. */
  95267. set useBlurCloseExponentialShadowMap(value: boolean);
  95268. /**
  95269. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95270. */
  95271. get usePercentageCloserFiltering(): boolean;
  95272. /**
  95273. * Sets the current filter to "PCF" (percentage closer filtering).
  95274. */
  95275. set usePercentageCloserFiltering(value: boolean);
  95276. protected _filteringQuality: number;
  95277. /**
  95278. * Gets the PCF or PCSS Quality.
  95279. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95280. */
  95281. get filteringQuality(): number;
  95282. /**
  95283. * Sets the PCF or PCSS Quality.
  95284. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95285. */
  95286. set filteringQuality(filteringQuality: number);
  95287. /**
  95288. * Gets if the current filter is set to "PCSS" (contact hardening).
  95289. */
  95290. get useContactHardeningShadow(): boolean;
  95291. /**
  95292. * Sets the current filter to "PCSS" (contact hardening).
  95293. */
  95294. set useContactHardeningShadow(value: boolean);
  95295. protected _contactHardeningLightSizeUVRatio: number;
  95296. /**
  95297. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95298. * Using a ratio helps keeping shape stability independently of the map size.
  95299. *
  95300. * It does not account for the light projection as it was having too much
  95301. * instability during the light setup or during light position changes.
  95302. *
  95303. * Only valid if useContactHardeningShadow is true.
  95304. */
  95305. get contactHardeningLightSizeUVRatio(): number;
  95306. /**
  95307. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95308. * Using a ratio helps keeping shape stability independently of the map size.
  95309. *
  95310. * It does not account for the light projection as it was having too much
  95311. * instability during the light setup or during light position changes.
  95312. *
  95313. * Only valid if useContactHardeningShadow is true.
  95314. */
  95315. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95316. protected _darkness: number;
  95317. /** Gets or sets the actual darkness of a shadow */
  95318. get darkness(): number;
  95319. set darkness(value: number);
  95320. /**
  95321. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95322. * 0 means strongest and 1 would means no shadow.
  95323. * @returns the darkness.
  95324. */
  95325. getDarkness(): number;
  95326. /**
  95327. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95328. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95329. * @returns the shadow generator allowing fluent coding.
  95330. */
  95331. setDarkness(darkness: number): ShadowGenerator;
  95332. protected _transparencyShadow: boolean;
  95333. /** Gets or sets the ability to have transparent shadow */
  95334. get transparencyShadow(): boolean;
  95335. set transparencyShadow(value: boolean);
  95336. /**
  95337. * Sets the ability to have transparent shadow (boolean).
  95338. * @param transparent True if transparent else False
  95339. * @returns the shadow generator allowing fluent coding
  95340. */
  95341. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95342. /**
  95343. * Enables or disables shadows with varying strength based on the transparency
  95344. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95345. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95346. * mesh.visibility * alphaTexture.a
  95347. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95348. */
  95349. enableSoftTransparentShadow: boolean;
  95350. protected _shadowMap: Nullable<RenderTargetTexture>;
  95351. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95352. /**
  95353. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95354. * @returns The render target texture if present otherwise, null
  95355. */
  95356. getShadowMap(): Nullable<RenderTargetTexture>;
  95357. /**
  95358. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95359. * @returns The render target texture if the shadow map is present otherwise, null
  95360. */
  95361. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95362. /**
  95363. * Gets the class name of that object
  95364. * @returns "ShadowGenerator"
  95365. */
  95366. getClassName(): string;
  95367. /**
  95368. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95369. * @param mesh Mesh to add
  95370. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95371. * @returns the Shadow Generator itself
  95372. */
  95373. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95374. /**
  95375. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95376. * @param mesh Mesh to remove
  95377. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95378. * @returns the Shadow Generator itself
  95379. */
  95380. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95381. /**
  95382. * Controls the extent to which the shadows fade out at the edge of the frustum
  95383. */
  95384. frustumEdgeFalloff: number;
  95385. protected _light: IShadowLight;
  95386. /**
  95387. * Returns the associated light object.
  95388. * @returns the light generating the shadow
  95389. */
  95390. getLight(): IShadowLight;
  95391. /**
  95392. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95393. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95394. * It might on the other hand introduce peter panning.
  95395. */
  95396. forceBackFacesOnly: boolean;
  95397. protected _scene: Scene;
  95398. protected _lightDirection: Vector3;
  95399. protected _effect: Effect;
  95400. protected _viewMatrix: Matrix;
  95401. protected _projectionMatrix: Matrix;
  95402. protected _transformMatrix: Matrix;
  95403. protected _cachedPosition: Vector3;
  95404. protected _cachedDirection: Vector3;
  95405. protected _cachedDefines: string;
  95406. protected _currentRenderID: number;
  95407. protected _boxBlurPostprocess: Nullable<PostProcess>;
  95408. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  95409. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  95410. protected _blurPostProcesses: PostProcess[];
  95411. protected _mapSize: number;
  95412. protected _currentFaceIndex: number;
  95413. protected _currentFaceIndexCache: number;
  95414. protected _textureType: number;
  95415. protected _defaultTextureMatrix: Matrix;
  95416. protected _storedUniqueId: Nullable<number>;
  95417. /** @hidden */
  95418. static _SceneComponentInitialization: (scene: Scene) => void;
  95419. /**
  95420. * Creates a ShadowGenerator object.
  95421. * A ShadowGenerator is the required tool to use the shadows.
  95422. * Each light casting shadows needs to use its own ShadowGenerator.
  95423. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  95424. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  95425. * @param light The light object generating the shadows.
  95426. * @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.
  95427. */
  95428. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  95429. protected _initializeGenerator(): void;
  95430. protected _createTargetRenderTexture(): void;
  95431. protected _initializeShadowMap(): void;
  95432. protected _initializeBlurRTTAndPostProcesses(): void;
  95433. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  95434. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  95435. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  95436. protected _applyFilterValues(): void;
  95437. /**
  95438. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95439. * @param onCompiled Callback triggered at the and of the effects compilation
  95440. * @param options Sets of optional options forcing the compilation with different modes
  95441. */
  95442. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95443. useInstances: boolean;
  95444. }>): void;
  95445. /**
  95446. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95447. * @param options Sets of optional options forcing the compilation with different modes
  95448. * @returns A promise that resolves when the compilation completes
  95449. */
  95450. forceCompilationAsync(options?: Partial<{
  95451. useInstances: boolean;
  95452. }>): Promise<void>;
  95453. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  95454. private _prepareShadowDefines;
  95455. /**
  95456. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95457. * @param subMesh The submesh we want to render in the shadow map
  95458. * @param useInstances Defines wether will draw in the map using instances
  95459. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95460. * @returns true if ready otherwise, false
  95461. */
  95462. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95463. /**
  95464. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95465. * @param defines Defines of the material we want to update
  95466. * @param lightIndex Index of the light in the enabled light list of the material
  95467. */
  95468. prepareDefines(defines: any, lightIndex: number): void;
  95469. /**
  95470. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95471. * defined in the generator but impacting the effect).
  95472. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95473. * @param effect The effect we are binfing the information for
  95474. */
  95475. bindShadowLight(lightIndex: string, effect: Effect): void;
  95476. /**
  95477. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95478. * (eq to shadow prjection matrix * light transform matrix)
  95479. * @returns The transform matrix used to create the shadow map
  95480. */
  95481. getTransformMatrix(): Matrix;
  95482. /**
  95483. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95484. * Cube and 2D textures for instance.
  95485. */
  95486. recreateShadowMap(): void;
  95487. protected _disposeBlurPostProcesses(): void;
  95488. protected _disposeRTTandPostProcesses(): void;
  95489. /**
  95490. * Disposes the ShadowGenerator.
  95491. * Returns nothing.
  95492. */
  95493. dispose(): void;
  95494. /**
  95495. * Serializes the shadow generator setup to a json object.
  95496. * @returns The serialized JSON object
  95497. */
  95498. serialize(): any;
  95499. /**
  95500. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95501. * @param parsedShadowGenerator The JSON object to parse
  95502. * @param scene The scene to create the shadow map for
  95503. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95504. * @returns The parsed shadow generator
  95505. */
  95506. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95507. }
  95508. }
  95509. declare module BABYLON {
  95510. /**
  95511. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95512. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95513. * 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.
  95514. */
  95515. export abstract class Light extends Node {
  95516. /**
  95517. * Falloff Default: light is falling off following the material specification:
  95518. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95519. */
  95520. static readonly FALLOFF_DEFAULT: number;
  95521. /**
  95522. * Falloff Physical: light is falling off following the inverse squared distance law.
  95523. */
  95524. static readonly FALLOFF_PHYSICAL: number;
  95525. /**
  95526. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95527. * to enhance interoperability with other engines.
  95528. */
  95529. static readonly FALLOFF_GLTF: number;
  95530. /**
  95531. * Falloff Standard: light is falling off like in the standard material
  95532. * to enhance interoperability with other materials.
  95533. */
  95534. static readonly FALLOFF_STANDARD: number;
  95535. /**
  95536. * If every light affecting the material is in this lightmapMode,
  95537. * material.lightmapTexture adds or multiplies
  95538. * (depends on material.useLightmapAsShadowmap)
  95539. * after every other light calculations.
  95540. */
  95541. static readonly LIGHTMAP_DEFAULT: number;
  95542. /**
  95543. * material.lightmapTexture as only diffuse lighting from this light
  95544. * adds only specular lighting from this light
  95545. * adds dynamic shadows
  95546. */
  95547. static readonly LIGHTMAP_SPECULAR: number;
  95548. /**
  95549. * material.lightmapTexture as only lighting
  95550. * no light calculation from this light
  95551. * only adds dynamic shadows from this light
  95552. */
  95553. static readonly LIGHTMAP_SHADOWSONLY: number;
  95554. /**
  95555. * Each light type uses the default quantity according to its type:
  95556. * point/spot lights use luminous intensity
  95557. * directional lights use illuminance
  95558. */
  95559. static readonly INTENSITYMODE_AUTOMATIC: number;
  95560. /**
  95561. * lumen (lm)
  95562. */
  95563. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95564. /**
  95565. * candela (lm/sr)
  95566. */
  95567. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95568. /**
  95569. * lux (lm/m^2)
  95570. */
  95571. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95572. /**
  95573. * nit (cd/m^2)
  95574. */
  95575. static readonly INTENSITYMODE_LUMINANCE: number;
  95576. /**
  95577. * Light type const id of the point light.
  95578. */
  95579. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95580. /**
  95581. * Light type const id of the directional light.
  95582. */
  95583. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95584. /**
  95585. * Light type const id of the spot light.
  95586. */
  95587. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  95588. /**
  95589. * Light type const id of the hemispheric light.
  95590. */
  95591. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  95592. /**
  95593. * Diffuse gives the basic color to an object.
  95594. */
  95595. diffuse: Color3;
  95596. /**
  95597. * Specular produces a highlight color on an object.
  95598. * Note: This is note affecting PBR materials.
  95599. */
  95600. specular: Color3;
  95601. /**
  95602. * Defines the falloff type for this light. This lets overrriding how punctual light are
  95603. * falling off base on range or angle.
  95604. * This can be set to any values in Light.FALLOFF_x.
  95605. *
  95606. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  95607. * other types of materials.
  95608. */
  95609. falloffType: number;
  95610. /**
  95611. * Strength of the light.
  95612. * Note: By default it is define in the framework own unit.
  95613. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  95614. */
  95615. intensity: number;
  95616. private _range;
  95617. protected _inverseSquaredRange: number;
  95618. /**
  95619. * Defines how far from the source the light is impacting in scene units.
  95620. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95621. */
  95622. get range(): number;
  95623. /**
  95624. * Defines how far from the source the light is impacting in scene units.
  95625. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95626. */
  95627. set range(value: number);
  95628. /**
  95629. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  95630. * of light.
  95631. */
  95632. private _photometricScale;
  95633. private _intensityMode;
  95634. /**
  95635. * Gets the photometric scale used to interpret the intensity.
  95636. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95637. */
  95638. get intensityMode(): number;
  95639. /**
  95640. * Sets the photometric scale used to interpret the intensity.
  95641. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95642. */
  95643. set intensityMode(value: number);
  95644. private _radius;
  95645. /**
  95646. * Gets the light radius used by PBR Materials to simulate soft area lights.
  95647. */
  95648. get radius(): number;
  95649. /**
  95650. * sets the light radius used by PBR Materials to simulate soft area lights.
  95651. */
  95652. set radius(value: number);
  95653. private _renderPriority;
  95654. /**
  95655. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  95656. * exceeding the number allowed of the materials.
  95657. */
  95658. renderPriority: number;
  95659. private _shadowEnabled;
  95660. /**
  95661. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95662. * the current shadow generator.
  95663. */
  95664. get shadowEnabled(): boolean;
  95665. /**
  95666. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95667. * the current shadow generator.
  95668. */
  95669. set shadowEnabled(value: boolean);
  95670. private _includedOnlyMeshes;
  95671. /**
  95672. * Gets the only meshes impacted by this light.
  95673. */
  95674. get includedOnlyMeshes(): AbstractMesh[];
  95675. /**
  95676. * Sets the only meshes impacted by this light.
  95677. */
  95678. set includedOnlyMeshes(value: AbstractMesh[]);
  95679. private _excludedMeshes;
  95680. /**
  95681. * Gets the meshes not impacted by this light.
  95682. */
  95683. get excludedMeshes(): AbstractMesh[];
  95684. /**
  95685. * Sets the meshes not impacted by this light.
  95686. */
  95687. set excludedMeshes(value: AbstractMesh[]);
  95688. private _excludeWithLayerMask;
  95689. /**
  95690. * Gets the layer id use to find what meshes are not impacted by the light.
  95691. * Inactive if 0
  95692. */
  95693. get excludeWithLayerMask(): number;
  95694. /**
  95695. * Sets the layer id use to find what meshes are not impacted by the light.
  95696. * Inactive if 0
  95697. */
  95698. set excludeWithLayerMask(value: number);
  95699. private _includeOnlyWithLayerMask;
  95700. /**
  95701. * Gets the layer id use to find what meshes are impacted by the light.
  95702. * Inactive if 0
  95703. */
  95704. get includeOnlyWithLayerMask(): number;
  95705. /**
  95706. * Sets the layer id use to find what meshes are impacted by the light.
  95707. * Inactive if 0
  95708. */
  95709. set includeOnlyWithLayerMask(value: number);
  95710. private _lightmapMode;
  95711. /**
  95712. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95713. */
  95714. get lightmapMode(): number;
  95715. /**
  95716. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95717. */
  95718. set lightmapMode(value: number);
  95719. /**
  95720. * Shadow generator associted to the light.
  95721. * @hidden Internal use only.
  95722. */
  95723. _shadowGenerator: Nullable<IShadowGenerator>;
  95724. /**
  95725. * @hidden Internal use only.
  95726. */
  95727. _excludedMeshesIds: string[];
  95728. /**
  95729. * @hidden Internal use only.
  95730. */
  95731. _includedOnlyMeshesIds: string[];
  95732. /**
  95733. * The current light unifom buffer.
  95734. * @hidden Internal use only.
  95735. */
  95736. _uniformBuffer: UniformBuffer;
  95737. /** @hidden */
  95738. _renderId: number;
  95739. /**
  95740. * Creates a Light object in the scene.
  95741. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95742. * @param name The firendly name of the light
  95743. * @param scene The scene the light belongs too
  95744. */
  95745. constructor(name: string, scene: Scene);
  95746. protected abstract _buildUniformLayout(): void;
  95747. /**
  95748. * Sets the passed Effect "effect" with the Light information.
  95749. * @param effect The effect to update
  95750. * @param lightIndex The index of the light in the effect to update
  95751. * @returns The light
  95752. */
  95753. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  95754. /**
  95755. * Sets the passed Effect "effect" with the Light textures.
  95756. * @param effect The effect to update
  95757. * @param lightIndex The index of the light in the effect to update
  95758. * @returns The light
  95759. */
  95760. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  95761. /**
  95762. * Binds the lights information from the scene to the effect for the given mesh.
  95763. * @param lightIndex Light index
  95764. * @param scene The scene where the light belongs to
  95765. * @param effect The effect we are binding the data to
  95766. * @param useSpecular Defines if specular is supported
  95767. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  95768. */
  95769. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  95770. /**
  95771. * Sets the passed Effect "effect" with the Light information.
  95772. * @param effect The effect to update
  95773. * @param lightDataUniformName The uniform used to store light data (position or direction)
  95774. * @returns The light
  95775. */
  95776. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  95777. /**
  95778. * Returns the string "Light".
  95779. * @returns the class name
  95780. */
  95781. getClassName(): string;
  95782. /** @hidden */
  95783. readonly _isLight: boolean;
  95784. /**
  95785. * Converts the light information to a readable string for debug purpose.
  95786. * @param fullDetails Supports for multiple levels of logging within scene loading
  95787. * @returns the human readable light info
  95788. */
  95789. toString(fullDetails?: boolean): string;
  95790. /** @hidden */
  95791. protected _syncParentEnabledState(): void;
  95792. /**
  95793. * Set the enabled state of this node.
  95794. * @param value - the new enabled state
  95795. */
  95796. setEnabled(value: boolean): void;
  95797. /**
  95798. * Returns the Light associated shadow generator if any.
  95799. * @return the associated shadow generator.
  95800. */
  95801. getShadowGenerator(): Nullable<IShadowGenerator>;
  95802. /**
  95803. * Returns a Vector3, the absolute light position in the World.
  95804. * @returns the world space position of the light
  95805. */
  95806. getAbsolutePosition(): Vector3;
  95807. /**
  95808. * Specifies if the light will affect the passed mesh.
  95809. * @param mesh The mesh to test against the light
  95810. * @return true the mesh is affected otherwise, false.
  95811. */
  95812. canAffectMesh(mesh: AbstractMesh): boolean;
  95813. /**
  95814. * Sort function to order lights for rendering.
  95815. * @param a First Light object to compare to second.
  95816. * @param b Second Light object to compare first.
  95817. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  95818. */
  95819. static CompareLightsPriority(a: Light, b: Light): number;
  95820. /**
  95821. * Releases resources associated with this node.
  95822. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95823. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95824. */
  95825. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95826. /**
  95827. * Returns the light type ID (integer).
  95828. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95829. */
  95830. getTypeID(): number;
  95831. /**
  95832. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  95833. * @returns the scaled intensity in intensity mode unit
  95834. */
  95835. getScaledIntensity(): number;
  95836. /**
  95837. * Returns a new Light object, named "name", from the current one.
  95838. * @param name The name of the cloned light
  95839. * @param newParent The parent of this light, if it has one
  95840. * @returns the new created light
  95841. */
  95842. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  95843. /**
  95844. * Serializes the current light into a Serialization object.
  95845. * @returns the serialized object.
  95846. */
  95847. serialize(): any;
  95848. /**
  95849. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  95850. * This new light is named "name" and added to the passed scene.
  95851. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  95852. * @param name The friendly name of the light
  95853. * @param scene The scene the new light will belong to
  95854. * @returns the constructor function
  95855. */
  95856. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  95857. /**
  95858. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  95859. * @param parsedLight The JSON representation of the light
  95860. * @param scene The scene to create the parsed light in
  95861. * @returns the created light after parsing
  95862. */
  95863. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  95864. private _hookArrayForExcluded;
  95865. private _hookArrayForIncludedOnly;
  95866. private _resyncMeshes;
  95867. /**
  95868. * Forces the meshes to update their light related information in their rendering used effects
  95869. * @hidden Internal Use Only
  95870. */
  95871. _markMeshesAsLightDirty(): void;
  95872. /**
  95873. * Recomputes the cached photometric scale if needed.
  95874. */
  95875. private _computePhotometricScale;
  95876. /**
  95877. * Returns the Photometric Scale according to the light type and intensity mode.
  95878. */
  95879. private _getPhotometricScale;
  95880. /**
  95881. * Reorder the light in the scene according to their defined priority.
  95882. * @hidden Internal Use Only
  95883. */
  95884. _reorderLightsInScene(): void;
  95885. /**
  95886. * Prepares the list of defines specific to the light type.
  95887. * @param defines the list of defines
  95888. * @param lightIndex defines the index of the light for the effect
  95889. */
  95890. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95891. }
  95892. }
  95893. declare module BABYLON {
  95894. /**
  95895. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95896. * This is the base of the follow, arc rotate cameras and Free camera
  95897. * @see http://doc.babylonjs.com/features/cameras
  95898. */
  95899. export class TargetCamera extends Camera {
  95900. private static _RigCamTransformMatrix;
  95901. private static _TargetTransformMatrix;
  95902. private static _TargetFocalPoint;
  95903. private _tmpUpVector;
  95904. private _tmpTargetVector;
  95905. /**
  95906. * Define the current direction the camera is moving to
  95907. */
  95908. cameraDirection: Vector3;
  95909. /**
  95910. * Define the current rotation the camera is rotating to
  95911. */
  95912. cameraRotation: Vector2;
  95913. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  95914. ignoreParentScaling: boolean;
  95915. /**
  95916. * When set, the up vector of the camera will be updated by the rotation of the camera
  95917. */
  95918. updateUpVectorFromRotation: boolean;
  95919. private _tmpQuaternion;
  95920. /**
  95921. * Define the current rotation of the camera
  95922. */
  95923. rotation: Vector3;
  95924. /**
  95925. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95926. */
  95927. rotationQuaternion: Quaternion;
  95928. /**
  95929. * Define the current speed of the camera
  95930. */
  95931. speed: number;
  95932. /**
  95933. * Add constraint to the camera to prevent it to move freely in all directions and
  95934. * around all axis.
  95935. */
  95936. noRotationConstraint: boolean;
  95937. /**
  95938. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95939. * panning
  95940. */
  95941. invertRotation: boolean;
  95942. /**
  95943. * Speed multiplier for inverse camera panning
  95944. */
  95945. inverseRotationSpeed: number;
  95946. /**
  95947. * Define the current target of the camera as an object or a position.
  95948. */
  95949. lockedTarget: any;
  95950. /** @hidden */
  95951. _currentTarget: Vector3;
  95952. /** @hidden */
  95953. _initialFocalDistance: number;
  95954. /** @hidden */
  95955. _viewMatrix: Matrix;
  95956. /** @hidden */
  95957. _camMatrix: Matrix;
  95958. /** @hidden */
  95959. _cameraTransformMatrix: Matrix;
  95960. /** @hidden */
  95961. _cameraRotationMatrix: Matrix;
  95962. /** @hidden */
  95963. _referencePoint: Vector3;
  95964. /** @hidden */
  95965. _transformedReferencePoint: Vector3;
  95966. /** @hidden */
  95967. _reset: () => void;
  95968. private _defaultUp;
  95969. /**
  95970. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95971. * This is the base of the follow, arc rotate cameras and Free camera
  95972. * @see http://doc.babylonjs.com/features/cameras
  95973. * @param name Defines the name of the camera in the scene
  95974. * @param position Defines the start position of the camera in the scene
  95975. * @param scene Defines the scene the camera belongs to
  95976. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95977. */
  95978. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95979. /**
  95980. * Gets the position in front of the camera at a given distance.
  95981. * @param distance The distance from the camera we want the position to be
  95982. * @returns the position
  95983. */
  95984. getFrontPosition(distance: number): Vector3;
  95985. /** @hidden */
  95986. _getLockedTargetPosition(): Nullable<Vector3>;
  95987. private _storedPosition;
  95988. private _storedRotation;
  95989. private _storedRotationQuaternion;
  95990. /**
  95991. * Store current camera state of the camera (fov, position, rotation, etc..)
  95992. * @returns the camera
  95993. */
  95994. storeState(): Camera;
  95995. /**
  95996. * Restored camera state. You must call storeState() first
  95997. * @returns whether it was successful or not
  95998. * @hidden
  95999. */
  96000. _restoreStateValues(): boolean;
  96001. /** @hidden */
  96002. _initCache(): void;
  96003. /** @hidden */
  96004. _updateCache(ignoreParentClass?: boolean): void;
  96005. /** @hidden */
  96006. _isSynchronizedViewMatrix(): boolean;
  96007. /** @hidden */
  96008. _computeLocalCameraSpeed(): number;
  96009. /**
  96010. * Defines the target the camera should look at.
  96011. * @param target Defines the new target as a Vector or a mesh
  96012. */
  96013. setTarget(target: Vector3): void;
  96014. /**
  96015. * Return the current target position of the camera. This value is expressed in local space.
  96016. * @returns the target position
  96017. */
  96018. getTarget(): Vector3;
  96019. /** @hidden */
  96020. _decideIfNeedsToMove(): boolean;
  96021. /** @hidden */
  96022. _updatePosition(): void;
  96023. /** @hidden */
  96024. _checkInputs(): void;
  96025. protected _updateCameraRotationMatrix(): void;
  96026. /**
  96027. * 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)
  96028. * @returns the current camera
  96029. */
  96030. private _rotateUpVectorWithCameraRotationMatrix;
  96031. private _cachedRotationZ;
  96032. private _cachedQuaternionRotationZ;
  96033. /** @hidden */
  96034. _getViewMatrix(): Matrix;
  96035. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96036. /**
  96037. * @hidden
  96038. */
  96039. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96040. /**
  96041. * @hidden
  96042. */
  96043. _updateRigCameras(): void;
  96044. private _getRigCamPositionAndTarget;
  96045. /**
  96046. * Gets the current object class name.
  96047. * @return the class name
  96048. */
  96049. getClassName(): string;
  96050. }
  96051. }
  96052. declare module BABYLON {
  96053. /**
  96054. * Gather the list of keyboard event types as constants.
  96055. */
  96056. export class KeyboardEventTypes {
  96057. /**
  96058. * The keydown event is fired when a key becomes active (pressed).
  96059. */
  96060. static readonly KEYDOWN: number;
  96061. /**
  96062. * The keyup event is fired when a key has been released.
  96063. */
  96064. static readonly KEYUP: number;
  96065. }
  96066. /**
  96067. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96068. */
  96069. export class KeyboardInfo {
  96070. /**
  96071. * Defines the type of event (KeyboardEventTypes)
  96072. */
  96073. type: number;
  96074. /**
  96075. * Defines the related dom event
  96076. */
  96077. event: KeyboardEvent;
  96078. /**
  96079. * Instantiates a new keyboard info.
  96080. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96081. * @param type Defines the type of event (KeyboardEventTypes)
  96082. * @param event Defines the related dom event
  96083. */
  96084. constructor(
  96085. /**
  96086. * Defines the type of event (KeyboardEventTypes)
  96087. */
  96088. type: number,
  96089. /**
  96090. * Defines the related dom event
  96091. */
  96092. event: KeyboardEvent);
  96093. }
  96094. /**
  96095. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96096. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96097. */
  96098. export class KeyboardInfoPre extends KeyboardInfo {
  96099. /**
  96100. * Defines the type of event (KeyboardEventTypes)
  96101. */
  96102. type: number;
  96103. /**
  96104. * Defines the related dom event
  96105. */
  96106. event: KeyboardEvent;
  96107. /**
  96108. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96109. */
  96110. skipOnPointerObservable: boolean;
  96111. /**
  96112. * Instantiates a new keyboard pre info.
  96113. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96114. * @param type Defines the type of event (KeyboardEventTypes)
  96115. * @param event Defines the related dom event
  96116. */
  96117. constructor(
  96118. /**
  96119. * Defines the type of event (KeyboardEventTypes)
  96120. */
  96121. type: number,
  96122. /**
  96123. * Defines the related dom event
  96124. */
  96125. event: KeyboardEvent);
  96126. }
  96127. }
  96128. declare module BABYLON {
  96129. /**
  96130. * Manage the keyboard inputs to control the movement of a free camera.
  96131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96132. */
  96133. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96134. /**
  96135. * Defines the camera the input is attached to.
  96136. */
  96137. camera: FreeCamera;
  96138. /**
  96139. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96140. */
  96141. keysUp: number[];
  96142. /**
  96143. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96144. */
  96145. keysUpward: number[];
  96146. /**
  96147. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96148. */
  96149. keysDown: number[];
  96150. /**
  96151. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96152. */
  96153. keysDownward: number[];
  96154. /**
  96155. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96156. */
  96157. keysLeft: number[];
  96158. /**
  96159. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96160. */
  96161. keysRight: number[];
  96162. private _keys;
  96163. private _onCanvasBlurObserver;
  96164. private _onKeyboardObserver;
  96165. private _engine;
  96166. private _scene;
  96167. /**
  96168. * Attach the input controls to a specific dom element to get the input from.
  96169. * @param element Defines the element the controls should be listened from
  96170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96171. */
  96172. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96173. /**
  96174. * Detach the current controls from the specified dom element.
  96175. * @param element Defines the element to stop listening the inputs from
  96176. */
  96177. detachControl(element: Nullable<HTMLElement>): void;
  96178. /**
  96179. * Update the current camera state depending on the inputs that have been used this frame.
  96180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96181. */
  96182. checkInputs(): void;
  96183. /**
  96184. * Gets the class name of the current intput.
  96185. * @returns the class name
  96186. */
  96187. getClassName(): string;
  96188. /** @hidden */
  96189. _onLostFocus(): void;
  96190. /**
  96191. * Get the friendly name associated with the input class.
  96192. * @returns the input friendly name
  96193. */
  96194. getSimpleName(): string;
  96195. }
  96196. }
  96197. declare module BABYLON {
  96198. /**
  96199. * Gather the list of pointer event types as constants.
  96200. */
  96201. export class PointerEventTypes {
  96202. /**
  96203. * 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.
  96204. */
  96205. static readonly POINTERDOWN: number;
  96206. /**
  96207. * The pointerup event is fired when a pointer is no longer active.
  96208. */
  96209. static readonly POINTERUP: number;
  96210. /**
  96211. * The pointermove event is fired when a pointer changes coordinates.
  96212. */
  96213. static readonly POINTERMOVE: number;
  96214. /**
  96215. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96216. */
  96217. static readonly POINTERWHEEL: number;
  96218. /**
  96219. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96220. */
  96221. static readonly POINTERPICK: number;
  96222. /**
  96223. * The pointertap event is fired when a the object has been touched and released without drag.
  96224. */
  96225. static readonly POINTERTAP: number;
  96226. /**
  96227. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96228. */
  96229. static readonly POINTERDOUBLETAP: number;
  96230. }
  96231. /**
  96232. * Base class of pointer info types.
  96233. */
  96234. export class PointerInfoBase {
  96235. /**
  96236. * Defines the type of event (PointerEventTypes)
  96237. */
  96238. type: number;
  96239. /**
  96240. * Defines the related dom event
  96241. */
  96242. event: PointerEvent | MouseWheelEvent;
  96243. /**
  96244. * Instantiates the base class of pointers info.
  96245. * @param type Defines the type of event (PointerEventTypes)
  96246. * @param event Defines the related dom event
  96247. */
  96248. constructor(
  96249. /**
  96250. * Defines the type of event (PointerEventTypes)
  96251. */
  96252. type: number,
  96253. /**
  96254. * Defines the related dom event
  96255. */
  96256. event: PointerEvent | MouseWheelEvent);
  96257. }
  96258. /**
  96259. * This class is used to store pointer related info for the onPrePointerObservable event.
  96260. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96261. */
  96262. export class PointerInfoPre extends PointerInfoBase {
  96263. /**
  96264. * Ray from a pointer if availible (eg. 6dof controller)
  96265. */
  96266. ray: Nullable<Ray>;
  96267. /**
  96268. * Defines the local position of the pointer on the canvas.
  96269. */
  96270. localPosition: Vector2;
  96271. /**
  96272. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96273. */
  96274. skipOnPointerObservable: boolean;
  96275. /**
  96276. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96277. * @param type Defines the type of event (PointerEventTypes)
  96278. * @param event Defines the related dom event
  96279. * @param localX Defines the local x coordinates of the pointer when the event occured
  96280. * @param localY Defines the local y coordinates of the pointer when the event occured
  96281. */
  96282. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96283. }
  96284. /**
  96285. * This type contains all the data related to a pointer event in Babylon.js.
  96286. * 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.
  96287. */
  96288. export class PointerInfo extends PointerInfoBase {
  96289. /**
  96290. * Defines the picking info associated to the info (if any)\
  96291. */
  96292. pickInfo: Nullable<PickingInfo>;
  96293. /**
  96294. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96295. * @param type Defines the type of event (PointerEventTypes)
  96296. * @param event Defines the related dom event
  96297. * @param pickInfo Defines the picking info associated to the info (if any)\
  96298. */
  96299. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96300. /**
  96301. * Defines the picking info associated to the info (if any)\
  96302. */
  96303. pickInfo: Nullable<PickingInfo>);
  96304. }
  96305. /**
  96306. * Data relating to a touch event on the screen.
  96307. */
  96308. export interface PointerTouch {
  96309. /**
  96310. * X coordinate of touch.
  96311. */
  96312. x: number;
  96313. /**
  96314. * Y coordinate of touch.
  96315. */
  96316. y: number;
  96317. /**
  96318. * Id of touch. Unique for each finger.
  96319. */
  96320. pointerId: number;
  96321. /**
  96322. * Event type passed from DOM.
  96323. */
  96324. type: any;
  96325. }
  96326. }
  96327. declare module BABYLON {
  96328. /**
  96329. * Manage the mouse inputs to control the movement of a free camera.
  96330. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96331. */
  96332. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96333. /**
  96334. * Define if touch is enabled in the mouse input
  96335. */
  96336. touchEnabled: boolean;
  96337. /**
  96338. * Defines the camera the input is attached to.
  96339. */
  96340. camera: FreeCamera;
  96341. /**
  96342. * Defines the buttons associated with the input to handle camera move.
  96343. */
  96344. buttons: number[];
  96345. /**
  96346. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96347. */
  96348. angularSensibility: number;
  96349. private _pointerInput;
  96350. private _onMouseMove;
  96351. private _observer;
  96352. private previousPosition;
  96353. /**
  96354. * Observable for when a pointer move event occurs containing the move offset
  96355. */
  96356. onPointerMovedObservable: Observable<{
  96357. offsetX: number;
  96358. offsetY: number;
  96359. }>;
  96360. /**
  96361. * @hidden
  96362. * If the camera should be rotated automatically based on pointer movement
  96363. */
  96364. _allowCameraRotation: boolean;
  96365. /**
  96366. * Manage the mouse inputs to control the movement of a free camera.
  96367. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96368. * @param touchEnabled Defines if touch is enabled or not
  96369. */
  96370. constructor(
  96371. /**
  96372. * Define if touch is enabled in the mouse input
  96373. */
  96374. touchEnabled?: boolean);
  96375. /**
  96376. * Attach the input controls to a specific dom element to get the input from.
  96377. * @param element Defines the element the controls should be listened from
  96378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96379. */
  96380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96381. /**
  96382. * Called on JS contextmenu event.
  96383. * Override this method to provide functionality.
  96384. */
  96385. protected onContextMenu(evt: PointerEvent): void;
  96386. /**
  96387. * Detach the current controls from the specified dom element.
  96388. * @param element Defines the element to stop listening the inputs from
  96389. */
  96390. detachControl(element: Nullable<HTMLElement>): void;
  96391. /**
  96392. * Gets the class name of the current intput.
  96393. * @returns the class name
  96394. */
  96395. getClassName(): string;
  96396. /**
  96397. * Get the friendly name associated with the input class.
  96398. * @returns the input friendly name
  96399. */
  96400. getSimpleName(): string;
  96401. }
  96402. }
  96403. declare module BABYLON {
  96404. /**
  96405. * Manage the touch inputs to control the movement of a free camera.
  96406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96407. */
  96408. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  96409. /**
  96410. * Defines the camera the input is attached to.
  96411. */
  96412. camera: FreeCamera;
  96413. /**
  96414. * Defines the touch sensibility for rotation.
  96415. * The higher the faster.
  96416. */
  96417. touchAngularSensibility: number;
  96418. /**
  96419. * Defines the touch sensibility for move.
  96420. * The higher the faster.
  96421. */
  96422. touchMoveSensibility: number;
  96423. private _offsetX;
  96424. private _offsetY;
  96425. private _pointerPressed;
  96426. private _pointerInput;
  96427. private _observer;
  96428. private _onLostFocus;
  96429. /**
  96430. * Attach the input controls to a specific dom element to get the input from.
  96431. * @param element Defines the element the controls should be listened from
  96432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96433. */
  96434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96435. /**
  96436. * Detach the current controls from the specified dom element.
  96437. * @param element Defines the element to stop listening the inputs from
  96438. */
  96439. detachControl(element: Nullable<HTMLElement>): void;
  96440. /**
  96441. * Update the current camera state depending on the inputs that have been used this frame.
  96442. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96443. */
  96444. checkInputs(): void;
  96445. /**
  96446. * Gets the class name of the current intput.
  96447. * @returns the class name
  96448. */
  96449. getClassName(): string;
  96450. /**
  96451. * Get the friendly name associated with the input class.
  96452. * @returns the input friendly name
  96453. */
  96454. getSimpleName(): string;
  96455. }
  96456. }
  96457. declare module BABYLON {
  96458. /**
  96459. * Default Inputs manager for the FreeCamera.
  96460. * It groups all the default supported inputs for ease of use.
  96461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96462. */
  96463. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96464. /**
  96465. * @hidden
  96466. */
  96467. _mouseInput: Nullable<FreeCameraMouseInput>;
  96468. /**
  96469. * Instantiates a new FreeCameraInputsManager.
  96470. * @param camera Defines the camera the inputs belong to
  96471. */
  96472. constructor(camera: FreeCamera);
  96473. /**
  96474. * Add keyboard input support to the input manager.
  96475. * @returns the current input manager
  96476. */
  96477. addKeyboard(): FreeCameraInputsManager;
  96478. /**
  96479. * Add mouse input support to the input manager.
  96480. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96481. * @returns the current input manager
  96482. */
  96483. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96484. /**
  96485. * Removes the mouse input support from the manager
  96486. * @returns the current input manager
  96487. */
  96488. removeMouse(): FreeCameraInputsManager;
  96489. /**
  96490. * Add touch input support to the input manager.
  96491. * @returns the current input manager
  96492. */
  96493. addTouch(): FreeCameraInputsManager;
  96494. /**
  96495. * Remove all attached input methods from a camera
  96496. */
  96497. clear(): void;
  96498. }
  96499. }
  96500. declare module BABYLON {
  96501. /**
  96502. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96503. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96504. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96505. */
  96506. export class FreeCamera extends TargetCamera {
  96507. /**
  96508. * Define the collision ellipsoid of the camera.
  96509. * This is helpful to simulate a camera body like the player body around the camera
  96510. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96511. */
  96512. ellipsoid: Vector3;
  96513. /**
  96514. * Define an offset for the position of the ellipsoid around the camera.
  96515. * This can be helpful to determine the center of the body near the gravity center of the body
  96516. * instead of its head.
  96517. */
  96518. ellipsoidOffset: Vector3;
  96519. /**
  96520. * Enable or disable collisions of the camera with the rest of the scene objects.
  96521. */
  96522. checkCollisions: boolean;
  96523. /**
  96524. * Enable or disable gravity on the camera.
  96525. */
  96526. applyGravity: boolean;
  96527. /**
  96528. * Define the input manager associated to the camera.
  96529. */
  96530. inputs: FreeCameraInputsManager;
  96531. /**
  96532. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96533. * Higher values reduce sensitivity.
  96534. */
  96535. get angularSensibility(): number;
  96536. /**
  96537. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96538. * Higher values reduce sensitivity.
  96539. */
  96540. set angularSensibility(value: number);
  96541. /**
  96542. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96543. */
  96544. get keysUp(): number[];
  96545. set keysUp(value: number[]);
  96546. /**
  96547. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96548. */
  96549. get keysUpward(): number[];
  96550. set keysUpward(value: number[]);
  96551. /**
  96552. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96553. */
  96554. get keysDown(): number[];
  96555. set keysDown(value: number[]);
  96556. /**
  96557. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96558. */
  96559. get keysDownward(): number[];
  96560. set keysDownward(value: number[]);
  96561. /**
  96562. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96563. */
  96564. get keysLeft(): number[];
  96565. set keysLeft(value: number[]);
  96566. /**
  96567. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96568. */
  96569. get keysRight(): number[];
  96570. set keysRight(value: number[]);
  96571. /**
  96572. * Event raised when the camera collide with a mesh in the scene.
  96573. */
  96574. onCollide: (collidedMesh: AbstractMesh) => void;
  96575. private _collider;
  96576. private _needMoveForGravity;
  96577. private _oldPosition;
  96578. private _diffPosition;
  96579. private _newPosition;
  96580. /** @hidden */
  96581. _localDirection: Vector3;
  96582. /** @hidden */
  96583. _transformedDirection: Vector3;
  96584. /**
  96585. * Instantiates a Free Camera.
  96586. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96587. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  96588. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96589. * @param name Define the name of the camera in the scene
  96590. * @param position Define the start position of the camera in the scene
  96591. * @param scene Define the scene the camera belongs to
  96592. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96593. */
  96594. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96595. /**
  96596. * Attached controls to the current camera.
  96597. * @param element Defines the element the controls should be listened from
  96598. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96599. */
  96600. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96601. /**
  96602. * Detach the current controls from the camera.
  96603. * The camera will stop reacting to inputs.
  96604. * @param element Defines the element to stop listening the inputs from
  96605. */
  96606. detachControl(element: HTMLElement): void;
  96607. private _collisionMask;
  96608. /**
  96609. * Define a collision mask to limit the list of object the camera can collide with
  96610. */
  96611. get collisionMask(): number;
  96612. set collisionMask(mask: number);
  96613. /** @hidden */
  96614. _collideWithWorld(displacement: Vector3): void;
  96615. private _onCollisionPositionChange;
  96616. /** @hidden */
  96617. _checkInputs(): void;
  96618. /** @hidden */
  96619. _decideIfNeedsToMove(): boolean;
  96620. /** @hidden */
  96621. _updatePosition(): void;
  96622. /**
  96623. * Destroy the camera and release the current resources hold by it.
  96624. */
  96625. dispose(): void;
  96626. /**
  96627. * Gets the current object class name.
  96628. * @return the class name
  96629. */
  96630. getClassName(): string;
  96631. }
  96632. }
  96633. declare module BABYLON {
  96634. /**
  96635. * Represents a gamepad control stick position
  96636. */
  96637. export class StickValues {
  96638. /**
  96639. * The x component of the control stick
  96640. */
  96641. x: number;
  96642. /**
  96643. * The y component of the control stick
  96644. */
  96645. y: number;
  96646. /**
  96647. * Initializes the gamepad x and y control stick values
  96648. * @param x The x component of the gamepad control stick value
  96649. * @param y The y component of the gamepad control stick value
  96650. */
  96651. constructor(
  96652. /**
  96653. * The x component of the control stick
  96654. */
  96655. x: number,
  96656. /**
  96657. * The y component of the control stick
  96658. */
  96659. y: number);
  96660. }
  96661. /**
  96662. * An interface which manages callbacks for gamepad button changes
  96663. */
  96664. export interface GamepadButtonChanges {
  96665. /**
  96666. * Called when a gamepad has been changed
  96667. */
  96668. changed: boolean;
  96669. /**
  96670. * Called when a gamepad press event has been triggered
  96671. */
  96672. pressChanged: boolean;
  96673. /**
  96674. * Called when a touch event has been triggered
  96675. */
  96676. touchChanged: boolean;
  96677. /**
  96678. * Called when a value has changed
  96679. */
  96680. valueChanged: boolean;
  96681. }
  96682. /**
  96683. * Represents a gamepad
  96684. */
  96685. export class Gamepad {
  96686. /**
  96687. * The id of the gamepad
  96688. */
  96689. id: string;
  96690. /**
  96691. * The index of the gamepad
  96692. */
  96693. index: number;
  96694. /**
  96695. * The browser gamepad
  96696. */
  96697. browserGamepad: any;
  96698. /**
  96699. * Specifies what type of gamepad this represents
  96700. */
  96701. type: number;
  96702. private _leftStick;
  96703. private _rightStick;
  96704. /** @hidden */
  96705. _isConnected: boolean;
  96706. private _leftStickAxisX;
  96707. private _leftStickAxisY;
  96708. private _rightStickAxisX;
  96709. private _rightStickAxisY;
  96710. /**
  96711. * Triggered when the left control stick has been changed
  96712. */
  96713. private _onleftstickchanged;
  96714. /**
  96715. * Triggered when the right control stick has been changed
  96716. */
  96717. private _onrightstickchanged;
  96718. /**
  96719. * Represents a gamepad controller
  96720. */
  96721. static GAMEPAD: number;
  96722. /**
  96723. * Represents a generic controller
  96724. */
  96725. static GENERIC: number;
  96726. /**
  96727. * Represents an XBox controller
  96728. */
  96729. static XBOX: number;
  96730. /**
  96731. * Represents a pose-enabled controller
  96732. */
  96733. static POSE_ENABLED: number;
  96734. /**
  96735. * Represents an Dual Shock controller
  96736. */
  96737. static DUALSHOCK: number;
  96738. /**
  96739. * Specifies whether the left control stick should be Y-inverted
  96740. */
  96741. protected _invertLeftStickY: boolean;
  96742. /**
  96743. * Specifies if the gamepad has been connected
  96744. */
  96745. get isConnected(): boolean;
  96746. /**
  96747. * Initializes the gamepad
  96748. * @param id The id of the gamepad
  96749. * @param index The index of the gamepad
  96750. * @param browserGamepad The browser gamepad
  96751. * @param leftStickX The x component of the left joystick
  96752. * @param leftStickY The y component of the left joystick
  96753. * @param rightStickX The x component of the right joystick
  96754. * @param rightStickY The y component of the right joystick
  96755. */
  96756. constructor(
  96757. /**
  96758. * The id of the gamepad
  96759. */
  96760. id: string,
  96761. /**
  96762. * The index of the gamepad
  96763. */
  96764. index: number,
  96765. /**
  96766. * The browser gamepad
  96767. */
  96768. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  96769. /**
  96770. * Callback triggered when the left joystick has changed
  96771. * @param callback
  96772. */
  96773. onleftstickchanged(callback: (values: StickValues) => void): void;
  96774. /**
  96775. * Callback triggered when the right joystick has changed
  96776. * @param callback
  96777. */
  96778. onrightstickchanged(callback: (values: StickValues) => void): void;
  96779. /**
  96780. * Gets the left joystick
  96781. */
  96782. get leftStick(): StickValues;
  96783. /**
  96784. * Sets the left joystick values
  96785. */
  96786. set leftStick(newValues: StickValues);
  96787. /**
  96788. * Gets the right joystick
  96789. */
  96790. get rightStick(): StickValues;
  96791. /**
  96792. * Sets the right joystick value
  96793. */
  96794. set rightStick(newValues: StickValues);
  96795. /**
  96796. * Updates the gamepad joystick positions
  96797. */
  96798. update(): void;
  96799. /**
  96800. * Disposes the gamepad
  96801. */
  96802. dispose(): void;
  96803. }
  96804. /**
  96805. * Represents a generic gamepad
  96806. */
  96807. export class GenericPad extends Gamepad {
  96808. private _buttons;
  96809. private _onbuttondown;
  96810. private _onbuttonup;
  96811. /**
  96812. * Observable triggered when a button has been pressed
  96813. */
  96814. onButtonDownObservable: Observable<number>;
  96815. /**
  96816. * Observable triggered when a button has been released
  96817. */
  96818. onButtonUpObservable: Observable<number>;
  96819. /**
  96820. * Callback triggered when a button has been pressed
  96821. * @param callback Called when a button has been pressed
  96822. */
  96823. onbuttondown(callback: (buttonPressed: number) => void): void;
  96824. /**
  96825. * Callback triggered when a button has been released
  96826. * @param callback Called when a button has been released
  96827. */
  96828. onbuttonup(callback: (buttonReleased: number) => void): void;
  96829. /**
  96830. * Initializes the generic gamepad
  96831. * @param id The id of the generic gamepad
  96832. * @param index The index of the generic gamepad
  96833. * @param browserGamepad The browser gamepad
  96834. */
  96835. constructor(id: string, index: number, browserGamepad: any);
  96836. private _setButtonValue;
  96837. /**
  96838. * Updates the generic gamepad
  96839. */
  96840. update(): void;
  96841. /**
  96842. * Disposes the generic gamepad
  96843. */
  96844. dispose(): void;
  96845. }
  96846. }
  96847. declare module BABYLON {
  96848. /**
  96849. * Defines the types of pose enabled controllers that are supported
  96850. */
  96851. export enum PoseEnabledControllerType {
  96852. /**
  96853. * HTC Vive
  96854. */
  96855. VIVE = 0,
  96856. /**
  96857. * Oculus Rift
  96858. */
  96859. OCULUS = 1,
  96860. /**
  96861. * Windows mixed reality
  96862. */
  96863. WINDOWS = 2,
  96864. /**
  96865. * Samsung gear VR
  96866. */
  96867. GEAR_VR = 3,
  96868. /**
  96869. * Google Daydream
  96870. */
  96871. DAYDREAM = 4,
  96872. /**
  96873. * Generic
  96874. */
  96875. GENERIC = 5
  96876. }
  96877. /**
  96878. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96879. */
  96880. export interface MutableGamepadButton {
  96881. /**
  96882. * Value of the button/trigger
  96883. */
  96884. value: number;
  96885. /**
  96886. * If the button/trigger is currently touched
  96887. */
  96888. touched: boolean;
  96889. /**
  96890. * If the button/trigger is currently pressed
  96891. */
  96892. pressed: boolean;
  96893. }
  96894. /**
  96895. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96896. * @hidden
  96897. */
  96898. export interface ExtendedGamepadButton extends GamepadButton {
  96899. /**
  96900. * If the button/trigger is currently pressed
  96901. */
  96902. readonly pressed: boolean;
  96903. /**
  96904. * If the button/trigger is currently touched
  96905. */
  96906. readonly touched: boolean;
  96907. /**
  96908. * Value of the button/trigger
  96909. */
  96910. readonly value: number;
  96911. }
  96912. /** @hidden */
  96913. export interface _GamePadFactory {
  96914. /**
  96915. * Returns whether or not the current gamepad can be created for this type of controller.
  96916. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96917. * @returns true if it can be created, otherwise false
  96918. */
  96919. canCreate(gamepadInfo: any): boolean;
  96920. /**
  96921. * Creates a new instance of the Gamepad.
  96922. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96923. * @returns the new gamepad instance
  96924. */
  96925. create(gamepadInfo: any): Gamepad;
  96926. }
  96927. /**
  96928. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96929. */
  96930. export class PoseEnabledControllerHelper {
  96931. /** @hidden */
  96932. static _ControllerFactories: _GamePadFactory[];
  96933. /** @hidden */
  96934. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96935. /**
  96936. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96937. * @param vrGamepad the gamepad to initialized
  96938. * @returns a vr controller of the type the gamepad identified as
  96939. */
  96940. static InitiateController(vrGamepad: any): Gamepad;
  96941. }
  96942. /**
  96943. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96944. */
  96945. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96946. /**
  96947. * If the controller is used in a webXR session
  96948. */
  96949. isXR: boolean;
  96950. private _deviceRoomPosition;
  96951. private _deviceRoomRotationQuaternion;
  96952. /**
  96953. * The device position in babylon space
  96954. */
  96955. devicePosition: Vector3;
  96956. /**
  96957. * The device rotation in babylon space
  96958. */
  96959. deviceRotationQuaternion: Quaternion;
  96960. /**
  96961. * The scale factor of the device in babylon space
  96962. */
  96963. deviceScaleFactor: number;
  96964. /**
  96965. * (Likely devicePosition should be used instead) The device position in its room space
  96966. */
  96967. position: Vector3;
  96968. /**
  96969. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96970. */
  96971. rotationQuaternion: Quaternion;
  96972. /**
  96973. * The type of controller (Eg. Windows mixed reality)
  96974. */
  96975. controllerType: PoseEnabledControllerType;
  96976. protected _calculatedPosition: Vector3;
  96977. private _calculatedRotation;
  96978. /**
  96979. * The raw pose from the device
  96980. */
  96981. rawPose: DevicePose;
  96982. private _trackPosition;
  96983. private _maxRotationDistFromHeadset;
  96984. private _draggedRoomRotation;
  96985. /**
  96986. * @hidden
  96987. */
  96988. _disableTrackPosition(fixedPosition: Vector3): void;
  96989. /**
  96990. * Internal, the mesh attached to the controller
  96991. * @hidden
  96992. */
  96993. _mesh: Nullable<AbstractMesh>;
  96994. private _poseControlledCamera;
  96995. private _leftHandSystemQuaternion;
  96996. /**
  96997. * Internal, matrix used to convert room space to babylon space
  96998. * @hidden
  96999. */
  97000. _deviceToWorld: Matrix;
  97001. /**
  97002. * Node to be used when casting a ray from the controller
  97003. * @hidden
  97004. */
  97005. _pointingPoseNode: Nullable<TransformNode>;
  97006. /**
  97007. * Name of the child mesh that can be used to cast a ray from the controller
  97008. */
  97009. static readonly POINTING_POSE: string;
  97010. /**
  97011. * Creates a new PoseEnabledController from a gamepad
  97012. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97013. */
  97014. constructor(browserGamepad: any);
  97015. private _workingMatrix;
  97016. /**
  97017. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97018. */
  97019. update(): void;
  97020. /**
  97021. * Updates only the pose device and mesh without doing any button event checking
  97022. */
  97023. protected _updatePoseAndMesh(): void;
  97024. /**
  97025. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97026. * @param poseData raw pose fromthe device
  97027. */
  97028. updateFromDevice(poseData: DevicePose): void;
  97029. /**
  97030. * @hidden
  97031. */
  97032. _meshAttachedObservable: Observable<AbstractMesh>;
  97033. /**
  97034. * Attaches a mesh to the controller
  97035. * @param mesh the mesh to be attached
  97036. */
  97037. attachToMesh(mesh: AbstractMesh): void;
  97038. /**
  97039. * Attaches the controllers mesh to a camera
  97040. * @param camera the camera the mesh should be attached to
  97041. */
  97042. attachToPoseControlledCamera(camera: TargetCamera): void;
  97043. /**
  97044. * Disposes of the controller
  97045. */
  97046. dispose(): void;
  97047. /**
  97048. * The mesh that is attached to the controller
  97049. */
  97050. get mesh(): Nullable<AbstractMesh>;
  97051. /**
  97052. * Gets the ray of the controller in the direction the controller is pointing
  97053. * @param length the length the resulting ray should be
  97054. * @returns a ray in the direction the controller is pointing
  97055. */
  97056. getForwardRay(length?: number): Ray;
  97057. }
  97058. }
  97059. declare module BABYLON {
  97060. /**
  97061. * Defines the WebVRController object that represents controllers tracked in 3D space
  97062. */
  97063. export abstract class WebVRController extends PoseEnabledController {
  97064. /**
  97065. * Internal, the default controller model for the controller
  97066. */
  97067. protected _defaultModel: Nullable<AbstractMesh>;
  97068. /**
  97069. * Fired when the trigger state has changed
  97070. */
  97071. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97072. /**
  97073. * Fired when the main button state has changed
  97074. */
  97075. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97076. /**
  97077. * Fired when the secondary button state has changed
  97078. */
  97079. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97080. /**
  97081. * Fired when the pad state has changed
  97082. */
  97083. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97084. /**
  97085. * Fired when controllers stick values have changed
  97086. */
  97087. onPadValuesChangedObservable: Observable<StickValues>;
  97088. /**
  97089. * Array of button availible on the controller
  97090. */
  97091. protected _buttons: Array<MutableGamepadButton>;
  97092. private _onButtonStateChange;
  97093. /**
  97094. * Fired when a controller button's state has changed
  97095. * @param callback the callback containing the button that was modified
  97096. */
  97097. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97098. /**
  97099. * X and Y axis corresponding to the controllers joystick
  97100. */
  97101. pad: StickValues;
  97102. /**
  97103. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97104. */
  97105. hand: string;
  97106. /**
  97107. * The default controller model for the controller
  97108. */
  97109. get defaultModel(): Nullable<AbstractMesh>;
  97110. /**
  97111. * Creates a new WebVRController from a gamepad
  97112. * @param vrGamepad the gamepad that the WebVRController should be created from
  97113. */
  97114. constructor(vrGamepad: any);
  97115. /**
  97116. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97117. */
  97118. update(): void;
  97119. /**
  97120. * Function to be called when a button is modified
  97121. */
  97122. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97123. /**
  97124. * Loads a mesh and attaches it to the controller
  97125. * @param scene the scene the mesh should be added to
  97126. * @param meshLoaded callback for when the mesh has been loaded
  97127. */
  97128. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97129. private _setButtonValue;
  97130. private _changes;
  97131. private _checkChanges;
  97132. /**
  97133. * Disposes of th webVRCOntroller
  97134. */
  97135. dispose(): void;
  97136. }
  97137. }
  97138. declare module BABYLON {
  97139. /**
  97140. * The HemisphericLight simulates the ambient environment light,
  97141. * so the passed direction is the light reflection direction, not the incoming direction.
  97142. */
  97143. export class HemisphericLight extends Light {
  97144. /**
  97145. * The groundColor is the light in the opposite direction to the one specified during creation.
  97146. * 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.
  97147. */
  97148. groundColor: Color3;
  97149. /**
  97150. * The light reflection direction, not the incoming direction.
  97151. */
  97152. direction: Vector3;
  97153. /**
  97154. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97155. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97156. * The HemisphericLight can't cast shadows.
  97157. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97158. * @param name The friendly name of the light
  97159. * @param direction The direction of the light reflection
  97160. * @param scene The scene the light belongs to
  97161. */
  97162. constructor(name: string, direction: Vector3, scene: Scene);
  97163. protected _buildUniformLayout(): void;
  97164. /**
  97165. * Returns the string "HemisphericLight".
  97166. * @return The class name
  97167. */
  97168. getClassName(): string;
  97169. /**
  97170. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97171. * Returns the updated direction.
  97172. * @param target The target the direction should point to
  97173. * @return The computed direction
  97174. */
  97175. setDirectionToTarget(target: Vector3): Vector3;
  97176. /**
  97177. * Returns the shadow generator associated to the light.
  97178. * @returns Always null for hemispheric lights because it does not support shadows.
  97179. */
  97180. getShadowGenerator(): Nullable<IShadowGenerator>;
  97181. /**
  97182. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97183. * @param effect The effect to update
  97184. * @param lightIndex The index of the light in the effect to update
  97185. * @returns The hemispheric light
  97186. */
  97187. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97188. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97189. /**
  97190. * Computes the world matrix of the node
  97191. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97192. * @param useWasUpdatedFlag defines a reserved property
  97193. * @returns the world matrix
  97194. */
  97195. computeWorldMatrix(): Matrix;
  97196. /**
  97197. * Returns the integer 3.
  97198. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97199. */
  97200. getTypeID(): number;
  97201. /**
  97202. * Prepares the list of defines specific to the light type.
  97203. * @param defines the list of defines
  97204. * @param lightIndex defines the index of the light for the effect
  97205. */
  97206. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97207. }
  97208. }
  97209. declare module BABYLON {
  97210. /** @hidden */
  97211. export var vrMultiviewToSingleviewPixelShader: {
  97212. name: string;
  97213. shader: string;
  97214. };
  97215. }
  97216. declare module BABYLON {
  97217. /**
  97218. * Renders to multiple views with a single draw call
  97219. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97220. */
  97221. export class MultiviewRenderTarget extends RenderTargetTexture {
  97222. /**
  97223. * Creates a multiview render target
  97224. * @param scene scene used with the render target
  97225. * @param size the size of the render target (used for each view)
  97226. */
  97227. constructor(scene: Scene, size?: number | {
  97228. width: number;
  97229. height: number;
  97230. } | {
  97231. ratio: number;
  97232. });
  97233. /**
  97234. * @hidden
  97235. * @param faceIndex the face index, if its a cube texture
  97236. */
  97237. _bindFrameBuffer(faceIndex?: number): void;
  97238. /**
  97239. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97240. * @returns the view count
  97241. */
  97242. getViewCount(): number;
  97243. }
  97244. }
  97245. declare module BABYLON {
  97246. interface Engine {
  97247. /**
  97248. * Creates a new multiview render target
  97249. * @param width defines the width of the texture
  97250. * @param height defines the height of the texture
  97251. * @returns the created multiview texture
  97252. */
  97253. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97254. /**
  97255. * Binds a multiview framebuffer to be drawn to
  97256. * @param multiviewTexture texture to bind
  97257. */
  97258. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97259. }
  97260. interface Camera {
  97261. /**
  97262. * @hidden
  97263. * 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)
  97264. */
  97265. _useMultiviewToSingleView: boolean;
  97266. /**
  97267. * @hidden
  97268. * 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)
  97269. */
  97270. _multiviewTexture: Nullable<RenderTargetTexture>;
  97271. /**
  97272. * @hidden
  97273. * ensures the multiview texture of the camera exists and has the specified width/height
  97274. * @param width height to set on the multiview texture
  97275. * @param height width to set on the multiview texture
  97276. */
  97277. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97278. }
  97279. interface Scene {
  97280. /** @hidden */
  97281. _transformMatrixR: Matrix;
  97282. /** @hidden */
  97283. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97284. /** @hidden */
  97285. _createMultiviewUbo(): void;
  97286. /** @hidden */
  97287. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97288. /** @hidden */
  97289. _renderMultiviewToSingleView(camera: Camera): void;
  97290. }
  97291. }
  97292. declare module BABYLON {
  97293. /**
  97294. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97295. * This will not be used for webXR as it supports displaying texture arrays directly
  97296. */
  97297. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97298. /**
  97299. * Initializes a VRMultiviewToSingleview
  97300. * @param name name of the post process
  97301. * @param camera camera to be applied to
  97302. * @param scaleFactor scaling factor to the size of the output texture
  97303. */
  97304. constructor(name: string, camera: Camera, scaleFactor: number);
  97305. }
  97306. }
  97307. declare module BABYLON {
  97308. /**
  97309. * Interface used to define additional presentation attributes
  97310. */
  97311. export interface IVRPresentationAttributes {
  97312. /**
  97313. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97314. */
  97315. highRefreshRate: boolean;
  97316. /**
  97317. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97318. */
  97319. foveationLevel: number;
  97320. }
  97321. interface Engine {
  97322. /** @hidden */
  97323. _vrDisplay: any;
  97324. /** @hidden */
  97325. _vrSupported: boolean;
  97326. /** @hidden */
  97327. _oldSize: Size;
  97328. /** @hidden */
  97329. _oldHardwareScaleFactor: number;
  97330. /** @hidden */
  97331. _vrExclusivePointerMode: boolean;
  97332. /** @hidden */
  97333. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97334. /** @hidden */
  97335. _onVRDisplayPointerRestricted: () => void;
  97336. /** @hidden */
  97337. _onVRDisplayPointerUnrestricted: () => void;
  97338. /** @hidden */
  97339. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97340. /** @hidden */
  97341. _onVrDisplayDisconnect: Nullable<() => void>;
  97342. /** @hidden */
  97343. _onVrDisplayPresentChange: Nullable<() => void>;
  97344. /**
  97345. * Observable signaled when VR display mode changes
  97346. */
  97347. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97348. /**
  97349. * Observable signaled when VR request present is complete
  97350. */
  97351. onVRRequestPresentComplete: Observable<boolean>;
  97352. /**
  97353. * Observable signaled when VR request present starts
  97354. */
  97355. onVRRequestPresentStart: Observable<Engine>;
  97356. /**
  97357. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97358. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97359. */
  97360. isInVRExclusivePointerMode: boolean;
  97361. /**
  97362. * Gets a boolean indicating if a webVR device was detected
  97363. * @returns true if a webVR device was detected
  97364. */
  97365. isVRDevicePresent(): boolean;
  97366. /**
  97367. * Gets the current webVR device
  97368. * @returns the current webVR device (or null)
  97369. */
  97370. getVRDevice(): any;
  97371. /**
  97372. * Initializes a webVR display and starts listening to display change events
  97373. * The onVRDisplayChangedObservable will be notified upon these changes
  97374. * @returns A promise containing a VRDisplay and if vr is supported
  97375. */
  97376. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97377. /** @hidden */
  97378. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97379. /**
  97380. * Gets or sets the presentation attributes used to configure VR rendering
  97381. */
  97382. vrPresentationAttributes?: IVRPresentationAttributes;
  97383. /**
  97384. * Call this function to switch to webVR mode
  97385. * Will do nothing if webVR is not supported or if there is no webVR device
  97386. * @param options the webvr options provided to the camera. mainly used for multiview
  97387. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97388. */
  97389. enableVR(options: WebVROptions): void;
  97390. /** @hidden */
  97391. _onVRFullScreenTriggered(): void;
  97392. }
  97393. }
  97394. declare module BABYLON {
  97395. /**
  97396. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97397. * IMPORTANT!! The data is right-hand data.
  97398. * @export
  97399. * @interface DevicePose
  97400. */
  97401. export interface DevicePose {
  97402. /**
  97403. * The position of the device, values in array are [x,y,z].
  97404. */
  97405. readonly position: Nullable<Float32Array>;
  97406. /**
  97407. * The linearVelocity of the device, values in array are [x,y,z].
  97408. */
  97409. readonly linearVelocity: Nullable<Float32Array>;
  97410. /**
  97411. * The linearAcceleration of the device, values in array are [x,y,z].
  97412. */
  97413. readonly linearAcceleration: Nullable<Float32Array>;
  97414. /**
  97415. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  97416. */
  97417. readonly orientation: Nullable<Float32Array>;
  97418. /**
  97419. * The angularVelocity of the device, values in array are [x,y,z].
  97420. */
  97421. readonly angularVelocity: Nullable<Float32Array>;
  97422. /**
  97423. * The angularAcceleration of the device, values in array are [x,y,z].
  97424. */
  97425. readonly angularAcceleration: Nullable<Float32Array>;
  97426. }
  97427. /**
  97428. * Interface representing a pose controlled object in Babylon.
  97429. * A pose controlled object has both regular pose values as well as pose values
  97430. * from an external device such as a VR head mounted display
  97431. */
  97432. export interface PoseControlled {
  97433. /**
  97434. * The position of the object in babylon space.
  97435. */
  97436. position: Vector3;
  97437. /**
  97438. * The rotation quaternion of the object in babylon space.
  97439. */
  97440. rotationQuaternion: Quaternion;
  97441. /**
  97442. * The position of the device in babylon space.
  97443. */
  97444. devicePosition?: Vector3;
  97445. /**
  97446. * The rotation quaternion of the device in babylon space.
  97447. */
  97448. deviceRotationQuaternion: Quaternion;
  97449. /**
  97450. * The raw pose coming from the device.
  97451. */
  97452. rawPose: Nullable<DevicePose>;
  97453. /**
  97454. * The scale of the device to be used when translating from device space to babylon space.
  97455. */
  97456. deviceScaleFactor: number;
  97457. /**
  97458. * Updates the poseControlled values based on the input device pose.
  97459. * @param poseData the pose data to update the object with
  97460. */
  97461. updateFromDevice(poseData: DevicePose): void;
  97462. }
  97463. /**
  97464. * Set of options to customize the webVRCamera
  97465. */
  97466. export interface WebVROptions {
  97467. /**
  97468. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97469. */
  97470. trackPosition?: boolean;
  97471. /**
  97472. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97473. */
  97474. positionScale?: number;
  97475. /**
  97476. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97477. */
  97478. displayName?: string;
  97479. /**
  97480. * Should the native controller meshes be initialized. (default: true)
  97481. */
  97482. controllerMeshes?: boolean;
  97483. /**
  97484. * Creating a default HemiLight only on controllers. (default: true)
  97485. */
  97486. defaultLightingOnControllers?: boolean;
  97487. /**
  97488. * If you don't want to use the default VR button of the helper. (default: false)
  97489. */
  97490. useCustomVRButton?: boolean;
  97491. /**
  97492. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97493. */
  97494. customVRButton?: HTMLButtonElement;
  97495. /**
  97496. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97497. */
  97498. rayLength?: number;
  97499. /**
  97500. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97501. */
  97502. defaultHeight?: number;
  97503. /**
  97504. * If multiview should be used if availible (default: false)
  97505. */
  97506. useMultiview?: boolean;
  97507. }
  97508. /**
  97509. * This represents a WebVR camera.
  97510. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97511. * @example http://doc.babylonjs.com/how_to/webvr_camera
  97512. */
  97513. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97514. private webVROptions;
  97515. /**
  97516. * @hidden
  97517. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97518. */
  97519. _vrDevice: any;
  97520. /**
  97521. * The rawPose of the vrDevice.
  97522. */
  97523. rawPose: Nullable<DevicePose>;
  97524. private _onVREnabled;
  97525. private _specsVersion;
  97526. private _attached;
  97527. private _frameData;
  97528. protected _descendants: Array<Node>;
  97529. private _deviceRoomPosition;
  97530. /** @hidden */
  97531. _deviceRoomRotationQuaternion: Quaternion;
  97532. private _standingMatrix;
  97533. /**
  97534. * Represents device position in babylon space.
  97535. */
  97536. devicePosition: Vector3;
  97537. /**
  97538. * Represents device rotation in babylon space.
  97539. */
  97540. deviceRotationQuaternion: Quaternion;
  97541. /**
  97542. * The scale of the device to be used when translating from device space to babylon space.
  97543. */
  97544. deviceScaleFactor: number;
  97545. private _deviceToWorld;
  97546. private _worldToDevice;
  97547. /**
  97548. * References to the webVR controllers for the vrDevice.
  97549. */
  97550. controllers: Array<WebVRController>;
  97551. /**
  97552. * Emits an event when a controller is attached.
  97553. */
  97554. onControllersAttachedObservable: Observable<WebVRController[]>;
  97555. /**
  97556. * Emits an event when a controller's mesh has been loaded;
  97557. */
  97558. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97559. /**
  97560. * Emits an event when the HMD's pose has been updated.
  97561. */
  97562. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97563. private _poseSet;
  97564. /**
  97565. * If the rig cameras be used as parent instead of this camera.
  97566. */
  97567. rigParenting: boolean;
  97568. private _lightOnControllers;
  97569. private _defaultHeight?;
  97570. /**
  97571. * Instantiates a WebVRFreeCamera.
  97572. * @param name The name of the WebVRFreeCamera
  97573. * @param position The starting anchor position for the camera
  97574. * @param scene The scene the camera belongs to
  97575. * @param webVROptions a set of customizable options for the webVRCamera
  97576. */
  97577. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97578. /**
  97579. * Gets the device distance from the ground in meters.
  97580. * @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.
  97581. */
  97582. deviceDistanceToRoomGround(): number;
  97583. /**
  97584. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97585. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  97586. */
  97587. useStandingMatrix(callback?: (bool: boolean) => void): void;
  97588. /**
  97589. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97590. * @returns A promise with a boolean set to if the standing matrix is supported.
  97591. */
  97592. useStandingMatrixAsync(): Promise<boolean>;
  97593. /**
  97594. * Disposes the camera
  97595. */
  97596. dispose(): void;
  97597. /**
  97598. * Gets a vrController by name.
  97599. * @param name The name of the controller to retreive
  97600. * @returns the controller matching the name specified or null if not found
  97601. */
  97602. getControllerByName(name: string): Nullable<WebVRController>;
  97603. private _leftController;
  97604. /**
  97605. * The controller corresponding to the users left hand.
  97606. */
  97607. get leftController(): Nullable<WebVRController>;
  97608. private _rightController;
  97609. /**
  97610. * The controller corresponding to the users right hand.
  97611. */
  97612. get rightController(): Nullable<WebVRController>;
  97613. /**
  97614. * Casts a ray forward from the vrCamera's gaze.
  97615. * @param length Length of the ray (default: 100)
  97616. * @returns the ray corresponding to the gaze
  97617. */
  97618. getForwardRay(length?: number): Ray;
  97619. /**
  97620. * @hidden
  97621. * Updates the camera based on device's frame data
  97622. */
  97623. _checkInputs(): void;
  97624. /**
  97625. * Updates the poseControlled values based on the input device pose.
  97626. * @param poseData Pose coming from the device
  97627. */
  97628. updateFromDevice(poseData: DevicePose): void;
  97629. private _htmlElementAttached;
  97630. private _detachIfAttached;
  97631. /**
  97632. * WebVR's attach control will start broadcasting frames to the device.
  97633. * Note that in certain browsers (chrome for example) this function must be called
  97634. * within a user-interaction callback. Example:
  97635. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  97636. *
  97637. * @param element html element to attach the vrDevice to
  97638. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  97639. */
  97640. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97641. /**
  97642. * Detaches the camera from the html element and disables VR
  97643. *
  97644. * @param element html element to detach from
  97645. */
  97646. detachControl(element: HTMLElement): void;
  97647. /**
  97648. * @returns the name of this class
  97649. */
  97650. getClassName(): string;
  97651. /**
  97652. * Calls resetPose on the vrDisplay
  97653. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  97654. */
  97655. resetToCurrentRotation(): void;
  97656. /**
  97657. * @hidden
  97658. * Updates the rig cameras (left and right eye)
  97659. */
  97660. _updateRigCameras(): void;
  97661. private _workingVector;
  97662. private _oneVector;
  97663. private _workingMatrix;
  97664. private updateCacheCalled;
  97665. private _correctPositionIfNotTrackPosition;
  97666. /**
  97667. * @hidden
  97668. * Updates the cached values of the camera
  97669. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  97670. */
  97671. _updateCache(ignoreParentClass?: boolean): void;
  97672. /**
  97673. * @hidden
  97674. * Get current device position in babylon world
  97675. */
  97676. _computeDevicePosition(): void;
  97677. /**
  97678. * Updates the current device position and rotation in the babylon world
  97679. */
  97680. update(): void;
  97681. /**
  97682. * @hidden
  97683. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  97684. * @returns an identity matrix
  97685. */
  97686. _getViewMatrix(): Matrix;
  97687. private _tmpMatrix;
  97688. /**
  97689. * This function is called by the two RIG cameras.
  97690. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  97691. * @hidden
  97692. */
  97693. _getWebVRViewMatrix(): Matrix;
  97694. /** @hidden */
  97695. _getWebVRProjectionMatrix(): Matrix;
  97696. private _onGamepadConnectedObserver;
  97697. private _onGamepadDisconnectedObserver;
  97698. private _updateCacheWhenTrackingDisabledObserver;
  97699. /**
  97700. * Initializes the controllers and their meshes
  97701. */
  97702. initControllers(): void;
  97703. }
  97704. }
  97705. declare module BABYLON {
  97706. /**
  97707. * "Static Class" containing the most commonly used helper while dealing with material for
  97708. * rendering purpose.
  97709. *
  97710. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  97711. *
  97712. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  97713. */
  97714. export class MaterialHelper {
  97715. /**
  97716. * Bind the current view position to an effect.
  97717. * @param effect The effect to be bound
  97718. * @param scene The scene the eyes position is used from
  97719. * @param variableName name of the shader variable that will hold the eye position
  97720. */
  97721. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  97722. /**
  97723. * Helps preparing the defines values about the UVs in used in the effect.
  97724. * UVs are shared as much as we can accross channels in the shaders.
  97725. * @param texture The texture we are preparing the UVs for
  97726. * @param defines The defines to update
  97727. * @param key The channel key "diffuse", "specular"... used in the shader
  97728. */
  97729. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  97730. /**
  97731. * Binds a texture matrix value to its corrsponding uniform
  97732. * @param texture The texture to bind the matrix for
  97733. * @param uniformBuffer The uniform buffer receivin the data
  97734. * @param key The channel key "diffuse", "specular"... used in the shader
  97735. */
  97736. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  97737. /**
  97738. * Gets the current status of the fog (should it be enabled?)
  97739. * @param mesh defines the mesh to evaluate for fog support
  97740. * @param scene defines the hosting scene
  97741. * @returns true if fog must be enabled
  97742. */
  97743. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  97744. /**
  97745. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  97746. * @param mesh defines the current mesh
  97747. * @param scene defines the current scene
  97748. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  97749. * @param pointsCloud defines if point cloud rendering has to be turned on
  97750. * @param fogEnabled defines if fog has to be turned on
  97751. * @param alphaTest defines if alpha testing has to be turned on
  97752. * @param defines defines the current list of defines
  97753. */
  97754. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  97755. /**
  97756. * Helper used to prepare the list of defines associated with frame values for shader compilation
  97757. * @param scene defines the current scene
  97758. * @param engine defines the current engine
  97759. * @param defines specifies the list of active defines
  97760. * @param useInstances defines if instances have to be turned on
  97761. * @param useClipPlane defines if clip plane have to be turned on
  97762. * @param useInstances defines if instances have to be turned on
  97763. * @param useThinInstances defines if thin instances have to be turned on
  97764. */
  97765. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  97766. /**
  97767. * Prepares the defines for bones
  97768. * @param mesh The mesh containing the geometry data we will draw
  97769. * @param defines The defines to update
  97770. */
  97771. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  97772. /**
  97773. * Prepares the defines for morph targets
  97774. * @param mesh The mesh containing the geometry data we will draw
  97775. * @param defines The defines to update
  97776. */
  97777. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  97778. /**
  97779. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  97780. * @param mesh The mesh containing the geometry data we will draw
  97781. * @param defines The defines to update
  97782. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  97783. * @param useBones Precise whether bones should be used or not (override mesh info)
  97784. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  97785. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  97786. * @returns false if defines are considered not dirty and have not been checked
  97787. */
  97788. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  97789. /**
  97790. * Prepares the defines related to multiview
  97791. * @param scene The scene we are intending to draw
  97792. * @param defines The defines to update
  97793. */
  97794. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  97795. /**
  97796. * Prepares the defines related to the light information passed in parameter
  97797. * @param scene The scene we are intending to draw
  97798. * @param mesh The mesh the effect is compiling for
  97799. * @param light The light the effect is compiling for
  97800. * @param lightIndex The index of the light
  97801. * @param defines The defines to update
  97802. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97803. * @param state Defines the current state regarding what is needed (normals, etc...)
  97804. */
  97805. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  97806. needNormals: boolean;
  97807. needRebuild: boolean;
  97808. shadowEnabled: boolean;
  97809. specularEnabled: boolean;
  97810. lightmapMode: boolean;
  97811. }): void;
  97812. /**
  97813. * Prepares the defines related to the light information passed in parameter
  97814. * @param scene The scene we are intending to draw
  97815. * @param mesh The mesh the effect is compiling for
  97816. * @param defines The defines to update
  97817. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97818. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  97819. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  97820. * @returns true if normals will be required for the rest of the effect
  97821. */
  97822. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  97823. /**
  97824. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  97825. * @param lightIndex defines the light index
  97826. * @param uniformsList The uniform list
  97827. * @param samplersList The sampler list
  97828. * @param projectedLightTexture defines if projected texture must be used
  97829. * @param uniformBuffersList defines an optional list of uniform buffers
  97830. */
  97831. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  97832. /**
  97833. * Prepares the uniforms and samplers list to be used in the effect
  97834. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  97835. * @param samplersList The sampler list
  97836. * @param defines The defines helping in the list generation
  97837. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  97838. */
  97839. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  97840. /**
  97841. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  97842. * @param defines The defines to update while falling back
  97843. * @param fallbacks The authorized effect fallbacks
  97844. * @param maxSimultaneousLights The maximum number of lights allowed
  97845. * @param rank the current rank of the Effect
  97846. * @returns The newly affected rank
  97847. */
  97848. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  97849. private static _TmpMorphInfluencers;
  97850. /**
  97851. * Prepares the list of attributes required for morph targets according to the effect defines.
  97852. * @param attribs The current list of supported attribs
  97853. * @param mesh The mesh to prepare the morph targets attributes for
  97854. * @param influencers The number of influencers
  97855. */
  97856. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  97857. /**
  97858. * Prepares the list of attributes required for morph targets according to the effect defines.
  97859. * @param attribs The current list of supported attribs
  97860. * @param mesh The mesh to prepare the morph targets attributes for
  97861. * @param defines The current Defines of the effect
  97862. */
  97863. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  97864. /**
  97865. * Prepares the list of attributes required for bones according to the effect defines.
  97866. * @param attribs The current list of supported attribs
  97867. * @param mesh The mesh to prepare the bones attributes for
  97868. * @param defines The current Defines of the effect
  97869. * @param fallbacks The current efffect fallback strategy
  97870. */
  97871. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97872. /**
  97873. * Check and prepare the list of attributes required for instances according to the effect defines.
  97874. * @param attribs The current list of supported attribs
  97875. * @param defines The current MaterialDefines of the effect
  97876. */
  97877. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97878. /**
  97879. * Add the list of attributes required for instances to the attribs array.
  97880. * @param attribs The current list of supported attribs
  97881. */
  97882. static PushAttributesForInstances(attribs: string[]): void;
  97883. /**
  97884. * Binds the light information to the effect.
  97885. * @param light The light containing the generator
  97886. * @param effect The effect we are binding the data to
  97887. * @param lightIndex The light index in the effect used to render
  97888. */
  97889. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97890. /**
  97891. * Binds the lights information from the scene to the effect for the given mesh.
  97892. * @param light Light to bind
  97893. * @param lightIndex Light index
  97894. * @param scene The scene where the light belongs to
  97895. * @param effect The effect we are binding the data to
  97896. * @param useSpecular Defines if specular is supported
  97897. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97898. */
  97899. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97900. /**
  97901. * Binds the lights information from the scene to the effect for the given mesh.
  97902. * @param scene The scene the lights belongs to
  97903. * @param mesh The mesh we are binding the information to render
  97904. * @param effect The effect we are binding the data to
  97905. * @param defines The generated defines for the effect
  97906. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97907. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97908. */
  97909. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97910. private static _tempFogColor;
  97911. /**
  97912. * Binds the fog information from the scene to the effect for the given mesh.
  97913. * @param scene The scene the lights belongs to
  97914. * @param mesh The mesh we are binding the information to render
  97915. * @param effect The effect we are binding the data to
  97916. * @param linearSpace Defines if the fog effect is applied in linear space
  97917. */
  97918. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97919. /**
  97920. * Binds the bones information from the mesh to the effect.
  97921. * @param mesh The mesh we are binding the information to render
  97922. * @param effect The effect we are binding the data to
  97923. */
  97924. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97925. /**
  97926. * Binds the morph targets information from the mesh to the effect.
  97927. * @param abstractMesh The mesh we are binding the information to render
  97928. * @param effect The effect we are binding the data to
  97929. */
  97930. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97931. /**
  97932. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97933. * @param defines The generated defines used in the effect
  97934. * @param effect The effect we are binding the data to
  97935. * @param scene The scene we are willing to render with logarithmic scale for
  97936. */
  97937. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97938. /**
  97939. * Binds the clip plane information from the scene to the effect.
  97940. * @param scene The scene the clip plane information are extracted from
  97941. * @param effect The effect we are binding the data to
  97942. */
  97943. static BindClipPlane(effect: Effect, scene: Scene): void;
  97944. }
  97945. }
  97946. declare module BABYLON {
  97947. /**
  97948. * Block used to expose an input value
  97949. */
  97950. export class InputBlock extends NodeMaterialBlock {
  97951. private _mode;
  97952. private _associatedVariableName;
  97953. private _storedValue;
  97954. private _valueCallback;
  97955. private _type;
  97956. private _animationType;
  97957. /** Gets or set a value used to limit the range of float values */
  97958. min: number;
  97959. /** Gets or set a value used to limit the range of float values */
  97960. max: number;
  97961. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97962. isBoolean: boolean;
  97963. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97964. matrixMode: number;
  97965. /** @hidden */
  97966. _systemValue: Nullable<NodeMaterialSystemValues>;
  97967. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97968. visibleInInspector: boolean;
  97969. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97970. isConstant: boolean;
  97971. /** Gets or sets the group to use to display this block in the Inspector */
  97972. groupInInspector: string;
  97973. /** Gets an observable raised when the value is changed */
  97974. onValueChangedObservable: Observable<InputBlock>;
  97975. /**
  97976. * Gets or sets the connection point type (default is float)
  97977. */
  97978. get type(): NodeMaterialBlockConnectionPointTypes;
  97979. /**
  97980. * Creates a new InputBlock
  97981. * @param name defines the block name
  97982. * @param target defines the target of that block (Vertex by default)
  97983. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97984. */
  97985. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97986. /**
  97987. * Gets the output component
  97988. */
  97989. get output(): NodeMaterialConnectionPoint;
  97990. /**
  97991. * Set the source of this connection point to a vertex attribute
  97992. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97993. * @returns the current connection point
  97994. */
  97995. setAsAttribute(attributeName?: string): InputBlock;
  97996. /**
  97997. * Set the source of this connection point to a system value
  97998. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97999. * @returns the current connection point
  98000. */
  98001. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98002. /**
  98003. * Gets or sets the value of that point.
  98004. * Please note that this value will be ignored if valueCallback is defined
  98005. */
  98006. get value(): any;
  98007. set value(value: any);
  98008. /**
  98009. * Gets or sets a callback used to get the value of that point.
  98010. * Please note that setting this value will force the connection point to ignore the value property
  98011. */
  98012. get valueCallback(): () => any;
  98013. set valueCallback(value: () => any);
  98014. /**
  98015. * Gets or sets the associated variable name in the shader
  98016. */
  98017. get associatedVariableName(): string;
  98018. set associatedVariableName(value: string);
  98019. /** Gets or sets the type of animation applied to the input */
  98020. get animationType(): AnimatedInputBlockTypes;
  98021. set animationType(value: AnimatedInputBlockTypes);
  98022. /**
  98023. * Gets a boolean indicating that this connection point not defined yet
  98024. */
  98025. get isUndefined(): boolean;
  98026. /**
  98027. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98028. * In this case the connection point name must be the name of the uniform to use.
  98029. * Can only be set on inputs
  98030. */
  98031. get isUniform(): boolean;
  98032. set isUniform(value: boolean);
  98033. /**
  98034. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98035. * In this case the connection point name must be the name of the attribute to use
  98036. * Can only be set on inputs
  98037. */
  98038. get isAttribute(): boolean;
  98039. set isAttribute(value: boolean);
  98040. /**
  98041. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98042. * Can only be set on exit points
  98043. */
  98044. get isVarying(): boolean;
  98045. set isVarying(value: boolean);
  98046. /**
  98047. * Gets a boolean indicating that the current connection point is a system value
  98048. */
  98049. get isSystemValue(): boolean;
  98050. /**
  98051. * Gets or sets the current well known value or null if not defined as a system value
  98052. */
  98053. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98054. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98055. /**
  98056. * Gets the current class name
  98057. * @returns the class name
  98058. */
  98059. getClassName(): string;
  98060. /**
  98061. * Animate the input if animationType !== None
  98062. * @param scene defines the rendering scene
  98063. */
  98064. animate(scene: Scene): void;
  98065. private _emitDefine;
  98066. initialize(state: NodeMaterialBuildState): void;
  98067. /**
  98068. * Set the input block to its default value (based on its type)
  98069. */
  98070. setDefaultValue(): void;
  98071. private _emitConstant;
  98072. /** @hidden */
  98073. get _noContextSwitch(): boolean;
  98074. private _emit;
  98075. /** @hidden */
  98076. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98077. /** @hidden */
  98078. _transmit(effect: Effect, scene: Scene): void;
  98079. protected _buildBlock(state: NodeMaterialBuildState): void;
  98080. protected _dumpPropertiesCode(): string;
  98081. dispose(): void;
  98082. serialize(): any;
  98083. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98084. }
  98085. }
  98086. declare module BABYLON {
  98087. /**
  98088. * Enum used to define the compatibility state between two connection points
  98089. */
  98090. export enum NodeMaterialConnectionPointCompatibilityStates {
  98091. /** Points are compatibles */
  98092. Compatible = 0,
  98093. /** Points are incompatible because of their types */
  98094. TypeIncompatible = 1,
  98095. /** Points are incompatible because of their targets (vertex vs fragment) */
  98096. TargetIncompatible = 2
  98097. }
  98098. /**
  98099. * Defines the direction of a connection point
  98100. */
  98101. export enum NodeMaterialConnectionPointDirection {
  98102. /** Input */
  98103. Input = 0,
  98104. /** Output */
  98105. Output = 1
  98106. }
  98107. /**
  98108. * Defines a connection point for a block
  98109. */
  98110. export class NodeMaterialConnectionPoint {
  98111. /** @hidden */
  98112. _ownerBlock: NodeMaterialBlock;
  98113. /** @hidden */
  98114. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98115. private _endpoints;
  98116. private _associatedVariableName;
  98117. private _direction;
  98118. /** @hidden */
  98119. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98120. /** @hidden */
  98121. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98122. private _type;
  98123. /** @hidden */
  98124. _enforceAssociatedVariableName: boolean;
  98125. /** Gets the direction of the point */
  98126. get direction(): NodeMaterialConnectionPointDirection;
  98127. /** Indicates that this connection point needs dual validation before being connected to another point */
  98128. needDualDirectionValidation: boolean;
  98129. /**
  98130. * Gets or sets the additional types supported by this connection point
  98131. */
  98132. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98133. /**
  98134. * Gets or sets the additional types excluded by this connection point
  98135. */
  98136. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98137. /**
  98138. * Observable triggered when this point is connected
  98139. */
  98140. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98141. /**
  98142. * Gets or sets the associated variable name in the shader
  98143. */
  98144. get associatedVariableName(): string;
  98145. set associatedVariableName(value: string);
  98146. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98147. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98148. /**
  98149. * Gets or sets the connection point type (default is float)
  98150. */
  98151. get type(): NodeMaterialBlockConnectionPointTypes;
  98152. set type(value: NodeMaterialBlockConnectionPointTypes);
  98153. /**
  98154. * Gets or sets the connection point name
  98155. */
  98156. name: string;
  98157. /**
  98158. * Gets or sets the connection point name
  98159. */
  98160. displayName: string;
  98161. /**
  98162. * Gets or sets a boolean indicating that this connection point can be omitted
  98163. */
  98164. isOptional: boolean;
  98165. /**
  98166. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98167. */
  98168. isExposedOnFrame: boolean;
  98169. /**
  98170. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98171. */
  98172. define: string;
  98173. /** @hidden */
  98174. _prioritizeVertex: boolean;
  98175. private _target;
  98176. /** Gets or sets the target of that connection point */
  98177. get target(): NodeMaterialBlockTargets;
  98178. set target(value: NodeMaterialBlockTargets);
  98179. /**
  98180. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98181. */
  98182. get isConnected(): boolean;
  98183. /**
  98184. * Gets a boolean indicating that the current point is connected to an input block
  98185. */
  98186. get isConnectedToInputBlock(): boolean;
  98187. /**
  98188. * Gets a the connected input block (if any)
  98189. */
  98190. get connectInputBlock(): Nullable<InputBlock>;
  98191. /** Get the other side of the connection (if any) */
  98192. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98193. /** Get the block that owns this connection point */
  98194. get ownerBlock(): NodeMaterialBlock;
  98195. /** Get the block connected on the other side of this connection (if any) */
  98196. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98197. /** Get the block connected on the endpoints of this connection (if any) */
  98198. get connectedBlocks(): Array<NodeMaterialBlock>;
  98199. /** Gets the list of connected endpoints */
  98200. get endpoints(): NodeMaterialConnectionPoint[];
  98201. /** Gets a boolean indicating if that output point is connected to at least one input */
  98202. get hasEndpoints(): boolean;
  98203. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98204. get isConnectedInVertexShader(): boolean;
  98205. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98206. get isConnectedInFragmentShader(): boolean;
  98207. /**
  98208. * Creates a block suitable to be used as an input for this input point.
  98209. * If null is returned, a block based on the point type will be created.
  98210. * @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
  98211. */
  98212. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98213. /**
  98214. * Creates a new connection point
  98215. * @param name defines the connection point name
  98216. * @param ownerBlock defines the block hosting this connection point
  98217. * @param direction defines the direction of the connection point
  98218. */
  98219. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98220. /**
  98221. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98222. * @returns the class name
  98223. */
  98224. getClassName(): string;
  98225. /**
  98226. * Gets a boolean indicating if the current point can be connected to another point
  98227. * @param connectionPoint defines the other connection point
  98228. * @returns a boolean
  98229. */
  98230. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98231. /**
  98232. * Gets a number indicating if the current point can be connected to another point
  98233. * @param connectionPoint defines the other connection point
  98234. * @returns a number defining the compatibility state
  98235. */
  98236. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98237. /**
  98238. * Connect this point to another connection point
  98239. * @param connectionPoint defines the other connection point
  98240. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98241. * @returns the current connection point
  98242. */
  98243. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98244. /**
  98245. * Disconnect this point from one of his endpoint
  98246. * @param endpoint defines the other connection point
  98247. * @returns the current connection point
  98248. */
  98249. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98250. /**
  98251. * Serializes this point in a JSON representation
  98252. * @param isInput defines if the connection point is an input (default is true)
  98253. * @returns the serialized point object
  98254. */
  98255. serialize(isInput?: boolean): any;
  98256. /**
  98257. * Release resources
  98258. */
  98259. dispose(): void;
  98260. }
  98261. }
  98262. declare module BABYLON {
  98263. /**
  98264. * Enum used to define the material modes
  98265. */
  98266. export enum NodeMaterialModes {
  98267. /** Regular material */
  98268. Material = 0,
  98269. /** For post process */
  98270. PostProcess = 1,
  98271. /** For particle system */
  98272. Particle = 2
  98273. }
  98274. }
  98275. declare module BABYLON {
  98276. /**
  98277. * Block used to read a texture from a sampler
  98278. */
  98279. export class TextureBlock extends NodeMaterialBlock {
  98280. private _defineName;
  98281. private _linearDefineName;
  98282. private _gammaDefineName;
  98283. private _tempTextureRead;
  98284. private _samplerName;
  98285. private _transformedUVName;
  98286. private _textureTransformName;
  98287. private _textureInfoName;
  98288. private _mainUVName;
  98289. private _mainUVDefineName;
  98290. private _fragmentOnly;
  98291. /**
  98292. * Gets or sets the texture associated with the node
  98293. */
  98294. texture: Nullable<Texture>;
  98295. /**
  98296. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98297. */
  98298. convertToGammaSpace: boolean;
  98299. /**
  98300. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98301. */
  98302. convertToLinearSpace: boolean;
  98303. /**
  98304. * Create a new TextureBlock
  98305. * @param name defines the block name
  98306. */
  98307. constructor(name: string, fragmentOnly?: boolean);
  98308. /**
  98309. * Gets the current class name
  98310. * @returns the class name
  98311. */
  98312. getClassName(): string;
  98313. /**
  98314. * Gets the uv input component
  98315. */
  98316. get uv(): NodeMaterialConnectionPoint;
  98317. /**
  98318. * Gets the rgba output component
  98319. */
  98320. get rgba(): NodeMaterialConnectionPoint;
  98321. /**
  98322. * Gets the rgb output component
  98323. */
  98324. get rgb(): NodeMaterialConnectionPoint;
  98325. /**
  98326. * Gets the r output component
  98327. */
  98328. get r(): NodeMaterialConnectionPoint;
  98329. /**
  98330. * Gets the g output component
  98331. */
  98332. get g(): NodeMaterialConnectionPoint;
  98333. /**
  98334. * Gets the b output component
  98335. */
  98336. get b(): NodeMaterialConnectionPoint;
  98337. /**
  98338. * Gets the a output component
  98339. */
  98340. get a(): NodeMaterialConnectionPoint;
  98341. get target(): NodeMaterialBlockTargets;
  98342. autoConfigure(material: NodeMaterial): void;
  98343. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98345. isReady(): boolean;
  98346. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98347. private get _isMixed();
  98348. private _injectVertexCode;
  98349. private _writeTextureRead;
  98350. private _writeOutput;
  98351. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98352. protected _dumpPropertiesCode(): string;
  98353. serialize(): any;
  98354. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98355. }
  98356. }
  98357. declare module BABYLON {
  98358. /** @hidden */
  98359. export var reflectionFunction: {
  98360. name: string;
  98361. shader: string;
  98362. };
  98363. }
  98364. declare module BABYLON {
  98365. /**
  98366. * Base block used to read a reflection texture from a sampler
  98367. */
  98368. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98369. /** @hidden */
  98370. _define3DName: string;
  98371. /** @hidden */
  98372. _defineCubicName: string;
  98373. /** @hidden */
  98374. _defineExplicitName: string;
  98375. /** @hidden */
  98376. _defineProjectionName: string;
  98377. /** @hidden */
  98378. _defineLocalCubicName: string;
  98379. /** @hidden */
  98380. _defineSphericalName: string;
  98381. /** @hidden */
  98382. _definePlanarName: string;
  98383. /** @hidden */
  98384. _defineEquirectangularName: string;
  98385. /** @hidden */
  98386. _defineMirroredEquirectangularFixedName: string;
  98387. /** @hidden */
  98388. _defineEquirectangularFixedName: string;
  98389. /** @hidden */
  98390. _defineSkyboxName: string;
  98391. /** @hidden */
  98392. _defineOppositeZ: string;
  98393. /** @hidden */
  98394. _cubeSamplerName: string;
  98395. /** @hidden */
  98396. _2DSamplerName: string;
  98397. protected _positionUVWName: string;
  98398. protected _directionWName: string;
  98399. protected _reflectionVectorName: string;
  98400. /** @hidden */
  98401. _reflectionCoordsName: string;
  98402. /** @hidden */
  98403. _reflectionMatrixName: string;
  98404. protected _reflectionColorName: string;
  98405. /**
  98406. * Gets or sets the texture associated with the node
  98407. */
  98408. texture: Nullable<BaseTexture>;
  98409. /**
  98410. * Create a new ReflectionTextureBaseBlock
  98411. * @param name defines the block name
  98412. */
  98413. constructor(name: string);
  98414. /**
  98415. * Gets the current class name
  98416. * @returns the class name
  98417. */
  98418. getClassName(): string;
  98419. /**
  98420. * Gets the world position input component
  98421. */
  98422. abstract get position(): NodeMaterialConnectionPoint;
  98423. /**
  98424. * Gets the world position input component
  98425. */
  98426. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98427. /**
  98428. * Gets the world normal input component
  98429. */
  98430. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98431. /**
  98432. * Gets the world input component
  98433. */
  98434. abstract get world(): NodeMaterialConnectionPoint;
  98435. /**
  98436. * Gets the camera (or eye) position component
  98437. */
  98438. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98439. /**
  98440. * Gets the view input component
  98441. */
  98442. abstract get view(): NodeMaterialConnectionPoint;
  98443. protected _getTexture(): Nullable<BaseTexture>;
  98444. autoConfigure(material: NodeMaterial): void;
  98445. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98446. isReady(): boolean;
  98447. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98448. /**
  98449. * Gets the code to inject in the vertex shader
  98450. * @param state current state of the node material building
  98451. * @returns the shader code
  98452. */
  98453. handleVertexSide(state: NodeMaterialBuildState): string;
  98454. /**
  98455. * Handles the inits for the fragment code path
  98456. * @param state node material build state
  98457. */
  98458. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98459. /**
  98460. * Generates the reflection coords code for the fragment code path
  98461. * @param worldNormalVarName name of the world normal variable
  98462. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98463. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98464. * @returns the shader code
  98465. */
  98466. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98467. /**
  98468. * Generates the reflection color code for the fragment code path
  98469. * @param lodVarName name of the lod variable
  98470. * @param swizzleLookupTexture swizzle to use for the final color variable
  98471. * @returns the shader code
  98472. */
  98473. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98474. /**
  98475. * Generates the code corresponding to the connected output points
  98476. * @param state node material build state
  98477. * @param varName name of the variable to output
  98478. * @returns the shader code
  98479. */
  98480. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98481. protected _buildBlock(state: NodeMaterialBuildState): this;
  98482. protected _dumpPropertiesCode(): string;
  98483. serialize(): any;
  98484. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98485. }
  98486. }
  98487. declare module BABYLON {
  98488. /**
  98489. * Defines a connection point to be used for points with a custom object type
  98490. */
  98491. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98492. private _blockType;
  98493. private _blockName;
  98494. private _nameForCheking?;
  98495. /**
  98496. * Creates a new connection point
  98497. * @param name defines the connection point name
  98498. * @param ownerBlock defines the block hosting this connection point
  98499. * @param direction defines the direction of the connection point
  98500. */
  98501. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98502. /**
  98503. * Gets a number indicating if the current point can be connected to another point
  98504. * @param connectionPoint defines the other connection point
  98505. * @returns a number defining the compatibility state
  98506. */
  98507. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98508. /**
  98509. * Creates a block suitable to be used as an input for this input point.
  98510. * If null is returned, a block based on the point type will be created.
  98511. * @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
  98512. */
  98513. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98514. }
  98515. }
  98516. declare module BABYLON {
  98517. /**
  98518. * Enum defining the type of properties that can be edited in the property pages in the NME
  98519. */
  98520. export enum PropertyTypeForEdition {
  98521. /** property is a boolean */
  98522. Boolean = 0,
  98523. /** property is a float */
  98524. Float = 1,
  98525. /** property is a Vector2 */
  98526. Vector2 = 2,
  98527. /** property is a list of values */
  98528. List = 3
  98529. }
  98530. /**
  98531. * Interface that defines an option in a variable of type list
  98532. */
  98533. export interface IEditablePropertyListOption {
  98534. /** label of the option */
  98535. "label": string;
  98536. /** value of the option */
  98537. "value": number;
  98538. }
  98539. /**
  98540. * Interface that defines the options available for an editable property
  98541. */
  98542. export interface IEditablePropertyOption {
  98543. /** min value */
  98544. "min"?: number;
  98545. /** max value */
  98546. "max"?: number;
  98547. /** notifiers: indicates which actions to take when the property is changed */
  98548. "notifiers"?: {
  98549. /** the material should be rebuilt */
  98550. "rebuild"?: boolean;
  98551. /** the preview should be updated */
  98552. "update"?: boolean;
  98553. };
  98554. /** list of the options for a variable of type list */
  98555. "options"?: IEditablePropertyListOption[];
  98556. }
  98557. /**
  98558. * Interface that describes an editable property
  98559. */
  98560. export interface IPropertyDescriptionForEdition {
  98561. /** name of the property */
  98562. "propertyName": string;
  98563. /** display name of the property */
  98564. "displayName": string;
  98565. /** type of the property */
  98566. "type": PropertyTypeForEdition;
  98567. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98568. "groupName": string;
  98569. /** options for the property */
  98570. "options": IEditablePropertyOption;
  98571. }
  98572. /**
  98573. * Decorator that flags a property in a node material block as being editable
  98574. */
  98575. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98576. }
  98577. declare module BABYLON {
  98578. /**
  98579. * Block used to implement the refraction part of the sub surface module of the PBR material
  98580. */
  98581. export class RefractionBlock extends NodeMaterialBlock {
  98582. /** @hidden */
  98583. _define3DName: string;
  98584. /** @hidden */
  98585. _refractionMatrixName: string;
  98586. /** @hidden */
  98587. _defineLODRefractionAlpha: string;
  98588. /** @hidden */
  98589. _defineLinearSpecularRefraction: string;
  98590. /** @hidden */
  98591. _defineOppositeZ: string;
  98592. /** @hidden */
  98593. _cubeSamplerName: string;
  98594. /** @hidden */
  98595. _2DSamplerName: string;
  98596. /** @hidden */
  98597. _vRefractionMicrosurfaceInfosName: string;
  98598. /** @hidden */
  98599. _vRefractionInfosName: string;
  98600. private _scene;
  98601. /**
  98602. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98603. * Materials half opaque for instance using refraction could benefit from this control.
  98604. */
  98605. linkRefractionWithTransparency: boolean;
  98606. /**
  98607. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98608. */
  98609. invertRefractionY: boolean;
  98610. /**
  98611. * Gets or sets the texture associated with the node
  98612. */
  98613. texture: Nullable<BaseTexture>;
  98614. /**
  98615. * Create a new RefractionBlock
  98616. * @param name defines the block name
  98617. */
  98618. constructor(name: string);
  98619. /**
  98620. * Gets the current class name
  98621. * @returns the class name
  98622. */
  98623. getClassName(): string;
  98624. /**
  98625. * Gets the intensity input component
  98626. */
  98627. get intensity(): NodeMaterialConnectionPoint;
  98628. /**
  98629. * Gets the index of refraction input component
  98630. */
  98631. get indexOfRefraction(): NodeMaterialConnectionPoint;
  98632. /**
  98633. * Gets the tint at distance input component
  98634. */
  98635. get tintAtDistance(): NodeMaterialConnectionPoint;
  98636. /**
  98637. * Gets the view input component
  98638. */
  98639. get view(): NodeMaterialConnectionPoint;
  98640. /**
  98641. * Gets the refraction object output component
  98642. */
  98643. get refraction(): NodeMaterialConnectionPoint;
  98644. /**
  98645. * Returns true if the block has a texture
  98646. */
  98647. get hasTexture(): boolean;
  98648. protected _getTexture(): Nullable<BaseTexture>;
  98649. autoConfigure(material: NodeMaterial): void;
  98650. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98651. isReady(): boolean;
  98652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98653. /**
  98654. * Gets the main code of the block (fragment side)
  98655. * @param state current state of the node material building
  98656. * @returns the shader code
  98657. */
  98658. getCode(state: NodeMaterialBuildState): string;
  98659. protected _buildBlock(state: NodeMaterialBuildState): this;
  98660. protected _dumpPropertiesCode(): string;
  98661. serialize(): any;
  98662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98663. }
  98664. }
  98665. declare module BABYLON {
  98666. /**
  98667. * Base block used as input for post process
  98668. */
  98669. export class CurrentScreenBlock extends NodeMaterialBlock {
  98670. private _samplerName;
  98671. private _linearDefineName;
  98672. private _gammaDefineName;
  98673. private _mainUVName;
  98674. private _tempTextureRead;
  98675. /**
  98676. * Gets or sets the texture associated with the node
  98677. */
  98678. texture: Nullable<BaseTexture>;
  98679. /**
  98680. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98681. */
  98682. convertToGammaSpace: boolean;
  98683. /**
  98684. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98685. */
  98686. convertToLinearSpace: boolean;
  98687. /**
  98688. * Create a new CurrentScreenBlock
  98689. * @param name defines the block name
  98690. */
  98691. constructor(name: string);
  98692. /**
  98693. * Gets the current class name
  98694. * @returns the class name
  98695. */
  98696. getClassName(): string;
  98697. /**
  98698. * Gets the uv input component
  98699. */
  98700. get uv(): NodeMaterialConnectionPoint;
  98701. /**
  98702. * Gets the rgba output component
  98703. */
  98704. get rgba(): NodeMaterialConnectionPoint;
  98705. /**
  98706. * Gets the rgb output component
  98707. */
  98708. get rgb(): NodeMaterialConnectionPoint;
  98709. /**
  98710. * Gets the r output component
  98711. */
  98712. get r(): NodeMaterialConnectionPoint;
  98713. /**
  98714. * Gets the g output component
  98715. */
  98716. get g(): NodeMaterialConnectionPoint;
  98717. /**
  98718. * Gets the b output component
  98719. */
  98720. get b(): NodeMaterialConnectionPoint;
  98721. /**
  98722. * Gets the a output component
  98723. */
  98724. get a(): NodeMaterialConnectionPoint;
  98725. /**
  98726. * Initialize the block and prepare the context for build
  98727. * @param state defines the state that will be used for the build
  98728. */
  98729. initialize(state: NodeMaterialBuildState): void;
  98730. get target(): NodeMaterialBlockTargets;
  98731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98732. isReady(): boolean;
  98733. private _injectVertexCode;
  98734. private _writeTextureRead;
  98735. private _writeOutput;
  98736. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98737. serialize(): any;
  98738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98739. }
  98740. }
  98741. declare module BABYLON {
  98742. /**
  98743. * Base block used for the particle texture
  98744. */
  98745. export class ParticleTextureBlock extends NodeMaterialBlock {
  98746. private _samplerName;
  98747. private _linearDefineName;
  98748. private _gammaDefineName;
  98749. private _tempTextureRead;
  98750. /**
  98751. * Gets or sets the texture associated with the node
  98752. */
  98753. texture: Nullable<BaseTexture>;
  98754. /**
  98755. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98756. */
  98757. convertToGammaSpace: boolean;
  98758. /**
  98759. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98760. */
  98761. convertToLinearSpace: boolean;
  98762. /**
  98763. * Create a new ParticleTextureBlock
  98764. * @param name defines the block name
  98765. */
  98766. constructor(name: string);
  98767. /**
  98768. * Gets the current class name
  98769. * @returns the class name
  98770. */
  98771. getClassName(): string;
  98772. /**
  98773. * Gets the uv input component
  98774. */
  98775. get uv(): NodeMaterialConnectionPoint;
  98776. /**
  98777. * Gets the rgba output component
  98778. */
  98779. get rgba(): NodeMaterialConnectionPoint;
  98780. /**
  98781. * Gets the rgb output component
  98782. */
  98783. get rgb(): NodeMaterialConnectionPoint;
  98784. /**
  98785. * Gets the r output component
  98786. */
  98787. get r(): NodeMaterialConnectionPoint;
  98788. /**
  98789. * Gets the g output component
  98790. */
  98791. get g(): NodeMaterialConnectionPoint;
  98792. /**
  98793. * Gets the b output component
  98794. */
  98795. get b(): NodeMaterialConnectionPoint;
  98796. /**
  98797. * Gets the a output component
  98798. */
  98799. get a(): NodeMaterialConnectionPoint;
  98800. /**
  98801. * Initialize the block and prepare the context for build
  98802. * @param state defines the state that will be used for the build
  98803. */
  98804. initialize(state: NodeMaterialBuildState): void;
  98805. autoConfigure(material: NodeMaterial): void;
  98806. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98807. isReady(): boolean;
  98808. private _writeOutput;
  98809. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98810. serialize(): any;
  98811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98812. }
  98813. }
  98814. declare module BABYLON {
  98815. /**
  98816. * Class used to store shared data between 2 NodeMaterialBuildState
  98817. */
  98818. export class NodeMaterialBuildStateSharedData {
  98819. /**
  98820. * Gets the list of emitted varyings
  98821. */
  98822. temps: string[];
  98823. /**
  98824. * Gets the list of emitted varyings
  98825. */
  98826. varyings: string[];
  98827. /**
  98828. * Gets the varying declaration string
  98829. */
  98830. varyingDeclaration: string;
  98831. /**
  98832. * Input blocks
  98833. */
  98834. inputBlocks: InputBlock[];
  98835. /**
  98836. * Input blocks
  98837. */
  98838. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98839. /**
  98840. * Bindable blocks (Blocks that need to set data to the effect)
  98841. */
  98842. bindableBlocks: NodeMaterialBlock[];
  98843. /**
  98844. * List of blocks that can provide a compilation fallback
  98845. */
  98846. blocksWithFallbacks: NodeMaterialBlock[];
  98847. /**
  98848. * List of blocks that can provide a define update
  98849. */
  98850. blocksWithDefines: NodeMaterialBlock[];
  98851. /**
  98852. * List of blocks that can provide a repeatable content
  98853. */
  98854. repeatableContentBlocks: NodeMaterialBlock[];
  98855. /**
  98856. * List of blocks that can provide a dynamic list of uniforms
  98857. */
  98858. dynamicUniformBlocks: NodeMaterialBlock[];
  98859. /**
  98860. * List of blocks that can block the isReady function for the material
  98861. */
  98862. blockingBlocks: NodeMaterialBlock[];
  98863. /**
  98864. * Gets the list of animated inputs
  98865. */
  98866. animatedInputs: InputBlock[];
  98867. /**
  98868. * Build Id used to avoid multiple recompilations
  98869. */
  98870. buildId: number;
  98871. /** List of emitted variables */
  98872. variableNames: {
  98873. [key: string]: number;
  98874. };
  98875. /** List of emitted defines */
  98876. defineNames: {
  98877. [key: string]: number;
  98878. };
  98879. /** Should emit comments? */
  98880. emitComments: boolean;
  98881. /** Emit build activity */
  98882. verbose: boolean;
  98883. /** Gets or sets the hosting scene */
  98884. scene: Scene;
  98885. /**
  98886. * Gets the compilation hints emitted at compilation time
  98887. */
  98888. hints: {
  98889. needWorldViewMatrix: boolean;
  98890. needWorldViewProjectionMatrix: boolean;
  98891. needAlphaBlending: boolean;
  98892. needAlphaTesting: boolean;
  98893. };
  98894. /**
  98895. * List of compilation checks
  98896. */
  98897. checks: {
  98898. emitVertex: boolean;
  98899. emitFragment: boolean;
  98900. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98901. };
  98902. /**
  98903. * Is vertex program allowed to be empty?
  98904. */
  98905. allowEmptyVertexProgram: boolean;
  98906. /** Creates a new shared data */
  98907. constructor();
  98908. /**
  98909. * Emits console errors and exceptions if there is a failing check
  98910. */
  98911. emitErrors(): void;
  98912. }
  98913. }
  98914. declare module BABYLON {
  98915. /**
  98916. * Class used to store node based material build state
  98917. */
  98918. export class NodeMaterialBuildState {
  98919. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98920. supportUniformBuffers: boolean;
  98921. /**
  98922. * Gets the list of emitted attributes
  98923. */
  98924. attributes: string[];
  98925. /**
  98926. * Gets the list of emitted uniforms
  98927. */
  98928. uniforms: string[];
  98929. /**
  98930. * Gets the list of emitted constants
  98931. */
  98932. constants: string[];
  98933. /**
  98934. * Gets the list of emitted samplers
  98935. */
  98936. samplers: string[];
  98937. /**
  98938. * Gets the list of emitted functions
  98939. */
  98940. functions: {
  98941. [key: string]: string;
  98942. };
  98943. /**
  98944. * Gets the list of emitted extensions
  98945. */
  98946. extensions: {
  98947. [key: string]: string;
  98948. };
  98949. /**
  98950. * Gets the target of the compilation state
  98951. */
  98952. target: NodeMaterialBlockTargets;
  98953. /**
  98954. * Gets the list of emitted counters
  98955. */
  98956. counters: {
  98957. [key: string]: number;
  98958. };
  98959. /**
  98960. * Shared data between multiple NodeMaterialBuildState instances
  98961. */
  98962. sharedData: NodeMaterialBuildStateSharedData;
  98963. /** @hidden */
  98964. _vertexState: NodeMaterialBuildState;
  98965. /** @hidden */
  98966. _attributeDeclaration: string;
  98967. /** @hidden */
  98968. _uniformDeclaration: string;
  98969. /** @hidden */
  98970. _constantDeclaration: string;
  98971. /** @hidden */
  98972. _samplerDeclaration: string;
  98973. /** @hidden */
  98974. _varyingTransfer: string;
  98975. /** @hidden */
  98976. _injectAtEnd: string;
  98977. private _repeatableContentAnchorIndex;
  98978. /** @hidden */
  98979. _builtCompilationString: string;
  98980. /**
  98981. * Gets the emitted compilation strings
  98982. */
  98983. compilationString: string;
  98984. /**
  98985. * Finalize the compilation strings
  98986. * @param state defines the current compilation state
  98987. */
  98988. finalize(state: NodeMaterialBuildState): void;
  98989. /** @hidden */
  98990. get _repeatableContentAnchor(): string;
  98991. /** @hidden */
  98992. _getFreeVariableName(prefix: string): string;
  98993. /** @hidden */
  98994. _getFreeDefineName(prefix: string): string;
  98995. /** @hidden */
  98996. _excludeVariableName(name: string): void;
  98997. /** @hidden */
  98998. _emit2DSampler(name: string): void;
  98999. /** @hidden */
  99000. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99001. /** @hidden */
  99002. _emitExtension(name: string, extension: string, define?: string): void;
  99003. /** @hidden */
  99004. _emitFunction(name: string, code: string, comments: string): void;
  99005. /** @hidden */
  99006. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99007. replaceStrings?: {
  99008. search: RegExp;
  99009. replace: string;
  99010. }[];
  99011. repeatKey?: string;
  99012. }): string;
  99013. /** @hidden */
  99014. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99015. repeatKey?: string;
  99016. removeAttributes?: boolean;
  99017. removeUniforms?: boolean;
  99018. removeVaryings?: boolean;
  99019. removeIfDef?: boolean;
  99020. replaceStrings?: {
  99021. search: RegExp;
  99022. replace: string;
  99023. }[];
  99024. }, storeKey?: string): void;
  99025. /** @hidden */
  99026. _registerTempVariable(name: string): boolean;
  99027. /** @hidden */
  99028. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99029. /** @hidden */
  99030. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99031. /** @hidden */
  99032. _emitFloat(value: number): string;
  99033. }
  99034. }
  99035. declare module BABYLON {
  99036. /**
  99037. * Helper class used to generate session unique ID
  99038. */
  99039. export class UniqueIdGenerator {
  99040. private static _UniqueIdCounter;
  99041. /**
  99042. * Gets an unique (relatively to the current scene) Id
  99043. */
  99044. static get UniqueId(): number;
  99045. }
  99046. }
  99047. declare module BABYLON {
  99048. /**
  99049. * Defines a block that can be used inside a node based material
  99050. */
  99051. export class NodeMaterialBlock {
  99052. private _buildId;
  99053. private _buildTarget;
  99054. private _target;
  99055. private _isFinalMerger;
  99056. private _isInput;
  99057. protected _isUnique: boolean;
  99058. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99059. inputsAreExclusive: boolean;
  99060. /** @hidden */
  99061. _codeVariableName: string;
  99062. /** @hidden */
  99063. _inputs: NodeMaterialConnectionPoint[];
  99064. /** @hidden */
  99065. _outputs: NodeMaterialConnectionPoint[];
  99066. /** @hidden */
  99067. _preparationId: number;
  99068. /**
  99069. * Gets or sets the name of the block
  99070. */
  99071. name: string;
  99072. /**
  99073. * Gets or sets the unique id of the node
  99074. */
  99075. uniqueId: number;
  99076. /**
  99077. * Gets or sets the comments associated with this block
  99078. */
  99079. comments: string;
  99080. /**
  99081. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99082. */
  99083. get isUnique(): boolean;
  99084. /**
  99085. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99086. */
  99087. get isFinalMerger(): boolean;
  99088. /**
  99089. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99090. */
  99091. get isInput(): boolean;
  99092. /**
  99093. * Gets or sets the build Id
  99094. */
  99095. get buildId(): number;
  99096. set buildId(value: number);
  99097. /**
  99098. * Gets or sets the target of the block
  99099. */
  99100. get target(): NodeMaterialBlockTargets;
  99101. set target(value: NodeMaterialBlockTargets);
  99102. /**
  99103. * Gets the list of input points
  99104. */
  99105. get inputs(): NodeMaterialConnectionPoint[];
  99106. /** Gets the list of output points */
  99107. get outputs(): NodeMaterialConnectionPoint[];
  99108. /**
  99109. * Find an input by its name
  99110. * @param name defines the name of the input to look for
  99111. * @returns the input or null if not found
  99112. */
  99113. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99114. /**
  99115. * Find an output by its name
  99116. * @param name defines the name of the outputto look for
  99117. * @returns the output or null if not found
  99118. */
  99119. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99120. /**
  99121. * Creates a new NodeMaterialBlock
  99122. * @param name defines the block name
  99123. * @param target defines the target of that block (Vertex by default)
  99124. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99125. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99126. */
  99127. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99128. /**
  99129. * Initialize the block and prepare the context for build
  99130. * @param state defines the state that will be used for the build
  99131. */
  99132. initialize(state: NodeMaterialBuildState): void;
  99133. /**
  99134. * Bind data to effect. Will only be called for blocks with isBindable === true
  99135. * @param effect defines the effect to bind data to
  99136. * @param nodeMaterial defines the hosting NodeMaterial
  99137. * @param mesh defines the mesh that will be rendered
  99138. * @param subMesh defines the submesh that will be rendered
  99139. */
  99140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99141. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99142. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99143. protected _writeFloat(value: number): string;
  99144. /**
  99145. * Gets the current class name e.g. "NodeMaterialBlock"
  99146. * @returns the class name
  99147. */
  99148. getClassName(): string;
  99149. /**
  99150. * Register a new input. Must be called inside a block constructor
  99151. * @param name defines the connection point name
  99152. * @param type defines the connection point type
  99153. * @param isOptional defines a boolean indicating that this input can be omitted
  99154. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99155. * @param point an already created connection point. If not provided, create a new one
  99156. * @returns the current block
  99157. */
  99158. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99159. /**
  99160. * Register a new output. Must be called inside a block constructor
  99161. * @param name defines the connection point name
  99162. * @param type defines the connection point type
  99163. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99164. * @param point an already created connection point. If not provided, create a new one
  99165. * @returns the current block
  99166. */
  99167. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99168. /**
  99169. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99170. * @param forOutput defines an optional connection point to check compatibility with
  99171. * @returns the first available input or null
  99172. */
  99173. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99174. /**
  99175. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99176. * @param forBlock defines an optional block to check compatibility with
  99177. * @returns the first available input or null
  99178. */
  99179. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99180. /**
  99181. * Gets the sibling of the given output
  99182. * @param current defines the current output
  99183. * @returns the next output in the list or null
  99184. */
  99185. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99186. /**
  99187. * Connect current block with another block
  99188. * @param other defines the block to connect with
  99189. * @param options define the various options to help pick the right connections
  99190. * @returns the current block
  99191. */
  99192. connectTo(other: NodeMaterialBlock, options?: {
  99193. input?: string;
  99194. output?: string;
  99195. outputSwizzle?: string;
  99196. }): this | undefined;
  99197. protected _buildBlock(state: NodeMaterialBuildState): void;
  99198. /**
  99199. * Add uniforms, samplers and uniform buffers at compilation time
  99200. * @param state defines the state to update
  99201. * @param nodeMaterial defines the node material requesting the update
  99202. * @param defines defines the material defines to update
  99203. * @param uniformBuffers defines the list of uniform buffer names
  99204. */
  99205. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99206. /**
  99207. * Add potential fallbacks if shader compilation fails
  99208. * @param mesh defines the mesh to be rendered
  99209. * @param fallbacks defines the current prioritized list of fallbacks
  99210. */
  99211. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99212. /**
  99213. * Initialize defines for shader compilation
  99214. * @param mesh defines the mesh to be rendered
  99215. * @param nodeMaterial defines the node material requesting the update
  99216. * @param defines defines the material defines to update
  99217. * @param useInstances specifies that instances should be used
  99218. */
  99219. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99220. /**
  99221. * Update defines for shader compilation
  99222. * @param mesh defines the mesh to be rendered
  99223. * @param nodeMaterial defines the node material requesting the update
  99224. * @param defines defines the material defines to update
  99225. * @param useInstances specifies that instances should be used
  99226. * @param subMesh defines which submesh to render
  99227. */
  99228. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99229. /**
  99230. * Lets the block try to connect some inputs automatically
  99231. * @param material defines the hosting NodeMaterial
  99232. */
  99233. autoConfigure(material: NodeMaterial): void;
  99234. /**
  99235. * Function called when a block is declared as repeatable content generator
  99236. * @param vertexShaderState defines the current compilation state for the vertex shader
  99237. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99238. * @param mesh defines the mesh to be rendered
  99239. * @param defines defines the material defines to update
  99240. */
  99241. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99242. /**
  99243. * Checks if the block is ready
  99244. * @param mesh defines the mesh to be rendered
  99245. * @param nodeMaterial defines the node material requesting the update
  99246. * @param defines defines the material defines to update
  99247. * @param useInstances specifies that instances should be used
  99248. * @returns true if the block is ready
  99249. */
  99250. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99251. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99252. private _processBuild;
  99253. /**
  99254. * Compile the current node and generate the shader code
  99255. * @param state defines the current compilation state (uniforms, samplers, current string)
  99256. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99257. * @returns true if already built
  99258. */
  99259. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99260. protected _inputRename(name: string): string;
  99261. protected _outputRename(name: string): string;
  99262. protected _dumpPropertiesCode(): string;
  99263. /** @hidden */
  99264. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99265. /** @hidden */
  99266. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99267. /**
  99268. * Clone the current block to a new identical block
  99269. * @param scene defines the hosting scene
  99270. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99271. * @returns a copy of the current block
  99272. */
  99273. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99274. /**
  99275. * Serializes this block in a JSON representation
  99276. * @returns the serialized block object
  99277. */
  99278. serialize(): any;
  99279. /** @hidden */
  99280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99281. private _deserializePortDisplayNamesAndExposedOnFrame;
  99282. /**
  99283. * Release resources
  99284. */
  99285. dispose(): void;
  99286. }
  99287. }
  99288. declare module BABYLON {
  99289. /**
  99290. * Base class of materials working in push mode in babylon JS
  99291. * @hidden
  99292. */
  99293. export class PushMaterial extends Material {
  99294. protected _activeEffect: Effect;
  99295. protected _normalMatrix: Matrix;
  99296. constructor(name: string, scene: Scene);
  99297. getEffect(): Effect;
  99298. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99299. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99300. /**
  99301. * Binds the given world matrix to the active effect
  99302. *
  99303. * @param world the matrix to bind
  99304. */
  99305. bindOnlyWorldMatrix(world: Matrix): void;
  99306. /**
  99307. * Binds the given normal matrix to the active effect
  99308. *
  99309. * @param normalMatrix the matrix to bind
  99310. */
  99311. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99312. bind(world: Matrix, mesh?: Mesh): void;
  99313. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99314. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99315. }
  99316. }
  99317. declare module BABYLON {
  99318. /**
  99319. * Root class for all node material optimizers
  99320. */
  99321. export class NodeMaterialOptimizer {
  99322. /**
  99323. * Function used to optimize a NodeMaterial graph
  99324. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99325. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99326. */
  99327. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99328. }
  99329. }
  99330. declare module BABYLON {
  99331. /**
  99332. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99333. */
  99334. export class TransformBlock extends NodeMaterialBlock {
  99335. /**
  99336. * Defines the value to use to complement W value to transform it to a Vector4
  99337. */
  99338. complementW: number;
  99339. /**
  99340. * Defines the value to use to complement z value to transform it to a Vector4
  99341. */
  99342. complementZ: number;
  99343. /**
  99344. * Creates a new TransformBlock
  99345. * @param name defines the block name
  99346. */
  99347. constructor(name: string);
  99348. /**
  99349. * Gets the current class name
  99350. * @returns the class name
  99351. */
  99352. getClassName(): string;
  99353. /**
  99354. * Gets the vector input
  99355. */
  99356. get vector(): NodeMaterialConnectionPoint;
  99357. /**
  99358. * Gets the output component
  99359. */
  99360. get output(): NodeMaterialConnectionPoint;
  99361. /**
  99362. * Gets the xyz output component
  99363. */
  99364. get xyz(): NodeMaterialConnectionPoint;
  99365. /**
  99366. * Gets the matrix transform input
  99367. */
  99368. get transform(): NodeMaterialConnectionPoint;
  99369. protected _buildBlock(state: NodeMaterialBuildState): this;
  99370. /**
  99371. * Update defines for shader compilation
  99372. * @param mesh defines the mesh to be rendered
  99373. * @param nodeMaterial defines the node material requesting the update
  99374. * @param defines defines the material defines to update
  99375. * @param useInstances specifies that instances should be used
  99376. * @param subMesh defines which submesh to render
  99377. */
  99378. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99379. serialize(): any;
  99380. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99381. protected _dumpPropertiesCode(): string;
  99382. }
  99383. }
  99384. declare module BABYLON {
  99385. /**
  99386. * Block used to output the vertex position
  99387. */
  99388. export class VertexOutputBlock extends NodeMaterialBlock {
  99389. /**
  99390. * Creates a new VertexOutputBlock
  99391. * @param name defines the block name
  99392. */
  99393. constructor(name: string);
  99394. /**
  99395. * Gets the current class name
  99396. * @returns the class name
  99397. */
  99398. getClassName(): string;
  99399. /**
  99400. * Gets the vector input component
  99401. */
  99402. get vector(): NodeMaterialConnectionPoint;
  99403. protected _buildBlock(state: NodeMaterialBuildState): this;
  99404. }
  99405. }
  99406. declare module BABYLON {
  99407. /**
  99408. * Block used to output the final color
  99409. */
  99410. export class FragmentOutputBlock extends NodeMaterialBlock {
  99411. /**
  99412. * Create a new FragmentOutputBlock
  99413. * @param name defines the block name
  99414. */
  99415. constructor(name: string);
  99416. /**
  99417. * Gets the current class name
  99418. * @returns the class name
  99419. */
  99420. getClassName(): string;
  99421. /**
  99422. * Gets the rgba input component
  99423. */
  99424. get rgba(): NodeMaterialConnectionPoint;
  99425. /**
  99426. * Gets the rgb input component
  99427. */
  99428. get rgb(): NodeMaterialConnectionPoint;
  99429. /**
  99430. * Gets the a input component
  99431. */
  99432. get a(): NodeMaterialConnectionPoint;
  99433. protected _buildBlock(state: NodeMaterialBuildState): this;
  99434. }
  99435. }
  99436. declare module BABYLON {
  99437. /**
  99438. * Block used for the particle ramp gradient section
  99439. */
  99440. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99441. /**
  99442. * Create a new ParticleRampGradientBlock
  99443. * @param name defines the block name
  99444. */
  99445. constructor(name: string);
  99446. /**
  99447. * Gets the current class name
  99448. * @returns the class name
  99449. */
  99450. getClassName(): string;
  99451. /**
  99452. * Gets the color input component
  99453. */
  99454. get color(): NodeMaterialConnectionPoint;
  99455. /**
  99456. * Gets the rampColor output component
  99457. */
  99458. get rampColor(): NodeMaterialConnectionPoint;
  99459. /**
  99460. * Initialize the block and prepare the context for build
  99461. * @param state defines the state that will be used for the build
  99462. */
  99463. initialize(state: NodeMaterialBuildState): void;
  99464. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99465. }
  99466. }
  99467. declare module BABYLON {
  99468. /**
  99469. * Block used for the particle blend multiply section
  99470. */
  99471. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99472. /**
  99473. * Create a new ParticleBlendMultiplyBlock
  99474. * @param name defines the block name
  99475. */
  99476. constructor(name: string);
  99477. /**
  99478. * Gets the current class name
  99479. * @returns the class name
  99480. */
  99481. getClassName(): string;
  99482. /**
  99483. * Gets the color input component
  99484. */
  99485. get color(): NodeMaterialConnectionPoint;
  99486. /**
  99487. * Gets the alphaTexture input component
  99488. */
  99489. get alphaTexture(): NodeMaterialConnectionPoint;
  99490. /**
  99491. * Gets the alphaColor input component
  99492. */
  99493. get alphaColor(): NodeMaterialConnectionPoint;
  99494. /**
  99495. * Gets the blendColor output component
  99496. */
  99497. get blendColor(): NodeMaterialConnectionPoint;
  99498. /**
  99499. * Initialize the block and prepare the context for build
  99500. * @param state defines the state that will be used for the build
  99501. */
  99502. initialize(state: NodeMaterialBuildState): void;
  99503. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99504. }
  99505. }
  99506. declare module BABYLON {
  99507. /**
  99508. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99509. */
  99510. export class VectorMergerBlock extends NodeMaterialBlock {
  99511. /**
  99512. * Create a new VectorMergerBlock
  99513. * @param name defines the block name
  99514. */
  99515. constructor(name: string);
  99516. /**
  99517. * Gets the current class name
  99518. * @returns the class name
  99519. */
  99520. getClassName(): string;
  99521. /**
  99522. * Gets the xyz component (input)
  99523. */
  99524. get xyzIn(): NodeMaterialConnectionPoint;
  99525. /**
  99526. * Gets the xy component (input)
  99527. */
  99528. get xyIn(): NodeMaterialConnectionPoint;
  99529. /**
  99530. * Gets the x component (input)
  99531. */
  99532. get x(): NodeMaterialConnectionPoint;
  99533. /**
  99534. * Gets the y component (input)
  99535. */
  99536. get y(): NodeMaterialConnectionPoint;
  99537. /**
  99538. * Gets the z component (input)
  99539. */
  99540. get z(): NodeMaterialConnectionPoint;
  99541. /**
  99542. * Gets the w component (input)
  99543. */
  99544. get w(): NodeMaterialConnectionPoint;
  99545. /**
  99546. * Gets the xyzw component (output)
  99547. */
  99548. get xyzw(): NodeMaterialConnectionPoint;
  99549. /**
  99550. * Gets the xyz component (output)
  99551. */
  99552. get xyzOut(): NodeMaterialConnectionPoint;
  99553. /**
  99554. * Gets the xy component (output)
  99555. */
  99556. get xyOut(): NodeMaterialConnectionPoint;
  99557. /**
  99558. * Gets the xy component (output)
  99559. * @deprecated Please use xyOut instead.
  99560. */
  99561. get xy(): NodeMaterialConnectionPoint;
  99562. /**
  99563. * Gets the xyz component (output)
  99564. * @deprecated Please use xyzOut instead.
  99565. */
  99566. get xyz(): NodeMaterialConnectionPoint;
  99567. protected _buildBlock(state: NodeMaterialBuildState): this;
  99568. }
  99569. }
  99570. declare module BABYLON {
  99571. /**
  99572. * Block used to remap a float from a range to a new one
  99573. */
  99574. export class RemapBlock extends NodeMaterialBlock {
  99575. /**
  99576. * Gets or sets the source range
  99577. */
  99578. sourceRange: Vector2;
  99579. /**
  99580. * Gets or sets the target range
  99581. */
  99582. targetRange: Vector2;
  99583. /**
  99584. * Creates a new RemapBlock
  99585. * @param name defines the block name
  99586. */
  99587. constructor(name: string);
  99588. /**
  99589. * Gets the current class name
  99590. * @returns the class name
  99591. */
  99592. getClassName(): string;
  99593. /**
  99594. * Gets the input component
  99595. */
  99596. get input(): NodeMaterialConnectionPoint;
  99597. /**
  99598. * Gets the source min input component
  99599. */
  99600. get sourceMin(): NodeMaterialConnectionPoint;
  99601. /**
  99602. * Gets the source max input component
  99603. */
  99604. get sourceMax(): NodeMaterialConnectionPoint;
  99605. /**
  99606. * Gets the target min input component
  99607. */
  99608. get targetMin(): NodeMaterialConnectionPoint;
  99609. /**
  99610. * Gets the target max input component
  99611. */
  99612. get targetMax(): NodeMaterialConnectionPoint;
  99613. /**
  99614. * Gets the output component
  99615. */
  99616. get output(): NodeMaterialConnectionPoint;
  99617. protected _buildBlock(state: NodeMaterialBuildState): this;
  99618. protected _dumpPropertiesCode(): string;
  99619. serialize(): any;
  99620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99621. }
  99622. }
  99623. declare module BABYLON {
  99624. /**
  99625. * Block used to multiply 2 values
  99626. */
  99627. export class MultiplyBlock extends NodeMaterialBlock {
  99628. /**
  99629. * Creates a new MultiplyBlock
  99630. * @param name defines the block name
  99631. */
  99632. constructor(name: string);
  99633. /**
  99634. * Gets the current class name
  99635. * @returns the class name
  99636. */
  99637. getClassName(): string;
  99638. /**
  99639. * Gets the left operand input component
  99640. */
  99641. get left(): NodeMaterialConnectionPoint;
  99642. /**
  99643. * Gets the right operand input component
  99644. */
  99645. get right(): NodeMaterialConnectionPoint;
  99646. /**
  99647. * Gets the output component
  99648. */
  99649. get output(): NodeMaterialConnectionPoint;
  99650. protected _buildBlock(state: NodeMaterialBuildState): this;
  99651. }
  99652. }
  99653. declare module BABYLON {
  99654. /**
  99655. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  99656. */
  99657. export class ColorSplitterBlock extends NodeMaterialBlock {
  99658. /**
  99659. * Create a new ColorSplitterBlock
  99660. * @param name defines the block name
  99661. */
  99662. constructor(name: string);
  99663. /**
  99664. * Gets the current class name
  99665. * @returns the class name
  99666. */
  99667. getClassName(): string;
  99668. /**
  99669. * Gets the rgba component (input)
  99670. */
  99671. get rgba(): NodeMaterialConnectionPoint;
  99672. /**
  99673. * Gets the rgb component (input)
  99674. */
  99675. get rgbIn(): NodeMaterialConnectionPoint;
  99676. /**
  99677. * Gets the rgb component (output)
  99678. */
  99679. get rgbOut(): NodeMaterialConnectionPoint;
  99680. /**
  99681. * Gets the r component (output)
  99682. */
  99683. get r(): NodeMaterialConnectionPoint;
  99684. /**
  99685. * Gets the g component (output)
  99686. */
  99687. get g(): NodeMaterialConnectionPoint;
  99688. /**
  99689. * Gets the b component (output)
  99690. */
  99691. get b(): NodeMaterialConnectionPoint;
  99692. /**
  99693. * Gets the a component (output)
  99694. */
  99695. get a(): NodeMaterialConnectionPoint;
  99696. protected _inputRename(name: string): string;
  99697. protected _outputRename(name: string): string;
  99698. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99699. }
  99700. }
  99701. declare module BABYLON {
  99702. /**
  99703. * Interface used to configure the node material editor
  99704. */
  99705. export interface INodeMaterialEditorOptions {
  99706. /** Define the URl to load node editor script */
  99707. editorURL?: string;
  99708. }
  99709. /** @hidden */
  99710. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99711. NORMAL: boolean;
  99712. TANGENT: boolean;
  99713. UV1: boolean;
  99714. /** BONES */
  99715. NUM_BONE_INFLUENCERS: number;
  99716. BonesPerMesh: number;
  99717. BONETEXTURE: boolean;
  99718. /** MORPH TARGETS */
  99719. MORPHTARGETS: boolean;
  99720. MORPHTARGETS_NORMAL: boolean;
  99721. MORPHTARGETS_TANGENT: boolean;
  99722. MORPHTARGETS_UV: boolean;
  99723. NUM_MORPH_INFLUENCERS: number;
  99724. /** IMAGE PROCESSING */
  99725. IMAGEPROCESSING: boolean;
  99726. VIGNETTE: boolean;
  99727. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99728. VIGNETTEBLENDMODEOPAQUE: boolean;
  99729. TONEMAPPING: boolean;
  99730. TONEMAPPING_ACES: boolean;
  99731. CONTRAST: boolean;
  99732. EXPOSURE: boolean;
  99733. COLORCURVES: boolean;
  99734. COLORGRADING: boolean;
  99735. COLORGRADING3D: boolean;
  99736. SAMPLER3DGREENDEPTH: boolean;
  99737. SAMPLER3DBGRMAP: boolean;
  99738. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99739. /** MISC. */
  99740. BUMPDIRECTUV: number;
  99741. constructor();
  99742. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  99743. }
  99744. /**
  99745. * Class used to configure NodeMaterial
  99746. */
  99747. export interface INodeMaterialOptions {
  99748. /**
  99749. * Defines if blocks should emit comments
  99750. */
  99751. emitComments: boolean;
  99752. }
  99753. /**
  99754. * Class used to create a node based material built by assembling shader blocks
  99755. */
  99756. export class NodeMaterial extends PushMaterial {
  99757. private static _BuildIdGenerator;
  99758. private _options;
  99759. private _vertexCompilationState;
  99760. private _fragmentCompilationState;
  99761. private _sharedData;
  99762. private _buildId;
  99763. private _buildWasSuccessful;
  99764. private _cachedWorldViewMatrix;
  99765. private _cachedWorldViewProjectionMatrix;
  99766. private _optimizers;
  99767. private _animationFrame;
  99768. /** Define the Url to load node editor script */
  99769. static EditorURL: string;
  99770. /** Define the Url to load snippets */
  99771. static SnippetUrl: string;
  99772. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  99773. static IgnoreTexturesAtLoadTime: boolean;
  99774. private BJSNODEMATERIALEDITOR;
  99775. /** Get the inspector from bundle or global */
  99776. private _getGlobalNodeMaterialEditor;
  99777. /**
  99778. * Snippet ID if the material was created from the snippet server
  99779. */
  99780. snippetId: string;
  99781. /**
  99782. * Gets or sets data used by visual editor
  99783. * @see https://nme.babylonjs.com
  99784. */
  99785. editorData: any;
  99786. /**
  99787. * 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)
  99788. */
  99789. ignoreAlpha: boolean;
  99790. /**
  99791. * Defines the maximum number of lights that can be used in the material
  99792. */
  99793. maxSimultaneousLights: number;
  99794. /**
  99795. * Observable raised when the material is built
  99796. */
  99797. onBuildObservable: Observable<NodeMaterial>;
  99798. /**
  99799. * Gets or sets the root nodes of the material vertex shader
  99800. */
  99801. _vertexOutputNodes: NodeMaterialBlock[];
  99802. /**
  99803. * Gets or sets the root nodes of the material fragment (pixel) shader
  99804. */
  99805. _fragmentOutputNodes: NodeMaterialBlock[];
  99806. /** Gets or sets options to control the node material overall behavior */
  99807. get options(): INodeMaterialOptions;
  99808. set options(options: INodeMaterialOptions);
  99809. /**
  99810. * Default configuration related to image processing available in the standard Material.
  99811. */
  99812. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99813. /**
  99814. * Gets the image processing configuration used either in this material.
  99815. */
  99816. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99817. /**
  99818. * Sets the Default image processing configuration used either in the this material.
  99819. *
  99820. * If sets to null, the scene one is in use.
  99821. */
  99822. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99823. /**
  99824. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99825. */
  99826. attachedBlocks: NodeMaterialBlock[];
  99827. /**
  99828. * Specifies the mode of the node material
  99829. * @hidden
  99830. */
  99831. _mode: NodeMaterialModes;
  99832. /**
  99833. * Gets the mode property
  99834. */
  99835. get mode(): NodeMaterialModes;
  99836. /**
  99837. * Create a new node based material
  99838. * @param name defines the material name
  99839. * @param scene defines the hosting scene
  99840. * @param options defines creation option
  99841. */
  99842. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99843. /**
  99844. * Gets the current class name of the material e.g. "NodeMaterial"
  99845. * @returns the class name
  99846. */
  99847. getClassName(): string;
  99848. /**
  99849. * Keep track of the image processing observer to allow dispose and replace.
  99850. */
  99851. private _imageProcessingObserver;
  99852. /**
  99853. * Attaches a new image processing configuration to the Standard Material.
  99854. * @param configuration
  99855. */
  99856. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99857. /**
  99858. * Get a block by its name
  99859. * @param name defines the name of the block to retrieve
  99860. * @returns the required block or null if not found
  99861. */
  99862. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99863. /**
  99864. * Get a block by its name
  99865. * @param predicate defines the predicate used to find the good candidate
  99866. * @returns the required block or null if not found
  99867. */
  99868. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99869. /**
  99870. * Get an input block by its name
  99871. * @param predicate defines the predicate used to find the good candidate
  99872. * @returns the required input block or null if not found
  99873. */
  99874. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99875. /**
  99876. * Gets the list of input blocks attached to this material
  99877. * @returns an array of InputBlocks
  99878. */
  99879. getInputBlocks(): InputBlock[];
  99880. /**
  99881. * Adds a new optimizer to the list of optimizers
  99882. * @param optimizer defines the optimizers to add
  99883. * @returns the current material
  99884. */
  99885. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99886. /**
  99887. * Remove an optimizer from the list of optimizers
  99888. * @param optimizer defines the optimizers to remove
  99889. * @returns the current material
  99890. */
  99891. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99892. /**
  99893. * Add a new block to the list of output nodes
  99894. * @param node defines the node to add
  99895. * @returns the current material
  99896. */
  99897. addOutputNode(node: NodeMaterialBlock): this;
  99898. /**
  99899. * Remove a block from the list of root nodes
  99900. * @param node defines the node to remove
  99901. * @returns the current material
  99902. */
  99903. removeOutputNode(node: NodeMaterialBlock): this;
  99904. private _addVertexOutputNode;
  99905. private _removeVertexOutputNode;
  99906. private _addFragmentOutputNode;
  99907. private _removeFragmentOutputNode;
  99908. /**
  99909. * Specifies if the material will require alpha blending
  99910. * @returns a boolean specifying if alpha blending is needed
  99911. */
  99912. needAlphaBlending(): boolean;
  99913. /**
  99914. * Specifies if this material should be rendered in alpha test mode
  99915. * @returns a boolean specifying if an alpha test is needed.
  99916. */
  99917. needAlphaTesting(): boolean;
  99918. private _initializeBlock;
  99919. private _resetDualBlocks;
  99920. /**
  99921. * Remove a block from the current node material
  99922. * @param block defines the block to remove
  99923. */
  99924. removeBlock(block: NodeMaterialBlock): void;
  99925. /**
  99926. * Build the material and generates the inner effect
  99927. * @param verbose defines if the build should log activity
  99928. */
  99929. build(verbose?: boolean): void;
  99930. /**
  99931. * Runs an otpimization phase to try to improve the shader code
  99932. */
  99933. optimize(): void;
  99934. private _prepareDefinesForAttributes;
  99935. /**
  99936. * Create a post process from the material
  99937. * @param camera The camera to apply the render pass to.
  99938. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99940. * @param engine The engine which the post process will be applied. (default: current engine)
  99941. * @param reusable If the post process can be reused on the same frame. (default: false)
  99942. * @param textureType Type of textures used when performing the post process. (default: 0)
  99943. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99944. * @returns the post process created
  99945. */
  99946. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99947. /**
  99948. * Create the post process effect from the material
  99949. * @param postProcess The post process to create the effect for
  99950. */
  99951. createEffectForPostProcess(postProcess: PostProcess): void;
  99952. private _createEffectOrPostProcess;
  99953. private _createEffectForParticles;
  99954. /**
  99955. * Create the effect to be used as the custom effect for a particle system
  99956. * @param particleSystem Particle system to create the effect for
  99957. * @param onCompiled defines a function to call when the effect creation is successful
  99958. * @param onError defines a function to call when the effect creation has failed
  99959. */
  99960. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99961. private _processDefines;
  99962. /**
  99963. * Get if the submesh is ready to be used and all its information available.
  99964. * Child classes can use it to update shaders
  99965. * @param mesh defines the mesh to check
  99966. * @param subMesh defines which submesh to check
  99967. * @param useInstances specifies that instances should be used
  99968. * @returns a boolean indicating that the submesh is ready or not
  99969. */
  99970. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99971. /**
  99972. * Get a string representing the shaders built by the current node graph
  99973. */
  99974. get compiledShaders(): string;
  99975. /**
  99976. * Binds the world matrix to the material
  99977. * @param world defines the world transformation matrix
  99978. */
  99979. bindOnlyWorldMatrix(world: Matrix): void;
  99980. /**
  99981. * Binds the submesh to this material by preparing the effect and shader to draw
  99982. * @param world defines the world transformation matrix
  99983. * @param mesh defines the mesh containing the submesh
  99984. * @param subMesh defines the submesh to bind the material to
  99985. */
  99986. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99987. /**
  99988. * Gets the active textures from the material
  99989. * @returns an array of textures
  99990. */
  99991. getActiveTextures(): BaseTexture[];
  99992. /**
  99993. * Gets the list of texture blocks
  99994. * @returns an array of texture blocks
  99995. */
  99996. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99997. /**
  99998. * Specifies if the material uses a texture
  99999. * @param texture defines the texture to check against the material
  100000. * @returns a boolean specifying if the material uses the texture
  100001. */
  100002. hasTexture(texture: BaseTexture): boolean;
  100003. /**
  100004. * Disposes the material
  100005. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100006. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100007. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100008. */
  100009. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100010. /** Creates the node editor window. */
  100011. private _createNodeEditor;
  100012. /**
  100013. * Launch the node material editor
  100014. * @param config Define the configuration of the editor
  100015. * @return a promise fulfilled when the node editor is visible
  100016. */
  100017. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100018. /**
  100019. * Clear the current material
  100020. */
  100021. clear(): void;
  100022. /**
  100023. * Clear the current material and set it to a default state
  100024. */
  100025. setToDefault(): void;
  100026. /**
  100027. * Clear the current material and set it to a default state for post process
  100028. */
  100029. setToDefaultPostProcess(): void;
  100030. /**
  100031. * Clear the current material and set it to a default state for particle
  100032. */
  100033. setToDefaultParticle(): void;
  100034. /**
  100035. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100036. * @param url defines the url to load from
  100037. * @returns a promise that will fullfil when the material is fully loaded
  100038. */
  100039. loadAsync(url: string): Promise<void>;
  100040. private _gatherBlocks;
  100041. /**
  100042. * Generate a string containing the code declaration required to create an equivalent of this material
  100043. * @returns a string
  100044. */
  100045. generateCode(): string;
  100046. /**
  100047. * Serializes this material in a JSON representation
  100048. * @returns the serialized material object
  100049. */
  100050. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100051. private _restoreConnections;
  100052. /**
  100053. * Clear the current graph and load a new one from a serialization object
  100054. * @param source defines the JSON representation of the material
  100055. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100056. * @param merge defines whether or not the source must be merged or replace the current content
  100057. */
  100058. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  100059. /**
  100060. * Makes a duplicate of the current material.
  100061. * @param name - name to use for the new material.
  100062. */
  100063. clone(name: string): NodeMaterial;
  100064. /**
  100065. * Creates a node material from parsed material data
  100066. * @param source defines the JSON representation of the material
  100067. * @param scene defines the hosting scene
  100068. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100069. * @returns a new node material
  100070. */
  100071. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100072. /**
  100073. * Creates a node material from a snippet saved in a remote file
  100074. * @param name defines the name of the material to create
  100075. * @param url defines the url to load from
  100076. * @param scene defines the hosting scene
  100077. * @returns a promise that will resolve to the new node material
  100078. */
  100079. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100080. /**
  100081. * Creates a node material from a snippet saved by the node material editor
  100082. * @param snippetId defines the snippet to load
  100083. * @param scene defines the hosting scene
  100084. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100085. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100086. * @returns a promise that will resolve to the new node material
  100087. */
  100088. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100089. /**
  100090. * Creates a new node material set to default basic configuration
  100091. * @param name defines the name of the material
  100092. * @param scene defines the hosting scene
  100093. * @returns a new NodeMaterial
  100094. */
  100095. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100096. }
  100097. }
  100098. declare module BABYLON {
  100099. /**
  100100. * Size options for a post process
  100101. */
  100102. export type PostProcessOptions = {
  100103. width: number;
  100104. height: number;
  100105. };
  100106. /**
  100107. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100108. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100109. */
  100110. export class PostProcess {
  100111. /** Name of the PostProcess. */
  100112. name: string;
  100113. /**
  100114. * Gets or sets the unique id of the post process
  100115. */
  100116. uniqueId: number;
  100117. /**
  100118. * Width of the texture to apply the post process on
  100119. */
  100120. width: number;
  100121. /**
  100122. * Height of the texture to apply the post process on
  100123. */
  100124. height: number;
  100125. /**
  100126. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100127. */
  100128. nodeMaterialSource: Nullable<NodeMaterial>;
  100129. /**
  100130. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100131. * @hidden
  100132. */
  100133. _outputTexture: Nullable<InternalTexture>;
  100134. /**
  100135. * Sampling mode used by the shader
  100136. * See https://doc.babylonjs.com/classes/3.1/texture
  100137. */
  100138. renderTargetSamplingMode: number;
  100139. /**
  100140. * Clear color to use when screen clearing
  100141. */
  100142. clearColor: Color4;
  100143. /**
  100144. * If the buffer needs to be cleared before applying the post process. (default: true)
  100145. * Should be set to false if shader will overwrite all previous pixels.
  100146. */
  100147. autoClear: boolean;
  100148. /**
  100149. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100150. */
  100151. alphaMode: number;
  100152. /**
  100153. * Sets the setAlphaBlendConstants of the babylon engine
  100154. */
  100155. alphaConstants: Color4;
  100156. /**
  100157. * Animations to be used for the post processing
  100158. */
  100159. animations: Animation[];
  100160. /**
  100161. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100162. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100163. */
  100164. enablePixelPerfectMode: boolean;
  100165. /**
  100166. * Force the postprocess to be applied without taking in account viewport
  100167. */
  100168. forceFullscreenViewport: boolean;
  100169. /**
  100170. * List of inspectable custom properties (used by the Inspector)
  100171. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100172. */
  100173. inspectableCustomProperties: IInspectable[];
  100174. /**
  100175. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100176. *
  100177. * | Value | Type | Description |
  100178. * | ----- | ----------------------------------- | ----------- |
  100179. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100180. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100181. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100182. *
  100183. */
  100184. scaleMode: number;
  100185. /**
  100186. * Force textures to be a power of two (default: false)
  100187. */
  100188. alwaysForcePOT: boolean;
  100189. private _samples;
  100190. /**
  100191. * Number of sample textures (default: 1)
  100192. */
  100193. get samples(): number;
  100194. set samples(n: number);
  100195. /**
  100196. * Modify the scale of the post process to be the same as the viewport (default: false)
  100197. */
  100198. adaptScaleToCurrentViewport: boolean;
  100199. private _camera;
  100200. private _scene;
  100201. private _engine;
  100202. private _options;
  100203. private _reusable;
  100204. private _textureType;
  100205. private _textureFormat;
  100206. /**
  100207. * Smart array of input and output textures for the post process.
  100208. * @hidden
  100209. */
  100210. _textures: SmartArray<InternalTexture>;
  100211. /**
  100212. * The index in _textures that corresponds to the output texture.
  100213. * @hidden
  100214. */
  100215. _currentRenderTextureInd: number;
  100216. private _effect;
  100217. private _samplers;
  100218. private _fragmentUrl;
  100219. private _vertexUrl;
  100220. private _parameters;
  100221. private _scaleRatio;
  100222. protected _indexParameters: any;
  100223. private _shareOutputWithPostProcess;
  100224. private _texelSize;
  100225. private _forcedOutputTexture;
  100226. /**
  100227. * Returns the fragment url or shader name used in the post process.
  100228. * @returns the fragment url or name in the shader store.
  100229. */
  100230. getEffectName(): string;
  100231. /**
  100232. * An event triggered when the postprocess is activated.
  100233. */
  100234. onActivateObservable: Observable<Camera>;
  100235. private _onActivateObserver;
  100236. /**
  100237. * A function that is added to the onActivateObservable
  100238. */
  100239. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100240. /**
  100241. * An event triggered when the postprocess changes its size.
  100242. */
  100243. onSizeChangedObservable: Observable<PostProcess>;
  100244. private _onSizeChangedObserver;
  100245. /**
  100246. * A function that is added to the onSizeChangedObservable
  100247. */
  100248. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100249. /**
  100250. * An event triggered when the postprocess applies its effect.
  100251. */
  100252. onApplyObservable: Observable<Effect>;
  100253. private _onApplyObserver;
  100254. /**
  100255. * A function that is added to the onApplyObservable
  100256. */
  100257. set onApply(callback: (effect: Effect) => void);
  100258. /**
  100259. * An event triggered before rendering the postprocess
  100260. */
  100261. onBeforeRenderObservable: Observable<Effect>;
  100262. private _onBeforeRenderObserver;
  100263. /**
  100264. * A function that is added to the onBeforeRenderObservable
  100265. */
  100266. set onBeforeRender(callback: (effect: Effect) => void);
  100267. /**
  100268. * An event triggered after rendering the postprocess
  100269. */
  100270. onAfterRenderObservable: Observable<Effect>;
  100271. private _onAfterRenderObserver;
  100272. /**
  100273. * A function that is added to the onAfterRenderObservable
  100274. */
  100275. set onAfterRender(callback: (efect: Effect) => void);
  100276. /**
  100277. * 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
  100278. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100279. */
  100280. get inputTexture(): InternalTexture;
  100281. set inputTexture(value: InternalTexture);
  100282. /**
  100283. * Gets the camera which post process is applied to.
  100284. * @returns The camera the post process is applied to.
  100285. */
  100286. getCamera(): Camera;
  100287. /**
  100288. * Gets the texel size of the postprocess.
  100289. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100290. */
  100291. get texelSize(): Vector2;
  100292. /**
  100293. * Creates a new instance PostProcess
  100294. * @param name The name of the PostProcess.
  100295. * @param fragmentUrl The url of the fragment shader to be used.
  100296. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100297. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100298. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100299. * @param camera The camera to apply the render pass to.
  100300. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100301. * @param engine The engine which the post process will be applied. (default: current engine)
  100302. * @param reusable If the post process can be reused on the same frame. (default: false)
  100303. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100304. * @param textureType Type of textures used when performing the post process. (default: 0)
  100305. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100306. * @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
  100307. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100308. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100309. */
  100310. constructor(
  100311. /** Name of the PostProcess. */
  100312. 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);
  100313. /**
  100314. * Gets a string idenfifying the name of the class
  100315. * @returns "PostProcess" string
  100316. */
  100317. getClassName(): string;
  100318. /**
  100319. * Gets the engine which this post process belongs to.
  100320. * @returns The engine the post process was enabled with.
  100321. */
  100322. getEngine(): Engine;
  100323. /**
  100324. * The effect that is created when initializing the post process.
  100325. * @returns The created effect corresponding the the postprocess.
  100326. */
  100327. getEffect(): Effect;
  100328. /**
  100329. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100330. * @param postProcess The post process to share the output with.
  100331. * @returns This post process.
  100332. */
  100333. shareOutputWith(postProcess: PostProcess): PostProcess;
  100334. /**
  100335. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100336. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100337. */
  100338. useOwnOutput(): void;
  100339. /**
  100340. * Updates the effect with the current post process compile time values and recompiles the shader.
  100341. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100342. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100343. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100344. * @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
  100345. * @param onCompiled Called when the shader has been compiled.
  100346. * @param onError Called if there is an error when compiling a shader.
  100347. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100348. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100349. */
  100350. 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;
  100351. /**
  100352. * The post process is reusable if it can be used multiple times within one frame.
  100353. * @returns If the post process is reusable
  100354. */
  100355. isReusable(): boolean;
  100356. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100357. markTextureDirty(): void;
  100358. /**
  100359. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100360. * 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.
  100361. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100362. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100363. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100364. * @returns The target texture that was bound to be written to.
  100365. */
  100366. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100367. /**
  100368. * If the post process is supported.
  100369. */
  100370. get isSupported(): boolean;
  100371. /**
  100372. * The aspect ratio of the output texture.
  100373. */
  100374. get aspectRatio(): number;
  100375. /**
  100376. * Get a value indicating if the post-process is ready to be used
  100377. * @returns true if the post-process is ready (shader is compiled)
  100378. */
  100379. isReady(): boolean;
  100380. /**
  100381. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100382. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100383. */
  100384. apply(): Nullable<Effect>;
  100385. private _disposeTextures;
  100386. /**
  100387. * Disposes the post process.
  100388. * @param camera The camera to dispose the post process on.
  100389. */
  100390. dispose(camera?: Camera): void;
  100391. }
  100392. }
  100393. declare module BABYLON {
  100394. /** @hidden */
  100395. export var kernelBlurVaryingDeclaration: {
  100396. name: string;
  100397. shader: string;
  100398. };
  100399. }
  100400. declare module BABYLON {
  100401. /** @hidden */
  100402. export var kernelBlurFragment: {
  100403. name: string;
  100404. shader: string;
  100405. };
  100406. }
  100407. declare module BABYLON {
  100408. /** @hidden */
  100409. export var kernelBlurFragment2: {
  100410. name: string;
  100411. shader: string;
  100412. };
  100413. }
  100414. declare module BABYLON {
  100415. /** @hidden */
  100416. export var kernelBlurPixelShader: {
  100417. name: string;
  100418. shader: string;
  100419. };
  100420. }
  100421. declare module BABYLON {
  100422. /** @hidden */
  100423. export var kernelBlurVertex: {
  100424. name: string;
  100425. shader: string;
  100426. };
  100427. }
  100428. declare module BABYLON {
  100429. /** @hidden */
  100430. export var kernelBlurVertexShader: {
  100431. name: string;
  100432. shader: string;
  100433. };
  100434. }
  100435. declare module BABYLON {
  100436. /**
  100437. * The Blur Post Process which blurs an image based on a kernel and direction.
  100438. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  100439. */
  100440. export class BlurPostProcess extends PostProcess {
  100441. /** The direction in which to blur the image. */
  100442. direction: Vector2;
  100443. private blockCompilation;
  100444. protected _kernel: number;
  100445. protected _idealKernel: number;
  100446. protected _packedFloat: boolean;
  100447. private _staticDefines;
  100448. /**
  100449. * Sets the length in pixels of the blur sample region
  100450. */
  100451. set kernel(v: number);
  100452. /**
  100453. * Gets the length in pixels of the blur sample region
  100454. */
  100455. get kernel(): number;
  100456. /**
  100457. * Sets wether or not the blur needs to unpack/repack floats
  100458. */
  100459. set packedFloat(v: boolean);
  100460. /**
  100461. * Gets wether or not the blur is unpacking/repacking floats
  100462. */
  100463. get packedFloat(): boolean;
  100464. /**
  100465. * Creates a new instance BlurPostProcess
  100466. * @param name The name of the effect.
  100467. * @param direction The direction in which to blur the image.
  100468. * @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.
  100469. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100470. * @param camera The camera to apply the render pass to.
  100471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100472. * @param engine The engine which the post process will be applied. (default: current engine)
  100473. * @param reusable If the post process can be reused on the same frame. (default: false)
  100474. * @param textureType Type of textures used when performing the post process. (default: 0)
  100475. * @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)
  100476. */
  100477. constructor(name: string,
  100478. /** The direction in which to blur the image. */
  100479. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100480. /**
  100481. * Updates the effect with the current post process compile time values and recompiles the shader.
  100482. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100483. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100484. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100485. * @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
  100486. * @param onCompiled Called when the shader has been compiled.
  100487. * @param onError Called if there is an error when compiling a shader.
  100488. */
  100489. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100490. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100491. /**
  100492. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100493. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100494. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100495. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100496. * The gaps between physical kernels are compensated for in the weighting of the samples
  100497. * @param idealKernel Ideal blur kernel.
  100498. * @return Nearest best kernel.
  100499. */
  100500. protected _nearestBestKernel(idealKernel: number): number;
  100501. /**
  100502. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100503. * @param x The point on the Gaussian distribution to sample.
  100504. * @return the value of the Gaussian function at x.
  100505. */
  100506. protected _gaussianWeight(x: number): number;
  100507. /**
  100508. * Generates a string that can be used as a floating point number in GLSL.
  100509. * @param x Value to print.
  100510. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100511. * @return GLSL float string.
  100512. */
  100513. protected _glslFloat(x: number, decimalFigures?: number): string;
  100514. }
  100515. }
  100516. declare module BABYLON {
  100517. /**
  100518. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100519. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100520. * You can then easily use it as a reflectionTexture on a flat surface.
  100521. * In case the surface is not a plane, please consider relying on reflection probes.
  100522. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100523. */
  100524. export class MirrorTexture extends RenderTargetTexture {
  100525. private scene;
  100526. /**
  100527. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100528. * 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.
  100529. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100530. */
  100531. mirrorPlane: Plane;
  100532. /**
  100533. * Define the blur ratio used to blur the reflection if needed.
  100534. */
  100535. set blurRatio(value: number);
  100536. get blurRatio(): number;
  100537. /**
  100538. * Define the adaptive blur kernel used to blur the reflection if needed.
  100539. * This will autocompute the closest best match for the `blurKernel`
  100540. */
  100541. set adaptiveBlurKernel(value: number);
  100542. /**
  100543. * Define the blur kernel used to blur the reflection if needed.
  100544. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100545. */
  100546. set blurKernel(value: number);
  100547. /**
  100548. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100549. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100550. */
  100551. set blurKernelX(value: number);
  100552. get blurKernelX(): number;
  100553. /**
  100554. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100555. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100556. */
  100557. set blurKernelY(value: number);
  100558. get blurKernelY(): number;
  100559. private _autoComputeBlurKernel;
  100560. protected _onRatioRescale(): void;
  100561. private _updateGammaSpace;
  100562. private _imageProcessingConfigChangeObserver;
  100563. private _transformMatrix;
  100564. private _mirrorMatrix;
  100565. private _savedViewMatrix;
  100566. private _blurX;
  100567. private _blurY;
  100568. private _adaptiveBlurKernel;
  100569. private _blurKernelX;
  100570. private _blurKernelY;
  100571. private _blurRatio;
  100572. /**
  100573. * Instantiates a Mirror Texture.
  100574. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100575. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100576. * You can then easily use it as a reflectionTexture on a flat surface.
  100577. * In case the surface is not a plane, please consider relying on reflection probes.
  100578. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100579. * @param name
  100580. * @param size
  100581. * @param scene
  100582. * @param generateMipMaps
  100583. * @param type
  100584. * @param samplingMode
  100585. * @param generateDepthBuffer
  100586. */
  100587. constructor(name: string, size: number | {
  100588. width: number;
  100589. height: number;
  100590. } | {
  100591. ratio: number;
  100592. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  100593. private _preparePostProcesses;
  100594. /**
  100595. * Clone the mirror texture.
  100596. * @returns the cloned texture
  100597. */
  100598. clone(): MirrorTexture;
  100599. /**
  100600. * Serialize the texture to a JSON representation you could use in Parse later on
  100601. * @returns the serialized JSON representation
  100602. */
  100603. serialize(): any;
  100604. /**
  100605. * Dispose the texture and release its associated resources.
  100606. */
  100607. dispose(): void;
  100608. }
  100609. }
  100610. declare module BABYLON {
  100611. /**
  100612. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100613. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100614. */
  100615. export class Texture extends BaseTexture {
  100616. /**
  100617. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  100618. */
  100619. static SerializeBuffers: boolean;
  100620. /** @hidden */
  100621. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  100622. /** @hidden */
  100623. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  100624. /** @hidden */
  100625. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  100626. /** nearest is mag = nearest and min = nearest and mip = linear */
  100627. static readonly NEAREST_SAMPLINGMODE: number;
  100628. /** nearest is mag = nearest and min = nearest and mip = linear */
  100629. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  100630. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100631. static readonly BILINEAR_SAMPLINGMODE: number;
  100632. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100633. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  100634. /** Trilinear is mag = linear and min = linear and mip = linear */
  100635. static readonly TRILINEAR_SAMPLINGMODE: number;
  100636. /** Trilinear is mag = linear and min = linear and mip = linear */
  100637. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  100638. /** mag = nearest and min = nearest and mip = nearest */
  100639. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  100640. /** mag = nearest and min = linear and mip = nearest */
  100641. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  100642. /** mag = nearest and min = linear and mip = linear */
  100643. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  100644. /** mag = nearest and min = linear and mip = none */
  100645. static readonly NEAREST_LINEAR: number;
  100646. /** mag = nearest and min = nearest and mip = none */
  100647. static readonly NEAREST_NEAREST: number;
  100648. /** mag = linear and min = nearest and mip = nearest */
  100649. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  100650. /** mag = linear and min = nearest and mip = linear */
  100651. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  100652. /** mag = linear and min = linear and mip = none */
  100653. static readonly LINEAR_LINEAR: number;
  100654. /** mag = linear and min = nearest and mip = none */
  100655. static readonly LINEAR_NEAREST: number;
  100656. /** Explicit coordinates mode */
  100657. static readonly EXPLICIT_MODE: number;
  100658. /** Spherical coordinates mode */
  100659. static readonly SPHERICAL_MODE: number;
  100660. /** Planar coordinates mode */
  100661. static readonly PLANAR_MODE: number;
  100662. /** Cubic coordinates mode */
  100663. static readonly CUBIC_MODE: number;
  100664. /** Projection coordinates mode */
  100665. static readonly PROJECTION_MODE: number;
  100666. /** Inverse Cubic coordinates mode */
  100667. static readonly SKYBOX_MODE: number;
  100668. /** Inverse Cubic coordinates mode */
  100669. static readonly INVCUBIC_MODE: number;
  100670. /** Equirectangular coordinates mode */
  100671. static readonly EQUIRECTANGULAR_MODE: number;
  100672. /** Equirectangular Fixed coordinates mode */
  100673. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  100674. /** Equirectangular Fixed Mirrored coordinates mode */
  100675. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100676. /** Texture is not repeating outside of 0..1 UVs */
  100677. static readonly CLAMP_ADDRESSMODE: number;
  100678. /** Texture is repeating outside of 0..1 UVs */
  100679. static readonly WRAP_ADDRESSMODE: number;
  100680. /** Texture is repeating and mirrored */
  100681. static readonly MIRROR_ADDRESSMODE: number;
  100682. /**
  100683. * 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
  100684. */
  100685. static UseSerializedUrlIfAny: boolean;
  100686. /**
  100687. * Define the url of the texture.
  100688. */
  100689. url: Nullable<string>;
  100690. /**
  100691. * Define an offset on the texture to offset the u coordinates of the UVs
  100692. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100693. */
  100694. uOffset: number;
  100695. /**
  100696. * Define an offset on the texture to offset the v coordinates of the UVs
  100697. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100698. */
  100699. vOffset: number;
  100700. /**
  100701. * Define an offset on the texture to scale the u coordinates of the UVs
  100702. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100703. */
  100704. uScale: number;
  100705. /**
  100706. * Define an offset on the texture to scale the v coordinates of the UVs
  100707. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100708. */
  100709. vScale: number;
  100710. /**
  100711. * Define an offset on the texture to rotate around the u coordinates of the UVs
  100712. * @see http://doc.babylonjs.com/how_to/more_materials
  100713. */
  100714. uAng: number;
  100715. /**
  100716. * Define an offset on the texture to rotate around the v coordinates of the UVs
  100717. * @see http://doc.babylonjs.com/how_to/more_materials
  100718. */
  100719. vAng: number;
  100720. /**
  100721. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  100722. * @see http://doc.babylonjs.com/how_to/more_materials
  100723. */
  100724. wAng: number;
  100725. /**
  100726. * Defines the center of rotation (U)
  100727. */
  100728. uRotationCenter: number;
  100729. /**
  100730. * Defines the center of rotation (V)
  100731. */
  100732. vRotationCenter: number;
  100733. /**
  100734. * Defines the center of rotation (W)
  100735. */
  100736. wRotationCenter: number;
  100737. /**
  100738. * Are mip maps generated for this texture or not.
  100739. */
  100740. get noMipmap(): boolean;
  100741. /**
  100742. * List of inspectable custom properties (used by the Inspector)
  100743. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100744. */
  100745. inspectableCustomProperties: Nullable<IInspectable[]>;
  100746. private _noMipmap;
  100747. /** @hidden */
  100748. _invertY: boolean;
  100749. private _rowGenerationMatrix;
  100750. private _cachedTextureMatrix;
  100751. private _projectionModeMatrix;
  100752. private _t0;
  100753. private _t1;
  100754. private _t2;
  100755. private _cachedUOffset;
  100756. private _cachedVOffset;
  100757. private _cachedUScale;
  100758. private _cachedVScale;
  100759. private _cachedUAng;
  100760. private _cachedVAng;
  100761. private _cachedWAng;
  100762. private _cachedProjectionMatrixId;
  100763. private _cachedCoordinatesMode;
  100764. /** @hidden */
  100765. protected _initialSamplingMode: number;
  100766. /** @hidden */
  100767. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100768. private _deleteBuffer;
  100769. protected _format: Nullable<number>;
  100770. private _delayedOnLoad;
  100771. private _delayedOnError;
  100772. private _mimeType?;
  100773. /**
  100774. * Observable triggered once the texture has been loaded.
  100775. */
  100776. onLoadObservable: Observable<Texture>;
  100777. protected _isBlocking: boolean;
  100778. /**
  100779. * Is the texture preventing material to render while loading.
  100780. * If false, a default texture will be used instead of the loading one during the preparation step.
  100781. */
  100782. set isBlocking(value: boolean);
  100783. get isBlocking(): boolean;
  100784. /**
  100785. * Get the current sampling mode associated with the texture.
  100786. */
  100787. get samplingMode(): number;
  100788. /**
  100789. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  100790. */
  100791. get invertY(): boolean;
  100792. /**
  100793. * Instantiates a new texture.
  100794. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100795. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100796. * @param url defines the url of the picture to load as a texture
  100797. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100798. * @param noMipmap defines if the texture will require mip maps or not
  100799. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  100800. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100801. * @param onLoad defines a callback triggered when the texture has been loaded
  100802. * @param onError defines a callback triggered when an error occurred during the loading session
  100803. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  100804. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  100805. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100806. * @param mimeType defines an optional mime type information
  100807. */
  100808. 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);
  100809. /**
  100810. * Update the url (and optional buffer) of this texture if url was null during construction.
  100811. * @param url the url of the texture
  100812. * @param buffer the buffer of the texture (defaults to null)
  100813. * @param onLoad callback called when the texture is loaded (defaults to null)
  100814. */
  100815. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  100816. /**
  100817. * Finish the loading sequence of a texture flagged as delayed load.
  100818. * @hidden
  100819. */
  100820. delayLoad(): void;
  100821. private _prepareRowForTextureGeneration;
  100822. /**
  100823. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  100824. * @returns the transform matrix of the texture.
  100825. */
  100826. getTextureMatrix(uBase?: number): Matrix;
  100827. /**
  100828. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  100829. * @returns The reflection texture transform
  100830. */
  100831. getReflectionTextureMatrix(): Matrix;
  100832. /**
  100833. * Clones the texture.
  100834. * @returns the cloned texture
  100835. */
  100836. clone(): Texture;
  100837. /**
  100838. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100839. * @returns The JSON representation of the texture
  100840. */
  100841. serialize(): any;
  100842. /**
  100843. * Get the current class name of the texture useful for serialization or dynamic coding.
  100844. * @returns "Texture"
  100845. */
  100846. getClassName(): string;
  100847. /**
  100848. * Dispose the texture and release its associated resources.
  100849. */
  100850. dispose(): void;
  100851. /**
  100852. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  100853. * @param parsedTexture Define the JSON representation of the texture
  100854. * @param scene Define the scene the parsed texture should be instantiated in
  100855. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  100856. * @returns The parsed texture if successful
  100857. */
  100858. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  100859. /**
  100860. * Creates a texture from its base 64 representation.
  100861. * @param data Define the base64 payload without the data: prefix
  100862. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100863. * @param scene Define the scene the texture should belong to
  100864. * @param noMipmap Forces the texture to not create mip map information if true
  100865. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100866. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100867. * @param onLoad define a callback triggered when the texture has been loaded
  100868. * @param onError define a callback triggered when an error occurred during the loading session
  100869. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100870. * @returns the created texture
  100871. */
  100872. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  100873. /**
  100874. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  100875. * @param data Define the base64 payload without the data: prefix
  100876. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100877. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  100878. * @param scene Define the scene the texture should belong to
  100879. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  100880. * @param noMipmap Forces the texture to not create mip map information if true
  100881. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100882. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100883. * @param onLoad define a callback triggered when the texture has been loaded
  100884. * @param onError define a callback triggered when an error occurred during the loading session
  100885. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100886. * @returns the created texture
  100887. */
  100888. 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;
  100889. }
  100890. }
  100891. declare module BABYLON {
  100892. /**
  100893. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100894. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100895. */
  100896. export class PostProcessManager {
  100897. private _scene;
  100898. private _indexBuffer;
  100899. private _vertexBuffers;
  100900. /**
  100901. * Creates a new instance PostProcess
  100902. * @param scene The scene that the post process is associated with.
  100903. */
  100904. constructor(scene: Scene);
  100905. private _prepareBuffers;
  100906. private _buildIndexBuffer;
  100907. /**
  100908. * Rebuilds the vertex buffers of the manager.
  100909. * @hidden
  100910. */
  100911. _rebuild(): void;
  100912. /**
  100913. * Prepares a frame to be run through a post process.
  100914. * @param sourceTexture The input texture to the post procesess. (default: null)
  100915. * @param postProcesses An array of post processes to be run. (default: null)
  100916. * @returns True if the post processes were able to be run.
  100917. * @hidden
  100918. */
  100919. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100920. /**
  100921. * Manually render a set of post processes to a texture.
  100922. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100923. * @param postProcesses An array of post processes to be run.
  100924. * @param targetTexture The target texture to render to.
  100925. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100926. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100927. * @param lodLevel defines which lod of the texture to render to
  100928. */
  100929. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100930. /**
  100931. * Finalize the result of the output of the postprocesses.
  100932. * @param doNotPresent If true the result will not be displayed to the screen.
  100933. * @param targetTexture The target texture to render to.
  100934. * @param faceIndex The index of the face to bind the target texture to.
  100935. * @param postProcesses The array of post processes to render.
  100936. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100937. * @hidden
  100938. */
  100939. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100940. /**
  100941. * Disposes of the post process manager.
  100942. */
  100943. dispose(): void;
  100944. }
  100945. }
  100946. declare module BABYLON {
  100947. /**
  100948. * This Helps creating a texture that will be created from a camera in your scene.
  100949. * It is basically a dynamic texture that could be used to create special effects for instance.
  100950. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100951. */
  100952. export class RenderTargetTexture extends Texture {
  100953. isCube: boolean;
  100954. /**
  100955. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100956. */
  100957. static readonly REFRESHRATE_RENDER_ONCE: number;
  100958. /**
  100959. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100960. */
  100961. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100962. /**
  100963. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100964. * the central point of your effect and can save a lot of performances.
  100965. */
  100966. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100967. /**
  100968. * Use this predicate to dynamically define the list of mesh you want to render.
  100969. * If set, the renderList property will be overwritten.
  100970. */
  100971. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100972. private _renderList;
  100973. /**
  100974. * Use this list to define the list of mesh you want to render.
  100975. */
  100976. get renderList(): Nullable<Array<AbstractMesh>>;
  100977. set renderList(value: Nullable<Array<AbstractMesh>>);
  100978. /**
  100979. * Use this function to overload the renderList array at rendering time.
  100980. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  100981. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  100982. * the cube (if the RTT is a cube, else layerOrFace=0).
  100983. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  100984. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  100985. * hold dummy elements!
  100986. */
  100987. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  100988. private _hookArray;
  100989. /**
  100990. * Define if particles should be rendered in your texture.
  100991. */
  100992. renderParticles: boolean;
  100993. /**
  100994. * Define if sprites should be rendered in your texture.
  100995. */
  100996. renderSprites: boolean;
  100997. /**
  100998. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  100999. */
  101000. coordinatesMode: number;
  101001. /**
  101002. * Define the camera used to render the texture.
  101003. */
  101004. activeCamera: Nullable<Camera>;
  101005. /**
  101006. * Override the mesh isReady function with your own one.
  101007. */
  101008. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101009. /**
  101010. * Override the render function of the texture with your own one.
  101011. */
  101012. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101013. /**
  101014. * Define if camera post processes should be use while rendering the texture.
  101015. */
  101016. useCameraPostProcesses: boolean;
  101017. /**
  101018. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101019. */
  101020. ignoreCameraViewport: boolean;
  101021. private _postProcessManager;
  101022. private _postProcesses;
  101023. private _resizeObserver;
  101024. /**
  101025. * An event triggered when the texture is unbind.
  101026. */
  101027. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101028. /**
  101029. * An event triggered when the texture is unbind.
  101030. */
  101031. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101032. private _onAfterUnbindObserver;
  101033. /**
  101034. * Set a after unbind callback in the texture.
  101035. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101036. */
  101037. set onAfterUnbind(callback: () => void);
  101038. /**
  101039. * An event triggered before rendering the texture
  101040. */
  101041. onBeforeRenderObservable: Observable<number>;
  101042. private _onBeforeRenderObserver;
  101043. /**
  101044. * Set a before render callback in the texture.
  101045. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101046. */
  101047. set onBeforeRender(callback: (faceIndex: number) => void);
  101048. /**
  101049. * An event triggered after rendering the texture
  101050. */
  101051. onAfterRenderObservable: Observable<number>;
  101052. private _onAfterRenderObserver;
  101053. /**
  101054. * Set a after render callback in the texture.
  101055. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101056. */
  101057. set onAfterRender(callback: (faceIndex: number) => void);
  101058. /**
  101059. * An event triggered after the texture clear
  101060. */
  101061. onClearObservable: Observable<Engine>;
  101062. private _onClearObserver;
  101063. /**
  101064. * Set a clear callback in the texture.
  101065. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101066. */
  101067. set onClear(callback: (Engine: Engine) => void);
  101068. /**
  101069. * An event triggered when the texture is resized.
  101070. */
  101071. onResizeObservable: Observable<RenderTargetTexture>;
  101072. /**
  101073. * Define the clear color of the Render Target if it should be different from the scene.
  101074. */
  101075. clearColor: Color4;
  101076. protected _size: number | {
  101077. width: number;
  101078. height: number;
  101079. layers?: number;
  101080. };
  101081. protected _initialSizeParameter: number | {
  101082. width: number;
  101083. height: number;
  101084. } | {
  101085. ratio: number;
  101086. };
  101087. protected _sizeRatio: Nullable<number>;
  101088. /** @hidden */
  101089. _generateMipMaps: boolean;
  101090. protected _renderingManager: RenderingManager;
  101091. /** @hidden */
  101092. _waitingRenderList: string[];
  101093. protected _doNotChangeAspectRatio: boolean;
  101094. protected _currentRefreshId: number;
  101095. protected _refreshRate: number;
  101096. protected _textureMatrix: Matrix;
  101097. protected _samples: number;
  101098. protected _renderTargetOptions: RenderTargetCreationOptions;
  101099. /**
  101100. * Gets render target creation options that were used.
  101101. */
  101102. get renderTargetOptions(): RenderTargetCreationOptions;
  101103. protected _onRatioRescale(): void;
  101104. /**
  101105. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101106. * It must define where the camera used to render the texture is set
  101107. */
  101108. boundingBoxPosition: Vector3;
  101109. private _boundingBoxSize;
  101110. /**
  101111. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101112. * When defined, the cubemap will switch to local mode
  101113. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101114. * @example https://www.babylonjs-playground.com/#RNASML
  101115. */
  101116. set boundingBoxSize(value: Vector3);
  101117. get boundingBoxSize(): Vector3;
  101118. /**
  101119. * In case the RTT has been created with a depth texture, get the associated
  101120. * depth texture.
  101121. * Otherwise, return null.
  101122. */
  101123. get depthStencilTexture(): Nullable<InternalTexture>;
  101124. /**
  101125. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101126. * or used a shadow, depth texture...
  101127. * @param name The friendly name of the texture
  101128. * @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)
  101129. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101130. * @param generateMipMaps True if mip maps need to be generated after render.
  101131. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101132. * @param type The type of the buffer in the RTT (int, half float, float...)
  101133. * @param isCube True if a cube texture needs to be created
  101134. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101135. * @param generateDepthBuffer True to generate a depth buffer
  101136. * @param generateStencilBuffer True to generate a stencil buffer
  101137. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101138. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101139. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101140. */
  101141. constructor(name: string, size: number | {
  101142. width: number;
  101143. height: number;
  101144. layers?: number;
  101145. } | {
  101146. ratio: number;
  101147. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101148. /**
  101149. * Creates a depth stencil texture.
  101150. * This is only available in WebGL 2 or with the depth texture extension available.
  101151. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101152. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101153. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101154. */
  101155. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101156. private _processSizeParameter;
  101157. /**
  101158. * Define the number of samples to use in case of MSAA.
  101159. * It defaults to one meaning no MSAA has been enabled.
  101160. */
  101161. get samples(): number;
  101162. set samples(value: number);
  101163. /**
  101164. * Resets the refresh counter of the texture and start bak from scratch.
  101165. * Could be useful to regenerate the texture if it is setup to render only once.
  101166. */
  101167. resetRefreshCounter(): void;
  101168. /**
  101169. * Define the refresh rate of the texture or the rendering frequency.
  101170. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101171. */
  101172. get refreshRate(): number;
  101173. set refreshRate(value: number);
  101174. /**
  101175. * Adds a post process to the render target rendering passes.
  101176. * @param postProcess define the post process to add
  101177. */
  101178. addPostProcess(postProcess: PostProcess): void;
  101179. /**
  101180. * Clear all the post processes attached to the render target
  101181. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101182. */
  101183. clearPostProcesses(dispose?: boolean): void;
  101184. /**
  101185. * Remove one of the post process from the list of attached post processes to the texture
  101186. * @param postProcess define the post process to remove from the list
  101187. */
  101188. removePostProcess(postProcess: PostProcess): void;
  101189. /** @hidden */
  101190. _shouldRender(): boolean;
  101191. /**
  101192. * Gets the actual render size of the texture.
  101193. * @returns the width of the render size
  101194. */
  101195. getRenderSize(): number;
  101196. /**
  101197. * Gets the actual render width of the texture.
  101198. * @returns the width of the render size
  101199. */
  101200. getRenderWidth(): number;
  101201. /**
  101202. * Gets the actual render height of the texture.
  101203. * @returns the height of the render size
  101204. */
  101205. getRenderHeight(): number;
  101206. /**
  101207. * Gets the actual number of layers of the texture.
  101208. * @returns the number of layers
  101209. */
  101210. getRenderLayers(): number;
  101211. /**
  101212. * Get if the texture can be rescaled or not.
  101213. */
  101214. get canRescale(): boolean;
  101215. /**
  101216. * Resize the texture using a ratio.
  101217. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101218. */
  101219. scale(ratio: number): void;
  101220. /**
  101221. * Get the texture reflection matrix used to rotate/transform the reflection.
  101222. * @returns the reflection matrix
  101223. */
  101224. getReflectionTextureMatrix(): Matrix;
  101225. /**
  101226. * Resize the texture to a new desired size.
  101227. * Be carrefull as it will recreate all the data in the new texture.
  101228. * @param size Define the new size. It can be:
  101229. * - a number for squared texture,
  101230. * - an object containing { width: number, height: number }
  101231. * - or an object containing a ratio { ratio: number }
  101232. */
  101233. resize(size: number | {
  101234. width: number;
  101235. height: number;
  101236. } | {
  101237. ratio: number;
  101238. }): void;
  101239. private _defaultRenderListPrepared;
  101240. /**
  101241. * Renders all the objects from the render list into the texture.
  101242. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101243. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101244. */
  101245. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101246. private _bestReflectionRenderTargetDimension;
  101247. private _prepareRenderingManager;
  101248. /**
  101249. * @hidden
  101250. * @param faceIndex face index to bind to if this is a cubetexture
  101251. * @param layer defines the index of the texture to bind in the array
  101252. */
  101253. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101254. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101255. private renderToTarget;
  101256. /**
  101257. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101258. * This allowed control for front to back rendering or reversly depending of the special needs.
  101259. *
  101260. * @param renderingGroupId The rendering group id corresponding to its index
  101261. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101262. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101263. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101264. */
  101265. 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;
  101266. /**
  101267. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101268. *
  101269. * @param renderingGroupId The rendering group id corresponding to its index
  101270. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101271. */
  101272. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101273. /**
  101274. * Clones the texture.
  101275. * @returns the cloned texture
  101276. */
  101277. clone(): RenderTargetTexture;
  101278. /**
  101279. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101280. * @returns The JSON representation of the texture
  101281. */
  101282. serialize(): any;
  101283. /**
  101284. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101285. */
  101286. disposeFramebufferObjects(): void;
  101287. /**
  101288. * Dispose the texture and release its associated resources.
  101289. */
  101290. dispose(): void;
  101291. /** @hidden */
  101292. _rebuild(): void;
  101293. /**
  101294. * Clear the info related to rendering groups preventing retention point in material dispose.
  101295. */
  101296. freeRenderingGroups(): void;
  101297. /**
  101298. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101299. * @returns the view count
  101300. */
  101301. getViewCount(): number;
  101302. }
  101303. }
  101304. declare module BABYLON {
  101305. /**
  101306. * Class used to manipulate GUIDs
  101307. */
  101308. export class GUID {
  101309. /**
  101310. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101311. * Be aware Math.random() could cause collisions, but:
  101312. * "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"
  101313. * @returns a pseudo random id
  101314. */
  101315. static RandomId(): string;
  101316. }
  101317. }
  101318. declare module BABYLON {
  101319. /**
  101320. * Options to be used when creating a shadow depth material
  101321. */
  101322. export interface IIOptionShadowDepthMaterial {
  101323. /** Variables in the vertex shader code that need to have their names remapped.
  101324. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101325. * "var_name" should be either: worldPos or vNormalW
  101326. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101327. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101328. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101329. */
  101330. remappedVariables?: string[];
  101331. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101332. standalone?: boolean;
  101333. }
  101334. /**
  101335. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101336. */
  101337. export class ShadowDepthWrapper {
  101338. private _scene;
  101339. private _options?;
  101340. private _baseMaterial;
  101341. private _onEffectCreatedObserver;
  101342. private _subMeshToEffect;
  101343. private _subMeshToDepthEffect;
  101344. private _meshes;
  101345. /** @hidden */
  101346. _matriceNames: any;
  101347. /** Gets the standalone status of the wrapper */
  101348. get standalone(): boolean;
  101349. /** Gets the base material the wrapper is built upon */
  101350. get baseMaterial(): Material;
  101351. /**
  101352. * Instantiate a new shadow depth wrapper.
  101353. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101354. * generate the shadow depth map. For more information, please refer to the documentation:
  101355. * https://doc.babylonjs.com/babylon101/shadows
  101356. * @param baseMaterial Material to wrap
  101357. * @param scene Define the scene the material belongs to
  101358. * @param options Options used to create the wrapper
  101359. */
  101360. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101361. /**
  101362. * Gets the effect to use to generate the depth map
  101363. * @param subMesh subMesh to get the effect for
  101364. * @param shadowGenerator shadow generator to get the effect for
  101365. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101366. */
  101367. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101368. /**
  101369. * Specifies that the submesh is ready to be used for depth rendering
  101370. * @param subMesh submesh to check
  101371. * @param defines the list of defines to take into account when checking the effect
  101372. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101373. * @param useInstances specifies that instances should be used
  101374. * @returns a boolean indicating that the submesh is ready or not
  101375. */
  101376. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101377. /**
  101378. * Disposes the resources
  101379. */
  101380. dispose(): void;
  101381. private _makeEffect;
  101382. }
  101383. }
  101384. declare module BABYLON {
  101385. /**
  101386. * Options for compiling materials.
  101387. */
  101388. export interface IMaterialCompilationOptions {
  101389. /**
  101390. * Defines whether clip planes are enabled.
  101391. */
  101392. clipPlane: boolean;
  101393. /**
  101394. * Defines whether instances are enabled.
  101395. */
  101396. useInstances: boolean;
  101397. }
  101398. /**
  101399. * Options passed when calling customShaderNameResolve
  101400. */
  101401. export interface ICustomShaderNameResolveOptions {
  101402. /**
  101403. * 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
  101404. */
  101405. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  101406. }
  101407. /**
  101408. * Base class for the main features of a material in Babylon.js
  101409. */
  101410. export class Material implements IAnimatable {
  101411. /**
  101412. * Returns the triangle fill mode
  101413. */
  101414. static readonly TriangleFillMode: number;
  101415. /**
  101416. * Returns the wireframe mode
  101417. */
  101418. static readonly WireFrameFillMode: number;
  101419. /**
  101420. * Returns the point fill mode
  101421. */
  101422. static readonly PointFillMode: number;
  101423. /**
  101424. * Returns the point list draw mode
  101425. */
  101426. static readonly PointListDrawMode: number;
  101427. /**
  101428. * Returns the line list draw mode
  101429. */
  101430. static readonly LineListDrawMode: number;
  101431. /**
  101432. * Returns the line loop draw mode
  101433. */
  101434. static readonly LineLoopDrawMode: number;
  101435. /**
  101436. * Returns the line strip draw mode
  101437. */
  101438. static readonly LineStripDrawMode: number;
  101439. /**
  101440. * Returns the triangle strip draw mode
  101441. */
  101442. static readonly TriangleStripDrawMode: number;
  101443. /**
  101444. * Returns the triangle fan draw mode
  101445. */
  101446. static readonly TriangleFanDrawMode: number;
  101447. /**
  101448. * Stores the clock-wise side orientation
  101449. */
  101450. static readonly ClockWiseSideOrientation: number;
  101451. /**
  101452. * Stores the counter clock-wise side orientation
  101453. */
  101454. static readonly CounterClockWiseSideOrientation: number;
  101455. /**
  101456. * The dirty texture flag value
  101457. */
  101458. static readonly TextureDirtyFlag: number;
  101459. /**
  101460. * The dirty light flag value
  101461. */
  101462. static readonly LightDirtyFlag: number;
  101463. /**
  101464. * The dirty fresnel flag value
  101465. */
  101466. static readonly FresnelDirtyFlag: number;
  101467. /**
  101468. * The dirty attribute flag value
  101469. */
  101470. static readonly AttributesDirtyFlag: number;
  101471. /**
  101472. * The dirty misc flag value
  101473. */
  101474. static readonly MiscDirtyFlag: number;
  101475. /**
  101476. * The all dirty flag value
  101477. */
  101478. static readonly AllDirtyFlag: number;
  101479. /**
  101480. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101481. */
  101482. static readonly MATERIAL_OPAQUE: number;
  101483. /**
  101484. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101485. */
  101486. static readonly MATERIAL_ALPHATEST: number;
  101487. /**
  101488. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101489. */
  101490. static readonly MATERIAL_ALPHABLEND: number;
  101491. /**
  101492. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101493. * They are also discarded below the alpha cutoff threshold to improve performances.
  101494. */
  101495. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101496. /**
  101497. * The Whiteout method is used to blend normals.
  101498. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101499. */
  101500. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  101501. /**
  101502. * The Reoriented Normal Mapping method is used to blend normals.
  101503. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101504. */
  101505. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  101506. /**
  101507. * Custom callback helping to override the default shader used in the material.
  101508. */
  101509. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101510. /**
  101511. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101512. */
  101513. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101514. /**
  101515. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  101516. * This means that the material can keep using a previous shader while a new one is being compiled.
  101517. * This is mostly used when shader parallel compilation is supported (true by default)
  101518. */
  101519. allowShaderHotSwapping: boolean;
  101520. /**
  101521. * The ID of the material
  101522. */
  101523. id: string;
  101524. /**
  101525. * Gets or sets the unique id of the material
  101526. */
  101527. uniqueId: number;
  101528. /**
  101529. * The name of the material
  101530. */
  101531. name: string;
  101532. /**
  101533. * Gets or sets user defined metadata
  101534. */
  101535. metadata: any;
  101536. /**
  101537. * For internal use only. Please do not use.
  101538. */
  101539. reservedDataStore: any;
  101540. /**
  101541. * Specifies if the ready state should be checked on each call
  101542. */
  101543. checkReadyOnEveryCall: boolean;
  101544. /**
  101545. * Specifies if the ready state should be checked once
  101546. */
  101547. checkReadyOnlyOnce: boolean;
  101548. /**
  101549. * The state of the material
  101550. */
  101551. state: string;
  101552. /**
  101553. * The alpha value of the material
  101554. */
  101555. protected _alpha: number;
  101556. /**
  101557. * List of inspectable custom properties (used by the Inspector)
  101558. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101559. */
  101560. inspectableCustomProperties: IInspectable[];
  101561. /**
  101562. * Sets the alpha value of the material
  101563. */
  101564. set alpha(value: number);
  101565. /**
  101566. * Gets the alpha value of the material
  101567. */
  101568. get alpha(): number;
  101569. /**
  101570. * Specifies if back face culling is enabled
  101571. */
  101572. protected _backFaceCulling: boolean;
  101573. /**
  101574. * Sets the back-face culling state
  101575. */
  101576. set backFaceCulling(value: boolean);
  101577. /**
  101578. * Gets the back-face culling state
  101579. */
  101580. get backFaceCulling(): boolean;
  101581. /**
  101582. * Stores the value for side orientation
  101583. */
  101584. sideOrientation: number;
  101585. /**
  101586. * Callback triggered when the material is compiled
  101587. */
  101588. onCompiled: Nullable<(effect: Effect) => void>;
  101589. /**
  101590. * Callback triggered when an error occurs
  101591. */
  101592. onError: Nullable<(effect: Effect, errors: string) => void>;
  101593. /**
  101594. * Callback triggered to get the render target textures
  101595. */
  101596. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  101597. /**
  101598. * Gets a boolean indicating that current material needs to register RTT
  101599. */
  101600. get hasRenderTargetTextures(): boolean;
  101601. /**
  101602. * Specifies if the material should be serialized
  101603. */
  101604. doNotSerialize: boolean;
  101605. /**
  101606. * @hidden
  101607. */
  101608. _storeEffectOnSubMeshes: boolean;
  101609. /**
  101610. * Stores the animations for the material
  101611. */
  101612. animations: Nullable<Array<Animation>>;
  101613. /**
  101614. * An event triggered when the material is disposed
  101615. */
  101616. onDisposeObservable: Observable<Material>;
  101617. /**
  101618. * An observer which watches for dispose events
  101619. */
  101620. private _onDisposeObserver;
  101621. private _onUnBindObservable;
  101622. /**
  101623. * Called during a dispose event
  101624. */
  101625. set onDispose(callback: () => void);
  101626. private _onBindObservable;
  101627. /**
  101628. * An event triggered when the material is bound
  101629. */
  101630. get onBindObservable(): Observable<AbstractMesh>;
  101631. /**
  101632. * An observer which watches for bind events
  101633. */
  101634. private _onBindObserver;
  101635. /**
  101636. * Called during a bind event
  101637. */
  101638. set onBind(callback: (Mesh: AbstractMesh) => void);
  101639. /**
  101640. * An event triggered when the material is unbound
  101641. */
  101642. get onUnBindObservable(): Observable<Material>;
  101643. protected _onEffectCreatedObservable: Nullable<Observable<{
  101644. effect: Effect;
  101645. subMesh: Nullable<SubMesh>;
  101646. }>>;
  101647. /**
  101648. * An event triggered when the effect is (re)created
  101649. */
  101650. get onEffectCreatedObservable(): Observable<{
  101651. effect: Effect;
  101652. subMesh: Nullable<SubMesh>;
  101653. }>;
  101654. /**
  101655. * Stores the value of the alpha mode
  101656. */
  101657. private _alphaMode;
  101658. /**
  101659. * Sets the value of the alpha mode.
  101660. *
  101661. * | Value | Type | Description |
  101662. * | --- | --- | --- |
  101663. * | 0 | ALPHA_DISABLE | |
  101664. * | 1 | ALPHA_ADD | |
  101665. * | 2 | ALPHA_COMBINE | |
  101666. * | 3 | ALPHA_SUBTRACT | |
  101667. * | 4 | ALPHA_MULTIPLY | |
  101668. * | 5 | ALPHA_MAXIMIZED | |
  101669. * | 6 | ALPHA_ONEONE | |
  101670. * | 7 | ALPHA_PREMULTIPLIED | |
  101671. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  101672. * | 9 | ALPHA_INTERPOLATE | |
  101673. * | 10 | ALPHA_SCREENMODE | |
  101674. *
  101675. */
  101676. set alphaMode(value: number);
  101677. /**
  101678. * Gets the value of the alpha mode
  101679. */
  101680. get alphaMode(): number;
  101681. /**
  101682. * Stores the state of the need depth pre-pass value
  101683. */
  101684. private _needDepthPrePass;
  101685. /**
  101686. * Sets the need depth pre-pass value
  101687. */
  101688. set needDepthPrePass(value: boolean);
  101689. /**
  101690. * Gets the depth pre-pass value
  101691. */
  101692. get needDepthPrePass(): boolean;
  101693. /**
  101694. * Specifies if depth writing should be disabled
  101695. */
  101696. disableDepthWrite: boolean;
  101697. /**
  101698. * Specifies if color writing should be disabled
  101699. */
  101700. disableColorWrite: boolean;
  101701. /**
  101702. * Specifies if depth writing should be forced
  101703. */
  101704. forceDepthWrite: boolean;
  101705. /**
  101706. * Specifies the depth function that should be used. 0 means the default engine function
  101707. */
  101708. depthFunction: number;
  101709. /**
  101710. * Specifies if there should be a separate pass for culling
  101711. */
  101712. separateCullingPass: boolean;
  101713. /**
  101714. * Stores the state specifing if fog should be enabled
  101715. */
  101716. private _fogEnabled;
  101717. /**
  101718. * Sets the state for enabling fog
  101719. */
  101720. set fogEnabled(value: boolean);
  101721. /**
  101722. * Gets the value of the fog enabled state
  101723. */
  101724. get fogEnabled(): boolean;
  101725. /**
  101726. * Stores the size of points
  101727. */
  101728. pointSize: number;
  101729. /**
  101730. * Stores the z offset value
  101731. */
  101732. zOffset: number;
  101733. get wireframe(): boolean;
  101734. /**
  101735. * Sets the state of wireframe mode
  101736. */
  101737. set wireframe(value: boolean);
  101738. /**
  101739. * Gets the value specifying if point clouds are enabled
  101740. */
  101741. get pointsCloud(): boolean;
  101742. /**
  101743. * Sets the state of point cloud mode
  101744. */
  101745. set pointsCloud(value: boolean);
  101746. /**
  101747. * Gets the material fill mode
  101748. */
  101749. get fillMode(): number;
  101750. /**
  101751. * Sets the material fill mode
  101752. */
  101753. set fillMode(value: number);
  101754. /**
  101755. * @hidden
  101756. * Stores the effects for the material
  101757. */
  101758. _effect: Nullable<Effect>;
  101759. /**
  101760. * Specifies if uniform buffers should be used
  101761. */
  101762. private _useUBO;
  101763. /**
  101764. * Stores a reference to the scene
  101765. */
  101766. private _scene;
  101767. /**
  101768. * Stores the fill mode state
  101769. */
  101770. private _fillMode;
  101771. /**
  101772. * Specifies if the depth write state should be cached
  101773. */
  101774. private _cachedDepthWriteState;
  101775. /**
  101776. * Specifies if the color write state should be cached
  101777. */
  101778. private _cachedColorWriteState;
  101779. /**
  101780. * Specifies if the depth function state should be cached
  101781. */
  101782. private _cachedDepthFunctionState;
  101783. /**
  101784. * Stores the uniform buffer
  101785. */
  101786. protected _uniformBuffer: UniformBuffer;
  101787. /** @hidden */
  101788. _indexInSceneMaterialArray: number;
  101789. /** @hidden */
  101790. meshMap: Nullable<{
  101791. [id: string]: AbstractMesh | undefined;
  101792. }>;
  101793. /**
  101794. * Creates a material instance
  101795. * @param name defines the name of the material
  101796. * @param scene defines the scene to reference
  101797. * @param doNotAdd specifies if the material should be added to the scene
  101798. */
  101799. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  101800. /**
  101801. * Returns a string representation of the current material
  101802. * @param fullDetails defines a boolean indicating which levels of logging is desired
  101803. * @returns a string with material information
  101804. */
  101805. toString(fullDetails?: boolean): string;
  101806. /**
  101807. * Gets the class name of the material
  101808. * @returns a string with the class name of the material
  101809. */
  101810. getClassName(): string;
  101811. /**
  101812. * Specifies if updates for the material been locked
  101813. */
  101814. get isFrozen(): boolean;
  101815. /**
  101816. * Locks updates for the material
  101817. */
  101818. freeze(): void;
  101819. /**
  101820. * Unlocks updates for the material
  101821. */
  101822. unfreeze(): void;
  101823. /**
  101824. * Specifies if the material is ready to be used
  101825. * @param mesh defines the mesh to check
  101826. * @param useInstances specifies if instances should be used
  101827. * @returns a boolean indicating if the material is ready to be used
  101828. */
  101829. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101830. /**
  101831. * Specifies that the submesh is ready to be used
  101832. * @param mesh defines the mesh to check
  101833. * @param subMesh defines which submesh to check
  101834. * @param useInstances specifies that instances should be used
  101835. * @returns a boolean indicating that the submesh is ready or not
  101836. */
  101837. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101838. /**
  101839. * Returns the material effect
  101840. * @returns the effect associated with the material
  101841. */
  101842. getEffect(): Nullable<Effect>;
  101843. /**
  101844. * Returns the current scene
  101845. * @returns a Scene
  101846. */
  101847. getScene(): Scene;
  101848. /**
  101849. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101850. */
  101851. protected _forceAlphaTest: boolean;
  101852. /**
  101853. * The transparency mode of the material.
  101854. */
  101855. protected _transparencyMode: Nullable<number>;
  101856. /**
  101857. * Gets the current transparency mode.
  101858. */
  101859. get transparencyMode(): Nullable<number>;
  101860. /**
  101861. * Sets the transparency mode of the material.
  101862. *
  101863. * | Value | Type | Description |
  101864. * | ----- | ----------------------------------- | ----------- |
  101865. * | 0 | OPAQUE | |
  101866. * | 1 | ALPHATEST | |
  101867. * | 2 | ALPHABLEND | |
  101868. * | 3 | ALPHATESTANDBLEND | |
  101869. *
  101870. */
  101871. set transparencyMode(value: Nullable<number>);
  101872. /**
  101873. * Returns true if alpha blending should be disabled.
  101874. */
  101875. protected get _disableAlphaBlending(): boolean;
  101876. /**
  101877. * Specifies whether or not this material should be rendered in alpha blend mode.
  101878. * @returns a boolean specifying if alpha blending is needed
  101879. */
  101880. needAlphaBlending(): boolean;
  101881. /**
  101882. * Specifies if the mesh will require alpha blending
  101883. * @param mesh defines the mesh to check
  101884. * @returns a boolean specifying if alpha blending is needed for the mesh
  101885. */
  101886. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101887. /**
  101888. * Specifies whether or not this material should be rendered in alpha test mode.
  101889. * @returns a boolean specifying if an alpha test is needed.
  101890. */
  101891. needAlphaTesting(): boolean;
  101892. /**
  101893. * Specifies if material alpha testing should be turned on for the mesh
  101894. * @param mesh defines the mesh to check
  101895. */
  101896. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  101897. /**
  101898. * Gets the texture used for the alpha test
  101899. * @returns the texture to use for alpha testing
  101900. */
  101901. getAlphaTestTexture(): Nullable<BaseTexture>;
  101902. /**
  101903. * Marks the material to indicate that it needs to be re-calculated
  101904. */
  101905. markDirty(): void;
  101906. /** @hidden */
  101907. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  101908. /**
  101909. * Binds the material to the mesh
  101910. * @param world defines the world transformation matrix
  101911. * @param mesh defines the mesh to bind the material to
  101912. */
  101913. bind(world: Matrix, mesh?: Mesh): void;
  101914. /**
  101915. * Binds the submesh to the material
  101916. * @param world defines the world transformation matrix
  101917. * @param mesh defines the mesh containing the submesh
  101918. * @param subMesh defines the submesh to bind the material to
  101919. */
  101920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101921. /**
  101922. * Binds the world matrix to the material
  101923. * @param world defines the world transformation matrix
  101924. */
  101925. bindOnlyWorldMatrix(world: Matrix): void;
  101926. /**
  101927. * Binds the scene's uniform buffer to the effect.
  101928. * @param effect defines the effect to bind to the scene uniform buffer
  101929. * @param sceneUbo defines the uniform buffer storing scene data
  101930. */
  101931. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101932. /**
  101933. * Binds the view matrix to the effect
  101934. * @param effect defines the effect to bind the view matrix to
  101935. */
  101936. bindView(effect: Effect): void;
  101937. /**
  101938. * Binds the view projection matrix to the effect
  101939. * @param effect defines the effect to bind the view projection matrix to
  101940. */
  101941. bindViewProjection(effect: Effect): void;
  101942. /**
  101943. * Processes to execute after binding the material to a mesh
  101944. * @param mesh defines the rendered mesh
  101945. */
  101946. protected _afterBind(mesh?: Mesh): void;
  101947. /**
  101948. * Unbinds the material from the mesh
  101949. */
  101950. unbind(): void;
  101951. /**
  101952. * Gets the active textures from the material
  101953. * @returns an array of textures
  101954. */
  101955. getActiveTextures(): BaseTexture[];
  101956. /**
  101957. * Specifies if the material uses a texture
  101958. * @param texture defines the texture to check against the material
  101959. * @returns a boolean specifying if the material uses the texture
  101960. */
  101961. hasTexture(texture: BaseTexture): boolean;
  101962. /**
  101963. * Makes a duplicate of the material, and gives it a new name
  101964. * @param name defines the new name for the duplicated material
  101965. * @returns the cloned material
  101966. */
  101967. clone(name: string): Nullable<Material>;
  101968. /**
  101969. * Gets the meshes bound to the material
  101970. * @returns an array of meshes bound to the material
  101971. */
  101972. getBindedMeshes(): AbstractMesh[];
  101973. /**
  101974. * Force shader compilation
  101975. * @param mesh defines the mesh associated with this material
  101976. * @param onCompiled defines a function to execute once the material is compiled
  101977. * @param options defines the options to configure the compilation
  101978. * @param onError defines a function to execute if the material fails compiling
  101979. */
  101980. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  101981. /**
  101982. * Force shader compilation
  101983. * @param mesh defines the mesh that will use this material
  101984. * @param options defines additional options for compiling the shaders
  101985. * @returns a promise that resolves when the compilation completes
  101986. */
  101987. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  101988. private static readonly _AllDirtyCallBack;
  101989. private static readonly _ImageProcessingDirtyCallBack;
  101990. private static readonly _TextureDirtyCallBack;
  101991. private static readonly _FresnelDirtyCallBack;
  101992. private static readonly _MiscDirtyCallBack;
  101993. private static readonly _LightsDirtyCallBack;
  101994. private static readonly _AttributeDirtyCallBack;
  101995. private static _FresnelAndMiscDirtyCallBack;
  101996. private static _TextureAndMiscDirtyCallBack;
  101997. private static readonly _DirtyCallbackArray;
  101998. private static readonly _RunDirtyCallBacks;
  101999. /**
  102000. * Marks a define in the material to indicate that it needs to be re-computed
  102001. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  102002. */
  102003. markAsDirty(flag: number): void;
  102004. /**
  102005. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  102006. * @param func defines a function which checks material defines against the submeshes
  102007. */
  102008. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  102009. /**
  102010. * Indicates that we need to re-calculated for all submeshes
  102011. */
  102012. protected _markAllSubMeshesAsAllDirty(): void;
  102013. /**
  102014. * Indicates that image processing needs to be re-calculated for all submeshes
  102015. */
  102016. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  102017. /**
  102018. * Indicates that textures need to be re-calculated for all submeshes
  102019. */
  102020. protected _markAllSubMeshesAsTexturesDirty(): void;
  102021. /**
  102022. * Indicates that fresnel needs to be re-calculated for all submeshes
  102023. */
  102024. protected _markAllSubMeshesAsFresnelDirty(): void;
  102025. /**
  102026. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  102027. */
  102028. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  102029. /**
  102030. * Indicates that lights need to be re-calculated for all submeshes
  102031. */
  102032. protected _markAllSubMeshesAsLightsDirty(): void;
  102033. /**
  102034. * Indicates that attributes need to be re-calculated for all submeshes
  102035. */
  102036. protected _markAllSubMeshesAsAttributesDirty(): void;
  102037. /**
  102038. * Indicates that misc needs to be re-calculated for all submeshes
  102039. */
  102040. protected _markAllSubMeshesAsMiscDirty(): void;
  102041. /**
  102042. * Indicates that textures and misc need to be re-calculated for all submeshes
  102043. */
  102044. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  102045. /**
  102046. * Disposes the material
  102047. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102048. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102049. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102050. */
  102051. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102052. /** @hidden */
  102053. private releaseVertexArrayObject;
  102054. /**
  102055. * Serializes this material
  102056. * @returns the serialized material object
  102057. */
  102058. serialize(): any;
  102059. /**
  102060. * Creates a material from parsed material data
  102061. * @param parsedMaterial defines parsed material data
  102062. * @param scene defines the hosting scene
  102063. * @param rootUrl defines the root URL to use to load textures
  102064. * @returns a new material
  102065. */
  102066. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  102067. }
  102068. }
  102069. declare module BABYLON {
  102070. /**
  102071. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102072. * separate meshes. This can be use to improve performances.
  102073. * @see http://doc.babylonjs.com/how_to/multi_materials
  102074. */
  102075. export class MultiMaterial extends Material {
  102076. private _subMaterials;
  102077. /**
  102078. * Gets or Sets the list of Materials used within the multi material.
  102079. * They need to be ordered according to the submeshes order in the associated mesh
  102080. */
  102081. get subMaterials(): Nullable<Material>[];
  102082. set subMaterials(value: Nullable<Material>[]);
  102083. /**
  102084. * Function used to align with Node.getChildren()
  102085. * @returns the list of Materials used within the multi material
  102086. */
  102087. getChildren(): Nullable<Material>[];
  102088. /**
  102089. * Instantiates a new Multi Material
  102090. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102091. * separate meshes. This can be use to improve performances.
  102092. * @see http://doc.babylonjs.com/how_to/multi_materials
  102093. * @param name Define the name in the scene
  102094. * @param scene Define the scene the material belongs to
  102095. */
  102096. constructor(name: string, scene: Scene);
  102097. private _hookArray;
  102098. /**
  102099. * Get one of the submaterial by its index in the submaterials array
  102100. * @param index The index to look the sub material at
  102101. * @returns The Material if the index has been defined
  102102. */
  102103. getSubMaterial(index: number): Nullable<Material>;
  102104. /**
  102105. * Get the list of active textures for the whole sub materials list.
  102106. * @returns All the textures that will be used during the rendering
  102107. */
  102108. getActiveTextures(): BaseTexture[];
  102109. /**
  102110. * Gets the current class name of the material e.g. "MultiMaterial"
  102111. * Mainly use in serialization.
  102112. * @returns the class name
  102113. */
  102114. getClassName(): string;
  102115. /**
  102116. * Checks if the material is ready to render the requested sub mesh
  102117. * @param mesh Define the mesh the submesh belongs to
  102118. * @param subMesh Define the sub mesh to look readyness for
  102119. * @param useInstances Define whether or not the material is used with instances
  102120. * @returns true if ready, otherwise false
  102121. */
  102122. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102123. /**
  102124. * Clones the current material and its related sub materials
  102125. * @param name Define the name of the newly cloned material
  102126. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102127. * @returns the cloned material
  102128. */
  102129. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102130. /**
  102131. * Serializes the materials into a JSON representation.
  102132. * @returns the JSON representation
  102133. */
  102134. serialize(): any;
  102135. /**
  102136. * Dispose the material and release its associated resources
  102137. * @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)
  102138. * @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)
  102139. * @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)
  102140. */
  102141. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102142. /**
  102143. * Creates a MultiMaterial from parsed MultiMaterial data.
  102144. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102145. * @param scene defines the hosting scene
  102146. * @returns a new MultiMaterial
  102147. */
  102148. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102149. }
  102150. }
  102151. declare module BABYLON {
  102152. /**
  102153. * Defines a subdivision inside a mesh
  102154. */
  102155. export class SubMesh implements ICullable {
  102156. /** the material index to use */
  102157. materialIndex: number;
  102158. /** vertex index start */
  102159. verticesStart: number;
  102160. /** vertices count */
  102161. verticesCount: number;
  102162. /** index start */
  102163. indexStart: number;
  102164. /** indices count */
  102165. indexCount: number;
  102166. /** @hidden */
  102167. _materialDefines: Nullable<MaterialDefines>;
  102168. /** @hidden */
  102169. _materialEffect: Nullable<Effect>;
  102170. /** @hidden */
  102171. _effectOverride: Nullable<Effect>;
  102172. /**
  102173. * Gets material defines used by the effect associated to the sub mesh
  102174. */
  102175. get materialDefines(): Nullable<MaterialDefines>;
  102176. /**
  102177. * Sets material defines used by the effect associated to the sub mesh
  102178. */
  102179. set materialDefines(defines: Nullable<MaterialDefines>);
  102180. /**
  102181. * Gets associated effect
  102182. */
  102183. get effect(): Nullable<Effect>;
  102184. /**
  102185. * Sets associated effect (effect used to render this submesh)
  102186. * @param effect defines the effect to associate with
  102187. * @param defines defines the set of defines used to compile this effect
  102188. */
  102189. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102190. /** @hidden */
  102191. _linesIndexCount: number;
  102192. private _mesh;
  102193. private _renderingMesh;
  102194. private _boundingInfo;
  102195. private _linesIndexBuffer;
  102196. /** @hidden */
  102197. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102198. /** @hidden */
  102199. _trianglePlanes: Plane[];
  102200. /** @hidden */
  102201. _lastColliderTransformMatrix: Nullable<Matrix>;
  102202. /** @hidden */
  102203. _renderId: number;
  102204. /** @hidden */
  102205. _alphaIndex: number;
  102206. /** @hidden */
  102207. _distanceToCamera: number;
  102208. /** @hidden */
  102209. _id: number;
  102210. private _currentMaterial;
  102211. /**
  102212. * Add a new submesh to a mesh
  102213. * @param materialIndex defines the material index to use
  102214. * @param verticesStart defines vertex index start
  102215. * @param verticesCount defines vertices count
  102216. * @param indexStart defines index start
  102217. * @param indexCount defines indices count
  102218. * @param mesh defines the parent mesh
  102219. * @param renderingMesh defines an optional rendering mesh
  102220. * @param createBoundingBox defines if bounding box should be created for this submesh
  102221. * @returns the new submesh
  102222. */
  102223. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102224. /**
  102225. * Creates a new submesh
  102226. * @param materialIndex defines the material index to use
  102227. * @param verticesStart defines vertex index start
  102228. * @param verticesCount defines vertices count
  102229. * @param indexStart defines index start
  102230. * @param indexCount defines indices count
  102231. * @param mesh defines the parent mesh
  102232. * @param renderingMesh defines an optional rendering mesh
  102233. * @param createBoundingBox defines if bounding box should be created for this submesh
  102234. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102235. */
  102236. constructor(
  102237. /** the material index to use */
  102238. materialIndex: number,
  102239. /** vertex index start */
  102240. verticesStart: number,
  102241. /** vertices count */
  102242. verticesCount: number,
  102243. /** index start */
  102244. indexStart: number,
  102245. /** indices count */
  102246. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102247. /**
  102248. * Returns true if this submesh covers the entire parent mesh
  102249. * @ignorenaming
  102250. */
  102251. get IsGlobal(): boolean;
  102252. /**
  102253. * Returns the submesh BoudingInfo object
  102254. * @returns current bounding info (or mesh's one if the submesh is global)
  102255. */
  102256. getBoundingInfo(): BoundingInfo;
  102257. /**
  102258. * Sets the submesh BoundingInfo
  102259. * @param boundingInfo defines the new bounding info to use
  102260. * @returns the SubMesh
  102261. */
  102262. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102263. /**
  102264. * Returns the mesh of the current submesh
  102265. * @return the parent mesh
  102266. */
  102267. getMesh(): AbstractMesh;
  102268. /**
  102269. * Returns the rendering mesh of the submesh
  102270. * @returns the rendering mesh (could be different from parent mesh)
  102271. */
  102272. getRenderingMesh(): Mesh;
  102273. /**
  102274. * Returns the replacement mesh of the submesh
  102275. * @returns the replacement mesh (could be different from parent mesh)
  102276. */
  102277. getReplacementMesh(): Nullable<AbstractMesh>;
  102278. /**
  102279. * Returns the effective mesh of the submesh
  102280. * @returns the effective mesh (could be different from parent mesh)
  102281. */
  102282. getEffectiveMesh(): AbstractMesh;
  102283. /**
  102284. * Returns the submesh material
  102285. * @returns null or the current material
  102286. */
  102287. getMaterial(): Nullable<Material>;
  102288. private _IsMultiMaterial;
  102289. /**
  102290. * Sets a new updated BoundingInfo object to the submesh
  102291. * @param data defines an optional position array to use to determine the bounding info
  102292. * @returns the SubMesh
  102293. */
  102294. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102295. /** @hidden */
  102296. _checkCollision(collider: Collider): boolean;
  102297. /**
  102298. * Updates the submesh BoundingInfo
  102299. * @param world defines the world matrix to use to update the bounding info
  102300. * @returns the submesh
  102301. */
  102302. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102303. /**
  102304. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102305. * @param frustumPlanes defines the frustum planes
  102306. * @returns true if the submesh is intersecting with the frustum
  102307. */
  102308. isInFrustum(frustumPlanes: Plane[]): boolean;
  102309. /**
  102310. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102311. * @param frustumPlanes defines the frustum planes
  102312. * @returns true if the submesh is inside the frustum
  102313. */
  102314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102315. /**
  102316. * Renders the submesh
  102317. * @param enableAlphaMode defines if alpha needs to be used
  102318. * @returns the submesh
  102319. */
  102320. render(enableAlphaMode: boolean): SubMesh;
  102321. /**
  102322. * @hidden
  102323. */
  102324. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102325. /**
  102326. * Checks if the submesh intersects with a ray
  102327. * @param ray defines the ray to test
  102328. * @returns true is the passed ray intersects the submesh bounding box
  102329. */
  102330. canIntersects(ray: Ray): boolean;
  102331. /**
  102332. * Intersects current submesh with a ray
  102333. * @param ray defines the ray to test
  102334. * @param positions defines mesh's positions array
  102335. * @param indices defines mesh's indices array
  102336. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102337. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102338. * @returns intersection info or null if no intersection
  102339. */
  102340. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102341. /** @hidden */
  102342. private _intersectLines;
  102343. /** @hidden */
  102344. private _intersectUnIndexedLines;
  102345. /** @hidden */
  102346. private _intersectTriangles;
  102347. /** @hidden */
  102348. private _intersectUnIndexedTriangles;
  102349. /** @hidden */
  102350. _rebuild(): void;
  102351. /**
  102352. * Creates a new submesh from the passed mesh
  102353. * @param newMesh defines the new hosting mesh
  102354. * @param newRenderingMesh defines an optional rendering mesh
  102355. * @returns the new submesh
  102356. */
  102357. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102358. /**
  102359. * Release associated resources
  102360. */
  102361. dispose(): void;
  102362. /**
  102363. * Gets the class name
  102364. * @returns the string "SubMesh".
  102365. */
  102366. getClassName(): string;
  102367. /**
  102368. * Creates a new submesh from indices data
  102369. * @param materialIndex the index of the main mesh material
  102370. * @param startIndex the index where to start the copy in the mesh indices array
  102371. * @param indexCount the number of indices to copy then from the startIndex
  102372. * @param mesh the main mesh to create the submesh from
  102373. * @param renderingMesh the optional rendering mesh
  102374. * @returns a new submesh
  102375. */
  102376. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102377. }
  102378. }
  102379. declare module BABYLON {
  102380. /**
  102381. * Class used to represent data loading progression
  102382. */
  102383. export class SceneLoaderFlags {
  102384. private static _ForceFullSceneLoadingForIncremental;
  102385. private static _ShowLoadingScreen;
  102386. private static _CleanBoneMatrixWeights;
  102387. private static _loggingLevel;
  102388. /**
  102389. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102390. */
  102391. static get ForceFullSceneLoadingForIncremental(): boolean;
  102392. static set ForceFullSceneLoadingForIncremental(value: boolean);
  102393. /**
  102394. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102395. */
  102396. static get ShowLoadingScreen(): boolean;
  102397. static set ShowLoadingScreen(value: boolean);
  102398. /**
  102399. * Defines the current logging level (while loading the scene)
  102400. * @ignorenaming
  102401. */
  102402. static get loggingLevel(): number;
  102403. static set loggingLevel(value: number);
  102404. /**
  102405. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102406. */
  102407. static get CleanBoneMatrixWeights(): boolean;
  102408. static set CleanBoneMatrixWeights(value: boolean);
  102409. }
  102410. }
  102411. declare module BABYLON {
  102412. /**
  102413. * Class used to store geometry data (vertex buffers + index buffer)
  102414. */
  102415. export class Geometry implements IGetSetVerticesData {
  102416. /**
  102417. * Gets or sets the ID of the geometry
  102418. */
  102419. id: string;
  102420. /**
  102421. * Gets or sets the unique ID of the geometry
  102422. */
  102423. uniqueId: number;
  102424. /**
  102425. * Gets the delay loading state of the geometry (none by default which means not delayed)
  102426. */
  102427. delayLoadState: number;
  102428. /**
  102429. * Gets the file containing the data to load when running in delay load state
  102430. */
  102431. delayLoadingFile: Nullable<string>;
  102432. /**
  102433. * Callback called when the geometry is updated
  102434. */
  102435. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  102436. private _scene;
  102437. private _engine;
  102438. private _meshes;
  102439. private _totalVertices;
  102440. /** @hidden */
  102441. _indices: IndicesArray;
  102442. /** @hidden */
  102443. _vertexBuffers: {
  102444. [key: string]: VertexBuffer;
  102445. };
  102446. private _isDisposed;
  102447. private _extend;
  102448. private _boundingBias;
  102449. /** @hidden */
  102450. _delayInfo: Array<string>;
  102451. private _indexBuffer;
  102452. private _indexBufferIsUpdatable;
  102453. /** @hidden */
  102454. _boundingInfo: Nullable<BoundingInfo>;
  102455. /** @hidden */
  102456. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  102457. /** @hidden */
  102458. _softwareSkinningFrameId: number;
  102459. private _vertexArrayObjects;
  102460. private _updatable;
  102461. /** @hidden */
  102462. _positions: Nullable<Vector3[]>;
  102463. /**
  102464. * 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
  102465. */
  102466. get boundingBias(): Vector2;
  102467. /**
  102468. * 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
  102469. */
  102470. set boundingBias(value: Vector2);
  102471. /**
  102472. * Static function used to attach a new empty geometry to a mesh
  102473. * @param mesh defines the mesh to attach the geometry to
  102474. * @returns the new Geometry
  102475. */
  102476. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  102477. /** Get the list of meshes using this geometry */
  102478. get meshes(): Mesh[];
  102479. /**
  102480. * Creates a new geometry
  102481. * @param id defines the unique ID
  102482. * @param scene defines the hosting scene
  102483. * @param vertexData defines the VertexData used to get geometry data
  102484. * @param updatable defines if geometry must be updatable (false by default)
  102485. * @param mesh defines the mesh that will be associated with the geometry
  102486. */
  102487. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102488. /**
  102489. * Gets the current extend of the geometry
  102490. */
  102491. get extend(): {
  102492. minimum: Vector3;
  102493. maximum: Vector3;
  102494. };
  102495. /**
  102496. * Gets the hosting scene
  102497. * @returns the hosting Scene
  102498. */
  102499. getScene(): Scene;
  102500. /**
  102501. * Gets the hosting engine
  102502. * @returns the hosting Engine
  102503. */
  102504. getEngine(): Engine;
  102505. /**
  102506. * Defines if the geometry is ready to use
  102507. * @returns true if the geometry is ready to be used
  102508. */
  102509. isReady(): boolean;
  102510. /**
  102511. * Gets a value indicating that the geometry should not be serialized
  102512. */
  102513. get doNotSerialize(): boolean;
  102514. /** @hidden */
  102515. _rebuild(): void;
  102516. /**
  102517. * Affects all geometry data in one call
  102518. * @param vertexData defines the geometry data
  102519. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102520. */
  102521. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102522. /**
  102523. * Set specific vertex data
  102524. * @param kind defines the data kind (Position, normal, etc...)
  102525. * @param data defines the vertex data to use
  102526. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102527. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102528. */
  102529. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102530. /**
  102531. * Removes a specific vertex data
  102532. * @param kind defines the data kind (Position, normal, etc...)
  102533. */
  102534. removeVerticesData(kind: string): void;
  102535. /**
  102536. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102537. * @param buffer defines the vertex buffer to use
  102538. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102539. */
  102540. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102541. /**
  102542. * Update a specific vertex buffer
  102543. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102544. * It will do nothing if the buffer is not updatable
  102545. * @param kind defines the data kind (Position, normal, etc...)
  102546. * @param data defines the data to use
  102547. * @param offset defines the offset in the target buffer where to store the data
  102548. * @param useBytes set to true if the offset is in bytes
  102549. */
  102550. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102551. /**
  102552. * Update a specific vertex buffer
  102553. * This function will create a new buffer if the current one is not updatable
  102554. * @param kind defines the data kind (Position, normal, etc...)
  102555. * @param data defines the data to use
  102556. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102557. */
  102558. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102559. private _updateBoundingInfo;
  102560. /** @hidden */
  102561. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102562. /**
  102563. * Gets total number of vertices
  102564. * @returns the total number of vertices
  102565. */
  102566. getTotalVertices(): number;
  102567. /**
  102568. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102569. * @param kind defines the data kind (Position, normal, etc...)
  102570. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102571. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102572. * @returns a float array containing vertex data
  102573. */
  102574. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102575. /**
  102576. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  102577. * @param kind defines the data kind (Position, normal, etc...)
  102578. * @returns true if the vertex buffer with the specified kind is updatable
  102579. */
  102580. isVertexBufferUpdatable(kind: string): boolean;
  102581. /**
  102582. * Gets a specific vertex buffer
  102583. * @param kind defines the data kind (Position, normal, etc...)
  102584. * @returns a VertexBuffer
  102585. */
  102586. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  102587. /**
  102588. * Returns all vertex buffers
  102589. * @return an object holding all vertex buffers indexed by kind
  102590. */
  102591. getVertexBuffers(): Nullable<{
  102592. [key: string]: VertexBuffer;
  102593. }>;
  102594. /**
  102595. * Gets a boolean indicating if specific vertex buffer is present
  102596. * @param kind defines the data kind (Position, normal, etc...)
  102597. * @returns true if data is present
  102598. */
  102599. isVerticesDataPresent(kind: string): boolean;
  102600. /**
  102601. * Gets a list of all attached data kinds (Position, normal, etc...)
  102602. * @returns a list of string containing all kinds
  102603. */
  102604. getVerticesDataKinds(): string[];
  102605. /**
  102606. * Update index buffer
  102607. * @param indices defines the indices to store in the index buffer
  102608. * @param offset defines the offset in the target buffer where to store the data
  102609. * @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)
  102610. */
  102611. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  102612. /**
  102613. * Creates a new index buffer
  102614. * @param indices defines the indices to store in the index buffer
  102615. * @param totalVertices defines the total number of vertices (could be null)
  102616. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102617. */
  102618. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  102619. /**
  102620. * Return the total number of indices
  102621. * @returns the total number of indices
  102622. */
  102623. getTotalIndices(): number;
  102624. /**
  102625. * Gets the index buffer array
  102626. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102627. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102628. * @returns the index buffer array
  102629. */
  102630. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102631. /**
  102632. * Gets the index buffer
  102633. * @return the index buffer
  102634. */
  102635. getIndexBuffer(): Nullable<DataBuffer>;
  102636. /** @hidden */
  102637. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  102638. /**
  102639. * Release the associated resources for a specific mesh
  102640. * @param mesh defines the source mesh
  102641. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  102642. */
  102643. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  102644. /**
  102645. * Apply current geometry to a given mesh
  102646. * @param mesh defines the mesh to apply geometry to
  102647. */
  102648. applyToMesh(mesh: Mesh): void;
  102649. private _updateExtend;
  102650. private _applyToMesh;
  102651. private notifyUpdate;
  102652. /**
  102653. * Load the geometry if it was flagged as delay loaded
  102654. * @param scene defines the hosting scene
  102655. * @param onLoaded defines a callback called when the geometry is loaded
  102656. */
  102657. load(scene: Scene, onLoaded?: () => void): void;
  102658. private _queueLoad;
  102659. /**
  102660. * Invert the geometry to move from a right handed system to a left handed one.
  102661. */
  102662. toLeftHanded(): void;
  102663. /** @hidden */
  102664. _resetPointsArrayCache(): void;
  102665. /** @hidden */
  102666. _generatePointsArray(): boolean;
  102667. /**
  102668. * Gets a value indicating if the geometry is disposed
  102669. * @returns true if the geometry was disposed
  102670. */
  102671. isDisposed(): boolean;
  102672. private _disposeVertexArrayObjects;
  102673. /**
  102674. * Free all associated resources
  102675. */
  102676. dispose(): void;
  102677. /**
  102678. * Clone the current geometry into a new geometry
  102679. * @param id defines the unique ID of the new geometry
  102680. * @returns a new geometry object
  102681. */
  102682. copy(id: string): Geometry;
  102683. /**
  102684. * Serialize the current geometry info (and not the vertices data) into a JSON object
  102685. * @return a JSON representation of the current geometry data (without the vertices data)
  102686. */
  102687. serialize(): any;
  102688. private toNumberArray;
  102689. /**
  102690. * Serialize all vertices data into a JSON oject
  102691. * @returns a JSON representation of the current geometry data
  102692. */
  102693. serializeVerticeData(): any;
  102694. /**
  102695. * Extracts a clone of a mesh geometry
  102696. * @param mesh defines the source mesh
  102697. * @param id defines the unique ID of the new geometry object
  102698. * @returns the new geometry object
  102699. */
  102700. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  102701. /**
  102702. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  102703. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102704. * Be aware Math.random() could cause collisions, but:
  102705. * "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"
  102706. * @returns a string containing a new GUID
  102707. */
  102708. static RandomId(): string;
  102709. /** @hidden */
  102710. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  102711. private static _CleanMatricesWeights;
  102712. /**
  102713. * Create a new geometry from persisted data (Using .babylon file format)
  102714. * @param parsedVertexData defines the persisted data
  102715. * @param scene defines the hosting scene
  102716. * @param rootUrl defines the root url to use to load assets (like delayed data)
  102717. * @returns the new geometry object
  102718. */
  102719. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  102720. }
  102721. }
  102722. declare module BABYLON {
  102723. /**
  102724. * Define an interface for all classes that will get and set the data on vertices
  102725. */
  102726. export interface IGetSetVerticesData {
  102727. /**
  102728. * Gets a boolean indicating if specific vertex data is present
  102729. * @param kind defines the vertex data kind to use
  102730. * @returns true is data kind is present
  102731. */
  102732. isVerticesDataPresent(kind: string): boolean;
  102733. /**
  102734. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102735. * @param kind defines the data kind (Position, normal, etc...)
  102736. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102737. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102738. * @returns a float array containing vertex data
  102739. */
  102740. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102741. /**
  102742. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  102743. * @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.
  102744. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102745. * @returns the indices array or an empty array if the mesh has no geometry
  102746. */
  102747. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102748. /**
  102749. * Set specific vertex data
  102750. * @param kind defines the data kind (Position, normal, etc...)
  102751. * @param data defines the vertex data to use
  102752. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102753. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102754. */
  102755. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  102756. /**
  102757. * Update a specific associated vertex buffer
  102758. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  102759. * - VertexBuffer.PositionKind
  102760. * - VertexBuffer.UVKind
  102761. * - VertexBuffer.UV2Kind
  102762. * - VertexBuffer.UV3Kind
  102763. * - VertexBuffer.UV4Kind
  102764. * - VertexBuffer.UV5Kind
  102765. * - VertexBuffer.UV6Kind
  102766. * - VertexBuffer.ColorKind
  102767. * - VertexBuffer.MatricesIndicesKind
  102768. * - VertexBuffer.MatricesIndicesExtraKind
  102769. * - VertexBuffer.MatricesWeightsKind
  102770. * - VertexBuffer.MatricesWeightsExtraKind
  102771. * @param data defines the data source
  102772. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  102773. * @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)
  102774. */
  102775. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  102776. /**
  102777. * Creates a new index buffer
  102778. * @param indices defines the indices to store in the index buffer
  102779. * @param totalVertices defines the total number of vertices (could be null)
  102780. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102781. */
  102782. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  102783. }
  102784. /**
  102785. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  102786. */
  102787. export class VertexData {
  102788. /**
  102789. * Mesh side orientation : usually the external or front surface
  102790. */
  102791. static readonly FRONTSIDE: number;
  102792. /**
  102793. * Mesh side orientation : usually the internal or back surface
  102794. */
  102795. static readonly BACKSIDE: number;
  102796. /**
  102797. * Mesh side orientation : both internal and external or front and back surfaces
  102798. */
  102799. static readonly DOUBLESIDE: number;
  102800. /**
  102801. * Mesh side orientation : by default, `FRONTSIDE`
  102802. */
  102803. static readonly DEFAULTSIDE: number;
  102804. /**
  102805. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  102806. */
  102807. positions: Nullable<FloatArray>;
  102808. /**
  102809. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  102810. */
  102811. normals: Nullable<FloatArray>;
  102812. /**
  102813. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  102814. */
  102815. tangents: Nullable<FloatArray>;
  102816. /**
  102817. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102818. */
  102819. uvs: Nullable<FloatArray>;
  102820. /**
  102821. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102822. */
  102823. uvs2: Nullable<FloatArray>;
  102824. /**
  102825. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102826. */
  102827. uvs3: Nullable<FloatArray>;
  102828. /**
  102829. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102830. */
  102831. uvs4: Nullable<FloatArray>;
  102832. /**
  102833. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102834. */
  102835. uvs5: Nullable<FloatArray>;
  102836. /**
  102837. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102838. */
  102839. uvs6: Nullable<FloatArray>;
  102840. /**
  102841. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  102842. */
  102843. colors: Nullable<FloatArray>;
  102844. /**
  102845. * 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).
  102846. */
  102847. matricesIndices: Nullable<FloatArray>;
  102848. /**
  102849. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  102850. */
  102851. matricesWeights: Nullable<FloatArray>;
  102852. /**
  102853. * An array extending the number of possible indices
  102854. */
  102855. matricesIndicesExtra: Nullable<FloatArray>;
  102856. /**
  102857. * An array extending the number of possible weights when the number of indices is extended
  102858. */
  102859. matricesWeightsExtra: Nullable<FloatArray>;
  102860. /**
  102861. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  102862. */
  102863. indices: Nullable<IndicesArray>;
  102864. /**
  102865. * Uses the passed data array to set the set the values for the specified kind of data
  102866. * @param data a linear array of floating numbers
  102867. * @param kind the type of data that is being set, eg positions, colors etc
  102868. */
  102869. set(data: FloatArray, kind: string): void;
  102870. /**
  102871. * Associates the vertexData to the passed Mesh.
  102872. * Sets it as updatable or not (default `false`)
  102873. * @param mesh the mesh the vertexData is applied to
  102874. * @param updatable when used and having the value true allows new data to update the vertexData
  102875. * @returns the VertexData
  102876. */
  102877. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  102878. /**
  102879. * Associates the vertexData to the passed Geometry.
  102880. * Sets it as updatable or not (default `false`)
  102881. * @param geometry the geometry the vertexData is applied to
  102882. * @param updatable when used and having the value true allows new data to update the vertexData
  102883. * @returns VertexData
  102884. */
  102885. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  102886. /**
  102887. * Updates the associated mesh
  102888. * @param mesh the mesh to be updated
  102889. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102890. * @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
  102891. * @returns VertexData
  102892. */
  102893. updateMesh(mesh: Mesh): VertexData;
  102894. /**
  102895. * Updates the associated geometry
  102896. * @param geometry the geometry to be updated
  102897. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102898. * @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
  102899. * @returns VertexData.
  102900. */
  102901. updateGeometry(geometry: Geometry): VertexData;
  102902. private _applyTo;
  102903. private _update;
  102904. /**
  102905. * Transforms each position and each normal of the vertexData according to the passed Matrix
  102906. * @param matrix the transforming matrix
  102907. * @returns the VertexData
  102908. */
  102909. transform(matrix: Matrix): VertexData;
  102910. /**
  102911. * Merges the passed VertexData into the current one
  102912. * @param other the VertexData to be merged into the current one
  102913. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102914. * @returns the modified VertexData
  102915. */
  102916. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102917. private _mergeElement;
  102918. private _validate;
  102919. /**
  102920. * Serializes the VertexData
  102921. * @returns a serialized object
  102922. */
  102923. serialize(): any;
  102924. /**
  102925. * Extracts the vertexData from a mesh
  102926. * @param mesh the mesh from which to extract the VertexData
  102927. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102928. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102929. * @returns the object VertexData associated to the passed mesh
  102930. */
  102931. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102932. /**
  102933. * Extracts the vertexData from the geometry
  102934. * @param geometry the geometry from which to extract the VertexData
  102935. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102936. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102937. * @returns the object VertexData associated to the passed mesh
  102938. */
  102939. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102940. private static _ExtractFrom;
  102941. /**
  102942. * Creates the VertexData for a Ribbon
  102943. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102944. * * pathArray array of paths, each of which an array of successive Vector3
  102945. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102946. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102947. * * 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
  102948. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102949. * * 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)
  102950. * * 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)
  102951. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102952. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102953. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102954. * @returns the VertexData of the ribbon
  102955. */
  102956. static CreateRibbon(options: {
  102957. pathArray: Vector3[][];
  102958. closeArray?: boolean;
  102959. closePath?: boolean;
  102960. offset?: number;
  102961. sideOrientation?: number;
  102962. frontUVs?: Vector4;
  102963. backUVs?: Vector4;
  102964. invertUV?: boolean;
  102965. uvs?: Vector2[];
  102966. colors?: Color4[];
  102967. }): VertexData;
  102968. /**
  102969. * Creates the VertexData for a box
  102970. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102971. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102972. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102973. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102974. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102975. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102976. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102978. * * 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)
  102979. * * 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)
  102980. * @returns the VertexData of the box
  102981. */
  102982. static CreateBox(options: {
  102983. size?: number;
  102984. width?: number;
  102985. height?: number;
  102986. depth?: number;
  102987. faceUV?: Vector4[];
  102988. faceColors?: Color4[];
  102989. sideOrientation?: number;
  102990. frontUVs?: Vector4;
  102991. backUVs?: Vector4;
  102992. }): VertexData;
  102993. /**
  102994. * Creates the VertexData for a tiled box
  102995. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102996. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102997. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102998. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102999. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103000. * @returns the VertexData of the box
  103001. */
  103002. static CreateTiledBox(options: {
  103003. pattern?: number;
  103004. width?: number;
  103005. height?: number;
  103006. depth?: number;
  103007. tileSize?: number;
  103008. tileWidth?: number;
  103009. tileHeight?: number;
  103010. alignHorizontal?: number;
  103011. alignVertical?: number;
  103012. faceUV?: Vector4[];
  103013. faceColors?: Color4[];
  103014. sideOrientation?: number;
  103015. }): VertexData;
  103016. /**
  103017. * Creates the VertexData for a tiled plane
  103018. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103019. * * pattern a limited pattern arrangement depending on the number
  103020. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  103021. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  103022. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  103023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103024. * * 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)
  103025. * * 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)
  103026. * @returns the VertexData of the tiled plane
  103027. */
  103028. static CreateTiledPlane(options: {
  103029. pattern?: number;
  103030. tileSize?: number;
  103031. tileWidth?: number;
  103032. tileHeight?: number;
  103033. size?: number;
  103034. width?: number;
  103035. height?: number;
  103036. alignHorizontal?: number;
  103037. alignVertical?: number;
  103038. sideOrientation?: number;
  103039. frontUVs?: Vector4;
  103040. backUVs?: Vector4;
  103041. }): VertexData;
  103042. /**
  103043. * Creates the VertexData for an ellipsoid, defaults to a sphere
  103044. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103045. * * segments sets the number of horizontal strips optional, default 32
  103046. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  103047. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  103048. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  103049. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  103050. * * 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
  103051. * * 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
  103052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103053. * * 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)
  103054. * * 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)
  103055. * @returns the VertexData of the ellipsoid
  103056. */
  103057. static CreateSphere(options: {
  103058. segments?: number;
  103059. diameter?: number;
  103060. diameterX?: number;
  103061. diameterY?: number;
  103062. diameterZ?: number;
  103063. arc?: number;
  103064. slice?: number;
  103065. sideOrientation?: number;
  103066. frontUVs?: Vector4;
  103067. backUVs?: Vector4;
  103068. }): VertexData;
  103069. /**
  103070. * Creates the VertexData for a cylinder, cone or prism
  103071. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103072. * * height sets the height (y direction) of the cylinder, optional, default 2
  103073. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  103074. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  103075. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  103076. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103077. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  103078. * * 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
  103079. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103080. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103081. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  103082. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  103083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103084. * * 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)
  103085. * * 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)
  103086. * @returns the VertexData of the cylinder, cone or prism
  103087. */
  103088. static CreateCylinder(options: {
  103089. height?: number;
  103090. diameterTop?: number;
  103091. diameterBottom?: number;
  103092. diameter?: number;
  103093. tessellation?: number;
  103094. subdivisions?: number;
  103095. arc?: number;
  103096. faceColors?: Color4[];
  103097. faceUV?: Vector4[];
  103098. hasRings?: boolean;
  103099. enclose?: boolean;
  103100. sideOrientation?: number;
  103101. frontUVs?: Vector4;
  103102. backUVs?: Vector4;
  103103. }): VertexData;
  103104. /**
  103105. * Creates the VertexData for a torus
  103106. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103107. * * diameter the diameter of the torus, optional default 1
  103108. * * thickness the diameter of the tube forming the torus, optional default 0.5
  103109. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103111. * * 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)
  103112. * * 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)
  103113. * @returns the VertexData of the torus
  103114. */
  103115. static CreateTorus(options: {
  103116. diameter?: number;
  103117. thickness?: number;
  103118. tessellation?: number;
  103119. sideOrientation?: number;
  103120. frontUVs?: Vector4;
  103121. backUVs?: Vector4;
  103122. }): VertexData;
  103123. /**
  103124. * Creates the VertexData of the LineSystem
  103125. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103126. * - lines an array of lines, each line being an array of successive Vector3
  103127. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103128. * @returns the VertexData of the LineSystem
  103129. */
  103130. static CreateLineSystem(options: {
  103131. lines: Vector3[][];
  103132. colors?: Nullable<Color4[][]>;
  103133. }): VertexData;
  103134. /**
  103135. * Create the VertexData for a DashedLines
  103136. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103137. * - points an array successive Vector3
  103138. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103139. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103140. * - dashNb the intended total number of dashes, optional, default 200
  103141. * @returns the VertexData for the DashedLines
  103142. */
  103143. static CreateDashedLines(options: {
  103144. points: Vector3[];
  103145. dashSize?: number;
  103146. gapSize?: number;
  103147. dashNb?: number;
  103148. }): VertexData;
  103149. /**
  103150. * Creates the VertexData for a Ground
  103151. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103152. * - width the width (x direction) of the ground, optional, default 1
  103153. * - height the height (z direction) of the ground, optional, default 1
  103154. * - subdivisions the number of subdivisions per side, optional, default 1
  103155. * @returns the VertexData of the Ground
  103156. */
  103157. static CreateGround(options: {
  103158. width?: number;
  103159. height?: number;
  103160. subdivisions?: number;
  103161. subdivisionsX?: number;
  103162. subdivisionsY?: number;
  103163. }): VertexData;
  103164. /**
  103165. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103166. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103167. * * xmin the ground minimum X coordinate, optional, default -1
  103168. * * zmin the ground minimum Z coordinate, optional, default -1
  103169. * * xmax the ground maximum X coordinate, optional, default 1
  103170. * * zmax the ground maximum Z coordinate, optional, default 1
  103171. * * 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}
  103172. * * 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}
  103173. * @returns the VertexData of the TiledGround
  103174. */
  103175. static CreateTiledGround(options: {
  103176. xmin: number;
  103177. zmin: number;
  103178. xmax: number;
  103179. zmax: number;
  103180. subdivisions?: {
  103181. w: number;
  103182. h: number;
  103183. };
  103184. precision?: {
  103185. w: number;
  103186. h: number;
  103187. };
  103188. }): VertexData;
  103189. /**
  103190. * Creates the VertexData of the Ground designed from a heightmap
  103191. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103192. * * width the width (x direction) of the ground
  103193. * * height the height (z direction) of the ground
  103194. * * subdivisions the number of subdivisions per side
  103195. * * minHeight the minimum altitude on the ground, optional, default 0
  103196. * * maxHeight the maximum altitude on the ground, optional default 1
  103197. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103198. * * buffer the array holding the image color data
  103199. * * bufferWidth the width of image
  103200. * * bufferHeight the height of image
  103201. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103202. * @returns the VertexData of the Ground designed from a heightmap
  103203. */
  103204. static CreateGroundFromHeightMap(options: {
  103205. width: number;
  103206. height: number;
  103207. subdivisions: number;
  103208. minHeight: number;
  103209. maxHeight: number;
  103210. colorFilter: Color3;
  103211. buffer: Uint8Array;
  103212. bufferWidth: number;
  103213. bufferHeight: number;
  103214. alphaFilter: number;
  103215. }): VertexData;
  103216. /**
  103217. * Creates the VertexData for a Plane
  103218. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103219. * * size sets the width and height of the plane to the value of size, optional default 1
  103220. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103221. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103223. * * 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)
  103224. * * 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)
  103225. * @returns the VertexData of the box
  103226. */
  103227. static CreatePlane(options: {
  103228. size?: number;
  103229. width?: number;
  103230. height?: number;
  103231. sideOrientation?: number;
  103232. frontUVs?: Vector4;
  103233. backUVs?: Vector4;
  103234. }): VertexData;
  103235. /**
  103236. * Creates the VertexData of the Disc or regular Polygon
  103237. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103238. * * radius the radius of the disc, optional default 0.5
  103239. * * tessellation the number of polygon sides, optional, default 64
  103240. * * 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
  103241. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103242. * * 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)
  103243. * * 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)
  103244. * @returns the VertexData of the box
  103245. */
  103246. static CreateDisc(options: {
  103247. radius?: number;
  103248. tessellation?: number;
  103249. arc?: number;
  103250. sideOrientation?: number;
  103251. frontUVs?: Vector4;
  103252. backUVs?: Vector4;
  103253. }): VertexData;
  103254. /**
  103255. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103256. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103257. * @param polygon a mesh built from polygonTriangulation.build()
  103258. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103259. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103260. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103261. * @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)
  103262. * @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)
  103263. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103264. * @returns the VertexData of the Polygon
  103265. */
  103266. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103267. /**
  103268. * Creates the VertexData of the IcoSphere
  103269. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103270. * * radius the radius of the IcoSphere, optional default 1
  103271. * * radiusX allows stretching in the x direction, optional, default radius
  103272. * * radiusY allows stretching in the y direction, optional, default radius
  103273. * * radiusZ allows stretching in the z direction, optional, default radius
  103274. * * flat when true creates a flat shaded mesh, optional, default true
  103275. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103277. * * 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)
  103278. * * 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)
  103279. * @returns the VertexData of the IcoSphere
  103280. */
  103281. static CreateIcoSphere(options: {
  103282. radius?: number;
  103283. radiusX?: number;
  103284. radiusY?: number;
  103285. radiusZ?: number;
  103286. flat?: boolean;
  103287. subdivisions?: number;
  103288. sideOrientation?: number;
  103289. frontUVs?: Vector4;
  103290. backUVs?: Vector4;
  103291. }): VertexData;
  103292. /**
  103293. * Creates the VertexData for a Polyhedron
  103294. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103295. * * type provided types are:
  103296. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103297. * * 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)
  103298. * * size the size of the IcoSphere, optional default 1
  103299. * * sizeX allows stretching in the x direction, optional, default size
  103300. * * sizeY allows stretching in the y direction, optional, default size
  103301. * * sizeZ allows stretching in the z direction, optional, default size
  103302. * * 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
  103303. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103304. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103305. * * flat when true creates a flat shaded mesh, optional, default true
  103306. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103308. * * 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)
  103309. * * 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)
  103310. * @returns the VertexData of the Polyhedron
  103311. */
  103312. static CreatePolyhedron(options: {
  103313. type?: number;
  103314. size?: number;
  103315. sizeX?: number;
  103316. sizeY?: number;
  103317. sizeZ?: number;
  103318. custom?: any;
  103319. faceUV?: Vector4[];
  103320. faceColors?: Color4[];
  103321. flat?: boolean;
  103322. sideOrientation?: number;
  103323. frontUVs?: Vector4;
  103324. backUVs?: Vector4;
  103325. }): VertexData;
  103326. /**
  103327. * Creates the VertexData for a TorusKnot
  103328. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103329. * * radius the radius of the torus knot, optional, default 2
  103330. * * tube the thickness of the tube, optional, default 0.5
  103331. * * radialSegments the number of sides on each tube segments, optional, default 32
  103332. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103333. * * p the number of windings around the z axis, optional, default 2
  103334. * * q the number of windings around the x axis, optional, default 3
  103335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103336. * * 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)
  103337. * * 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)
  103338. * @returns the VertexData of the Torus Knot
  103339. */
  103340. static CreateTorusKnot(options: {
  103341. radius?: number;
  103342. tube?: number;
  103343. radialSegments?: number;
  103344. tubularSegments?: number;
  103345. p?: number;
  103346. q?: number;
  103347. sideOrientation?: number;
  103348. frontUVs?: Vector4;
  103349. backUVs?: Vector4;
  103350. }): VertexData;
  103351. /**
  103352. * Compute normals for given positions and indices
  103353. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103354. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103355. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103356. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103357. * * facetNormals : optional array of facet normals (vector3)
  103358. * * facetPositions : optional array of facet positions (vector3)
  103359. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103360. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103361. * * bInfo : optional bounding info, required for facetPartitioning computation
  103362. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103363. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103364. * * useRightHandedSystem: optional boolean to for right handed system computation
  103365. * * depthSort : optional boolean to enable the facet depth sort computation
  103366. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103367. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103368. */
  103369. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103370. facetNormals?: any;
  103371. facetPositions?: any;
  103372. facetPartitioning?: any;
  103373. ratio?: number;
  103374. bInfo?: any;
  103375. bbSize?: Vector3;
  103376. subDiv?: any;
  103377. useRightHandedSystem?: boolean;
  103378. depthSort?: boolean;
  103379. distanceTo?: Vector3;
  103380. depthSortedFacets?: any;
  103381. }): void;
  103382. /** @hidden */
  103383. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  103384. /**
  103385. * Applies VertexData created from the imported parameters to the geometry
  103386. * @param parsedVertexData the parsed data from an imported file
  103387. * @param geometry the geometry to apply the VertexData to
  103388. */
  103389. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  103390. }
  103391. }
  103392. declare module BABYLON {
  103393. /**
  103394. * Defines a target to use with MorphTargetManager
  103395. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103396. */
  103397. export class MorphTarget implements IAnimatable {
  103398. /** defines the name of the target */
  103399. name: string;
  103400. /**
  103401. * Gets or sets the list of animations
  103402. */
  103403. animations: Animation[];
  103404. private _scene;
  103405. private _positions;
  103406. private _normals;
  103407. private _tangents;
  103408. private _uvs;
  103409. private _influence;
  103410. private _uniqueId;
  103411. /**
  103412. * Observable raised when the influence changes
  103413. */
  103414. onInfluenceChanged: Observable<boolean>;
  103415. /** @hidden */
  103416. _onDataLayoutChanged: Observable<void>;
  103417. /**
  103418. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103419. */
  103420. get influence(): number;
  103421. set influence(influence: number);
  103422. /**
  103423. * Gets or sets the id of the morph Target
  103424. */
  103425. id: string;
  103426. private _animationPropertiesOverride;
  103427. /**
  103428. * Gets or sets the animation properties override
  103429. */
  103430. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103431. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103432. /**
  103433. * Creates a new MorphTarget
  103434. * @param name defines the name of the target
  103435. * @param influence defines the influence to use
  103436. * @param scene defines the scene the morphtarget belongs to
  103437. */
  103438. constructor(
  103439. /** defines the name of the target */
  103440. name: string, influence?: number, scene?: Nullable<Scene>);
  103441. /**
  103442. * Gets the unique ID of this manager
  103443. */
  103444. get uniqueId(): number;
  103445. /**
  103446. * Gets a boolean defining if the target contains position data
  103447. */
  103448. get hasPositions(): boolean;
  103449. /**
  103450. * Gets a boolean defining if the target contains normal data
  103451. */
  103452. get hasNormals(): boolean;
  103453. /**
  103454. * Gets a boolean defining if the target contains tangent data
  103455. */
  103456. get hasTangents(): boolean;
  103457. /**
  103458. * Gets a boolean defining if the target contains texture coordinates data
  103459. */
  103460. get hasUVs(): boolean;
  103461. /**
  103462. * Affects position data to this target
  103463. * @param data defines the position data to use
  103464. */
  103465. setPositions(data: Nullable<FloatArray>): void;
  103466. /**
  103467. * Gets the position data stored in this target
  103468. * @returns a FloatArray containing the position data (or null if not present)
  103469. */
  103470. getPositions(): Nullable<FloatArray>;
  103471. /**
  103472. * Affects normal data to this target
  103473. * @param data defines the normal data to use
  103474. */
  103475. setNormals(data: Nullable<FloatArray>): void;
  103476. /**
  103477. * Gets the normal data stored in this target
  103478. * @returns a FloatArray containing the normal data (or null if not present)
  103479. */
  103480. getNormals(): Nullable<FloatArray>;
  103481. /**
  103482. * Affects tangent data to this target
  103483. * @param data defines the tangent data to use
  103484. */
  103485. setTangents(data: Nullable<FloatArray>): void;
  103486. /**
  103487. * Gets the tangent data stored in this target
  103488. * @returns a FloatArray containing the tangent data (or null if not present)
  103489. */
  103490. getTangents(): Nullable<FloatArray>;
  103491. /**
  103492. * Affects texture coordinates data to this target
  103493. * @param data defines the texture coordinates data to use
  103494. */
  103495. setUVs(data: Nullable<FloatArray>): void;
  103496. /**
  103497. * Gets the texture coordinates data stored in this target
  103498. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103499. */
  103500. getUVs(): Nullable<FloatArray>;
  103501. /**
  103502. * Clone the current target
  103503. * @returns a new MorphTarget
  103504. */
  103505. clone(): MorphTarget;
  103506. /**
  103507. * Serializes the current target into a Serialization object
  103508. * @returns the serialized object
  103509. */
  103510. serialize(): any;
  103511. /**
  103512. * Returns the string "MorphTarget"
  103513. * @returns "MorphTarget"
  103514. */
  103515. getClassName(): string;
  103516. /**
  103517. * Creates a new target from serialized data
  103518. * @param serializationObject defines the serialized data to use
  103519. * @returns a new MorphTarget
  103520. */
  103521. static Parse(serializationObject: any): MorphTarget;
  103522. /**
  103523. * Creates a MorphTarget from mesh data
  103524. * @param mesh defines the source mesh
  103525. * @param name defines the name to use for the new target
  103526. * @param influence defines the influence to attach to the target
  103527. * @returns a new MorphTarget
  103528. */
  103529. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103530. }
  103531. }
  103532. declare module BABYLON {
  103533. /**
  103534. * This class is used to deform meshes using morphing between different targets
  103535. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103536. */
  103537. export class MorphTargetManager {
  103538. private _targets;
  103539. private _targetInfluenceChangedObservers;
  103540. private _targetDataLayoutChangedObservers;
  103541. private _activeTargets;
  103542. private _scene;
  103543. private _influences;
  103544. private _supportsNormals;
  103545. private _supportsTangents;
  103546. private _supportsUVs;
  103547. private _vertexCount;
  103548. private _uniqueId;
  103549. private _tempInfluences;
  103550. /**
  103551. * Gets or sets a boolean indicating if normals must be morphed
  103552. */
  103553. enableNormalMorphing: boolean;
  103554. /**
  103555. * Gets or sets a boolean indicating if tangents must be morphed
  103556. */
  103557. enableTangentMorphing: boolean;
  103558. /**
  103559. * Gets or sets a boolean indicating if UV must be morphed
  103560. */
  103561. enableUVMorphing: boolean;
  103562. /**
  103563. * Creates a new MorphTargetManager
  103564. * @param scene defines the current scene
  103565. */
  103566. constructor(scene?: Nullable<Scene>);
  103567. /**
  103568. * Gets the unique ID of this manager
  103569. */
  103570. get uniqueId(): number;
  103571. /**
  103572. * Gets the number of vertices handled by this manager
  103573. */
  103574. get vertexCount(): number;
  103575. /**
  103576. * Gets a boolean indicating if this manager supports morphing of normals
  103577. */
  103578. get supportsNormals(): boolean;
  103579. /**
  103580. * Gets a boolean indicating if this manager supports morphing of tangents
  103581. */
  103582. get supportsTangents(): boolean;
  103583. /**
  103584. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  103585. */
  103586. get supportsUVs(): boolean;
  103587. /**
  103588. * Gets the number of targets stored in this manager
  103589. */
  103590. get numTargets(): number;
  103591. /**
  103592. * Gets the number of influencers (ie. the number of targets with influences > 0)
  103593. */
  103594. get numInfluencers(): number;
  103595. /**
  103596. * Gets the list of influences (one per target)
  103597. */
  103598. get influences(): Float32Array;
  103599. /**
  103600. * Gets the active target at specified index. An active target is a target with an influence > 0
  103601. * @param index defines the index to check
  103602. * @returns the requested target
  103603. */
  103604. getActiveTarget(index: number): MorphTarget;
  103605. /**
  103606. * Gets the target at specified index
  103607. * @param index defines the index to check
  103608. * @returns the requested target
  103609. */
  103610. getTarget(index: number): MorphTarget;
  103611. /**
  103612. * Add a new target to this manager
  103613. * @param target defines the target to add
  103614. */
  103615. addTarget(target: MorphTarget): void;
  103616. /**
  103617. * Removes a target from the manager
  103618. * @param target defines the target to remove
  103619. */
  103620. removeTarget(target: MorphTarget): void;
  103621. /**
  103622. * Clone the current manager
  103623. * @returns a new MorphTargetManager
  103624. */
  103625. clone(): MorphTargetManager;
  103626. /**
  103627. * Serializes the current manager into a Serialization object
  103628. * @returns the serialized object
  103629. */
  103630. serialize(): any;
  103631. private _syncActiveTargets;
  103632. /**
  103633. * Syncrhonize the targets with all the meshes using this morph target manager
  103634. */
  103635. synchronize(): void;
  103636. /**
  103637. * Creates a new MorphTargetManager from serialized data
  103638. * @param serializationObject defines the serialized data
  103639. * @param scene defines the hosting scene
  103640. * @returns the new MorphTargetManager
  103641. */
  103642. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  103643. }
  103644. }
  103645. declare module BABYLON {
  103646. /**
  103647. * Class used to represent a specific level of detail of a mesh
  103648. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  103649. */
  103650. export class MeshLODLevel {
  103651. /** Defines the distance where this level should start being displayed */
  103652. distance: number;
  103653. /** Defines the mesh to use to render this level */
  103654. mesh: Nullable<Mesh>;
  103655. /**
  103656. * Creates a new LOD level
  103657. * @param distance defines the distance where this level should star being displayed
  103658. * @param mesh defines the mesh to use to render this level
  103659. */
  103660. constructor(
  103661. /** Defines the distance where this level should start being displayed */
  103662. distance: number,
  103663. /** Defines the mesh to use to render this level */
  103664. mesh: Nullable<Mesh>);
  103665. }
  103666. }
  103667. declare module BABYLON {
  103668. /**
  103669. * Mesh representing the gorund
  103670. */
  103671. export class GroundMesh extends Mesh {
  103672. /** If octree should be generated */
  103673. generateOctree: boolean;
  103674. private _heightQuads;
  103675. /** @hidden */
  103676. _subdivisionsX: number;
  103677. /** @hidden */
  103678. _subdivisionsY: number;
  103679. /** @hidden */
  103680. _width: number;
  103681. /** @hidden */
  103682. _height: number;
  103683. /** @hidden */
  103684. _minX: number;
  103685. /** @hidden */
  103686. _maxX: number;
  103687. /** @hidden */
  103688. _minZ: number;
  103689. /** @hidden */
  103690. _maxZ: number;
  103691. constructor(name: string, scene: Scene);
  103692. /**
  103693. * "GroundMesh"
  103694. * @returns "GroundMesh"
  103695. */
  103696. getClassName(): string;
  103697. /**
  103698. * The minimum of x and y subdivisions
  103699. */
  103700. get subdivisions(): number;
  103701. /**
  103702. * X subdivisions
  103703. */
  103704. get subdivisionsX(): number;
  103705. /**
  103706. * Y subdivisions
  103707. */
  103708. get subdivisionsY(): number;
  103709. /**
  103710. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  103711. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103712. * @param chunksCount the number of subdivisions for x and y
  103713. * @param octreeBlocksSize (Default: 32)
  103714. */
  103715. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  103716. /**
  103717. * Returns a height (y) value in the Worl system :
  103718. * the ground altitude at the coordinates (x, z) expressed in the World system.
  103719. * @param x x coordinate
  103720. * @param z z coordinate
  103721. * @returns the ground y position if (x, z) are outside the ground surface.
  103722. */
  103723. getHeightAtCoordinates(x: number, z: number): number;
  103724. /**
  103725. * Returns a normalized vector (Vector3) orthogonal to the ground
  103726. * at the ground coordinates (x, z) expressed in the World system.
  103727. * @param x x coordinate
  103728. * @param z z coordinate
  103729. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  103730. */
  103731. getNormalAtCoordinates(x: number, z: number): Vector3;
  103732. /**
  103733. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  103734. * at the ground coordinates (x, z) expressed in the World system.
  103735. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  103736. * @param x x coordinate
  103737. * @param z z coordinate
  103738. * @param ref vector to store the result
  103739. * @returns the GroundMesh.
  103740. */
  103741. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  103742. /**
  103743. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  103744. * if the ground has been updated.
  103745. * This can be used in the render loop.
  103746. * @returns the GroundMesh.
  103747. */
  103748. updateCoordinateHeights(): GroundMesh;
  103749. private _getFacetAt;
  103750. private _initHeightQuads;
  103751. private _computeHeightQuads;
  103752. /**
  103753. * Serializes this ground mesh
  103754. * @param serializationObject object to write serialization to
  103755. */
  103756. serialize(serializationObject: any): void;
  103757. /**
  103758. * Parses a serialized ground mesh
  103759. * @param parsedMesh the serialized mesh
  103760. * @param scene the scene to create the ground mesh in
  103761. * @returns the created ground mesh
  103762. */
  103763. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  103764. }
  103765. }
  103766. declare module BABYLON {
  103767. /**
  103768. * Interface for Physics-Joint data
  103769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103770. */
  103771. export interface PhysicsJointData {
  103772. /**
  103773. * The main pivot of the joint
  103774. */
  103775. mainPivot?: Vector3;
  103776. /**
  103777. * The connected pivot of the joint
  103778. */
  103779. connectedPivot?: Vector3;
  103780. /**
  103781. * The main axis of the joint
  103782. */
  103783. mainAxis?: Vector3;
  103784. /**
  103785. * The connected axis of the joint
  103786. */
  103787. connectedAxis?: Vector3;
  103788. /**
  103789. * The collision of the joint
  103790. */
  103791. collision?: boolean;
  103792. /**
  103793. * Native Oimo/Cannon/Energy data
  103794. */
  103795. nativeParams?: any;
  103796. }
  103797. /**
  103798. * This is a holder class for the physics joint created by the physics plugin
  103799. * It holds a set of functions to control the underlying joint
  103800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103801. */
  103802. export class PhysicsJoint {
  103803. /**
  103804. * The type of the physics joint
  103805. */
  103806. type: number;
  103807. /**
  103808. * The data for the physics joint
  103809. */
  103810. jointData: PhysicsJointData;
  103811. private _physicsJoint;
  103812. protected _physicsPlugin: IPhysicsEnginePlugin;
  103813. /**
  103814. * Initializes the physics joint
  103815. * @param type The type of the physics joint
  103816. * @param jointData The data for the physics joint
  103817. */
  103818. constructor(
  103819. /**
  103820. * The type of the physics joint
  103821. */
  103822. type: number,
  103823. /**
  103824. * The data for the physics joint
  103825. */
  103826. jointData: PhysicsJointData);
  103827. /**
  103828. * Gets the physics joint
  103829. */
  103830. get physicsJoint(): any;
  103831. /**
  103832. * Sets the physics joint
  103833. */
  103834. set physicsJoint(newJoint: any);
  103835. /**
  103836. * Sets the physics plugin
  103837. */
  103838. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  103839. /**
  103840. * Execute a function that is physics-plugin specific.
  103841. * @param {Function} func the function that will be executed.
  103842. * It accepts two parameters: the physics world and the physics joint
  103843. */
  103844. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  103845. /**
  103846. * Distance-Joint type
  103847. */
  103848. static DistanceJoint: number;
  103849. /**
  103850. * Hinge-Joint type
  103851. */
  103852. static HingeJoint: number;
  103853. /**
  103854. * Ball-and-Socket joint type
  103855. */
  103856. static BallAndSocketJoint: number;
  103857. /**
  103858. * Wheel-Joint type
  103859. */
  103860. static WheelJoint: number;
  103861. /**
  103862. * Slider-Joint type
  103863. */
  103864. static SliderJoint: number;
  103865. /**
  103866. * Prismatic-Joint type
  103867. */
  103868. static PrismaticJoint: number;
  103869. /**
  103870. * Universal-Joint type
  103871. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  103872. */
  103873. static UniversalJoint: number;
  103874. /**
  103875. * Hinge-Joint 2 type
  103876. */
  103877. static Hinge2Joint: number;
  103878. /**
  103879. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  103880. */
  103881. static PointToPointJoint: number;
  103882. /**
  103883. * Spring-Joint type
  103884. */
  103885. static SpringJoint: number;
  103886. /**
  103887. * Lock-Joint type
  103888. */
  103889. static LockJoint: number;
  103890. }
  103891. /**
  103892. * A class representing a physics distance joint
  103893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103894. */
  103895. export class DistanceJoint extends PhysicsJoint {
  103896. /**
  103897. *
  103898. * @param jointData The data for the Distance-Joint
  103899. */
  103900. constructor(jointData: DistanceJointData);
  103901. /**
  103902. * Update the predefined distance.
  103903. * @param maxDistance The maximum preferred distance
  103904. * @param minDistance The minimum preferred distance
  103905. */
  103906. updateDistance(maxDistance: number, minDistance?: number): void;
  103907. }
  103908. /**
  103909. * Represents a Motor-Enabled Joint
  103910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103911. */
  103912. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  103913. /**
  103914. * Initializes the Motor-Enabled Joint
  103915. * @param type The type of the joint
  103916. * @param jointData The physica joint data for the joint
  103917. */
  103918. constructor(type: number, jointData: PhysicsJointData);
  103919. /**
  103920. * Set the motor values.
  103921. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103922. * @param force the force to apply
  103923. * @param maxForce max force for this motor.
  103924. */
  103925. setMotor(force?: number, maxForce?: number): void;
  103926. /**
  103927. * Set the motor's limits.
  103928. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103929. * @param upperLimit The upper limit of the motor
  103930. * @param lowerLimit The lower limit of the motor
  103931. */
  103932. setLimit(upperLimit: number, lowerLimit?: number): void;
  103933. }
  103934. /**
  103935. * This class represents a single physics Hinge-Joint
  103936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103937. */
  103938. export class HingeJoint extends MotorEnabledJoint {
  103939. /**
  103940. * Initializes the Hinge-Joint
  103941. * @param jointData The joint data for the Hinge-Joint
  103942. */
  103943. constructor(jointData: PhysicsJointData);
  103944. /**
  103945. * Set the motor values.
  103946. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103947. * @param {number} force the force to apply
  103948. * @param {number} maxForce max force for this motor.
  103949. */
  103950. setMotor(force?: number, maxForce?: number): void;
  103951. /**
  103952. * Set the motor's limits.
  103953. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103954. * @param upperLimit The upper limit of the motor
  103955. * @param lowerLimit The lower limit of the motor
  103956. */
  103957. setLimit(upperLimit: number, lowerLimit?: number): void;
  103958. }
  103959. /**
  103960. * This class represents a dual hinge physics joint (same as wheel joint)
  103961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103962. */
  103963. export class Hinge2Joint extends MotorEnabledJoint {
  103964. /**
  103965. * Initializes the Hinge2-Joint
  103966. * @param jointData The joint data for the Hinge2-Joint
  103967. */
  103968. constructor(jointData: PhysicsJointData);
  103969. /**
  103970. * Set the motor values.
  103971. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103972. * @param {number} targetSpeed the speed the motor is to reach
  103973. * @param {number} maxForce max force for this motor.
  103974. * @param {motorIndex} the motor's index, 0 or 1.
  103975. */
  103976. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  103977. /**
  103978. * Set the motor limits.
  103979. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103980. * @param {number} upperLimit the upper limit
  103981. * @param {number} lowerLimit lower limit
  103982. * @param {motorIndex} the motor's index, 0 or 1.
  103983. */
  103984. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103985. }
  103986. /**
  103987. * Interface for a motor enabled joint
  103988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103989. */
  103990. export interface IMotorEnabledJoint {
  103991. /**
  103992. * Physics joint
  103993. */
  103994. physicsJoint: any;
  103995. /**
  103996. * Sets the motor of the motor-enabled joint
  103997. * @param force The force of the motor
  103998. * @param maxForce The maximum force of the motor
  103999. * @param motorIndex The index of the motor
  104000. */
  104001. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  104002. /**
  104003. * Sets the limit of the motor
  104004. * @param upperLimit The upper limit of the motor
  104005. * @param lowerLimit The lower limit of the motor
  104006. * @param motorIndex The index of the motor
  104007. */
  104008. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104009. }
  104010. /**
  104011. * Joint data for a Distance-Joint
  104012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104013. */
  104014. export interface DistanceJointData extends PhysicsJointData {
  104015. /**
  104016. * Max distance the 2 joint objects can be apart
  104017. */
  104018. maxDistance: number;
  104019. }
  104020. /**
  104021. * Joint data from a spring joint
  104022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104023. */
  104024. export interface SpringJointData extends PhysicsJointData {
  104025. /**
  104026. * Length of the spring
  104027. */
  104028. length: number;
  104029. /**
  104030. * Stiffness of the spring
  104031. */
  104032. stiffness: number;
  104033. /**
  104034. * Damping of the spring
  104035. */
  104036. damping: number;
  104037. /** this callback will be called when applying the force to the impostors. */
  104038. forceApplicationCallback: () => void;
  104039. }
  104040. }
  104041. declare module BABYLON {
  104042. /**
  104043. * Holds the data for the raycast result
  104044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104045. */
  104046. export class PhysicsRaycastResult {
  104047. private _hasHit;
  104048. private _hitDistance;
  104049. private _hitNormalWorld;
  104050. private _hitPointWorld;
  104051. private _rayFromWorld;
  104052. private _rayToWorld;
  104053. /**
  104054. * Gets if there was a hit
  104055. */
  104056. get hasHit(): boolean;
  104057. /**
  104058. * Gets the distance from the hit
  104059. */
  104060. get hitDistance(): number;
  104061. /**
  104062. * Gets the hit normal/direction in the world
  104063. */
  104064. get hitNormalWorld(): Vector3;
  104065. /**
  104066. * Gets the hit point in the world
  104067. */
  104068. get hitPointWorld(): Vector3;
  104069. /**
  104070. * Gets the ray "start point" of the ray in the world
  104071. */
  104072. get rayFromWorld(): Vector3;
  104073. /**
  104074. * Gets the ray "end point" of the ray in the world
  104075. */
  104076. get rayToWorld(): Vector3;
  104077. /**
  104078. * Sets the hit data (normal & point in world space)
  104079. * @param hitNormalWorld defines the normal in world space
  104080. * @param hitPointWorld defines the point in world space
  104081. */
  104082. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  104083. /**
  104084. * Sets the distance from the start point to the hit point
  104085. * @param distance
  104086. */
  104087. setHitDistance(distance: number): void;
  104088. /**
  104089. * Calculates the distance manually
  104090. */
  104091. calculateHitDistance(): void;
  104092. /**
  104093. * Resets all the values to default
  104094. * @param from The from point on world space
  104095. * @param to The to point on world space
  104096. */
  104097. reset(from?: Vector3, to?: Vector3): void;
  104098. }
  104099. /**
  104100. * Interface for the size containing width and height
  104101. */
  104102. interface IXYZ {
  104103. /**
  104104. * X
  104105. */
  104106. x: number;
  104107. /**
  104108. * Y
  104109. */
  104110. y: number;
  104111. /**
  104112. * Z
  104113. */
  104114. z: number;
  104115. }
  104116. }
  104117. declare module BABYLON {
  104118. /**
  104119. * Interface used to describe a physics joint
  104120. */
  104121. export interface PhysicsImpostorJoint {
  104122. /** Defines the main impostor to which the joint is linked */
  104123. mainImpostor: PhysicsImpostor;
  104124. /** Defines the impostor that is connected to the main impostor using this joint */
  104125. connectedImpostor: PhysicsImpostor;
  104126. /** Defines the joint itself */
  104127. joint: PhysicsJoint;
  104128. }
  104129. /** @hidden */
  104130. export interface IPhysicsEnginePlugin {
  104131. world: any;
  104132. name: string;
  104133. setGravity(gravity: Vector3): void;
  104134. setTimeStep(timeStep: number): void;
  104135. getTimeStep(): number;
  104136. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104137. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104138. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104139. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104140. removePhysicsBody(impostor: PhysicsImpostor): void;
  104141. generateJoint(joint: PhysicsImpostorJoint): void;
  104142. removeJoint(joint: PhysicsImpostorJoint): void;
  104143. isSupported(): boolean;
  104144. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104145. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104146. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104147. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104148. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104149. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104150. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104151. getBodyMass(impostor: PhysicsImpostor): number;
  104152. getBodyFriction(impostor: PhysicsImpostor): number;
  104153. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104154. getBodyRestitution(impostor: PhysicsImpostor): number;
  104155. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104156. getBodyPressure?(impostor: PhysicsImpostor): number;
  104157. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104158. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104159. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104160. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104161. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104162. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104163. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104164. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104165. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104166. sleepBody(impostor: PhysicsImpostor): void;
  104167. wakeUpBody(impostor: PhysicsImpostor): void;
  104168. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104169. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104170. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104171. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104172. getRadius(impostor: PhysicsImpostor): number;
  104173. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104174. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104175. dispose(): void;
  104176. }
  104177. /**
  104178. * Interface used to define a physics engine
  104179. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104180. */
  104181. export interface IPhysicsEngine {
  104182. /**
  104183. * Gets the gravity vector used by the simulation
  104184. */
  104185. gravity: Vector3;
  104186. /**
  104187. * Sets the gravity vector used by the simulation
  104188. * @param gravity defines the gravity vector to use
  104189. */
  104190. setGravity(gravity: Vector3): void;
  104191. /**
  104192. * Set the time step of the physics engine.
  104193. * Default is 1/60.
  104194. * To slow it down, enter 1/600 for example.
  104195. * To speed it up, 1/30
  104196. * @param newTimeStep the new timestep to apply to this world.
  104197. */
  104198. setTimeStep(newTimeStep: number): void;
  104199. /**
  104200. * Get the time step of the physics engine.
  104201. * @returns the current time step
  104202. */
  104203. getTimeStep(): number;
  104204. /**
  104205. * Set the sub time step of the physics engine.
  104206. * Default is 0 meaning there is no sub steps
  104207. * To increase physics resolution precision, set a small value (like 1 ms)
  104208. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104209. */
  104210. setSubTimeStep(subTimeStep: number): void;
  104211. /**
  104212. * Get the sub time step of the physics engine.
  104213. * @returns the current sub time step
  104214. */
  104215. getSubTimeStep(): number;
  104216. /**
  104217. * Release all resources
  104218. */
  104219. dispose(): void;
  104220. /**
  104221. * Gets the name of the current physics plugin
  104222. * @returns the name of the plugin
  104223. */
  104224. getPhysicsPluginName(): string;
  104225. /**
  104226. * Adding a new impostor for the impostor tracking.
  104227. * This will be done by the impostor itself.
  104228. * @param impostor the impostor to add
  104229. */
  104230. addImpostor(impostor: PhysicsImpostor): void;
  104231. /**
  104232. * Remove an impostor from the engine.
  104233. * This impostor and its mesh will not longer be updated by the physics engine.
  104234. * @param impostor the impostor to remove
  104235. */
  104236. removeImpostor(impostor: PhysicsImpostor): void;
  104237. /**
  104238. * Add a joint to the physics engine
  104239. * @param mainImpostor defines the main impostor to which the joint is added.
  104240. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104241. * @param joint defines the joint that will connect both impostors.
  104242. */
  104243. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104244. /**
  104245. * Removes a joint from the simulation
  104246. * @param mainImpostor defines the impostor used with the joint
  104247. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104248. * @param joint defines the joint to remove
  104249. */
  104250. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104251. /**
  104252. * Gets the current plugin used to run the simulation
  104253. * @returns current plugin
  104254. */
  104255. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104256. /**
  104257. * Gets the list of physic impostors
  104258. * @returns an array of PhysicsImpostor
  104259. */
  104260. getImpostors(): Array<PhysicsImpostor>;
  104261. /**
  104262. * Gets the impostor for a physics enabled object
  104263. * @param object defines the object impersonated by the impostor
  104264. * @returns the PhysicsImpostor or null if not found
  104265. */
  104266. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104267. /**
  104268. * Gets the impostor for a physics body object
  104269. * @param body defines physics body used by the impostor
  104270. * @returns the PhysicsImpostor or null if not found
  104271. */
  104272. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104273. /**
  104274. * Does a raycast in the physics world
  104275. * @param from when should the ray start?
  104276. * @param to when should the ray end?
  104277. * @returns PhysicsRaycastResult
  104278. */
  104279. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104280. /**
  104281. * Called by the scene. No need to call it.
  104282. * @param delta defines the timespam between frames
  104283. */
  104284. _step(delta: number): void;
  104285. }
  104286. }
  104287. declare module BABYLON {
  104288. /**
  104289. * The interface for the physics imposter parameters
  104290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104291. */
  104292. export interface PhysicsImpostorParameters {
  104293. /**
  104294. * The mass of the physics imposter
  104295. */
  104296. mass: number;
  104297. /**
  104298. * The friction of the physics imposter
  104299. */
  104300. friction?: number;
  104301. /**
  104302. * The coefficient of restitution of the physics imposter
  104303. */
  104304. restitution?: number;
  104305. /**
  104306. * The native options of the physics imposter
  104307. */
  104308. nativeOptions?: any;
  104309. /**
  104310. * Specifies if the parent should be ignored
  104311. */
  104312. ignoreParent?: boolean;
  104313. /**
  104314. * Specifies if bi-directional transformations should be disabled
  104315. */
  104316. disableBidirectionalTransformation?: boolean;
  104317. /**
  104318. * The pressure inside the physics imposter, soft object only
  104319. */
  104320. pressure?: number;
  104321. /**
  104322. * The stiffness the physics imposter, soft object only
  104323. */
  104324. stiffness?: number;
  104325. /**
  104326. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104327. */
  104328. velocityIterations?: number;
  104329. /**
  104330. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104331. */
  104332. positionIterations?: number;
  104333. /**
  104334. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104335. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104336. * Add to fix multiple points
  104337. */
  104338. fixedPoints?: number;
  104339. /**
  104340. * The collision margin around a soft object
  104341. */
  104342. margin?: number;
  104343. /**
  104344. * The collision margin around a soft object
  104345. */
  104346. damping?: number;
  104347. /**
  104348. * The path for a rope based on an extrusion
  104349. */
  104350. path?: any;
  104351. /**
  104352. * The shape of an extrusion used for a rope based on an extrusion
  104353. */
  104354. shape?: any;
  104355. }
  104356. /**
  104357. * Interface for a physics-enabled object
  104358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104359. */
  104360. export interface IPhysicsEnabledObject {
  104361. /**
  104362. * The position of the physics-enabled object
  104363. */
  104364. position: Vector3;
  104365. /**
  104366. * The rotation of the physics-enabled object
  104367. */
  104368. rotationQuaternion: Nullable<Quaternion>;
  104369. /**
  104370. * The scale of the physics-enabled object
  104371. */
  104372. scaling: Vector3;
  104373. /**
  104374. * The rotation of the physics-enabled object
  104375. */
  104376. rotation?: Vector3;
  104377. /**
  104378. * The parent of the physics-enabled object
  104379. */
  104380. parent?: any;
  104381. /**
  104382. * The bounding info of the physics-enabled object
  104383. * @returns The bounding info of the physics-enabled object
  104384. */
  104385. getBoundingInfo(): BoundingInfo;
  104386. /**
  104387. * Computes the world matrix
  104388. * @param force Specifies if the world matrix should be computed by force
  104389. * @returns A world matrix
  104390. */
  104391. computeWorldMatrix(force: boolean): Matrix;
  104392. /**
  104393. * Gets the world matrix
  104394. * @returns A world matrix
  104395. */
  104396. getWorldMatrix?(): Matrix;
  104397. /**
  104398. * Gets the child meshes
  104399. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  104400. * @returns An array of abstract meshes
  104401. */
  104402. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  104403. /**
  104404. * Gets the vertex data
  104405. * @param kind The type of vertex data
  104406. * @returns A nullable array of numbers, or a float32 array
  104407. */
  104408. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  104409. /**
  104410. * Gets the indices from the mesh
  104411. * @returns A nullable array of index arrays
  104412. */
  104413. getIndices?(): Nullable<IndicesArray>;
  104414. /**
  104415. * Gets the scene from the mesh
  104416. * @returns the indices array or null
  104417. */
  104418. getScene?(): Scene;
  104419. /**
  104420. * Gets the absolute position from the mesh
  104421. * @returns the absolute position
  104422. */
  104423. getAbsolutePosition(): Vector3;
  104424. /**
  104425. * Gets the absolute pivot point from the mesh
  104426. * @returns the absolute pivot point
  104427. */
  104428. getAbsolutePivotPoint(): Vector3;
  104429. /**
  104430. * Rotates the mesh
  104431. * @param axis The axis of rotation
  104432. * @param amount The amount of rotation
  104433. * @param space The space of the rotation
  104434. * @returns The rotation transform node
  104435. */
  104436. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  104437. /**
  104438. * Translates the mesh
  104439. * @param axis The axis of translation
  104440. * @param distance The distance of translation
  104441. * @param space The space of the translation
  104442. * @returns The transform node
  104443. */
  104444. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  104445. /**
  104446. * Sets the absolute position of the mesh
  104447. * @param absolutePosition The absolute position of the mesh
  104448. * @returns The transform node
  104449. */
  104450. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  104451. /**
  104452. * Gets the class name of the mesh
  104453. * @returns The class name
  104454. */
  104455. getClassName(): string;
  104456. }
  104457. /**
  104458. * Represents a physics imposter
  104459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104460. */
  104461. export class PhysicsImpostor {
  104462. /**
  104463. * The physics-enabled object used as the physics imposter
  104464. */
  104465. object: IPhysicsEnabledObject;
  104466. /**
  104467. * The type of the physics imposter
  104468. */
  104469. type: number;
  104470. private _options;
  104471. private _scene?;
  104472. /**
  104473. * The default object size of the imposter
  104474. */
  104475. static DEFAULT_OBJECT_SIZE: Vector3;
  104476. /**
  104477. * The identity quaternion of the imposter
  104478. */
  104479. static IDENTITY_QUATERNION: Quaternion;
  104480. /** @hidden */
  104481. _pluginData: any;
  104482. private _physicsEngine;
  104483. private _physicsBody;
  104484. private _bodyUpdateRequired;
  104485. private _onBeforePhysicsStepCallbacks;
  104486. private _onAfterPhysicsStepCallbacks;
  104487. /** @hidden */
  104488. _onPhysicsCollideCallbacks: Array<{
  104489. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104490. otherImpostors: Array<PhysicsImpostor>;
  104491. }>;
  104492. private _deltaPosition;
  104493. private _deltaRotation;
  104494. private _deltaRotationConjugated;
  104495. /** @hidden */
  104496. _isFromLine: boolean;
  104497. private _parent;
  104498. private _isDisposed;
  104499. private static _tmpVecs;
  104500. private static _tmpQuat;
  104501. /**
  104502. * Specifies if the physics imposter is disposed
  104503. */
  104504. get isDisposed(): boolean;
  104505. /**
  104506. * Gets the mass of the physics imposter
  104507. */
  104508. get mass(): number;
  104509. set mass(value: number);
  104510. /**
  104511. * Gets the coefficient of friction
  104512. */
  104513. get friction(): number;
  104514. /**
  104515. * Sets the coefficient of friction
  104516. */
  104517. set friction(value: number);
  104518. /**
  104519. * Gets the coefficient of restitution
  104520. */
  104521. get restitution(): number;
  104522. /**
  104523. * Sets the coefficient of restitution
  104524. */
  104525. set restitution(value: number);
  104526. /**
  104527. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104528. */
  104529. get pressure(): number;
  104530. /**
  104531. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104532. */
  104533. set pressure(value: number);
  104534. /**
  104535. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104536. */
  104537. get stiffness(): number;
  104538. /**
  104539. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104540. */
  104541. set stiffness(value: number);
  104542. /**
  104543. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104544. */
  104545. get velocityIterations(): number;
  104546. /**
  104547. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104548. */
  104549. set velocityIterations(value: number);
  104550. /**
  104551. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104552. */
  104553. get positionIterations(): number;
  104554. /**
  104555. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104556. */
  104557. set positionIterations(value: number);
  104558. /**
  104559. * The unique id of the physics imposter
  104560. * set by the physics engine when adding this impostor to the array
  104561. */
  104562. uniqueId: number;
  104563. /**
  104564. * @hidden
  104565. */
  104566. soft: boolean;
  104567. /**
  104568. * @hidden
  104569. */
  104570. segments: number;
  104571. private _joints;
  104572. /**
  104573. * Initializes the physics imposter
  104574. * @param object The physics-enabled object used as the physics imposter
  104575. * @param type The type of the physics imposter
  104576. * @param _options The options for the physics imposter
  104577. * @param _scene The Babylon scene
  104578. */
  104579. constructor(
  104580. /**
  104581. * The physics-enabled object used as the physics imposter
  104582. */
  104583. object: IPhysicsEnabledObject,
  104584. /**
  104585. * The type of the physics imposter
  104586. */
  104587. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  104588. /**
  104589. * This function will completly initialize this impostor.
  104590. * It will create a new body - but only if this mesh has no parent.
  104591. * If it has, this impostor will not be used other than to define the impostor
  104592. * of the child mesh.
  104593. * @hidden
  104594. */
  104595. _init(): void;
  104596. private _getPhysicsParent;
  104597. /**
  104598. * Should a new body be generated.
  104599. * @returns boolean specifying if body initialization is required
  104600. */
  104601. isBodyInitRequired(): boolean;
  104602. /**
  104603. * Sets the updated scaling
  104604. * @param updated Specifies if the scaling is updated
  104605. */
  104606. setScalingUpdated(): void;
  104607. /**
  104608. * Force a regeneration of this or the parent's impostor's body.
  104609. * Use under cautious - This will remove all joints already implemented.
  104610. */
  104611. forceUpdate(): void;
  104612. /**
  104613. * Gets the body that holds this impostor. Either its own, or its parent.
  104614. */
  104615. get physicsBody(): any;
  104616. /**
  104617. * Get the parent of the physics imposter
  104618. * @returns Physics imposter or null
  104619. */
  104620. get parent(): Nullable<PhysicsImpostor>;
  104621. /**
  104622. * Sets the parent of the physics imposter
  104623. */
  104624. set parent(value: Nullable<PhysicsImpostor>);
  104625. /**
  104626. * Set the physics body. Used mainly by the physics engine/plugin
  104627. */
  104628. set physicsBody(physicsBody: any);
  104629. /**
  104630. * Resets the update flags
  104631. */
  104632. resetUpdateFlags(): void;
  104633. /**
  104634. * Gets the object extend size
  104635. * @returns the object extend size
  104636. */
  104637. getObjectExtendSize(): Vector3;
  104638. /**
  104639. * Gets the object center
  104640. * @returns The object center
  104641. */
  104642. getObjectCenter(): Vector3;
  104643. /**
  104644. * Get a specific parameter from the options parameters
  104645. * @param paramName The object parameter name
  104646. * @returns The object parameter
  104647. */
  104648. getParam(paramName: string): any;
  104649. /**
  104650. * Sets a specific parameter in the options given to the physics plugin
  104651. * @param paramName The parameter name
  104652. * @param value The value of the parameter
  104653. */
  104654. setParam(paramName: string, value: number): void;
  104655. /**
  104656. * Specifically change the body's mass option. Won't recreate the physics body object
  104657. * @param mass The mass of the physics imposter
  104658. */
  104659. setMass(mass: number): void;
  104660. /**
  104661. * Gets the linear velocity
  104662. * @returns linear velocity or null
  104663. */
  104664. getLinearVelocity(): Nullable<Vector3>;
  104665. /**
  104666. * Sets the linear velocity
  104667. * @param velocity linear velocity or null
  104668. */
  104669. setLinearVelocity(velocity: Nullable<Vector3>): void;
  104670. /**
  104671. * Gets the angular velocity
  104672. * @returns angular velocity or null
  104673. */
  104674. getAngularVelocity(): Nullable<Vector3>;
  104675. /**
  104676. * Sets the angular velocity
  104677. * @param velocity The velocity or null
  104678. */
  104679. setAngularVelocity(velocity: Nullable<Vector3>): void;
  104680. /**
  104681. * Execute a function with the physics plugin native code
  104682. * Provide a function the will have two variables - the world object and the physics body object
  104683. * @param func The function to execute with the physics plugin native code
  104684. */
  104685. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  104686. /**
  104687. * Register a function that will be executed before the physics world is stepping forward
  104688. * @param func The function to execute before the physics world is stepped forward
  104689. */
  104690. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104691. /**
  104692. * Unregister a function that will be executed before the physics world is stepping forward
  104693. * @param func The function to execute before the physics world is stepped forward
  104694. */
  104695. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104696. /**
  104697. * Register a function that will be executed after the physics step
  104698. * @param func The function to execute after physics step
  104699. */
  104700. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104701. /**
  104702. * Unregisters a function that will be executed after the physics step
  104703. * @param func The function to execute after physics step
  104704. */
  104705. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104706. /**
  104707. * register a function that will be executed when this impostor collides against a different body
  104708. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  104709. * @param func Callback that is executed on collision
  104710. */
  104711. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  104712. /**
  104713. * Unregisters the physics imposter on contact
  104714. * @param collideAgainst The physics object to collide against
  104715. * @param func Callback to execute on collision
  104716. */
  104717. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  104718. private _tmpQuat;
  104719. private _tmpQuat2;
  104720. /**
  104721. * Get the parent rotation
  104722. * @returns The parent rotation
  104723. */
  104724. getParentsRotation(): Quaternion;
  104725. /**
  104726. * this function is executed by the physics engine.
  104727. */
  104728. beforeStep: () => void;
  104729. /**
  104730. * this function is executed by the physics engine
  104731. */
  104732. afterStep: () => void;
  104733. /**
  104734. * Legacy collision detection event support
  104735. */
  104736. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  104737. /**
  104738. * event and body object due to cannon's event-based architecture.
  104739. */
  104740. onCollide: (e: {
  104741. body: any;
  104742. }) => void;
  104743. /**
  104744. * Apply a force
  104745. * @param force The force to apply
  104746. * @param contactPoint The contact point for the force
  104747. * @returns The physics imposter
  104748. */
  104749. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104750. /**
  104751. * Apply an impulse
  104752. * @param force The impulse force
  104753. * @param contactPoint The contact point for the impulse force
  104754. * @returns The physics imposter
  104755. */
  104756. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104757. /**
  104758. * A help function to create a joint
  104759. * @param otherImpostor A physics imposter used to create a joint
  104760. * @param jointType The type of joint
  104761. * @param jointData The data for the joint
  104762. * @returns The physics imposter
  104763. */
  104764. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  104765. /**
  104766. * Add a joint to this impostor with a different impostor
  104767. * @param otherImpostor A physics imposter used to add a joint
  104768. * @param joint The joint to add
  104769. * @returns The physics imposter
  104770. */
  104771. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  104772. /**
  104773. * Add an anchor to a cloth impostor
  104774. * @param otherImpostor rigid impostor to anchor to
  104775. * @param width ratio across width from 0 to 1
  104776. * @param height ratio up height from 0 to 1
  104777. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  104778. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  104779. * @returns impostor the soft imposter
  104780. */
  104781. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104782. /**
  104783. * Add a hook to a rope impostor
  104784. * @param otherImpostor rigid impostor to anchor to
  104785. * @param length ratio across rope from 0 to 1
  104786. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  104787. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  104788. * @returns impostor the rope imposter
  104789. */
  104790. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104791. /**
  104792. * Will keep this body still, in a sleep mode.
  104793. * @returns the physics imposter
  104794. */
  104795. sleep(): PhysicsImpostor;
  104796. /**
  104797. * Wake the body up.
  104798. * @returns The physics imposter
  104799. */
  104800. wakeUp(): PhysicsImpostor;
  104801. /**
  104802. * Clones the physics imposter
  104803. * @param newObject The physics imposter clones to this physics-enabled object
  104804. * @returns A nullable physics imposter
  104805. */
  104806. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104807. /**
  104808. * Disposes the physics imposter
  104809. */
  104810. dispose(): void;
  104811. /**
  104812. * Sets the delta position
  104813. * @param position The delta position amount
  104814. */
  104815. setDeltaPosition(position: Vector3): void;
  104816. /**
  104817. * Sets the delta rotation
  104818. * @param rotation The delta rotation amount
  104819. */
  104820. setDeltaRotation(rotation: Quaternion): void;
  104821. /**
  104822. * Gets the box size of the physics imposter and stores the result in the input parameter
  104823. * @param result Stores the box size
  104824. * @returns The physics imposter
  104825. */
  104826. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  104827. /**
  104828. * Gets the radius of the physics imposter
  104829. * @returns Radius of the physics imposter
  104830. */
  104831. getRadius(): number;
  104832. /**
  104833. * Sync a bone with this impostor
  104834. * @param bone The bone to sync to the impostor.
  104835. * @param boneMesh The mesh that the bone is influencing.
  104836. * @param jointPivot The pivot of the joint / bone in local space.
  104837. * @param distToJoint Optional distance from the impostor to the joint.
  104838. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104839. */
  104840. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  104841. /**
  104842. * Sync impostor to a bone
  104843. * @param bone The bone that the impostor will be synced to.
  104844. * @param boneMesh The mesh that the bone is influencing.
  104845. * @param jointPivot The pivot of the joint / bone in local space.
  104846. * @param distToJoint Optional distance from the impostor to the joint.
  104847. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104848. * @param boneAxis Optional vector3 axis the bone is aligned with
  104849. */
  104850. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  104851. /**
  104852. * No-Imposter type
  104853. */
  104854. static NoImpostor: number;
  104855. /**
  104856. * Sphere-Imposter type
  104857. */
  104858. static SphereImpostor: number;
  104859. /**
  104860. * Box-Imposter type
  104861. */
  104862. static BoxImpostor: number;
  104863. /**
  104864. * Plane-Imposter type
  104865. */
  104866. static PlaneImpostor: number;
  104867. /**
  104868. * Mesh-imposter type
  104869. */
  104870. static MeshImpostor: number;
  104871. /**
  104872. * Capsule-Impostor type (Ammo.js plugin only)
  104873. */
  104874. static CapsuleImpostor: number;
  104875. /**
  104876. * Cylinder-Imposter type
  104877. */
  104878. static CylinderImpostor: number;
  104879. /**
  104880. * Particle-Imposter type
  104881. */
  104882. static ParticleImpostor: number;
  104883. /**
  104884. * Heightmap-Imposter type
  104885. */
  104886. static HeightmapImpostor: number;
  104887. /**
  104888. * ConvexHull-Impostor type (Ammo.js plugin only)
  104889. */
  104890. static ConvexHullImpostor: number;
  104891. /**
  104892. * Custom-Imposter type (Ammo.js plugin only)
  104893. */
  104894. static CustomImpostor: number;
  104895. /**
  104896. * Rope-Imposter type
  104897. */
  104898. static RopeImpostor: number;
  104899. /**
  104900. * Cloth-Imposter type
  104901. */
  104902. static ClothImpostor: number;
  104903. /**
  104904. * Softbody-Imposter type
  104905. */
  104906. static SoftbodyImpostor: number;
  104907. }
  104908. }
  104909. declare module BABYLON {
  104910. /**
  104911. * @hidden
  104912. **/
  104913. export class _CreationDataStorage {
  104914. closePath?: boolean;
  104915. closeArray?: boolean;
  104916. idx: number[];
  104917. dashSize: number;
  104918. gapSize: number;
  104919. path3D: Path3D;
  104920. pathArray: Vector3[][];
  104921. arc: number;
  104922. radius: number;
  104923. cap: number;
  104924. tessellation: number;
  104925. }
  104926. /**
  104927. * @hidden
  104928. **/
  104929. class _InstanceDataStorage {
  104930. visibleInstances: any;
  104931. batchCache: _InstancesBatch;
  104932. instancesBufferSize: number;
  104933. instancesBuffer: Nullable<Buffer>;
  104934. instancesData: Float32Array;
  104935. overridenInstanceCount: number;
  104936. isFrozen: boolean;
  104937. previousBatch: Nullable<_InstancesBatch>;
  104938. hardwareInstancedRendering: boolean;
  104939. sideOrientation: number;
  104940. manualUpdate: boolean;
  104941. }
  104942. /**
  104943. * @hidden
  104944. **/
  104945. export class _InstancesBatch {
  104946. mustReturn: boolean;
  104947. visibleInstances: Nullable<InstancedMesh[]>[];
  104948. renderSelf: boolean[];
  104949. hardwareInstancedRendering: boolean[];
  104950. }
  104951. /**
  104952. * @hidden
  104953. **/
  104954. class _ThinInstanceDataStorage {
  104955. instancesCount: number;
  104956. matrixBuffer: Nullable<Buffer>;
  104957. matrixBufferSize: number;
  104958. matrixData: Nullable<Float32Array>;
  104959. boundingVectors: Array<Vector3>;
  104960. }
  104961. /**
  104962. * Class used to represent renderable models
  104963. */
  104964. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  104965. /**
  104966. * Mesh side orientation : usually the external or front surface
  104967. */
  104968. static readonly FRONTSIDE: number;
  104969. /**
  104970. * Mesh side orientation : usually the internal or back surface
  104971. */
  104972. static readonly BACKSIDE: number;
  104973. /**
  104974. * Mesh side orientation : both internal and external or front and back surfaces
  104975. */
  104976. static readonly DOUBLESIDE: number;
  104977. /**
  104978. * Mesh side orientation : by default, `FRONTSIDE`
  104979. */
  104980. static readonly DEFAULTSIDE: number;
  104981. /**
  104982. * Mesh cap setting : no cap
  104983. */
  104984. static readonly NO_CAP: number;
  104985. /**
  104986. * Mesh cap setting : one cap at the beginning of the mesh
  104987. */
  104988. static readonly CAP_START: number;
  104989. /**
  104990. * Mesh cap setting : one cap at the end of the mesh
  104991. */
  104992. static readonly CAP_END: number;
  104993. /**
  104994. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  104995. */
  104996. static readonly CAP_ALL: number;
  104997. /**
  104998. * Mesh pattern setting : no flip or rotate
  104999. */
  105000. static readonly NO_FLIP: number;
  105001. /**
  105002. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  105003. */
  105004. static readonly FLIP_TILE: number;
  105005. /**
  105006. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  105007. */
  105008. static readonly ROTATE_TILE: number;
  105009. /**
  105010. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  105011. */
  105012. static readonly FLIP_ROW: number;
  105013. /**
  105014. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  105015. */
  105016. static readonly ROTATE_ROW: number;
  105017. /**
  105018. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  105019. */
  105020. static readonly FLIP_N_ROTATE_TILE: number;
  105021. /**
  105022. * Mesh pattern setting : rotate pattern and rotate
  105023. */
  105024. static readonly FLIP_N_ROTATE_ROW: number;
  105025. /**
  105026. * Mesh tile positioning : part tiles same on left/right or top/bottom
  105027. */
  105028. static readonly CENTER: number;
  105029. /**
  105030. * Mesh tile positioning : part tiles on left
  105031. */
  105032. static readonly LEFT: number;
  105033. /**
  105034. * Mesh tile positioning : part tiles on right
  105035. */
  105036. static readonly RIGHT: number;
  105037. /**
  105038. * Mesh tile positioning : part tiles on top
  105039. */
  105040. static readonly TOP: number;
  105041. /**
  105042. * Mesh tile positioning : part tiles on bottom
  105043. */
  105044. static readonly BOTTOM: number;
  105045. /**
  105046. * Gets the default side orientation.
  105047. * @param orientation the orientation to value to attempt to get
  105048. * @returns the default orientation
  105049. * @hidden
  105050. */
  105051. static _GetDefaultSideOrientation(orientation?: number): number;
  105052. private _internalMeshDataInfo;
  105053. /**
  105054. * An event triggered before rendering the mesh
  105055. */
  105056. get onBeforeRenderObservable(): Observable<Mesh>;
  105057. /**
  105058. * An event triggered before binding the mesh
  105059. */
  105060. get onBeforeBindObservable(): Observable<Mesh>;
  105061. /**
  105062. * An event triggered after rendering the mesh
  105063. */
  105064. get onAfterRenderObservable(): Observable<Mesh>;
  105065. /**
  105066. * An event triggered before drawing the mesh
  105067. */
  105068. get onBeforeDrawObservable(): Observable<Mesh>;
  105069. private _onBeforeDrawObserver;
  105070. /**
  105071. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  105072. */
  105073. set onBeforeDraw(callback: () => void);
  105074. get hasInstances(): boolean;
  105075. get hasThinInstances(): boolean;
  105076. /**
  105077. * Gets the delay loading state of the mesh (when delay loading is turned on)
  105078. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  105079. */
  105080. delayLoadState: number;
  105081. /**
  105082. * Gets the list of instances created from this mesh
  105083. * it is not supposed to be modified manually.
  105084. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  105085. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105086. */
  105087. instances: InstancedMesh[];
  105088. /**
  105089. * Gets the file containing delay loading data for this mesh
  105090. */
  105091. delayLoadingFile: string;
  105092. /** @hidden */
  105093. _binaryInfo: any;
  105094. /**
  105095. * User defined function used to change how LOD level selection is done
  105096. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  105097. */
  105098. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  105099. /**
  105100. * Gets or sets the morph target manager
  105101. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105102. */
  105103. get morphTargetManager(): Nullable<MorphTargetManager>;
  105104. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105105. /** @hidden */
  105106. _creationDataStorage: Nullable<_CreationDataStorage>;
  105107. /** @hidden */
  105108. _geometry: Nullable<Geometry>;
  105109. /** @hidden */
  105110. _delayInfo: Array<string>;
  105111. /** @hidden */
  105112. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105113. /** @hidden */
  105114. _instanceDataStorage: _InstanceDataStorage;
  105115. /** @hidden */
  105116. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105117. private _effectiveMaterial;
  105118. /** @hidden */
  105119. _shouldGenerateFlatShading: boolean;
  105120. /** @hidden */
  105121. _originalBuilderSideOrientation: number;
  105122. /**
  105123. * Use this property to change the original side orientation defined at construction time
  105124. */
  105125. overrideMaterialSideOrientation: Nullable<number>;
  105126. /**
  105127. * Gets the source mesh (the one used to clone this one from)
  105128. */
  105129. get source(): Nullable<Mesh>;
  105130. /**
  105131. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105132. */
  105133. get isUnIndexed(): boolean;
  105134. set isUnIndexed(value: boolean);
  105135. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105136. get worldMatrixInstancedBuffer(): Float32Array;
  105137. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105138. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105139. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105140. /**
  105141. * @constructor
  105142. * @param name The value used by scene.getMeshByName() to do a lookup.
  105143. * @param scene The scene to add this mesh to.
  105144. * @param parent The parent of this mesh, if it has one
  105145. * @param source An optional Mesh from which geometry is shared, cloned.
  105146. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105147. * When false, achieved by calling a clone(), also passing False.
  105148. * This will make creation of children, recursive.
  105149. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105150. */
  105151. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105152. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105153. doNotInstantiate: boolean;
  105154. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105155. /**
  105156. * Gets the class name
  105157. * @returns the string "Mesh".
  105158. */
  105159. getClassName(): string;
  105160. /** @hidden */
  105161. get _isMesh(): boolean;
  105162. /**
  105163. * Returns a description of this mesh
  105164. * @param fullDetails define if full details about this mesh must be used
  105165. * @returns a descriptive string representing this mesh
  105166. */
  105167. toString(fullDetails?: boolean): string;
  105168. /** @hidden */
  105169. _unBindEffect(): void;
  105170. /**
  105171. * Gets a boolean indicating if this mesh has LOD
  105172. */
  105173. get hasLODLevels(): boolean;
  105174. /**
  105175. * Gets the list of MeshLODLevel associated with the current mesh
  105176. * @returns an array of MeshLODLevel
  105177. */
  105178. getLODLevels(): MeshLODLevel[];
  105179. private _sortLODLevels;
  105180. /**
  105181. * Add a mesh as LOD level triggered at the given distance.
  105182. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105183. * @param distance The distance from the center of the object to show this level
  105184. * @param mesh The mesh to be added as LOD level (can be null)
  105185. * @return This mesh (for chaining)
  105186. */
  105187. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105188. /**
  105189. * Returns the LOD level mesh at the passed distance or null if not found.
  105190. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105191. * @param distance The distance from the center of the object to show this level
  105192. * @returns a Mesh or `null`
  105193. */
  105194. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105195. /**
  105196. * Remove a mesh from the LOD array
  105197. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105198. * @param mesh defines the mesh to be removed
  105199. * @return This mesh (for chaining)
  105200. */
  105201. removeLODLevel(mesh: Mesh): Mesh;
  105202. /**
  105203. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105204. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105205. * @param camera defines the camera to use to compute distance
  105206. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105207. * @return This mesh (for chaining)
  105208. */
  105209. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105210. /**
  105211. * Gets the mesh internal Geometry object
  105212. */
  105213. get geometry(): Nullable<Geometry>;
  105214. /**
  105215. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105216. * @returns the total number of vertices
  105217. */
  105218. getTotalVertices(): number;
  105219. /**
  105220. * Returns the content of an associated vertex buffer
  105221. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105222. * - VertexBuffer.PositionKind
  105223. * - VertexBuffer.UVKind
  105224. * - VertexBuffer.UV2Kind
  105225. * - VertexBuffer.UV3Kind
  105226. * - VertexBuffer.UV4Kind
  105227. * - VertexBuffer.UV5Kind
  105228. * - VertexBuffer.UV6Kind
  105229. * - VertexBuffer.ColorKind
  105230. * - VertexBuffer.MatricesIndicesKind
  105231. * - VertexBuffer.MatricesIndicesExtraKind
  105232. * - VertexBuffer.MatricesWeightsKind
  105233. * - VertexBuffer.MatricesWeightsExtraKind
  105234. * @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
  105235. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105236. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105237. */
  105238. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105239. /**
  105240. * Returns the mesh VertexBuffer object from the requested `kind`
  105241. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105242. * - VertexBuffer.PositionKind
  105243. * - VertexBuffer.NormalKind
  105244. * - VertexBuffer.UVKind
  105245. * - VertexBuffer.UV2Kind
  105246. * - VertexBuffer.UV3Kind
  105247. * - VertexBuffer.UV4Kind
  105248. * - VertexBuffer.UV5Kind
  105249. * - VertexBuffer.UV6Kind
  105250. * - VertexBuffer.ColorKind
  105251. * - VertexBuffer.MatricesIndicesKind
  105252. * - VertexBuffer.MatricesIndicesExtraKind
  105253. * - VertexBuffer.MatricesWeightsKind
  105254. * - VertexBuffer.MatricesWeightsExtraKind
  105255. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105256. */
  105257. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105258. /**
  105259. * Tests if a specific vertex buffer is associated with this mesh
  105260. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105261. * - VertexBuffer.PositionKind
  105262. * - VertexBuffer.NormalKind
  105263. * - VertexBuffer.UVKind
  105264. * - VertexBuffer.UV2Kind
  105265. * - VertexBuffer.UV3Kind
  105266. * - VertexBuffer.UV4Kind
  105267. * - VertexBuffer.UV5Kind
  105268. * - VertexBuffer.UV6Kind
  105269. * - VertexBuffer.ColorKind
  105270. * - VertexBuffer.MatricesIndicesKind
  105271. * - VertexBuffer.MatricesIndicesExtraKind
  105272. * - VertexBuffer.MatricesWeightsKind
  105273. * - VertexBuffer.MatricesWeightsExtraKind
  105274. * @returns a boolean
  105275. */
  105276. isVerticesDataPresent(kind: string): boolean;
  105277. /**
  105278. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105279. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105280. * - VertexBuffer.PositionKind
  105281. * - VertexBuffer.UVKind
  105282. * - VertexBuffer.UV2Kind
  105283. * - VertexBuffer.UV3Kind
  105284. * - VertexBuffer.UV4Kind
  105285. * - VertexBuffer.UV5Kind
  105286. * - VertexBuffer.UV6Kind
  105287. * - VertexBuffer.ColorKind
  105288. * - VertexBuffer.MatricesIndicesKind
  105289. * - VertexBuffer.MatricesIndicesExtraKind
  105290. * - VertexBuffer.MatricesWeightsKind
  105291. * - VertexBuffer.MatricesWeightsExtraKind
  105292. * @returns a boolean
  105293. */
  105294. isVertexBufferUpdatable(kind: string): boolean;
  105295. /**
  105296. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105297. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105298. * - VertexBuffer.PositionKind
  105299. * - VertexBuffer.NormalKind
  105300. * - VertexBuffer.UVKind
  105301. * - VertexBuffer.UV2Kind
  105302. * - VertexBuffer.UV3Kind
  105303. * - VertexBuffer.UV4Kind
  105304. * - VertexBuffer.UV5Kind
  105305. * - VertexBuffer.UV6Kind
  105306. * - VertexBuffer.ColorKind
  105307. * - VertexBuffer.MatricesIndicesKind
  105308. * - VertexBuffer.MatricesIndicesExtraKind
  105309. * - VertexBuffer.MatricesWeightsKind
  105310. * - VertexBuffer.MatricesWeightsExtraKind
  105311. * @returns an array of strings
  105312. */
  105313. getVerticesDataKinds(): string[];
  105314. /**
  105315. * Returns a positive integer : the total number of indices in this mesh geometry.
  105316. * @returns the numner of indices or zero if the mesh has no geometry.
  105317. */
  105318. getTotalIndices(): number;
  105319. /**
  105320. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105321. * @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.
  105322. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105323. * @returns the indices array or an empty array if the mesh has no geometry
  105324. */
  105325. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105326. get isBlocked(): boolean;
  105327. /**
  105328. * Determine if the current mesh is ready to be rendered
  105329. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105330. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105331. * @returns true if all associated assets are ready (material, textures, shaders)
  105332. */
  105333. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105334. /**
  105335. * 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.
  105336. */
  105337. get areNormalsFrozen(): boolean;
  105338. /**
  105339. * 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.
  105340. * @returns the current mesh
  105341. */
  105342. freezeNormals(): Mesh;
  105343. /**
  105344. * 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
  105345. * @returns the current mesh
  105346. */
  105347. unfreezeNormals(): Mesh;
  105348. /**
  105349. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105350. */
  105351. set overridenInstanceCount(count: number);
  105352. /** @hidden */
  105353. _preActivate(): Mesh;
  105354. /** @hidden */
  105355. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105356. /** @hidden */
  105357. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105358. protected _afterComputeWorldMatrix(): void;
  105359. /** @hidden */
  105360. _postActivate(): void;
  105361. /**
  105362. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105363. * This means the mesh underlying bounding box and sphere are recomputed.
  105364. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105365. * @returns the current mesh
  105366. */
  105367. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  105368. /** @hidden */
  105369. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  105370. /**
  105371. * This function will subdivide the mesh into multiple submeshes
  105372. * @param count defines the expected number of submeshes
  105373. */
  105374. subdivide(count: number): void;
  105375. /**
  105376. * Copy a FloatArray into a specific associated vertex buffer
  105377. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105378. * - VertexBuffer.PositionKind
  105379. * - VertexBuffer.UVKind
  105380. * - VertexBuffer.UV2Kind
  105381. * - VertexBuffer.UV3Kind
  105382. * - VertexBuffer.UV4Kind
  105383. * - VertexBuffer.UV5Kind
  105384. * - VertexBuffer.UV6Kind
  105385. * - VertexBuffer.ColorKind
  105386. * - VertexBuffer.MatricesIndicesKind
  105387. * - VertexBuffer.MatricesIndicesExtraKind
  105388. * - VertexBuffer.MatricesWeightsKind
  105389. * - VertexBuffer.MatricesWeightsExtraKind
  105390. * @param data defines the data source
  105391. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105392. * @param stride defines the data stride size (can be null)
  105393. * @returns the current mesh
  105394. */
  105395. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  105396. /**
  105397. * Delete a vertex buffer associated with this mesh
  105398. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  105399. * - VertexBuffer.PositionKind
  105400. * - VertexBuffer.UVKind
  105401. * - VertexBuffer.UV2Kind
  105402. * - VertexBuffer.UV3Kind
  105403. * - VertexBuffer.UV4Kind
  105404. * - VertexBuffer.UV5Kind
  105405. * - VertexBuffer.UV6Kind
  105406. * - VertexBuffer.ColorKind
  105407. * - VertexBuffer.MatricesIndicesKind
  105408. * - VertexBuffer.MatricesIndicesExtraKind
  105409. * - VertexBuffer.MatricesWeightsKind
  105410. * - VertexBuffer.MatricesWeightsExtraKind
  105411. */
  105412. removeVerticesData(kind: string): void;
  105413. /**
  105414. * Flags an associated vertex buffer as updatable
  105415. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  105416. * - VertexBuffer.PositionKind
  105417. * - VertexBuffer.UVKind
  105418. * - VertexBuffer.UV2Kind
  105419. * - VertexBuffer.UV3Kind
  105420. * - VertexBuffer.UV4Kind
  105421. * - VertexBuffer.UV5Kind
  105422. * - VertexBuffer.UV6Kind
  105423. * - VertexBuffer.ColorKind
  105424. * - VertexBuffer.MatricesIndicesKind
  105425. * - VertexBuffer.MatricesIndicesExtraKind
  105426. * - VertexBuffer.MatricesWeightsKind
  105427. * - VertexBuffer.MatricesWeightsExtraKind
  105428. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105429. */
  105430. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  105431. /**
  105432. * Sets the mesh global Vertex Buffer
  105433. * @param buffer defines the buffer to use
  105434. * @returns the current mesh
  105435. */
  105436. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  105437. /**
  105438. * Update a specific associated vertex buffer
  105439. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105440. * - VertexBuffer.PositionKind
  105441. * - VertexBuffer.UVKind
  105442. * - VertexBuffer.UV2Kind
  105443. * - VertexBuffer.UV3Kind
  105444. * - VertexBuffer.UV4Kind
  105445. * - VertexBuffer.UV5Kind
  105446. * - VertexBuffer.UV6Kind
  105447. * - VertexBuffer.ColorKind
  105448. * - VertexBuffer.MatricesIndicesKind
  105449. * - VertexBuffer.MatricesIndicesExtraKind
  105450. * - VertexBuffer.MatricesWeightsKind
  105451. * - VertexBuffer.MatricesWeightsExtraKind
  105452. * @param data defines the data source
  105453. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105454. * @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)
  105455. * @returns the current mesh
  105456. */
  105457. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  105458. /**
  105459. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  105460. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  105461. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  105462. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  105463. * @returns the current mesh
  105464. */
  105465. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  105466. /**
  105467. * Creates a un-shared specific occurence of the geometry for the mesh.
  105468. * @returns the current mesh
  105469. */
  105470. makeGeometryUnique(): Mesh;
  105471. /**
  105472. * Set the index buffer of this mesh
  105473. * @param indices defines the source data
  105474. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  105475. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  105476. * @returns the current mesh
  105477. */
  105478. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  105479. /**
  105480. * Update the current index buffer
  105481. * @param indices defines the source data
  105482. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105483. * @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)
  105484. * @returns the current mesh
  105485. */
  105486. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105487. /**
  105488. * Invert the geometry to move from a right handed system to a left handed one.
  105489. * @returns the current mesh
  105490. */
  105491. toLeftHanded(): Mesh;
  105492. /** @hidden */
  105493. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105494. /** @hidden */
  105495. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105496. /**
  105497. * Registers for this mesh a javascript function called just before the rendering process
  105498. * @param func defines the function to call before rendering this mesh
  105499. * @returns the current mesh
  105500. */
  105501. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105502. /**
  105503. * Disposes a previously registered javascript function called before the rendering
  105504. * @param func defines the function to remove
  105505. * @returns the current mesh
  105506. */
  105507. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105508. /**
  105509. * Registers for this mesh a javascript function called just after the rendering is complete
  105510. * @param func defines the function to call after rendering this mesh
  105511. * @returns the current mesh
  105512. */
  105513. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105514. /**
  105515. * Disposes a previously registered javascript function called after the rendering.
  105516. * @param func defines the function to remove
  105517. * @returns the current mesh
  105518. */
  105519. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105520. /** @hidden */
  105521. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105522. /** @hidden */
  105523. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105524. /** @hidden */
  105525. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105526. /** @hidden */
  105527. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105528. /** @hidden */
  105529. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105530. /** @hidden */
  105531. _rebuild(): void;
  105532. /** @hidden */
  105533. _freeze(): void;
  105534. /** @hidden */
  105535. _unFreeze(): void;
  105536. /**
  105537. * 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
  105538. * @param subMesh defines the subMesh to render
  105539. * @param enableAlphaMode defines if alpha mode can be changed
  105540. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105541. * @returns the current mesh
  105542. */
  105543. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105544. private _onBeforeDraw;
  105545. /**
  105546. * Renormalize the mesh and patch it up if there are no weights
  105547. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105548. * However in the case of zero weights then we set just a single influence to 1.
  105549. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  105550. */
  105551. cleanMatrixWeights(): void;
  105552. private normalizeSkinFourWeights;
  105553. private normalizeSkinWeightsAndExtra;
  105554. /**
  105555. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  105556. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  105557. * the user know there was an issue with importing the mesh
  105558. * @returns a validation object with skinned, valid and report string
  105559. */
  105560. validateSkinning(): {
  105561. skinned: boolean;
  105562. valid: boolean;
  105563. report: string;
  105564. };
  105565. /** @hidden */
  105566. _checkDelayState(): Mesh;
  105567. private _queueLoad;
  105568. /**
  105569. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  105570. * A mesh is in the frustum if its bounding box intersects the frustum
  105571. * @param frustumPlanes defines the frustum to test
  105572. * @returns true if the mesh is in the frustum planes
  105573. */
  105574. isInFrustum(frustumPlanes: Plane[]): boolean;
  105575. /**
  105576. * Sets the mesh material by the material or multiMaterial `id` property
  105577. * @param id is a string identifying the material or the multiMaterial
  105578. * @returns the current mesh
  105579. */
  105580. setMaterialByID(id: string): Mesh;
  105581. /**
  105582. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  105583. * @returns an array of IAnimatable
  105584. */
  105585. getAnimatables(): IAnimatable[];
  105586. /**
  105587. * Modifies the mesh geometry according to the passed transformation matrix.
  105588. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  105589. * The mesh normals are modified using the same transformation.
  105590. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105591. * @param transform defines the transform matrix to use
  105592. * @see http://doc.babylonjs.com/resources/baking_transformations
  105593. * @returns the current mesh
  105594. */
  105595. bakeTransformIntoVertices(transform: Matrix): Mesh;
  105596. /**
  105597. * Modifies the mesh geometry according to its own current World Matrix.
  105598. * The mesh World Matrix is then reset.
  105599. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  105600. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105601. * @see http://doc.babylonjs.com/resources/baking_transformations
  105602. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  105603. * @returns the current mesh
  105604. */
  105605. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  105606. /** @hidden */
  105607. get _positions(): Nullable<Vector3[]>;
  105608. /** @hidden */
  105609. _resetPointsArrayCache(): Mesh;
  105610. /** @hidden */
  105611. _generatePointsArray(): boolean;
  105612. /**
  105613. * Returns a new Mesh object generated from the current mesh properties.
  105614. * This method must not get confused with createInstance()
  105615. * @param name is a string, the name given to the new mesh
  105616. * @param newParent can be any Node object (default `null`)
  105617. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  105618. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  105619. * @returns a new mesh
  105620. */
  105621. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  105622. /**
  105623. * Releases resources associated with this mesh.
  105624. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105625. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105626. */
  105627. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105628. /** @hidden */
  105629. _disposeInstanceSpecificData(): void;
  105630. /** @hidden */
  105631. _disposeThinInstanceSpecificData(): void;
  105632. /**
  105633. * Modifies the mesh geometry according to a displacement map.
  105634. * 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.
  105635. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105636. * @param url is a string, the URL from the image file is to be downloaded.
  105637. * @param minHeight is the lower limit of the displacement.
  105638. * @param maxHeight is the upper limit of the displacement.
  105639. * @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.
  105640. * @param uvOffset is an optional vector2 used to offset UV.
  105641. * @param uvScale is an optional vector2 used to scale UV.
  105642. * @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.
  105643. * @returns the Mesh.
  105644. */
  105645. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105646. /**
  105647. * Modifies the mesh geometry according to a displacementMap buffer.
  105648. * 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.
  105649. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105650. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  105651. * @param heightMapWidth is the width of the buffer image.
  105652. * @param heightMapHeight is the height of the buffer image.
  105653. * @param minHeight is the lower limit of the displacement.
  105654. * @param maxHeight is the upper limit of the displacement.
  105655. * @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.
  105656. * @param uvOffset is an optional vector2 used to offset UV.
  105657. * @param uvScale is an optional vector2 used to scale UV.
  105658. * @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.
  105659. * @returns the Mesh.
  105660. */
  105661. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105662. /**
  105663. * Modify the mesh to get a flat shading rendering.
  105664. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  105665. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  105666. * @returns current mesh
  105667. */
  105668. convertToFlatShadedMesh(): Mesh;
  105669. /**
  105670. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  105671. * In other words, more vertices, no more indices and a single bigger VBO.
  105672. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  105673. * @returns current mesh
  105674. */
  105675. convertToUnIndexedMesh(): Mesh;
  105676. /**
  105677. * Inverses facet orientations.
  105678. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105679. * @param flipNormals will also inverts the normals
  105680. * @returns current mesh
  105681. */
  105682. flipFaces(flipNormals?: boolean): Mesh;
  105683. /**
  105684. * Increase the number of facets and hence vertices in a mesh
  105685. * Vertex normals are interpolated from existing vertex normals
  105686. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105687. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  105688. */
  105689. increaseVertices(numberPerEdge: number): void;
  105690. /**
  105691. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  105692. * This will undo any application of covertToFlatShadedMesh
  105693. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105694. */
  105695. forceSharedVertices(): void;
  105696. /** @hidden */
  105697. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  105698. /** @hidden */
  105699. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  105700. /**
  105701. * Creates a new InstancedMesh object from the mesh model.
  105702. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105703. * @param name defines the name of the new instance
  105704. * @returns a new InstancedMesh
  105705. */
  105706. createInstance(name: string): InstancedMesh;
  105707. /**
  105708. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  105709. * After this call, all the mesh instances have the same submeshes than the current mesh.
  105710. * @returns the current mesh
  105711. */
  105712. synchronizeInstances(): Mesh;
  105713. /**
  105714. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  105715. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  105716. * This should be used together with the simplification to avoid disappearing triangles.
  105717. * @param successCallback an optional success callback to be called after the optimization finished.
  105718. * @returns the current mesh
  105719. */
  105720. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  105721. /**
  105722. * Serialize current mesh
  105723. * @param serializationObject defines the object which will receive the serialization data
  105724. */
  105725. serialize(serializationObject: any): void;
  105726. /** @hidden */
  105727. _syncGeometryWithMorphTargetManager(): void;
  105728. /** @hidden */
  105729. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  105730. /**
  105731. * Returns a new Mesh object parsed from the source provided.
  105732. * @param parsedMesh is the source
  105733. * @param scene defines the hosting scene
  105734. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  105735. * @returns a new Mesh
  105736. */
  105737. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  105738. /**
  105739. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  105740. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105741. * @param name defines the name of the mesh to create
  105742. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  105743. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  105744. * @param closePath creates a seam between the first and the last points of each path of the path array
  105745. * @param offset is taken in account only if the `pathArray` is containing a single path
  105746. * @param scene defines the hosting scene
  105747. * @param updatable defines if the mesh must be flagged as updatable
  105748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105749. * @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)
  105750. * @returns a new Mesh
  105751. */
  105752. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105753. /**
  105754. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  105755. * @param name defines the name of the mesh to create
  105756. * @param radius sets the radius size (float) of the polygon (default 0.5)
  105757. * @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
  105758. * @param scene defines the hosting scene
  105759. * @param updatable defines if the mesh must be flagged as updatable
  105760. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105761. * @returns a new Mesh
  105762. */
  105763. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105764. /**
  105765. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  105766. * @param name defines the name of the mesh to create
  105767. * @param size sets the size (float) of each box side (default 1)
  105768. * @param scene defines the hosting scene
  105769. * @param updatable defines if the mesh must be flagged as updatable
  105770. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105771. * @returns a new Mesh
  105772. */
  105773. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105774. /**
  105775. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  105776. * @param name defines the name of the mesh to create
  105777. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105778. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105779. * @param scene defines the hosting scene
  105780. * @param updatable defines if the mesh must be flagged as updatable
  105781. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105782. * @returns a new Mesh
  105783. */
  105784. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105785. /**
  105786. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  105787. * @param name defines the name of the mesh to create
  105788. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105789. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105790. * @param scene defines the hosting scene
  105791. * @returns a new Mesh
  105792. */
  105793. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  105794. /**
  105795. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  105796. * @param name defines the name of the mesh to create
  105797. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  105798. * @param diameterTop set the top cap diameter (floats, default 1)
  105799. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  105800. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  105801. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  105802. * @param scene defines the hosting scene
  105803. * @param updatable defines if the mesh must be flagged as updatable
  105804. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105805. * @returns a new Mesh
  105806. */
  105807. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  105808. /**
  105809. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  105810. * @param name defines the name of the mesh to create
  105811. * @param diameter sets the diameter size (float) of the torus (default 1)
  105812. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  105813. * @param tessellation sets the number of torus sides (postive integer, default 16)
  105814. * @param scene defines the hosting scene
  105815. * @param updatable defines if the mesh must be flagged as updatable
  105816. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105817. * @returns a new Mesh
  105818. */
  105819. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105820. /**
  105821. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  105822. * @param name defines the name of the mesh to create
  105823. * @param radius sets the global radius size (float) of the torus knot (default 2)
  105824. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  105825. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  105826. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  105827. * @param p the number of windings on X axis (positive integers, default 2)
  105828. * @param q the number of windings on Y axis (positive integers, default 3)
  105829. * @param scene defines the hosting scene
  105830. * @param updatable defines if the mesh must be flagged as updatable
  105831. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105832. * @returns a new Mesh
  105833. */
  105834. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105835. /**
  105836. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  105837. * @param name defines the name of the mesh to create
  105838. * @param points is an array successive Vector3
  105839. * @param scene defines the hosting scene
  105840. * @param updatable defines if the mesh must be flagged as updatable
  105841. * @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).
  105842. * @returns a new Mesh
  105843. */
  105844. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  105845. /**
  105846. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  105847. * @param name defines the name of the mesh to create
  105848. * @param points is an array successive Vector3
  105849. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  105850. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105851. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  105852. * @param scene defines the hosting scene
  105853. * @param updatable defines if the mesh must be flagged as updatable
  105854. * @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)
  105855. * @returns a new Mesh
  105856. */
  105857. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  105858. /**
  105859. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  105860. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  105861. * 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.
  105862. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105863. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105864. * Remember you can only change the shape positions, not their number when updating a polygon.
  105865. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105866. * @param name defines the name of the mesh to create
  105867. * @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
  105868. * @param scene defines the hosting scene
  105869. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105870. * @param updatable defines if the mesh must be flagged as updatable
  105871. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105872. * @param earcutInjection can be used to inject your own earcut reference
  105873. * @returns a new Mesh
  105874. */
  105875. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105876. /**
  105877. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  105878. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  105879. * @param name defines the name of the mesh to create
  105880. * @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
  105881. * @param depth defines the height of extrusion
  105882. * @param scene defines the hosting scene
  105883. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105884. * @param updatable defines if the mesh must be flagged as updatable
  105885. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105886. * @param earcutInjection can be used to inject your own earcut reference
  105887. * @returns a new Mesh
  105888. */
  105889. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105890. /**
  105891. * Creates an extruded shape mesh.
  105892. * 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
  105893. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105894. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105895. * @param name defines the name of the mesh to create
  105896. * @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
  105897. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105898. * @param scale is the value to scale the shape
  105899. * @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
  105900. * @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
  105901. * @param scene defines the hosting scene
  105902. * @param updatable defines if the mesh must be flagged as updatable
  105903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105904. * @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)
  105905. * @returns a new Mesh
  105906. */
  105907. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105908. /**
  105909. * Creates an custom extruded shape mesh.
  105910. * The custom extrusion is a parametric shape.
  105911. * It has no predefined shape. Its final shape will depend on the input parameters.
  105912. * Please consider using the same method from the MeshBuilder class instead
  105913. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105914. * @param name defines the name of the mesh to create
  105915. * @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
  105916. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105917. * @param scaleFunction is a custom Javascript function called on each path point
  105918. * @param rotationFunction is a custom Javascript function called on each path point
  105919. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105920. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  105921. * @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
  105922. * @param scene defines the hosting scene
  105923. * @param updatable defines if the mesh must be flagged as updatable
  105924. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105925. * @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)
  105926. * @returns a new Mesh
  105927. */
  105928. 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;
  105929. /**
  105930. * Creates lathe mesh.
  105931. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  105932. * Please consider using the same method from the MeshBuilder class instead
  105933. * @param name defines the name of the mesh to create
  105934. * @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
  105935. * @param radius is the radius value of the lathe
  105936. * @param tessellation is the side number of the lathe.
  105937. * @param scene defines the hosting scene
  105938. * @param updatable defines if the mesh must be flagged as updatable
  105939. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105940. * @returns a new Mesh
  105941. */
  105942. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105943. /**
  105944. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105945. * @param name defines the name of the mesh to create
  105946. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105947. * @param scene defines the hosting scene
  105948. * @param updatable defines if the mesh must be flagged as updatable
  105949. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105950. * @returns a new Mesh
  105951. */
  105952. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105953. /**
  105954. * Creates a ground mesh.
  105955. * Please consider using the same method from the MeshBuilder class instead
  105956. * @param name defines the name of the mesh to create
  105957. * @param width set the width of the ground
  105958. * @param height set the height of the ground
  105959. * @param subdivisions sets the number of subdivisions per side
  105960. * @param scene defines the hosting scene
  105961. * @param updatable defines if the mesh must be flagged as updatable
  105962. * @returns a new Mesh
  105963. */
  105964. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  105965. /**
  105966. * Creates a tiled ground mesh.
  105967. * Please consider using the same method from the MeshBuilder class instead
  105968. * @param name defines the name of the mesh to create
  105969. * @param xmin set the ground minimum X coordinate
  105970. * @param zmin set the ground minimum Y coordinate
  105971. * @param xmax set the ground maximum X coordinate
  105972. * @param zmax set the ground maximum Z coordinate
  105973. * @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
  105974. * @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
  105975. * @param scene defines the hosting scene
  105976. * @param updatable defines if the mesh must be flagged as updatable
  105977. * @returns a new Mesh
  105978. */
  105979. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  105980. w: number;
  105981. h: number;
  105982. }, precision: {
  105983. w: number;
  105984. h: number;
  105985. }, scene: Scene, updatable?: boolean): Mesh;
  105986. /**
  105987. * Creates a ground mesh from a height map.
  105988. * Please consider using the same method from the MeshBuilder class instead
  105989. * @see http://doc.babylonjs.com/babylon101/height_map
  105990. * @param name defines the name of the mesh to create
  105991. * @param url sets the URL of the height map image resource
  105992. * @param width set the ground width size
  105993. * @param height set the ground height size
  105994. * @param subdivisions sets the number of subdivision per side
  105995. * @param minHeight is the minimum altitude on the ground
  105996. * @param maxHeight is the maximum altitude on the ground
  105997. * @param scene defines the hosting scene
  105998. * @param updatable defines if the mesh must be flagged as updatable
  105999. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  106000. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106001. * @returns a new Mesh
  106002. */
  106003. 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;
  106004. /**
  106005. * Creates a tube mesh.
  106006. * The tube is a parametric shape.
  106007. * It has no predefined shape. Its final shape will depend on the input parameters.
  106008. * Please consider using the same method from the MeshBuilder class instead
  106009. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  106010. * @param name defines the name of the mesh to create
  106011. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  106012. * @param radius sets the tube radius size
  106013. * @param tessellation is the number of sides on the tubular surface
  106014. * @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
  106015. * @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
  106016. * @param scene defines the hosting scene
  106017. * @param updatable defines if the mesh must be flagged as updatable
  106018. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106019. * @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)
  106020. * @returns a new Mesh
  106021. */
  106022. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  106023. (i: number, distance: number): number;
  106024. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106025. /**
  106026. * Creates a polyhedron mesh.
  106027. * Please consider using the same method from the MeshBuilder class instead.
  106028. * * 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
  106029. * * The parameter `size` (positive float, default 1) sets the polygon size
  106030. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106031. * * 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`
  106032. * * 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
  106033. * * 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)`)
  106034. * * 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
  106035. * * 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
  106036. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106037. * * If you create a double-sided mesh, you can choose what parts of 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
  106038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106039. * @param name defines the name of the mesh to create
  106040. * @param options defines the options used to create the mesh
  106041. * @param scene defines the hosting scene
  106042. * @returns a new Mesh
  106043. */
  106044. static CreatePolyhedron(name: string, options: {
  106045. type?: number;
  106046. size?: number;
  106047. sizeX?: number;
  106048. sizeY?: number;
  106049. sizeZ?: number;
  106050. custom?: any;
  106051. faceUV?: Vector4[];
  106052. faceColors?: Color4[];
  106053. updatable?: boolean;
  106054. sideOrientation?: number;
  106055. }, scene: Scene): Mesh;
  106056. /**
  106057. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106058. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106059. * * 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`)
  106060. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106061. * * 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
  106062. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106063. * * If you create a double-sided mesh, you can choose what parts of 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
  106064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106065. * @param name defines the name of the mesh
  106066. * @param options defines the options used to create the mesh
  106067. * @param scene defines the hosting scene
  106068. * @returns a new Mesh
  106069. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106070. */
  106071. static CreateIcoSphere(name: string, options: {
  106072. radius?: number;
  106073. flat?: boolean;
  106074. subdivisions?: number;
  106075. sideOrientation?: number;
  106076. updatable?: boolean;
  106077. }, scene: Scene): Mesh;
  106078. /**
  106079. * Creates a decal mesh.
  106080. * Please consider using the same method from the MeshBuilder class instead.
  106081. * A decal is a mesh usually applied as a model onto the surface of another mesh
  106082. * @param name defines the name of the mesh
  106083. * @param sourceMesh defines the mesh receiving the decal
  106084. * @param position sets the position of the decal in world coordinates
  106085. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  106086. * @param size sets the decal scaling
  106087. * @param angle sets the angle to rotate the decal
  106088. * @returns a new Mesh
  106089. */
  106090. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  106091. /**
  106092. * Prepare internal position array for software CPU skinning
  106093. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  106094. */
  106095. setPositionsForCPUSkinning(): Float32Array;
  106096. /**
  106097. * Prepare internal normal array for software CPU skinning
  106098. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  106099. */
  106100. setNormalsForCPUSkinning(): Float32Array;
  106101. /**
  106102. * Updates the vertex buffer by applying transformation from the bones
  106103. * @param skeleton defines the skeleton to apply to current mesh
  106104. * @returns the current mesh
  106105. */
  106106. applySkeleton(skeleton: Skeleton): Mesh;
  106107. /**
  106108. * 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
  106109. * @param meshes defines the list of meshes to scan
  106110. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106111. */
  106112. static MinMax(meshes: AbstractMesh[]): {
  106113. min: Vector3;
  106114. max: Vector3;
  106115. };
  106116. /**
  106117. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106118. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106119. * @returns a vector3
  106120. */
  106121. static Center(meshesOrMinMaxVector: {
  106122. min: Vector3;
  106123. max: Vector3;
  106124. } | AbstractMesh[]): Vector3;
  106125. /**
  106126. * Merge the array of meshes into a single mesh for performance reasons.
  106127. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106128. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106129. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106130. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106131. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106132. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106133. * @returns a new mesh
  106134. */
  106135. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106136. /** @hidden */
  106137. addInstance(instance: InstancedMesh): void;
  106138. /** @hidden */
  106139. removeInstance(instance: InstancedMesh): void;
  106140. }
  106141. }
  106142. declare module BABYLON {
  106143. /**
  106144. * This is the base class of all the camera used in the application.
  106145. * @see http://doc.babylonjs.com/features/cameras
  106146. */
  106147. export class Camera extends Node {
  106148. /** @hidden */
  106149. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106150. /**
  106151. * This is the default projection mode used by the cameras.
  106152. * It helps recreating a feeling of perspective and better appreciate depth.
  106153. * This is the best way to simulate real life cameras.
  106154. */
  106155. static readonly PERSPECTIVE_CAMERA: number;
  106156. /**
  106157. * This helps creating camera with an orthographic mode.
  106158. * 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.
  106159. */
  106160. static readonly ORTHOGRAPHIC_CAMERA: number;
  106161. /**
  106162. * This is the default FOV mode for perspective cameras.
  106163. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106164. */
  106165. static readonly FOVMODE_VERTICAL_FIXED: number;
  106166. /**
  106167. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106168. */
  106169. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106170. /**
  106171. * This specifies ther is no need for a camera rig.
  106172. * Basically only one eye is rendered corresponding to the camera.
  106173. */
  106174. static readonly RIG_MODE_NONE: number;
  106175. /**
  106176. * Simulates a camera Rig with one blue eye and one red eye.
  106177. * This can be use with 3d blue and red glasses.
  106178. */
  106179. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106180. /**
  106181. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106182. */
  106183. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106184. /**
  106185. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106186. */
  106187. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106188. /**
  106189. * Defines that both eyes of the camera will be rendered over under each other.
  106190. */
  106191. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106192. /**
  106193. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106194. */
  106195. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106196. /**
  106197. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106198. */
  106199. static readonly RIG_MODE_VR: number;
  106200. /**
  106201. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106202. */
  106203. static readonly RIG_MODE_WEBVR: number;
  106204. /**
  106205. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106206. */
  106207. static readonly RIG_MODE_CUSTOM: number;
  106208. /**
  106209. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106210. */
  106211. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106212. /**
  106213. * Define the input manager associated with the camera.
  106214. */
  106215. inputs: CameraInputsManager<Camera>;
  106216. /** @hidden */
  106217. _position: Vector3;
  106218. /**
  106219. * Define the current local position of the camera in the scene
  106220. */
  106221. get position(): Vector3;
  106222. set position(newPosition: Vector3);
  106223. /**
  106224. * The vector the camera should consider as up.
  106225. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106226. */
  106227. upVector: Vector3;
  106228. /**
  106229. * Define the current limit on the left side for an orthographic camera
  106230. * In scene unit
  106231. */
  106232. orthoLeft: Nullable<number>;
  106233. /**
  106234. * Define the current limit on the right side for an orthographic camera
  106235. * In scene unit
  106236. */
  106237. orthoRight: Nullable<number>;
  106238. /**
  106239. * Define the current limit on the bottom side for an orthographic camera
  106240. * In scene unit
  106241. */
  106242. orthoBottom: Nullable<number>;
  106243. /**
  106244. * Define the current limit on the top side for an orthographic camera
  106245. * In scene unit
  106246. */
  106247. orthoTop: Nullable<number>;
  106248. /**
  106249. * Field Of View is set in Radians. (default is 0.8)
  106250. */
  106251. fov: number;
  106252. /**
  106253. * Define the minimum distance the camera can see from.
  106254. * This is important to note that the depth buffer are not infinite and the closer it starts
  106255. * the more your scene might encounter depth fighting issue.
  106256. */
  106257. minZ: number;
  106258. /**
  106259. * Define the maximum distance the camera can see to.
  106260. * This is important to note that the depth buffer are not infinite and the further it end
  106261. * the more your scene might encounter depth fighting issue.
  106262. */
  106263. maxZ: number;
  106264. /**
  106265. * Define the default inertia of the camera.
  106266. * This helps giving a smooth feeling to the camera movement.
  106267. */
  106268. inertia: number;
  106269. /**
  106270. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106271. */
  106272. mode: number;
  106273. /**
  106274. * Define whether the camera is intermediate.
  106275. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106276. */
  106277. isIntermediate: boolean;
  106278. /**
  106279. * Define the viewport of the camera.
  106280. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106281. */
  106282. viewport: Viewport;
  106283. /**
  106284. * Restricts the camera to viewing objects with the same layerMask.
  106285. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106286. */
  106287. layerMask: number;
  106288. /**
  106289. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106290. */
  106291. fovMode: number;
  106292. /**
  106293. * Rig mode of the camera.
  106294. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106295. * This is normally controlled byt the camera themselves as internal use.
  106296. */
  106297. cameraRigMode: number;
  106298. /**
  106299. * Defines the distance between both "eyes" in case of a RIG
  106300. */
  106301. interaxialDistance: number;
  106302. /**
  106303. * Defines if stereoscopic rendering is done side by side or over under.
  106304. */
  106305. isStereoscopicSideBySide: boolean;
  106306. /**
  106307. * 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
  106308. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106309. * else in the scene. (Eg. security camera)
  106310. *
  106311. * 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)
  106312. */
  106313. customRenderTargets: RenderTargetTexture[];
  106314. /**
  106315. * When set, the camera will render to this render target instead of the default canvas
  106316. *
  106317. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106318. */
  106319. outputRenderTarget: Nullable<RenderTargetTexture>;
  106320. /**
  106321. * Observable triggered when the camera view matrix has changed.
  106322. */
  106323. onViewMatrixChangedObservable: Observable<Camera>;
  106324. /**
  106325. * Observable triggered when the camera Projection matrix has changed.
  106326. */
  106327. onProjectionMatrixChangedObservable: Observable<Camera>;
  106328. /**
  106329. * Observable triggered when the inputs have been processed.
  106330. */
  106331. onAfterCheckInputsObservable: Observable<Camera>;
  106332. /**
  106333. * Observable triggered when reset has been called and applied to the camera.
  106334. */
  106335. onRestoreStateObservable: Observable<Camera>;
  106336. /**
  106337. * Is this camera a part of a rig system?
  106338. */
  106339. isRigCamera: boolean;
  106340. /**
  106341. * If isRigCamera set to true this will be set with the parent camera.
  106342. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106343. */
  106344. rigParent?: Camera;
  106345. /** @hidden */
  106346. _cameraRigParams: any;
  106347. /** @hidden */
  106348. _rigCameras: Camera[];
  106349. /** @hidden */
  106350. _rigPostProcess: Nullable<PostProcess>;
  106351. protected _webvrViewMatrix: Matrix;
  106352. /** @hidden */
  106353. _skipRendering: boolean;
  106354. /** @hidden */
  106355. _projectionMatrix: Matrix;
  106356. /** @hidden */
  106357. _postProcesses: Nullable<PostProcess>[];
  106358. /** @hidden */
  106359. _activeMeshes: SmartArray<AbstractMesh>;
  106360. protected _globalPosition: Vector3;
  106361. /** @hidden */
  106362. _computedViewMatrix: Matrix;
  106363. private _doNotComputeProjectionMatrix;
  106364. private _transformMatrix;
  106365. private _frustumPlanes;
  106366. private _refreshFrustumPlanes;
  106367. private _storedFov;
  106368. private _stateStored;
  106369. /**
  106370. * Instantiates a new camera object.
  106371. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  106372. * @see http://doc.babylonjs.com/features/cameras
  106373. * @param name Defines the name of the camera in the scene
  106374. * @param position Defines the position of the camera
  106375. * @param scene Defines the scene the camera belongs too
  106376. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  106377. */
  106378. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106379. /**
  106380. * Store current camera state (fov, position, etc..)
  106381. * @returns the camera
  106382. */
  106383. storeState(): Camera;
  106384. /**
  106385. * Restores the camera state values if it has been stored. You must call storeState() first
  106386. */
  106387. protected _restoreStateValues(): boolean;
  106388. /**
  106389. * Restored camera state. You must call storeState() first.
  106390. * @returns true if restored and false otherwise
  106391. */
  106392. restoreState(): boolean;
  106393. /**
  106394. * Gets the class name of the camera.
  106395. * @returns the class name
  106396. */
  106397. getClassName(): string;
  106398. /** @hidden */
  106399. readonly _isCamera: boolean;
  106400. /**
  106401. * Gets a string representation of the camera useful for debug purpose.
  106402. * @param fullDetails Defines that a more verboe level of logging is required
  106403. * @returns the string representation
  106404. */
  106405. toString(fullDetails?: boolean): string;
  106406. /**
  106407. * Gets the current world space position of the camera.
  106408. */
  106409. get globalPosition(): Vector3;
  106410. /**
  106411. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  106412. * @returns the active meshe list
  106413. */
  106414. getActiveMeshes(): SmartArray<AbstractMesh>;
  106415. /**
  106416. * Check whether a mesh is part of the current active mesh list of the camera
  106417. * @param mesh Defines the mesh to check
  106418. * @returns true if active, false otherwise
  106419. */
  106420. isActiveMesh(mesh: Mesh): boolean;
  106421. /**
  106422. * Is this camera ready to be used/rendered
  106423. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  106424. * @return true if the camera is ready
  106425. */
  106426. isReady(completeCheck?: boolean): boolean;
  106427. /** @hidden */
  106428. _initCache(): void;
  106429. /** @hidden */
  106430. _updateCache(ignoreParentClass?: boolean): void;
  106431. /** @hidden */
  106432. _isSynchronized(): boolean;
  106433. /** @hidden */
  106434. _isSynchronizedViewMatrix(): boolean;
  106435. /** @hidden */
  106436. _isSynchronizedProjectionMatrix(): boolean;
  106437. /**
  106438. * Attach the input controls to a specific dom element to get the input from.
  106439. * @param element Defines the element the controls should be listened from
  106440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106441. */
  106442. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106443. /**
  106444. * Detach the current controls from the specified dom element.
  106445. * @param element Defines the element to stop listening the inputs from
  106446. */
  106447. detachControl(element: HTMLElement): void;
  106448. /**
  106449. * Update the camera state according to the different inputs gathered during the frame.
  106450. */
  106451. update(): void;
  106452. /** @hidden */
  106453. _checkInputs(): void;
  106454. /** @hidden */
  106455. get rigCameras(): Camera[];
  106456. /**
  106457. * Gets the post process used by the rig cameras
  106458. */
  106459. get rigPostProcess(): Nullable<PostProcess>;
  106460. /**
  106461. * Internal, gets the first post proces.
  106462. * @returns the first post process to be run on this camera.
  106463. */
  106464. _getFirstPostProcess(): Nullable<PostProcess>;
  106465. private _cascadePostProcessesToRigCams;
  106466. /**
  106467. * Attach a post process to the camera.
  106468. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106469. * @param postProcess The post process to attach to the camera
  106470. * @param insertAt The position of the post process in case several of them are in use in the scene
  106471. * @returns the position the post process has been inserted at
  106472. */
  106473. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  106474. /**
  106475. * Detach a post process to the camera.
  106476. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106477. * @param postProcess The post process to detach from the camera
  106478. */
  106479. detachPostProcess(postProcess: PostProcess): void;
  106480. /**
  106481. * Gets the current world matrix of the camera
  106482. */
  106483. getWorldMatrix(): Matrix;
  106484. /** @hidden */
  106485. _getViewMatrix(): Matrix;
  106486. /**
  106487. * Gets the current view matrix of the camera.
  106488. * @param force forces the camera to recompute the matrix without looking at the cached state
  106489. * @returns the view matrix
  106490. */
  106491. getViewMatrix(force?: boolean): Matrix;
  106492. /**
  106493. * Freeze the projection matrix.
  106494. * It will prevent the cache check of the camera projection compute and can speed up perf
  106495. * if no parameter of the camera are meant to change
  106496. * @param projection Defines manually a projection if necessary
  106497. */
  106498. freezeProjectionMatrix(projection?: Matrix): void;
  106499. /**
  106500. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106501. */
  106502. unfreezeProjectionMatrix(): void;
  106503. /**
  106504. * Gets the current projection matrix of the camera.
  106505. * @param force forces the camera to recompute the matrix without looking at the cached state
  106506. * @returns the projection matrix
  106507. */
  106508. getProjectionMatrix(force?: boolean): Matrix;
  106509. /**
  106510. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106511. * @returns a Matrix
  106512. */
  106513. getTransformationMatrix(): Matrix;
  106514. private _updateFrustumPlanes;
  106515. /**
  106516. * Checks if a cullable object (mesh...) is in the camera frustum
  106517. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106518. * @param target The object to check
  106519. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106520. * @returns true if the object is in frustum otherwise false
  106521. */
  106522. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106523. /**
  106524. * Checks if a cullable object (mesh...) is in the camera frustum
  106525. * Unlike isInFrustum this cheks the full bounding box
  106526. * @param target The object to check
  106527. * @returns true if the object is in frustum otherwise false
  106528. */
  106529. isCompletelyInFrustum(target: ICullable): boolean;
  106530. /**
  106531. * Gets a ray in the forward direction from the camera.
  106532. * @param length Defines the length of the ray to create
  106533. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106534. * @param origin Defines the start point of the ray which defaults to the camera position
  106535. * @returns the forward ray
  106536. */
  106537. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106538. /**
  106539. * Releases resources associated with this node.
  106540. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106541. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106542. */
  106543. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106544. /** @hidden */
  106545. _isLeftCamera: boolean;
  106546. /**
  106547. * Gets the left camera of a rig setup in case of Rigged Camera
  106548. */
  106549. get isLeftCamera(): boolean;
  106550. /** @hidden */
  106551. _isRightCamera: boolean;
  106552. /**
  106553. * Gets the right camera of a rig setup in case of Rigged Camera
  106554. */
  106555. get isRightCamera(): boolean;
  106556. /**
  106557. * Gets the left camera of a rig setup in case of Rigged Camera
  106558. */
  106559. get leftCamera(): Nullable<FreeCamera>;
  106560. /**
  106561. * Gets the right camera of a rig setup in case of Rigged Camera
  106562. */
  106563. get rightCamera(): Nullable<FreeCamera>;
  106564. /**
  106565. * Gets the left camera target of a rig setup in case of Rigged Camera
  106566. * @returns the target position
  106567. */
  106568. getLeftTarget(): Nullable<Vector3>;
  106569. /**
  106570. * Gets the right camera target of a rig setup in case of Rigged Camera
  106571. * @returns the target position
  106572. */
  106573. getRightTarget(): Nullable<Vector3>;
  106574. /**
  106575. * @hidden
  106576. */
  106577. setCameraRigMode(mode: number, rigParams: any): void;
  106578. /** @hidden */
  106579. static _setStereoscopicRigMode(camera: Camera): void;
  106580. /** @hidden */
  106581. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  106582. /** @hidden */
  106583. static _setVRRigMode(camera: Camera, rigParams: any): void;
  106584. /** @hidden */
  106585. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  106586. /** @hidden */
  106587. _getVRProjectionMatrix(): Matrix;
  106588. protected _updateCameraRotationMatrix(): void;
  106589. protected _updateWebVRCameraRotationMatrix(): void;
  106590. /**
  106591. * This function MUST be overwritten by the different WebVR cameras available.
  106592. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106593. * @hidden
  106594. */
  106595. _getWebVRProjectionMatrix(): Matrix;
  106596. /**
  106597. * This function MUST be overwritten by the different WebVR cameras available.
  106598. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106599. * @hidden
  106600. */
  106601. _getWebVRViewMatrix(): Matrix;
  106602. /** @hidden */
  106603. setCameraRigParameter(name: string, value: any): void;
  106604. /**
  106605. * needs to be overridden by children so sub has required properties to be copied
  106606. * @hidden
  106607. */
  106608. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  106609. /**
  106610. * May need to be overridden by children
  106611. * @hidden
  106612. */
  106613. _updateRigCameras(): void;
  106614. /** @hidden */
  106615. _setupInputs(): void;
  106616. /**
  106617. * Serialiaze the camera setup to a json represention
  106618. * @returns the JSON representation
  106619. */
  106620. serialize(): any;
  106621. /**
  106622. * Clones the current camera.
  106623. * @param name The cloned camera name
  106624. * @returns the cloned camera
  106625. */
  106626. clone(name: string): Camera;
  106627. /**
  106628. * Gets the direction of the camera relative to a given local axis.
  106629. * @param localAxis Defines the reference axis to provide a relative direction.
  106630. * @return the direction
  106631. */
  106632. getDirection(localAxis: Vector3): Vector3;
  106633. /**
  106634. * Returns the current camera absolute rotation
  106635. */
  106636. get absoluteRotation(): Quaternion;
  106637. /**
  106638. * Gets the direction of the camera relative to a given local axis into a passed vector.
  106639. * @param localAxis Defines the reference axis to provide a relative direction.
  106640. * @param result Defines the vector to store the result in
  106641. */
  106642. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  106643. /**
  106644. * Gets a camera constructor for a given camera type
  106645. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  106646. * @param name The name of the camera the result will be able to instantiate
  106647. * @param scene The scene the result will construct the camera in
  106648. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  106649. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  106650. * @returns a factory method to construc the camera
  106651. */
  106652. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  106653. /**
  106654. * Compute the world matrix of the camera.
  106655. * @returns the camera world matrix
  106656. */
  106657. computeWorldMatrix(): Matrix;
  106658. /**
  106659. * Parse a JSON and creates the camera from the parsed information
  106660. * @param parsedCamera The JSON to parse
  106661. * @param scene The scene to instantiate the camera in
  106662. * @returns the newly constructed camera
  106663. */
  106664. static Parse(parsedCamera: any, scene: Scene): Camera;
  106665. }
  106666. }
  106667. declare module BABYLON {
  106668. /**
  106669. * Class containing static functions to help procedurally build meshes
  106670. */
  106671. export class DiscBuilder {
  106672. /**
  106673. * Creates a plane polygonal mesh. By default, this is a disc
  106674. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106675. * * 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
  106676. * * 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
  106677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106680. * @param name defines the name of the mesh
  106681. * @param options defines the options used to create the mesh
  106682. * @param scene defines the hosting scene
  106683. * @returns the plane polygonal mesh
  106684. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106685. */
  106686. static CreateDisc(name: string, options: {
  106687. radius?: number;
  106688. tessellation?: number;
  106689. arc?: number;
  106690. updatable?: boolean;
  106691. sideOrientation?: number;
  106692. frontUVs?: Vector4;
  106693. backUVs?: Vector4;
  106694. }, scene?: Nullable<Scene>): Mesh;
  106695. }
  106696. }
  106697. declare module BABYLON {
  106698. /**
  106699. * Options to be used when creating a FresnelParameters.
  106700. */
  106701. export type IFresnelParametersCreationOptions = {
  106702. /**
  106703. * Define the color used on edges (grazing angle)
  106704. */
  106705. leftColor?: Color3;
  106706. /**
  106707. * Define the color used on center
  106708. */
  106709. rightColor?: Color3;
  106710. /**
  106711. * Define bias applied to computed fresnel term
  106712. */
  106713. bias?: number;
  106714. /**
  106715. * Defined the power exponent applied to fresnel term
  106716. */
  106717. power?: number;
  106718. /**
  106719. * Define if the fresnel effect is enable or not.
  106720. */
  106721. isEnabled?: boolean;
  106722. };
  106723. /**
  106724. * Serialized format for FresnelParameters.
  106725. */
  106726. export type IFresnelParametersSerialized = {
  106727. /**
  106728. * Define the color used on edges (grazing angle) [as an array]
  106729. */
  106730. leftColor: number[];
  106731. /**
  106732. * Define the color used on center [as an array]
  106733. */
  106734. rightColor: number[];
  106735. /**
  106736. * Define bias applied to computed fresnel term
  106737. */
  106738. bias: number;
  106739. /**
  106740. * Defined the power exponent applied to fresnel term
  106741. */
  106742. power?: number;
  106743. /**
  106744. * Define if the fresnel effect is enable or not.
  106745. */
  106746. isEnabled: boolean;
  106747. };
  106748. /**
  106749. * This represents all the required information to add a fresnel effect on a material:
  106750. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106751. */
  106752. export class FresnelParameters {
  106753. private _isEnabled;
  106754. /**
  106755. * Define if the fresnel effect is enable or not.
  106756. */
  106757. get isEnabled(): boolean;
  106758. set isEnabled(value: boolean);
  106759. /**
  106760. * Define the color used on edges (grazing angle)
  106761. */
  106762. leftColor: Color3;
  106763. /**
  106764. * Define the color used on center
  106765. */
  106766. rightColor: Color3;
  106767. /**
  106768. * Define bias applied to computed fresnel term
  106769. */
  106770. bias: number;
  106771. /**
  106772. * Defined the power exponent applied to fresnel term
  106773. */
  106774. power: number;
  106775. /**
  106776. * Creates a new FresnelParameters object.
  106777. *
  106778. * @param options provide your own settings to optionally to override defaults
  106779. */
  106780. constructor(options?: IFresnelParametersCreationOptions);
  106781. /**
  106782. * Clones the current fresnel and its valuues
  106783. * @returns a clone fresnel configuration
  106784. */
  106785. clone(): FresnelParameters;
  106786. /**
  106787. * Determines equality between FresnelParameters objects
  106788. * @param otherFresnelParameters defines the second operand
  106789. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  106790. */
  106791. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  106792. /**
  106793. * Serializes the current fresnel parameters to a JSON representation.
  106794. * @return the JSON serialization
  106795. */
  106796. serialize(): IFresnelParametersSerialized;
  106797. /**
  106798. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  106799. * @param parsedFresnelParameters Define the JSON representation
  106800. * @returns the parsed parameters
  106801. */
  106802. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  106803. }
  106804. }
  106805. declare module BABYLON {
  106806. /**
  106807. * This groups all the flags used to control the materials channel.
  106808. */
  106809. export class MaterialFlags {
  106810. private static _DiffuseTextureEnabled;
  106811. /**
  106812. * Are diffuse textures enabled in the application.
  106813. */
  106814. static get DiffuseTextureEnabled(): boolean;
  106815. static set DiffuseTextureEnabled(value: boolean);
  106816. private static _DetailTextureEnabled;
  106817. /**
  106818. * Are detail textures enabled in the application.
  106819. */
  106820. static get DetailTextureEnabled(): boolean;
  106821. static set DetailTextureEnabled(value: boolean);
  106822. private static _AmbientTextureEnabled;
  106823. /**
  106824. * Are ambient textures enabled in the application.
  106825. */
  106826. static get AmbientTextureEnabled(): boolean;
  106827. static set AmbientTextureEnabled(value: boolean);
  106828. private static _OpacityTextureEnabled;
  106829. /**
  106830. * Are opacity textures enabled in the application.
  106831. */
  106832. static get OpacityTextureEnabled(): boolean;
  106833. static set OpacityTextureEnabled(value: boolean);
  106834. private static _ReflectionTextureEnabled;
  106835. /**
  106836. * Are reflection textures enabled in the application.
  106837. */
  106838. static get ReflectionTextureEnabled(): boolean;
  106839. static set ReflectionTextureEnabled(value: boolean);
  106840. private static _EmissiveTextureEnabled;
  106841. /**
  106842. * Are emissive textures enabled in the application.
  106843. */
  106844. static get EmissiveTextureEnabled(): boolean;
  106845. static set EmissiveTextureEnabled(value: boolean);
  106846. private static _SpecularTextureEnabled;
  106847. /**
  106848. * Are specular textures enabled in the application.
  106849. */
  106850. static get SpecularTextureEnabled(): boolean;
  106851. static set SpecularTextureEnabled(value: boolean);
  106852. private static _BumpTextureEnabled;
  106853. /**
  106854. * Are bump textures enabled in the application.
  106855. */
  106856. static get BumpTextureEnabled(): boolean;
  106857. static set BumpTextureEnabled(value: boolean);
  106858. private static _LightmapTextureEnabled;
  106859. /**
  106860. * Are lightmap textures enabled in the application.
  106861. */
  106862. static get LightmapTextureEnabled(): boolean;
  106863. static set LightmapTextureEnabled(value: boolean);
  106864. private static _RefractionTextureEnabled;
  106865. /**
  106866. * Are refraction textures enabled in the application.
  106867. */
  106868. static get RefractionTextureEnabled(): boolean;
  106869. static set RefractionTextureEnabled(value: boolean);
  106870. private static _ColorGradingTextureEnabled;
  106871. /**
  106872. * Are color grading textures enabled in the application.
  106873. */
  106874. static get ColorGradingTextureEnabled(): boolean;
  106875. static set ColorGradingTextureEnabled(value: boolean);
  106876. private static _FresnelEnabled;
  106877. /**
  106878. * Are fresnels enabled in the application.
  106879. */
  106880. static get FresnelEnabled(): boolean;
  106881. static set FresnelEnabled(value: boolean);
  106882. private static _ClearCoatTextureEnabled;
  106883. /**
  106884. * Are clear coat textures enabled in the application.
  106885. */
  106886. static get ClearCoatTextureEnabled(): boolean;
  106887. static set ClearCoatTextureEnabled(value: boolean);
  106888. private static _ClearCoatBumpTextureEnabled;
  106889. /**
  106890. * Are clear coat bump textures enabled in the application.
  106891. */
  106892. static get ClearCoatBumpTextureEnabled(): boolean;
  106893. static set ClearCoatBumpTextureEnabled(value: boolean);
  106894. private static _ClearCoatTintTextureEnabled;
  106895. /**
  106896. * Are clear coat tint textures enabled in the application.
  106897. */
  106898. static get ClearCoatTintTextureEnabled(): boolean;
  106899. static set ClearCoatTintTextureEnabled(value: boolean);
  106900. private static _SheenTextureEnabled;
  106901. /**
  106902. * Are sheen textures enabled in the application.
  106903. */
  106904. static get SheenTextureEnabled(): boolean;
  106905. static set SheenTextureEnabled(value: boolean);
  106906. private static _AnisotropicTextureEnabled;
  106907. /**
  106908. * Are anisotropic textures enabled in the application.
  106909. */
  106910. static get AnisotropicTextureEnabled(): boolean;
  106911. static set AnisotropicTextureEnabled(value: boolean);
  106912. private static _ThicknessTextureEnabled;
  106913. /**
  106914. * Are thickness textures enabled in the application.
  106915. */
  106916. static get ThicknessTextureEnabled(): boolean;
  106917. static set ThicknessTextureEnabled(value: boolean);
  106918. }
  106919. }
  106920. declare module BABYLON {
  106921. /** @hidden */
  106922. export var defaultFragmentDeclaration: {
  106923. name: string;
  106924. shader: string;
  106925. };
  106926. }
  106927. declare module BABYLON {
  106928. /** @hidden */
  106929. export var defaultUboDeclaration: {
  106930. name: string;
  106931. shader: string;
  106932. };
  106933. }
  106934. declare module BABYLON {
  106935. /** @hidden */
  106936. export var lightFragmentDeclaration: {
  106937. name: string;
  106938. shader: string;
  106939. };
  106940. }
  106941. declare module BABYLON {
  106942. /** @hidden */
  106943. export var lightUboDeclaration: {
  106944. name: string;
  106945. shader: string;
  106946. };
  106947. }
  106948. declare module BABYLON {
  106949. /** @hidden */
  106950. export var lightsFragmentFunctions: {
  106951. name: string;
  106952. shader: string;
  106953. };
  106954. }
  106955. declare module BABYLON {
  106956. /** @hidden */
  106957. export var shadowsFragmentFunctions: {
  106958. name: string;
  106959. shader: string;
  106960. };
  106961. }
  106962. declare module BABYLON {
  106963. /** @hidden */
  106964. export var fresnelFunction: {
  106965. name: string;
  106966. shader: string;
  106967. };
  106968. }
  106969. declare module BABYLON {
  106970. /** @hidden */
  106971. export var bumpFragmentMainFunctions: {
  106972. name: string;
  106973. shader: string;
  106974. };
  106975. }
  106976. declare module BABYLON {
  106977. /** @hidden */
  106978. export var bumpFragmentFunctions: {
  106979. name: string;
  106980. shader: string;
  106981. };
  106982. }
  106983. declare module BABYLON {
  106984. /** @hidden */
  106985. export var logDepthDeclaration: {
  106986. name: string;
  106987. shader: string;
  106988. };
  106989. }
  106990. declare module BABYLON {
  106991. /** @hidden */
  106992. export var bumpFragment: {
  106993. name: string;
  106994. shader: string;
  106995. };
  106996. }
  106997. declare module BABYLON {
  106998. /** @hidden */
  106999. export var depthPrePass: {
  107000. name: string;
  107001. shader: string;
  107002. };
  107003. }
  107004. declare module BABYLON {
  107005. /** @hidden */
  107006. export var lightFragment: {
  107007. name: string;
  107008. shader: string;
  107009. };
  107010. }
  107011. declare module BABYLON {
  107012. /** @hidden */
  107013. export var logDepthFragment: {
  107014. name: string;
  107015. shader: string;
  107016. };
  107017. }
  107018. declare module BABYLON {
  107019. /** @hidden */
  107020. export var defaultPixelShader: {
  107021. name: string;
  107022. shader: string;
  107023. };
  107024. }
  107025. declare module BABYLON {
  107026. /** @hidden */
  107027. export var defaultVertexDeclaration: {
  107028. name: string;
  107029. shader: string;
  107030. };
  107031. }
  107032. declare module BABYLON {
  107033. /** @hidden */
  107034. export var bumpVertexDeclaration: {
  107035. name: string;
  107036. shader: string;
  107037. };
  107038. }
  107039. declare module BABYLON {
  107040. /** @hidden */
  107041. export var bumpVertex: {
  107042. name: string;
  107043. shader: string;
  107044. };
  107045. }
  107046. declare module BABYLON {
  107047. /** @hidden */
  107048. export var fogVertex: {
  107049. name: string;
  107050. shader: string;
  107051. };
  107052. }
  107053. declare module BABYLON {
  107054. /** @hidden */
  107055. export var shadowsVertex: {
  107056. name: string;
  107057. shader: string;
  107058. };
  107059. }
  107060. declare module BABYLON {
  107061. /** @hidden */
  107062. export var pointCloudVertex: {
  107063. name: string;
  107064. shader: string;
  107065. };
  107066. }
  107067. declare module BABYLON {
  107068. /** @hidden */
  107069. export var logDepthVertex: {
  107070. name: string;
  107071. shader: string;
  107072. };
  107073. }
  107074. declare module BABYLON {
  107075. /** @hidden */
  107076. export var defaultVertexShader: {
  107077. name: string;
  107078. shader: string;
  107079. };
  107080. }
  107081. declare module BABYLON {
  107082. /**
  107083. * @hidden
  107084. */
  107085. export interface IMaterialDetailMapDefines {
  107086. DETAIL: boolean;
  107087. DETAILDIRECTUV: number;
  107088. DETAIL_NORMALBLENDMETHOD: number;
  107089. /** @hidden */
  107090. _areTexturesDirty: boolean;
  107091. }
  107092. /**
  107093. * Define the code related to the detail map parameters of a material
  107094. *
  107095. * Inspired from:
  107096. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  107097. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  107098. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  107099. */
  107100. export class DetailMapConfiguration {
  107101. private _texture;
  107102. /**
  107103. * The detail texture of the material.
  107104. */
  107105. texture: Nullable<BaseTexture>;
  107106. /**
  107107. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107108. * Bigger values mean stronger blending
  107109. */
  107110. diffuseBlendLevel: number;
  107111. /**
  107112. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107113. * Bigger values mean stronger blending. Only used with PBR materials
  107114. */
  107115. roughnessBlendLevel: number;
  107116. /**
  107117. * Defines how strong the bump effect from the detail map is
  107118. * Bigger values mean stronger effect
  107119. */
  107120. bumpLevel: number;
  107121. private _normalBlendMethod;
  107122. /**
  107123. * The method used to blend the bump and detail normals together
  107124. */
  107125. normalBlendMethod: number;
  107126. private _isEnabled;
  107127. /**
  107128. * Enable or disable the detail map on this material
  107129. */
  107130. isEnabled: boolean;
  107131. /** @hidden */
  107132. private _internalMarkAllSubMeshesAsTexturesDirty;
  107133. /** @hidden */
  107134. _markAllSubMeshesAsTexturesDirty(): void;
  107135. /**
  107136. * Instantiate a new detail map
  107137. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107138. */
  107139. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107140. /**
  107141. * Gets whether the submesh is ready to be used or not.
  107142. * @param defines the list of "defines" to update.
  107143. * @param scene defines the scene the material belongs to.
  107144. * @returns - boolean indicating that the submesh is ready or not.
  107145. */
  107146. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107147. /**
  107148. * Update the defines for detail map usage
  107149. * @param defines the list of "defines" to update.
  107150. * @param scene defines the scene the material belongs to.
  107151. */
  107152. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107153. /**
  107154. * Binds the material data.
  107155. * @param uniformBuffer defines the Uniform buffer to fill in.
  107156. * @param scene defines the scene the material belongs to.
  107157. * @param isFrozen defines whether the material is frozen or not.
  107158. */
  107159. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107160. /**
  107161. * Checks to see if a texture is used in the material.
  107162. * @param texture - Base texture to use.
  107163. * @returns - Boolean specifying if a texture is used in the material.
  107164. */
  107165. hasTexture(texture: BaseTexture): boolean;
  107166. /**
  107167. * Returns an array of the actively used textures.
  107168. * @param activeTextures Array of BaseTextures
  107169. */
  107170. getActiveTextures(activeTextures: BaseTexture[]): void;
  107171. /**
  107172. * Returns the animatable textures.
  107173. * @param animatables Array of animatable textures.
  107174. */
  107175. getAnimatables(animatables: IAnimatable[]): void;
  107176. /**
  107177. * Disposes the resources of the material.
  107178. * @param forceDisposeTextures - Forces the disposal of all textures.
  107179. */
  107180. dispose(forceDisposeTextures?: boolean): void;
  107181. /**
  107182. * Get the current class name useful for serialization or dynamic coding.
  107183. * @returns "DetailMap"
  107184. */
  107185. getClassName(): string;
  107186. /**
  107187. * Add the required uniforms to the current list.
  107188. * @param uniforms defines the current uniform list.
  107189. */
  107190. static AddUniforms(uniforms: string[]): void;
  107191. /**
  107192. * Add the required samplers to the current list.
  107193. * @param samplers defines the current sampler list.
  107194. */
  107195. static AddSamplers(samplers: string[]): void;
  107196. /**
  107197. * Add the required uniforms to the current buffer.
  107198. * @param uniformBuffer defines the current uniform buffer.
  107199. */
  107200. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107201. /**
  107202. * Makes a duplicate of the current instance into another one.
  107203. * @param detailMap define the instance where to copy the info
  107204. */
  107205. copyTo(detailMap: DetailMapConfiguration): void;
  107206. /**
  107207. * Serializes this detail map instance
  107208. * @returns - An object with the serialized instance.
  107209. */
  107210. serialize(): any;
  107211. /**
  107212. * Parses a detail map setting from a serialized object.
  107213. * @param source - Serialized object.
  107214. * @param scene Defines the scene we are parsing for
  107215. * @param rootUrl Defines the rootUrl to load from
  107216. */
  107217. parse(source: any, scene: Scene, rootUrl: string): void;
  107218. }
  107219. }
  107220. declare module BABYLON {
  107221. /** @hidden */
  107222. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107223. MAINUV1: boolean;
  107224. MAINUV2: boolean;
  107225. DIFFUSE: boolean;
  107226. DIFFUSEDIRECTUV: number;
  107227. DETAIL: boolean;
  107228. DETAILDIRECTUV: number;
  107229. DETAIL_NORMALBLENDMETHOD: number;
  107230. AMBIENT: boolean;
  107231. AMBIENTDIRECTUV: number;
  107232. OPACITY: boolean;
  107233. OPACITYDIRECTUV: number;
  107234. OPACITYRGB: boolean;
  107235. REFLECTION: boolean;
  107236. EMISSIVE: boolean;
  107237. EMISSIVEDIRECTUV: number;
  107238. SPECULAR: boolean;
  107239. SPECULARDIRECTUV: number;
  107240. BUMP: boolean;
  107241. BUMPDIRECTUV: number;
  107242. PARALLAX: boolean;
  107243. PARALLAXOCCLUSION: boolean;
  107244. SPECULAROVERALPHA: boolean;
  107245. CLIPPLANE: boolean;
  107246. CLIPPLANE2: boolean;
  107247. CLIPPLANE3: boolean;
  107248. CLIPPLANE4: boolean;
  107249. CLIPPLANE5: boolean;
  107250. CLIPPLANE6: boolean;
  107251. ALPHATEST: boolean;
  107252. DEPTHPREPASS: boolean;
  107253. ALPHAFROMDIFFUSE: boolean;
  107254. POINTSIZE: boolean;
  107255. FOG: boolean;
  107256. SPECULARTERM: boolean;
  107257. DIFFUSEFRESNEL: boolean;
  107258. OPACITYFRESNEL: boolean;
  107259. REFLECTIONFRESNEL: boolean;
  107260. REFRACTIONFRESNEL: boolean;
  107261. EMISSIVEFRESNEL: boolean;
  107262. FRESNEL: boolean;
  107263. NORMAL: boolean;
  107264. UV1: boolean;
  107265. UV2: boolean;
  107266. VERTEXCOLOR: boolean;
  107267. VERTEXALPHA: boolean;
  107268. NUM_BONE_INFLUENCERS: number;
  107269. BonesPerMesh: number;
  107270. BONETEXTURE: boolean;
  107271. INSTANCES: boolean;
  107272. THIN_INSTANCES: boolean;
  107273. GLOSSINESS: boolean;
  107274. ROUGHNESS: boolean;
  107275. EMISSIVEASILLUMINATION: boolean;
  107276. LINKEMISSIVEWITHDIFFUSE: boolean;
  107277. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107278. LIGHTMAP: boolean;
  107279. LIGHTMAPDIRECTUV: number;
  107280. OBJECTSPACE_NORMALMAP: boolean;
  107281. USELIGHTMAPASSHADOWMAP: boolean;
  107282. REFLECTIONMAP_3D: boolean;
  107283. REFLECTIONMAP_SPHERICAL: boolean;
  107284. REFLECTIONMAP_PLANAR: boolean;
  107285. REFLECTIONMAP_CUBIC: boolean;
  107286. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107287. REFLECTIONMAP_PROJECTION: boolean;
  107288. REFLECTIONMAP_SKYBOX: boolean;
  107289. REFLECTIONMAP_EXPLICIT: boolean;
  107290. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107291. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107292. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107293. INVERTCUBICMAP: boolean;
  107294. LOGARITHMICDEPTH: boolean;
  107295. REFRACTION: boolean;
  107296. REFRACTIONMAP_3D: boolean;
  107297. REFLECTIONOVERALPHA: boolean;
  107298. TWOSIDEDLIGHTING: boolean;
  107299. SHADOWFLOAT: boolean;
  107300. MORPHTARGETS: boolean;
  107301. MORPHTARGETS_NORMAL: boolean;
  107302. MORPHTARGETS_TANGENT: boolean;
  107303. MORPHTARGETS_UV: boolean;
  107304. NUM_MORPH_INFLUENCERS: number;
  107305. NONUNIFORMSCALING: boolean;
  107306. PREMULTIPLYALPHA: boolean;
  107307. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  107308. ALPHABLEND: boolean;
  107309. RGBDLIGHTMAP: boolean;
  107310. RGBDREFLECTION: boolean;
  107311. RGBDREFRACTION: boolean;
  107312. IMAGEPROCESSING: boolean;
  107313. VIGNETTE: boolean;
  107314. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107315. VIGNETTEBLENDMODEOPAQUE: boolean;
  107316. TONEMAPPING: boolean;
  107317. TONEMAPPING_ACES: boolean;
  107318. CONTRAST: boolean;
  107319. COLORCURVES: boolean;
  107320. COLORGRADING: boolean;
  107321. COLORGRADING3D: boolean;
  107322. SAMPLER3DGREENDEPTH: boolean;
  107323. SAMPLER3DBGRMAP: boolean;
  107324. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107325. MULTIVIEW: boolean;
  107326. /**
  107327. * If the reflection texture on this material is in linear color space
  107328. * @hidden
  107329. */
  107330. IS_REFLECTION_LINEAR: boolean;
  107331. /**
  107332. * If the refraction texture on this material is in linear color space
  107333. * @hidden
  107334. */
  107335. IS_REFRACTION_LINEAR: boolean;
  107336. EXPOSURE: boolean;
  107337. constructor();
  107338. setReflectionMode(modeToEnable: string): void;
  107339. }
  107340. /**
  107341. * This is the default material used in Babylon. It is the best trade off between quality
  107342. * and performances.
  107343. * @see http://doc.babylonjs.com/babylon101/materials
  107344. */
  107345. export class StandardMaterial extends PushMaterial {
  107346. private _diffuseTexture;
  107347. /**
  107348. * The basic texture of the material as viewed under a light.
  107349. */
  107350. diffuseTexture: Nullable<BaseTexture>;
  107351. private _ambientTexture;
  107352. /**
  107353. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107354. */
  107355. ambientTexture: Nullable<BaseTexture>;
  107356. private _opacityTexture;
  107357. /**
  107358. * Define the transparency of the material from a texture.
  107359. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107360. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107361. */
  107362. opacityTexture: Nullable<BaseTexture>;
  107363. private _reflectionTexture;
  107364. /**
  107365. * Define the texture used to display the reflection.
  107366. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107367. */
  107368. reflectionTexture: Nullable<BaseTexture>;
  107369. private _emissiveTexture;
  107370. /**
  107371. * Define texture of the material as if self lit.
  107372. * This will be mixed in the final result even in the absence of light.
  107373. */
  107374. emissiveTexture: Nullable<BaseTexture>;
  107375. private _specularTexture;
  107376. /**
  107377. * Define how the color and intensity of the highlight given by the light in the material.
  107378. */
  107379. specularTexture: Nullable<BaseTexture>;
  107380. private _bumpTexture;
  107381. /**
  107382. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107383. * 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.
  107384. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107385. */
  107386. bumpTexture: Nullable<BaseTexture>;
  107387. private _lightmapTexture;
  107388. /**
  107389. * Complex lighting can be computationally expensive to compute at runtime.
  107390. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107391. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107392. */
  107393. lightmapTexture: Nullable<BaseTexture>;
  107394. private _refractionTexture;
  107395. /**
  107396. * Define the texture used to display the refraction.
  107397. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107398. */
  107399. refractionTexture: Nullable<BaseTexture>;
  107400. /**
  107401. * The color of the material lit by the environmental background lighting.
  107402. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107403. */
  107404. ambientColor: Color3;
  107405. /**
  107406. * The basic color of the material as viewed under a light.
  107407. */
  107408. diffuseColor: Color3;
  107409. /**
  107410. * Define how the color and intensity of the highlight given by the light in the material.
  107411. */
  107412. specularColor: Color3;
  107413. /**
  107414. * Define the color of the material as if self lit.
  107415. * This will be mixed in the final result even in the absence of light.
  107416. */
  107417. emissiveColor: Color3;
  107418. /**
  107419. * Defines how sharp are the highlights in the material.
  107420. * The bigger the value the sharper giving a more glossy feeling to the result.
  107421. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107422. */
  107423. specularPower: number;
  107424. private _useAlphaFromDiffuseTexture;
  107425. /**
  107426. * Does the transparency come from the diffuse texture alpha channel.
  107427. */
  107428. useAlphaFromDiffuseTexture: boolean;
  107429. private _useEmissiveAsIllumination;
  107430. /**
  107431. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107432. */
  107433. useEmissiveAsIllumination: boolean;
  107434. private _linkEmissiveWithDiffuse;
  107435. /**
  107436. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107437. * the emissive level when the final color is close to one.
  107438. */
  107439. linkEmissiveWithDiffuse: boolean;
  107440. private _useSpecularOverAlpha;
  107441. /**
  107442. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107443. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107444. */
  107445. useSpecularOverAlpha: boolean;
  107446. private _useReflectionOverAlpha;
  107447. /**
  107448. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107449. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107450. */
  107451. useReflectionOverAlpha: boolean;
  107452. private _disableLighting;
  107453. /**
  107454. * Does lights from the scene impacts this material.
  107455. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107456. */
  107457. disableLighting: boolean;
  107458. private _useObjectSpaceNormalMap;
  107459. /**
  107460. * Allows using an object space normal map (instead of tangent space).
  107461. */
  107462. useObjectSpaceNormalMap: boolean;
  107463. private _useParallax;
  107464. /**
  107465. * Is parallax enabled or not.
  107466. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107467. */
  107468. useParallax: boolean;
  107469. private _useParallaxOcclusion;
  107470. /**
  107471. * Is parallax occlusion enabled or not.
  107472. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107473. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107474. */
  107475. useParallaxOcclusion: boolean;
  107476. /**
  107477. * 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.
  107478. */
  107479. parallaxScaleBias: number;
  107480. private _roughness;
  107481. /**
  107482. * Helps to define how blurry the reflections should appears in the material.
  107483. */
  107484. roughness: number;
  107485. /**
  107486. * In case of refraction, define the value of the index of refraction.
  107487. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107488. */
  107489. indexOfRefraction: number;
  107490. /**
  107491. * Invert the refraction texture alongside the y axis.
  107492. * It can be useful with procedural textures or probe for instance.
  107493. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107494. */
  107495. invertRefractionY: boolean;
  107496. /**
  107497. * Defines the alpha limits in alpha test mode.
  107498. */
  107499. alphaCutOff: number;
  107500. private _useLightmapAsShadowmap;
  107501. /**
  107502. * In case of light mapping, define whether the map contains light or shadow informations.
  107503. */
  107504. useLightmapAsShadowmap: boolean;
  107505. private _diffuseFresnelParameters;
  107506. /**
  107507. * Define the diffuse fresnel parameters of the material.
  107508. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107509. */
  107510. diffuseFresnelParameters: FresnelParameters;
  107511. private _opacityFresnelParameters;
  107512. /**
  107513. * Define the opacity fresnel parameters of the material.
  107514. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107515. */
  107516. opacityFresnelParameters: FresnelParameters;
  107517. private _reflectionFresnelParameters;
  107518. /**
  107519. * Define the reflection fresnel parameters of the material.
  107520. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107521. */
  107522. reflectionFresnelParameters: FresnelParameters;
  107523. private _refractionFresnelParameters;
  107524. /**
  107525. * Define the refraction fresnel parameters of the material.
  107526. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107527. */
  107528. refractionFresnelParameters: FresnelParameters;
  107529. private _emissiveFresnelParameters;
  107530. /**
  107531. * Define the emissive fresnel parameters of the material.
  107532. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107533. */
  107534. emissiveFresnelParameters: FresnelParameters;
  107535. private _useReflectionFresnelFromSpecular;
  107536. /**
  107537. * If true automatically deducts the fresnels values from the material specularity.
  107538. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107539. */
  107540. useReflectionFresnelFromSpecular: boolean;
  107541. private _useGlossinessFromSpecularMapAlpha;
  107542. /**
  107543. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107544. */
  107545. useGlossinessFromSpecularMapAlpha: boolean;
  107546. private _maxSimultaneousLights;
  107547. /**
  107548. * Defines the maximum number of lights that can be used in the material
  107549. */
  107550. maxSimultaneousLights: number;
  107551. private _invertNormalMapX;
  107552. /**
  107553. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107554. */
  107555. invertNormalMapX: boolean;
  107556. private _invertNormalMapY;
  107557. /**
  107558. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107559. */
  107560. invertNormalMapY: boolean;
  107561. private _twoSidedLighting;
  107562. /**
  107563. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107564. */
  107565. twoSidedLighting: boolean;
  107566. /**
  107567. * Default configuration related to image processing available in the standard Material.
  107568. */
  107569. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107570. /**
  107571. * Gets the image processing configuration used either in this material.
  107572. */
  107573. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107574. /**
  107575. * Sets the Default image processing configuration used either in the this material.
  107576. *
  107577. * If sets to null, the scene one is in use.
  107578. */
  107579. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107580. /**
  107581. * Keep track of the image processing observer to allow dispose and replace.
  107582. */
  107583. private _imageProcessingObserver;
  107584. /**
  107585. * Attaches a new image processing configuration to the Standard Material.
  107586. * @param configuration
  107587. */
  107588. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107589. /**
  107590. * Gets wether the color curves effect is enabled.
  107591. */
  107592. get cameraColorCurvesEnabled(): boolean;
  107593. /**
  107594. * Sets wether the color curves effect is enabled.
  107595. */
  107596. set cameraColorCurvesEnabled(value: boolean);
  107597. /**
  107598. * Gets wether the color grading effect is enabled.
  107599. */
  107600. get cameraColorGradingEnabled(): boolean;
  107601. /**
  107602. * Gets wether the color grading effect is enabled.
  107603. */
  107604. set cameraColorGradingEnabled(value: boolean);
  107605. /**
  107606. * Gets wether tonemapping is enabled or not.
  107607. */
  107608. get cameraToneMappingEnabled(): boolean;
  107609. /**
  107610. * Sets wether tonemapping is enabled or not
  107611. */
  107612. set cameraToneMappingEnabled(value: boolean);
  107613. /**
  107614. * The camera exposure used on this material.
  107615. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107616. * This corresponds to a photographic exposure.
  107617. */
  107618. get cameraExposure(): number;
  107619. /**
  107620. * The camera exposure used on this material.
  107621. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107622. * This corresponds to a photographic exposure.
  107623. */
  107624. set cameraExposure(value: number);
  107625. /**
  107626. * Gets The camera contrast used on this material.
  107627. */
  107628. get cameraContrast(): number;
  107629. /**
  107630. * Sets The camera contrast used on this material.
  107631. */
  107632. set cameraContrast(value: number);
  107633. /**
  107634. * Gets the Color Grading 2D Lookup Texture.
  107635. */
  107636. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107637. /**
  107638. * Sets the Color Grading 2D Lookup Texture.
  107639. */
  107640. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107641. /**
  107642. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107643. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107644. * 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;
  107645. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107646. */
  107647. get cameraColorCurves(): Nullable<ColorCurves>;
  107648. /**
  107649. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107650. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107651. * 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;
  107652. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107653. */
  107654. set cameraColorCurves(value: Nullable<ColorCurves>);
  107655. /**
  107656. * Defines the detail map parameters for the material.
  107657. */
  107658. readonly detailMap: DetailMapConfiguration;
  107659. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107660. protected _worldViewProjectionMatrix: Matrix;
  107661. protected _globalAmbientColor: Color3;
  107662. protected _useLogarithmicDepth: boolean;
  107663. protected _rebuildInParallel: boolean;
  107664. /**
  107665. * Instantiates a new standard material.
  107666. * This is the default material used in Babylon. It is the best trade off between quality
  107667. * and performances.
  107668. * @see http://doc.babylonjs.com/babylon101/materials
  107669. * @param name Define the name of the material in the scene
  107670. * @param scene Define the scene the material belong to
  107671. */
  107672. constructor(name: string, scene: Scene);
  107673. /**
  107674. * Gets a boolean indicating that current material needs to register RTT
  107675. */
  107676. get hasRenderTargetTextures(): boolean;
  107677. /**
  107678. * Gets the current class name of the material e.g. "StandardMaterial"
  107679. * Mainly use in serialization.
  107680. * @returns the class name
  107681. */
  107682. getClassName(): string;
  107683. /**
  107684. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107685. * You can try switching to logarithmic depth.
  107686. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107687. */
  107688. get useLogarithmicDepth(): boolean;
  107689. set useLogarithmicDepth(value: boolean);
  107690. /**
  107691. * Specifies if the material will require alpha blending
  107692. * @returns a boolean specifying if alpha blending is needed
  107693. */
  107694. needAlphaBlending(): boolean;
  107695. /**
  107696. * Specifies if this material should be rendered in alpha test mode
  107697. * @returns a boolean specifying if an alpha test is needed.
  107698. */
  107699. needAlphaTesting(): boolean;
  107700. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107701. /**
  107702. * Get the texture used for alpha test purpose.
  107703. * @returns the diffuse texture in case of the standard material.
  107704. */
  107705. getAlphaTestTexture(): Nullable<BaseTexture>;
  107706. /**
  107707. * Get if the submesh is ready to be used and all its information available.
  107708. * Child classes can use it to update shaders
  107709. * @param mesh defines the mesh to check
  107710. * @param subMesh defines which submesh to check
  107711. * @param useInstances specifies that instances should be used
  107712. * @returns a boolean indicating that the submesh is ready or not
  107713. */
  107714. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107715. /**
  107716. * Builds the material UBO layouts.
  107717. * Used internally during the effect preparation.
  107718. */
  107719. buildUniformLayout(): void;
  107720. /**
  107721. * Unbinds the material from the mesh
  107722. */
  107723. unbind(): void;
  107724. /**
  107725. * Binds the submesh to this material by preparing the effect and shader to draw
  107726. * @param world defines the world transformation matrix
  107727. * @param mesh defines the mesh containing the submesh
  107728. * @param subMesh defines the submesh to bind the material to
  107729. */
  107730. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107731. /**
  107732. * Get the list of animatables in the material.
  107733. * @returns the list of animatables object used in the material
  107734. */
  107735. getAnimatables(): IAnimatable[];
  107736. /**
  107737. * Gets the active textures from the material
  107738. * @returns an array of textures
  107739. */
  107740. getActiveTextures(): BaseTexture[];
  107741. /**
  107742. * Specifies if the material uses a texture
  107743. * @param texture defines the texture to check against the material
  107744. * @returns a boolean specifying if the material uses the texture
  107745. */
  107746. hasTexture(texture: BaseTexture): boolean;
  107747. /**
  107748. * Disposes the material
  107749. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107750. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107751. */
  107752. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107753. /**
  107754. * Makes a duplicate of the material, and gives it a new name
  107755. * @param name defines the new name for the duplicated material
  107756. * @returns the cloned material
  107757. */
  107758. clone(name: string): StandardMaterial;
  107759. /**
  107760. * Serializes this material in a JSON representation
  107761. * @returns the serialized material object
  107762. */
  107763. serialize(): any;
  107764. /**
  107765. * Creates a standard material from parsed material data
  107766. * @param source defines the JSON representation of the material
  107767. * @param scene defines the hosting scene
  107768. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107769. * @returns a new standard material
  107770. */
  107771. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107772. /**
  107773. * Are diffuse textures enabled in the application.
  107774. */
  107775. static get DiffuseTextureEnabled(): boolean;
  107776. static set DiffuseTextureEnabled(value: boolean);
  107777. /**
  107778. * Are detail textures enabled in the application.
  107779. */
  107780. static get DetailTextureEnabled(): boolean;
  107781. static set DetailTextureEnabled(value: boolean);
  107782. /**
  107783. * Are ambient textures enabled in the application.
  107784. */
  107785. static get AmbientTextureEnabled(): boolean;
  107786. static set AmbientTextureEnabled(value: boolean);
  107787. /**
  107788. * Are opacity textures enabled in the application.
  107789. */
  107790. static get OpacityTextureEnabled(): boolean;
  107791. static set OpacityTextureEnabled(value: boolean);
  107792. /**
  107793. * Are reflection textures enabled in the application.
  107794. */
  107795. static get ReflectionTextureEnabled(): boolean;
  107796. static set ReflectionTextureEnabled(value: boolean);
  107797. /**
  107798. * Are emissive textures enabled in the application.
  107799. */
  107800. static get EmissiveTextureEnabled(): boolean;
  107801. static set EmissiveTextureEnabled(value: boolean);
  107802. /**
  107803. * Are specular textures enabled in the application.
  107804. */
  107805. static get SpecularTextureEnabled(): boolean;
  107806. static set SpecularTextureEnabled(value: boolean);
  107807. /**
  107808. * Are bump textures enabled in the application.
  107809. */
  107810. static get BumpTextureEnabled(): boolean;
  107811. static set BumpTextureEnabled(value: boolean);
  107812. /**
  107813. * Are lightmap textures enabled in the application.
  107814. */
  107815. static get LightmapTextureEnabled(): boolean;
  107816. static set LightmapTextureEnabled(value: boolean);
  107817. /**
  107818. * Are refraction textures enabled in the application.
  107819. */
  107820. static get RefractionTextureEnabled(): boolean;
  107821. static set RefractionTextureEnabled(value: boolean);
  107822. /**
  107823. * Are color grading textures enabled in the application.
  107824. */
  107825. static get ColorGradingTextureEnabled(): boolean;
  107826. static set ColorGradingTextureEnabled(value: boolean);
  107827. /**
  107828. * Are fresnels enabled in the application.
  107829. */
  107830. static get FresnelEnabled(): boolean;
  107831. static set FresnelEnabled(value: boolean);
  107832. }
  107833. }
  107834. declare module BABYLON {
  107835. /**
  107836. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107837. *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.
  107838. * The SPS is also a particle system. It provides some methods to manage the particles.
  107839. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107840. *
  107841. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  107842. */
  107843. export class SolidParticleSystem implements IDisposable {
  107844. /**
  107845. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107846. * Example : var p = SPS.particles[i];
  107847. */
  107848. particles: SolidParticle[];
  107849. /**
  107850. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107851. */
  107852. nbParticles: number;
  107853. /**
  107854. * If the particles must ever face the camera (default false). Useful for planar particles.
  107855. */
  107856. billboard: boolean;
  107857. /**
  107858. * Recompute normals when adding a shape
  107859. */
  107860. recomputeNormals: boolean;
  107861. /**
  107862. * This a counter ofr your own usage. It's not set by any SPS functions.
  107863. */
  107864. counter: number;
  107865. /**
  107866. * The SPS name. This name is also given to the underlying mesh.
  107867. */
  107868. name: string;
  107869. /**
  107870. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  107871. */
  107872. mesh: Mesh;
  107873. /**
  107874. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107875. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  107876. */
  107877. vars: any;
  107878. /**
  107879. * This array is populated when the SPS is set as 'pickable'.
  107880. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  107881. * Each element of this array is an object `{idx: int, faceId: int}`.
  107882. * `idx` is the picked particle index in the `SPS.particles` array
  107883. * `faceId` is the picked face index counted within this particle.
  107884. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  107885. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  107886. * Use the method SPS.pickedParticle(pickingInfo) instead.
  107887. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107888. */
  107889. pickedParticles: {
  107890. idx: number;
  107891. faceId: number;
  107892. }[];
  107893. /**
  107894. * This array is populated when the SPS is set as 'pickable'
  107895. * Each key of this array is a submesh index.
  107896. * Each element of this array is a second array defined like this :
  107897. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  107898. * Each element of this second array is an object `{idx: int, faceId: int}`.
  107899. * `idx` is the picked particle index in the `SPS.particles` array
  107900. * `faceId` is the picked face index counted within this particle.
  107901. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  107902. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107903. */
  107904. pickedBySubMesh: {
  107905. idx: number;
  107906. faceId: number;
  107907. }[][];
  107908. /**
  107909. * This array is populated when `enableDepthSort` is set to true.
  107910. * Each element of this array is an instance of the class DepthSortedParticle.
  107911. */
  107912. depthSortedParticles: DepthSortedParticle[];
  107913. /**
  107914. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107915. * @hidden
  107916. */
  107917. _bSphereOnly: boolean;
  107918. /**
  107919. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107920. * @hidden
  107921. */
  107922. _bSphereRadiusFactor: number;
  107923. private _scene;
  107924. private _positions;
  107925. private _indices;
  107926. private _normals;
  107927. private _colors;
  107928. private _uvs;
  107929. private _indices32;
  107930. private _positions32;
  107931. private _normals32;
  107932. private _fixedNormal32;
  107933. private _colors32;
  107934. private _uvs32;
  107935. private _index;
  107936. private _updatable;
  107937. private _pickable;
  107938. private _isVisibilityBoxLocked;
  107939. private _alwaysVisible;
  107940. private _depthSort;
  107941. private _expandable;
  107942. private _shapeCounter;
  107943. private _copy;
  107944. private _color;
  107945. private _computeParticleColor;
  107946. private _computeParticleTexture;
  107947. private _computeParticleRotation;
  107948. private _computeParticleVertex;
  107949. private _computeBoundingBox;
  107950. private _depthSortParticles;
  107951. private _camera;
  107952. private _mustUnrotateFixedNormals;
  107953. private _particlesIntersect;
  107954. private _needs32Bits;
  107955. private _isNotBuilt;
  107956. private _lastParticleId;
  107957. private _idxOfId;
  107958. private _multimaterialEnabled;
  107959. private _useModelMaterial;
  107960. private _indicesByMaterial;
  107961. private _materialIndexes;
  107962. private _depthSortFunction;
  107963. private _materialSortFunction;
  107964. private _materials;
  107965. private _multimaterial;
  107966. private _materialIndexesById;
  107967. private _defaultMaterial;
  107968. private _autoUpdateSubMeshes;
  107969. private _tmpVertex;
  107970. /**
  107971. * Creates a SPS (Solid Particle System) object.
  107972. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107973. * @param scene (Scene) is the scene in which the SPS is added.
  107974. * @param options defines the options of the sps e.g.
  107975. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107976. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107977. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107978. * * 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.
  107979. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  107980. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  107981. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107982. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107983. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107984. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107985. */
  107986. constructor(name: string, scene: Scene, options?: {
  107987. updatable?: boolean;
  107988. isPickable?: boolean;
  107989. enableDepthSort?: boolean;
  107990. particleIntersection?: boolean;
  107991. boundingSphereOnly?: boolean;
  107992. bSphereRadiusFactor?: number;
  107993. expandable?: boolean;
  107994. useModelMaterial?: boolean;
  107995. enableMultiMaterial?: boolean;
  107996. });
  107997. /**
  107998. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107999. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108000. * @returns the created mesh
  108001. */
  108002. buildMesh(): Mesh;
  108003. /**
  108004. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108005. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108006. * Thus the particles generated from `digest()` have their property `position` set yet.
  108007. * @param mesh ( Mesh ) is the mesh to be digested
  108008. * @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
  108009. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108010. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108011. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108012. * @returns the current SPS
  108013. */
  108014. digest(mesh: Mesh, options?: {
  108015. facetNb?: number;
  108016. number?: number;
  108017. delta?: number;
  108018. storage?: [];
  108019. }): SolidParticleSystem;
  108020. /**
  108021. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108022. * @hidden
  108023. */
  108024. private _unrotateFixedNormals;
  108025. /**
  108026. * Resets the temporary working copy particle
  108027. * @hidden
  108028. */
  108029. private _resetCopy;
  108030. /**
  108031. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  108032. * @param p the current index in the positions array to be updated
  108033. * @param ind the current index in the indices array
  108034. * @param shape a Vector3 array, the shape geometry
  108035. * @param positions the positions array to be updated
  108036. * @param meshInd the shape indices array
  108037. * @param indices the indices array to be updated
  108038. * @param meshUV the shape uv array
  108039. * @param uvs the uv array to be updated
  108040. * @param meshCol the shape color array
  108041. * @param colors the color array to be updated
  108042. * @param meshNor the shape normals array
  108043. * @param normals the normals array to be updated
  108044. * @param idx the particle index
  108045. * @param idxInShape the particle index in its shape
  108046. * @param options the addShape() method passed options
  108047. * @model the particle model
  108048. * @hidden
  108049. */
  108050. private _meshBuilder;
  108051. /**
  108052. * Returns a shape Vector3 array from positions float array
  108053. * @param positions float array
  108054. * @returns a vector3 array
  108055. * @hidden
  108056. */
  108057. private _posToShape;
  108058. /**
  108059. * Returns a shapeUV array from a float uvs (array deep copy)
  108060. * @param uvs as a float array
  108061. * @returns a shapeUV array
  108062. * @hidden
  108063. */
  108064. private _uvsToShapeUV;
  108065. /**
  108066. * Adds a new particle object in the particles array
  108067. * @param idx particle index in particles array
  108068. * @param id particle id
  108069. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  108070. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  108071. * @param model particle ModelShape object
  108072. * @param shapeId model shape identifier
  108073. * @param idxInShape index of the particle in the current model
  108074. * @param bInfo model bounding info object
  108075. * @param storage target storage array, if any
  108076. * @hidden
  108077. */
  108078. private _addParticle;
  108079. /**
  108080. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108081. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  108082. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108083. * @param nb (positive integer) the number of particles to be created from this model
  108084. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108085. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108086. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108087. * @returns the number of shapes in the system
  108088. */
  108089. addShape(mesh: Mesh, nb: number, options?: {
  108090. positionFunction?: any;
  108091. vertexFunction?: any;
  108092. storage?: [];
  108093. }): number;
  108094. /**
  108095. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108096. * @hidden
  108097. */
  108098. private _rebuildParticle;
  108099. /**
  108100. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108101. * @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.
  108102. * @returns the SPS.
  108103. */
  108104. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108105. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108106. * Returns an array with the removed particles.
  108107. * 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.
  108108. * The SPS can't be empty so at least one particle needs to remain in place.
  108109. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108110. * @param start index of the first particle to remove
  108111. * @param end index of the last particle to remove (included)
  108112. * @returns an array populated with the removed particles
  108113. */
  108114. removeParticles(start: number, end: number): SolidParticle[];
  108115. /**
  108116. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108117. * @param solidParticleArray an array populated with Solid Particles objects
  108118. * @returns the SPS
  108119. */
  108120. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108121. /**
  108122. * Creates a new particle and modifies the SPS mesh geometry :
  108123. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108124. * - calls _addParticle() to populate the particle array
  108125. * factorized code from addShape() and insertParticlesFromArray()
  108126. * @param idx particle index in the particles array
  108127. * @param i particle index in its shape
  108128. * @param modelShape particle ModelShape object
  108129. * @param shape shape vertex array
  108130. * @param meshInd shape indices array
  108131. * @param meshUV shape uv array
  108132. * @param meshCol shape color array
  108133. * @param meshNor shape normals array
  108134. * @param bbInfo shape bounding info
  108135. * @param storage target particle storage
  108136. * @options addShape() passed options
  108137. * @hidden
  108138. */
  108139. private _insertNewParticle;
  108140. /**
  108141. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108142. * This method calls `updateParticle()` for each particle of the SPS.
  108143. * For an animated SPS, it is usually called within the render loop.
  108144. * 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.
  108145. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108146. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108147. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108148. * @returns the SPS.
  108149. */
  108150. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108151. /**
  108152. * Disposes the SPS.
  108153. */
  108154. dispose(): void;
  108155. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108156. * idx is the particle index in the SPS
  108157. * faceId is the picked face index counted within this particle.
  108158. * Returns null if the pickInfo can't identify a picked particle.
  108159. * @param pickingInfo (PickingInfo object)
  108160. * @returns {idx: number, faceId: number} or null
  108161. */
  108162. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108163. idx: number;
  108164. faceId: number;
  108165. }>;
  108166. /**
  108167. * Returns a SolidParticle object from its identifier : particle.id
  108168. * @param id (integer) the particle Id
  108169. * @returns the searched particle or null if not found in the SPS.
  108170. */
  108171. getParticleById(id: number): Nullable<SolidParticle>;
  108172. /**
  108173. * Returns a new array populated with the particles having the passed shapeId.
  108174. * @param shapeId (integer) the shape identifier
  108175. * @returns a new solid particle array
  108176. */
  108177. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108178. /**
  108179. * Populates the passed array "ref" with the particles having the passed shapeId.
  108180. * @param shapeId the shape identifier
  108181. * @returns the SPS
  108182. * @param ref
  108183. */
  108184. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108185. /**
  108186. * Computes the required SubMeshes according the materials assigned to the particles.
  108187. * @returns the solid particle system.
  108188. * Does nothing if called before the SPS mesh is built.
  108189. */
  108190. computeSubMeshes(): SolidParticleSystem;
  108191. /**
  108192. * Sorts the solid particles by material when MultiMaterial is enabled.
  108193. * Updates the indices32 array.
  108194. * Updates the indicesByMaterial array.
  108195. * Updates the mesh indices array.
  108196. * @returns the SPS
  108197. * @hidden
  108198. */
  108199. private _sortParticlesByMaterial;
  108200. /**
  108201. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108202. * @hidden
  108203. */
  108204. private _setMaterialIndexesById;
  108205. /**
  108206. * Returns an array with unique values of Materials from the passed array
  108207. * @param array the material array to be checked and filtered
  108208. * @hidden
  108209. */
  108210. private _filterUniqueMaterialId;
  108211. /**
  108212. * Sets a new Standard Material as _defaultMaterial if not already set.
  108213. * @hidden
  108214. */
  108215. private _setDefaultMaterial;
  108216. /**
  108217. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108218. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108219. * @returns the SPS.
  108220. */
  108221. refreshVisibleSize(): SolidParticleSystem;
  108222. /**
  108223. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108224. * @param size the size (float) of the visibility box
  108225. * note : this doesn't lock the SPS mesh bounding box.
  108226. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108227. */
  108228. setVisibilityBox(size: number): void;
  108229. /**
  108230. * Gets whether the SPS as always visible or not
  108231. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108232. */
  108233. get isAlwaysVisible(): boolean;
  108234. /**
  108235. * Sets the SPS as always visible or not
  108236. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108237. */
  108238. set isAlwaysVisible(val: boolean);
  108239. /**
  108240. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108241. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108242. */
  108243. set isVisibilityBoxLocked(val: boolean);
  108244. /**
  108245. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108246. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108247. */
  108248. get isVisibilityBoxLocked(): boolean;
  108249. /**
  108250. * Tells to `setParticles()` to compute the particle rotations or not.
  108251. * Default value : true. The SPS is faster when it's set to false.
  108252. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108253. */
  108254. set computeParticleRotation(val: boolean);
  108255. /**
  108256. * Tells to `setParticles()` to compute the particle colors or not.
  108257. * Default value : true. The SPS is faster when it's set to false.
  108258. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108259. */
  108260. set computeParticleColor(val: boolean);
  108261. set computeParticleTexture(val: boolean);
  108262. /**
  108263. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108264. * Default value : false. The SPS is faster when it's set to false.
  108265. * Note : the particle custom vertex positions aren't stored values.
  108266. */
  108267. set computeParticleVertex(val: boolean);
  108268. /**
  108269. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108270. */
  108271. set computeBoundingBox(val: boolean);
  108272. /**
  108273. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108274. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108275. * Default : `true`
  108276. */
  108277. set depthSortParticles(val: boolean);
  108278. /**
  108279. * Gets if `setParticles()` computes the particle rotations or not.
  108280. * Default value : true. The SPS is faster when it's set to false.
  108281. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108282. */
  108283. get computeParticleRotation(): boolean;
  108284. /**
  108285. * Gets if `setParticles()` computes the particle colors or not.
  108286. * Default value : true. The SPS is faster when it's set to false.
  108287. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108288. */
  108289. get computeParticleColor(): boolean;
  108290. /**
  108291. * Gets if `setParticles()` computes the particle textures or not.
  108292. * Default value : true. The SPS is faster when it's set to false.
  108293. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108294. */
  108295. get computeParticleTexture(): boolean;
  108296. /**
  108297. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108298. * Default value : false. The SPS is faster when it's set to false.
  108299. * Note : the particle custom vertex positions aren't stored values.
  108300. */
  108301. get computeParticleVertex(): boolean;
  108302. /**
  108303. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108304. */
  108305. get computeBoundingBox(): boolean;
  108306. /**
  108307. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108308. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108309. * Default : `true`
  108310. */
  108311. get depthSortParticles(): boolean;
  108312. /**
  108313. * Gets if the SPS is created as expandable at construction time.
  108314. * Default : `false`
  108315. */
  108316. get expandable(): boolean;
  108317. /**
  108318. * Gets if the SPS supports the Multi Materials
  108319. */
  108320. get multimaterialEnabled(): boolean;
  108321. /**
  108322. * Gets if the SPS uses the model materials for its own multimaterial.
  108323. */
  108324. get useModelMaterial(): boolean;
  108325. /**
  108326. * The SPS used material array.
  108327. */
  108328. get materials(): Material[];
  108329. /**
  108330. * Sets the SPS MultiMaterial from the passed materials.
  108331. * Note : the passed array is internally copied and not used then by reference.
  108332. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  108333. */
  108334. setMultiMaterial(materials: Material[]): void;
  108335. /**
  108336. * The SPS computed multimaterial object
  108337. */
  108338. get multimaterial(): MultiMaterial;
  108339. set multimaterial(mm: MultiMaterial);
  108340. /**
  108341. * If the subMeshes must be updated on the next call to setParticles()
  108342. */
  108343. get autoUpdateSubMeshes(): boolean;
  108344. set autoUpdateSubMeshes(val: boolean);
  108345. /**
  108346. * This function does nothing. It may be overwritten to set all the particle first values.
  108347. * The SPS doesn't call this function, you may have to call it by your own.
  108348. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108349. */
  108350. initParticles(): void;
  108351. /**
  108352. * This function does nothing. It may be overwritten to recycle a particle.
  108353. * The SPS doesn't call this function, you may have to call it by your own.
  108354. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108355. * @param particle The particle to recycle
  108356. * @returns the recycled particle
  108357. */
  108358. recycleParticle(particle: SolidParticle): SolidParticle;
  108359. /**
  108360. * Updates a particle : this function should be overwritten by the user.
  108361. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108362. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108363. * @example : just set a particle position or velocity and recycle conditions
  108364. * @param particle The particle to update
  108365. * @returns the updated particle
  108366. */
  108367. updateParticle(particle: SolidParticle): SolidParticle;
  108368. /**
  108369. * Updates a vertex of a particle : it can be overwritten by the user.
  108370. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108371. * @param particle the current particle
  108372. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  108373. * @param pt the index of the current vertex in the particle shape
  108374. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  108375. * @example : just set a vertex particle position or color
  108376. * @returns the sps
  108377. */
  108378. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  108379. /**
  108380. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108381. * This does nothing and may be overwritten by the user.
  108382. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108383. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108384. * @param update the boolean update value actually passed to setParticles()
  108385. */
  108386. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108387. /**
  108388. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108389. * This will be passed three parameters.
  108390. * This does nothing and may be overwritten by the user.
  108391. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108392. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108393. * @param update the boolean update value actually passed to setParticles()
  108394. */
  108395. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108396. }
  108397. }
  108398. declare module BABYLON {
  108399. /**
  108400. * Represents one particle of a solid particle system.
  108401. */
  108402. export class SolidParticle {
  108403. /**
  108404. * particle global index
  108405. */
  108406. idx: number;
  108407. /**
  108408. * particle identifier
  108409. */
  108410. id: number;
  108411. /**
  108412. * The color of the particle
  108413. */
  108414. color: Nullable<Color4>;
  108415. /**
  108416. * The world space position of the particle.
  108417. */
  108418. position: Vector3;
  108419. /**
  108420. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108421. */
  108422. rotation: Vector3;
  108423. /**
  108424. * The world space rotation quaternion of the particle.
  108425. */
  108426. rotationQuaternion: Nullable<Quaternion>;
  108427. /**
  108428. * The scaling of the particle.
  108429. */
  108430. scaling: Vector3;
  108431. /**
  108432. * The uvs of the particle.
  108433. */
  108434. uvs: Vector4;
  108435. /**
  108436. * The current speed of the particle.
  108437. */
  108438. velocity: Vector3;
  108439. /**
  108440. * The pivot point in the particle local space.
  108441. */
  108442. pivot: Vector3;
  108443. /**
  108444. * Must the particle be translated from its pivot point in its local space ?
  108445. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108446. * Default : false
  108447. */
  108448. translateFromPivot: boolean;
  108449. /**
  108450. * Is the particle active or not ?
  108451. */
  108452. alive: boolean;
  108453. /**
  108454. * Is the particle visible or not ?
  108455. */
  108456. isVisible: boolean;
  108457. /**
  108458. * Index of this particle in the global "positions" array (Internal use)
  108459. * @hidden
  108460. */
  108461. _pos: number;
  108462. /**
  108463. * @hidden Index of this particle in the global "indices" array (Internal use)
  108464. */
  108465. _ind: number;
  108466. /**
  108467. * @hidden ModelShape of this particle (Internal use)
  108468. */
  108469. _model: ModelShape;
  108470. /**
  108471. * ModelShape id of this particle
  108472. */
  108473. shapeId: number;
  108474. /**
  108475. * Index of the particle in its shape id
  108476. */
  108477. idxInShape: number;
  108478. /**
  108479. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  108480. */
  108481. _modelBoundingInfo: BoundingInfo;
  108482. /**
  108483. * @hidden Particle BoundingInfo object (Internal use)
  108484. */
  108485. _boundingInfo: BoundingInfo;
  108486. /**
  108487. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  108488. */
  108489. _sps: SolidParticleSystem;
  108490. /**
  108491. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108492. */
  108493. _stillInvisible: boolean;
  108494. /**
  108495. * @hidden Last computed particle rotation matrix
  108496. */
  108497. _rotationMatrix: number[];
  108498. /**
  108499. * Parent particle Id, if any.
  108500. * Default null.
  108501. */
  108502. parentId: Nullable<number>;
  108503. /**
  108504. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  108505. */
  108506. materialIndex: Nullable<number>;
  108507. /**
  108508. * Custom object or properties.
  108509. */
  108510. props: Nullable<any>;
  108511. /**
  108512. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108513. * The possible values are :
  108514. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108515. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108516. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108518. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108519. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108520. * */
  108521. cullingStrategy: number;
  108522. /**
  108523. * @hidden Internal global position in the SPS.
  108524. */
  108525. _globalPosition: Vector3;
  108526. /**
  108527. * Creates a Solid Particle object.
  108528. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108529. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  108530. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  108531. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108532. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108533. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108534. * @param shapeId (integer) is the model shape identifier in the SPS.
  108535. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108536. * @param sps defines the sps it is associated to
  108537. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108538. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  108539. */
  108540. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  108541. /**
  108542. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  108543. * @param target the particle target
  108544. * @returns the current particle
  108545. */
  108546. copyToRef(target: SolidParticle): SolidParticle;
  108547. /**
  108548. * Legacy support, changed scale to scaling
  108549. */
  108550. get scale(): Vector3;
  108551. /**
  108552. * Legacy support, changed scale to scaling
  108553. */
  108554. set scale(scale: Vector3);
  108555. /**
  108556. * Legacy support, changed quaternion to rotationQuaternion
  108557. */
  108558. get quaternion(): Nullable<Quaternion>;
  108559. /**
  108560. * Legacy support, changed quaternion to rotationQuaternion
  108561. */
  108562. set quaternion(q: Nullable<Quaternion>);
  108563. /**
  108564. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  108565. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  108566. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  108567. * @returns true if it intersects
  108568. */
  108569. intersectsMesh(target: Mesh | SolidParticle): boolean;
  108570. /**
  108571. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  108572. * A particle is in the frustum if its bounding box intersects the frustum
  108573. * @param frustumPlanes defines the frustum to test
  108574. * @returns true if the particle is in the frustum planes
  108575. */
  108576. isInFrustum(frustumPlanes: Plane[]): boolean;
  108577. /**
  108578. * get the rotation matrix of the particle
  108579. * @hidden
  108580. */
  108581. getRotationMatrix(m: Matrix): void;
  108582. }
  108583. /**
  108584. * Represents the shape of the model used by one particle of a solid particle system.
  108585. * SPS internal tool, don't use it manually.
  108586. */
  108587. export class ModelShape {
  108588. /**
  108589. * The shape id
  108590. * @hidden
  108591. */
  108592. shapeID: number;
  108593. /**
  108594. * flat array of model positions (internal use)
  108595. * @hidden
  108596. */
  108597. _shape: Vector3[];
  108598. /**
  108599. * flat array of model UVs (internal use)
  108600. * @hidden
  108601. */
  108602. _shapeUV: number[];
  108603. /**
  108604. * color array of the model
  108605. * @hidden
  108606. */
  108607. _shapeColors: number[];
  108608. /**
  108609. * indices array of the model
  108610. * @hidden
  108611. */
  108612. _indices: number[];
  108613. /**
  108614. * normals array of the model
  108615. * @hidden
  108616. */
  108617. _normals: number[];
  108618. /**
  108619. * length of the shape in the model indices array (internal use)
  108620. * @hidden
  108621. */
  108622. _indicesLength: number;
  108623. /**
  108624. * Custom position function (internal use)
  108625. * @hidden
  108626. */
  108627. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  108628. /**
  108629. * Custom vertex function (internal use)
  108630. * @hidden
  108631. */
  108632. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  108633. /**
  108634. * Model material (internal use)
  108635. * @hidden
  108636. */
  108637. _material: Nullable<Material>;
  108638. /**
  108639. * 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.
  108640. * SPS internal tool, don't use it manually.
  108641. * @hidden
  108642. */
  108643. 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>);
  108644. }
  108645. /**
  108646. * Represents a Depth Sorted Particle in the solid particle system.
  108647. * @hidden
  108648. */
  108649. export class DepthSortedParticle {
  108650. /**
  108651. * Particle index
  108652. */
  108653. idx: number;
  108654. /**
  108655. * Index of the particle in the "indices" array
  108656. */
  108657. ind: number;
  108658. /**
  108659. * Length of the particle shape in the "indices" array
  108660. */
  108661. indicesLength: number;
  108662. /**
  108663. * Squared distance from the particle to the camera
  108664. */
  108665. sqDistance: number;
  108666. /**
  108667. * Material index when used with MultiMaterials
  108668. */
  108669. materialIndex: number;
  108670. /**
  108671. * Creates a new sorted particle
  108672. * @param materialIndex
  108673. */
  108674. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  108675. }
  108676. /**
  108677. * Represents a solid particle vertex
  108678. */
  108679. export class SolidParticleVertex {
  108680. /**
  108681. * Vertex position
  108682. */
  108683. position: Vector3;
  108684. /**
  108685. * Vertex color
  108686. */
  108687. color: Color4;
  108688. /**
  108689. * Vertex UV
  108690. */
  108691. uv: Vector2;
  108692. /**
  108693. * Creates a new solid particle vertex
  108694. */
  108695. constructor();
  108696. /** Vertex x coordinate */
  108697. get x(): number;
  108698. set x(val: number);
  108699. /** Vertex y coordinate */
  108700. get y(): number;
  108701. set y(val: number);
  108702. /** Vertex z coordinate */
  108703. get z(): number;
  108704. set z(val: number);
  108705. }
  108706. }
  108707. declare module BABYLON {
  108708. /**
  108709. * @hidden
  108710. */
  108711. export class _MeshCollisionData {
  108712. _checkCollisions: boolean;
  108713. _collisionMask: number;
  108714. _collisionGroup: number;
  108715. _surroundingMeshes: Nullable<AbstractMesh[]>;
  108716. _collider: Nullable<Collider>;
  108717. _oldPositionForCollisions: Vector3;
  108718. _diffPositionForCollisions: Vector3;
  108719. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  108720. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  108721. }
  108722. }
  108723. declare module BABYLON {
  108724. /** @hidden */
  108725. class _FacetDataStorage {
  108726. facetPositions: Vector3[];
  108727. facetNormals: Vector3[];
  108728. facetPartitioning: number[][];
  108729. facetNb: number;
  108730. partitioningSubdivisions: number;
  108731. partitioningBBoxRatio: number;
  108732. facetDataEnabled: boolean;
  108733. facetParameters: any;
  108734. bbSize: Vector3;
  108735. subDiv: {
  108736. max: number;
  108737. X: number;
  108738. Y: number;
  108739. Z: number;
  108740. };
  108741. facetDepthSort: boolean;
  108742. facetDepthSortEnabled: boolean;
  108743. depthSortedIndices: IndicesArray;
  108744. depthSortedFacets: {
  108745. ind: number;
  108746. sqDistance: number;
  108747. }[];
  108748. facetDepthSortFunction: (f1: {
  108749. ind: number;
  108750. sqDistance: number;
  108751. }, f2: {
  108752. ind: number;
  108753. sqDistance: number;
  108754. }) => number;
  108755. facetDepthSortFrom: Vector3;
  108756. facetDepthSortOrigin: Vector3;
  108757. invertedMatrix: Matrix;
  108758. }
  108759. /**
  108760. * @hidden
  108761. **/
  108762. class _InternalAbstractMeshDataInfo {
  108763. _hasVertexAlpha: boolean;
  108764. _useVertexColors: boolean;
  108765. _numBoneInfluencers: number;
  108766. _applyFog: boolean;
  108767. _receiveShadows: boolean;
  108768. _facetData: _FacetDataStorage;
  108769. _visibility: number;
  108770. _skeleton: Nullable<Skeleton>;
  108771. _layerMask: number;
  108772. _computeBonesUsingShaders: boolean;
  108773. _isActive: boolean;
  108774. _onlyForInstances: boolean;
  108775. _isActiveIntermediate: boolean;
  108776. _onlyForInstancesIntermediate: boolean;
  108777. _actAsRegularMesh: boolean;
  108778. }
  108779. /**
  108780. * Class used to store all common mesh properties
  108781. */
  108782. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  108783. /** No occlusion */
  108784. static OCCLUSION_TYPE_NONE: number;
  108785. /** Occlusion set to optimisitic */
  108786. static OCCLUSION_TYPE_OPTIMISTIC: number;
  108787. /** Occlusion set to strict */
  108788. static OCCLUSION_TYPE_STRICT: number;
  108789. /** Use an accurante occlusion algorithm */
  108790. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  108791. /** Use a conservative occlusion algorithm */
  108792. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  108793. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  108794. * Test order :
  108795. * Is the bounding sphere outside the frustum ?
  108796. * If not, are the bounding box vertices outside the frustum ?
  108797. * It not, then the cullable object is in the frustum.
  108798. */
  108799. static readonly CULLINGSTRATEGY_STANDARD: number;
  108800. /** Culling strategy : Bounding Sphere Only.
  108801. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  108802. * It's also less accurate than the standard because some not visible objects can still be selected.
  108803. * Test : is the bounding sphere outside the frustum ?
  108804. * If not, then the cullable object is in the frustum.
  108805. */
  108806. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  108807. /** Culling strategy : Optimistic Inclusion.
  108808. * This in an inclusion test first, then the standard exclusion test.
  108809. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  108810. * 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.
  108811. * Anyway, it's as accurate as the standard strategy.
  108812. * Test :
  108813. * Is the cullable object bounding sphere center in the frustum ?
  108814. * If not, apply the default culling strategy.
  108815. */
  108816. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  108817. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  108818. * This in an inclusion test first, then the bounding sphere only exclusion test.
  108819. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  108820. * 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.
  108821. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  108822. * Test :
  108823. * Is the cullable object bounding sphere center in the frustum ?
  108824. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  108825. */
  108826. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  108827. /**
  108828. * No billboard
  108829. */
  108830. static get BILLBOARDMODE_NONE(): number;
  108831. /** Billboard on X axis */
  108832. static get BILLBOARDMODE_X(): number;
  108833. /** Billboard on Y axis */
  108834. static get BILLBOARDMODE_Y(): number;
  108835. /** Billboard on Z axis */
  108836. static get BILLBOARDMODE_Z(): number;
  108837. /** Billboard on all axes */
  108838. static get BILLBOARDMODE_ALL(): number;
  108839. /** Billboard on using position instead of orientation */
  108840. static get BILLBOARDMODE_USE_POSITION(): number;
  108841. /** @hidden */
  108842. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  108843. /**
  108844. * The culling strategy to use to check whether the mesh must be rendered or not.
  108845. * This value can be changed at any time and will be used on the next render mesh selection.
  108846. * The possible values are :
  108847. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108848. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108849. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108850. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108851. * Please read each static variable documentation to get details about the culling process.
  108852. * */
  108853. cullingStrategy: number;
  108854. /**
  108855. * Gets the number of facets in the mesh
  108856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108857. */
  108858. get facetNb(): number;
  108859. /**
  108860. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  108861. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108862. */
  108863. get partitioningSubdivisions(): number;
  108864. set partitioningSubdivisions(nb: number);
  108865. /**
  108866. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  108867. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  108868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108869. */
  108870. get partitioningBBoxRatio(): number;
  108871. set partitioningBBoxRatio(ratio: number);
  108872. /**
  108873. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  108874. * Works only for updatable meshes.
  108875. * Doesn't work with multi-materials
  108876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108877. */
  108878. get mustDepthSortFacets(): boolean;
  108879. set mustDepthSortFacets(sort: boolean);
  108880. /**
  108881. * The location (Vector3) where the facet depth sort must be computed from.
  108882. * By default, the active camera position.
  108883. * Used only when facet depth sort is enabled
  108884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108885. */
  108886. get facetDepthSortFrom(): Vector3;
  108887. set facetDepthSortFrom(location: Vector3);
  108888. /**
  108889. * gets a boolean indicating if facetData is enabled
  108890. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108891. */
  108892. get isFacetDataEnabled(): boolean;
  108893. /** @hidden */
  108894. _updateNonUniformScalingState(value: boolean): boolean;
  108895. /**
  108896. * An event triggered when this mesh collides with another one
  108897. */
  108898. onCollideObservable: Observable<AbstractMesh>;
  108899. /** Set a function to call when this mesh collides with another one */
  108900. set onCollide(callback: () => void);
  108901. /**
  108902. * An event triggered when the collision's position changes
  108903. */
  108904. onCollisionPositionChangeObservable: Observable<Vector3>;
  108905. /** Set a function to call when the collision's position changes */
  108906. set onCollisionPositionChange(callback: () => void);
  108907. /**
  108908. * An event triggered when material is changed
  108909. */
  108910. onMaterialChangedObservable: Observable<AbstractMesh>;
  108911. /**
  108912. * Gets or sets the orientation for POV movement & rotation
  108913. */
  108914. definedFacingForward: boolean;
  108915. /** @hidden */
  108916. _occlusionQuery: Nullable<WebGLQuery>;
  108917. /** @hidden */
  108918. _renderingGroup: Nullable<RenderingGroup>;
  108919. /**
  108920. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108921. */
  108922. get visibility(): number;
  108923. /**
  108924. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108925. */
  108926. set visibility(value: number);
  108927. /** Gets or sets the alpha index used to sort transparent meshes
  108928. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  108929. */
  108930. alphaIndex: number;
  108931. /**
  108932. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  108933. */
  108934. isVisible: boolean;
  108935. /**
  108936. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108937. */
  108938. isPickable: boolean;
  108939. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  108940. showSubMeshesBoundingBox: boolean;
  108941. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  108942. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  108943. */
  108944. isBlocker: boolean;
  108945. /**
  108946. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  108947. */
  108948. enablePointerMoveEvents: boolean;
  108949. /**
  108950. * Specifies the rendering group id for this mesh (0 by default)
  108951. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108952. */
  108953. renderingGroupId: number;
  108954. private _material;
  108955. /** Gets or sets current material */
  108956. get material(): Nullable<Material>;
  108957. set material(value: Nullable<Material>);
  108958. /**
  108959. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  108960. * @see http://doc.babylonjs.com/babylon101/shadows
  108961. */
  108962. get receiveShadows(): boolean;
  108963. set receiveShadows(value: boolean);
  108964. /** Defines color to use when rendering outline */
  108965. outlineColor: Color3;
  108966. /** Define width to use when rendering outline */
  108967. outlineWidth: number;
  108968. /** Defines color to use when rendering overlay */
  108969. overlayColor: Color3;
  108970. /** Defines alpha to use when rendering overlay */
  108971. overlayAlpha: number;
  108972. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  108973. get hasVertexAlpha(): boolean;
  108974. set hasVertexAlpha(value: boolean);
  108975. /** 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) */
  108976. get useVertexColors(): boolean;
  108977. set useVertexColors(value: boolean);
  108978. /**
  108979. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  108980. */
  108981. get computeBonesUsingShaders(): boolean;
  108982. set computeBonesUsingShaders(value: boolean);
  108983. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  108984. get numBoneInfluencers(): number;
  108985. set numBoneInfluencers(value: number);
  108986. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  108987. get applyFog(): boolean;
  108988. set applyFog(value: boolean);
  108989. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  108990. useOctreeForRenderingSelection: boolean;
  108991. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  108992. useOctreeForPicking: boolean;
  108993. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  108994. useOctreeForCollisions: boolean;
  108995. /**
  108996. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  108997. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  108998. */
  108999. get layerMask(): number;
  109000. set layerMask(value: number);
  109001. /**
  109002. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  109003. */
  109004. alwaysSelectAsActiveMesh: boolean;
  109005. /**
  109006. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  109007. */
  109008. doNotSyncBoundingInfo: boolean;
  109009. /**
  109010. * Gets or sets the current action manager
  109011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109012. */
  109013. actionManager: Nullable<AbstractActionManager>;
  109014. private _meshCollisionData;
  109015. /**
  109016. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  109017. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109018. */
  109019. ellipsoid: Vector3;
  109020. /**
  109021. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  109022. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109023. */
  109024. ellipsoidOffset: Vector3;
  109025. /**
  109026. * Gets or sets a collision mask used to mask collisions (default is -1).
  109027. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109028. */
  109029. get collisionMask(): number;
  109030. set collisionMask(mask: number);
  109031. /**
  109032. * Gets or sets the current collision group mask (-1 by default).
  109033. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109034. */
  109035. get collisionGroup(): number;
  109036. set collisionGroup(mask: number);
  109037. /**
  109038. * Gets or sets current surrounding meshes (null by default).
  109039. *
  109040. * By default collision detection is tested against every mesh in the scene.
  109041. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  109042. * meshes will be tested for the collision.
  109043. *
  109044. * Note: if set to an empty array no collision will happen when this mesh is moved.
  109045. */
  109046. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  109047. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  109048. /**
  109049. * Defines edge width used when edgesRenderer is enabled
  109050. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109051. */
  109052. edgesWidth: number;
  109053. /**
  109054. * Defines edge color used when edgesRenderer is enabled
  109055. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109056. */
  109057. edgesColor: Color4;
  109058. /** @hidden */
  109059. _edgesRenderer: Nullable<IEdgesRenderer>;
  109060. /** @hidden */
  109061. _masterMesh: Nullable<AbstractMesh>;
  109062. /** @hidden */
  109063. _boundingInfo: Nullable<BoundingInfo>;
  109064. /** @hidden */
  109065. _renderId: number;
  109066. /**
  109067. * Gets or sets the list of subMeshes
  109068. * @see http://doc.babylonjs.com/how_to/multi_materials
  109069. */
  109070. subMeshes: SubMesh[];
  109071. /** @hidden */
  109072. _intersectionsInProgress: AbstractMesh[];
  109073. /** @hidden */
  109074. _unIndexed: boolean;
  109075. /** @hidden */
  109076. _lightSources: Light[];
  109077. /** Gets the list of lights affecting that mesh */
  109078. get lightSources(): Light[];
  109079. /** @hidden */
  109080. get _positions(): Nullable<Vector3[]>;
  109081. /** @hidden */
  109082. _waitingData: {
  109083. lods: Nullable<any>;
  109084. actions: Nullable<any>;
  109085. freezeWorldMatrix: Nullable<boolean>;
  109086. };
  109087. /** @hidden */
  109088. _bonesTransformMatrices: Nullable<Float32Array>;
  109089. /** @hidden */
  109090. _transformMatrixTexture: Nullable<RawTexture>;
  109091. /**
  109092. * Gets or sets a skeleton to apply skining transformations
  109093. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109094. */
  109095. set skeleton(value: Nullable<Skeleton>);
  109096. get skeleton(): Nullable<Skeleton>;
  109097. /**
  109098. * An event triggered when the mesh is rebuilt.
  109099. */
  109100. onRebuildObservable: Observable<AbstractMesh>;
  109101. /**
  109102. * Creates a new AbstractMesh
  109103. * @param name defines the name of the mesh
  109104. * @param scene defines the hosting scene
  109105. */
  109106. constructor(name: string, scene?: Nullable<Scene>);
  109107. /**
  109108. * Returns the string "AbstractMesh"
  109109. * @returns "AbstractMesh"
  109110. */
  109111. getClassName(): string;
  109112. /**
  109113. * Gets a string representation of the current mesh
  109114. * @param fullDetails defines a boolean indicating if full details must be included
  109115. * @returns a string representation of the current mesh
  109116. */
  109117. toString(fullDetails?: boolean): string;
  109118. /**
  109119. * @hidden
  109120. */
  109121. protected _getEffectiveParent(): Nullable<Node>;
  109122. /** @hidden */
  109123. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109124. /** @hidden */
  109125. _rebuild(): void;
  109126. /** @hidden */
  109127. _resyncLightSources(): void;
  109128. /** @hidden */
  109129. _resyncLightSource(light: Light): void;
  109130. /** @hidden */
  109131. _unBindEffect(): void;
  109132. /** @hidden */
  109133. _removeLightSource(light: Light, dispose: boolean): void;
  109134. private _markSubMeshesAsDirty;
  109135. /** @hidden */
  109136. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109137. /** @hidden */
  109138. _markSubMeshesAsAttributesDirty(): void;
  109139. /** @hidden */
  109140. _markSubMeshesAsMiscDirty(): void;
  109141. /**
  109142. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109143. */
  109144. get scaling(): Vector3;
  109145. set scaling(newScaling: Vector3);
  109146. /**
  109147. * Returns true if the mesh is blocked. Implemented by child classes
  109148. */
  109149. get isBlocked(): boolean;
  109150. /**
  109151. * Returns the mesh itself by default. Implemented by child classes
  109152. * @param camera defines the camera to use to pick the right LOD level
  109153. * @returns the currentAbstractMesh
  109154. */
  109155. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109156. /**
  109157. * Returns 0 by default. Implemented by child classes
  109158. * @returns an integer
  109159. */
  109160. getTotalVertices(): number;
  109161. /**
  109162. * Returns a positive integer : the total number of indices in this mesh geometry.
  109163. * @returns the numner of indices or zero if the mesh has no geometry.
  109164. */
  109165. getTotalIndices(): number;
  109166. /**
  109167. * Returns null by default. Implemented by child classes
  109168. * @returns null
  109169. */
  109170. getIndices(): Nullable<IndicesArray>;
  109171. /**
  109172. * Returns the array of the requested vertex data kind. Implemented by child classes
  109173. * @param kind defines the vertex data kind to use
  109174. * @returns null
  109175. */
  109176. getVerticesData(kind: string): Nullable<FloatArray>;
  109177. /**
  109178. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109179. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109180. * Note that a new underlying VertexBuffer object is created each call.
  109181. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109182. * @param kind defines vertex data kind:
  109183. * * VertexBuffer.PositionKind
  109184. * * VertexBuffer.UVKind
  109185. * * VertexBuffer.UV2Kind
  109186. * * VertexBuffer.UV3Kind
  109187. * * VertexBuffer.UV4Kind
  109188. * * VertexBuffer.UV5Kind
  109189. * * VertexBuffer.UV6Kind
  109190. * * VertexBuffer.ColorKind
  109191. * * VertexBuffer.MatricesIndicesKind
  109192. * * VertexBuffer.MatricesIndicesExtraKind
  109193. * * VertexBuffer.MatricesWeightsKind
  109194. * * VertexBuffer.MatricesWeightsExtraKind
  109195. * @param data defines the data source
  109196. * @param updatable defines if the data must be flagged as updatable (or static)
  109197. * @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
  109198. * @returns the current mesh
  109199. */
  109200. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109201. /**
  109202. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109203. * If the mesh has no geometry, it is simply returned as it is.
  109204. * @param kind defines vertex data kind:
  109205. * * VertexBuffer.PositionKind
  109206. * * VertexBuffer.UVKind
  109207. * * VertexBuffer.UV2Kind
  109208. * * VertexBuffer.UV3Kind
  109209. * * VertexBuffer.UV4Kind
  109210. * * VertexBuffer.UV5Kind
  109211. * * VertexBuffer.UV6Kind
  109212. * * VertexBuffer.ColorKind
  109213. * * VertexBuffer.MatricesIndicesKind
  109214. * * VertexBuffer.MatricesIndicesExtraKind
  109215. * * VertexBuffer.MatricesWeightsKind
  109216. * * VertexBuffer.MatricesWeightsExtraKind
  109217. * @param data defines the data source
  109218. * @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
  109219. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109220. * @returns the current mesh
  109221. */
  109222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109223. /**
  109224. * Sets the mesh indices,
  109225. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109226. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109227. * @param totalVertices Defines the total number of vertices
  109228. * @returns the current mesh
  109229. */
  109230. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109231. /**
  109232. * Gets a boolean indicating if specific vertex data is present
  109233. * @param kind defines the vertex data kind to use
  109234. * @returns true is data kind is present
  109235. */
  109236. isVerticesDataPresent(kind: string): boolean;
  109237. /**
  109238. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109239. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  109240. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  109241. * @returns a BoundingInfo
  109242. */
  109243. getBoundingInfo(): BoundingInfo;
  109244. /**
  109245. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  109246. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  109247. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  109248. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  109249. * @returns the current mesh
  109250. */
  109251. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  109252. /**
  109253. * Overwrite the current bounding info
  109254. * @param boundingInfo defines the new bounding info
  109255. * @returns the current mesh
  109256. */
  109257. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  109258. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  109259. get useBones(): boolean;
  109260. /** @hidden */
  109261. _preActivate(): void;
  109262. /** @hidden */
  109263. _preActivateForIntermediateRendering(renderId: number): void;
  109264. /** @hidden */
  109265. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109266. /** @hidden */
  109267. _postActivate(): void;
  109268. /** @hidden */
  109269. _freeze(): void;
  109270. /** @hidden */
  109271. _unFreeze(): void;
  109272. /**
  109273. * Gets the current world matrix
  109274. * @returns a Matrix
  109275. */
  109276. getWorldMatrix(): Matrix;
  109277. /** @hidden */
  109278. _getWorldMatrixDeterminant(): number;
  109279. /**
  109280. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  109281. */
  109282. get isAnInstance(): boolean;
  109283. /**
  109284. * Gets a boolean indicating if this mesh has instances
  109285. */
  109286. get hasInstances(): boolean;
  109287. /**
  109288. * Gets a boolean indicating if this mesh has thin instances
  109289. */
  109290. get hasThinInstances(): boolean;
  109291. /**
  109292. * Perform relative position change from the point of view of behind the front of the mesh.
  109293. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109294. * Supports definition of mesh facing forward or backward
  109295. * @param amountRight defines the distance on the right axis
  109296. * @param amountUp defines the distance on the up axis
  109297. * @param amountForward defines the distance on the forward axis
  109298. * @returns the current mesh
  109299. */
  109300. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  109301. /**
  109302. * Calculate relative position change from the point of view of behind the front of the mesh.
  109303. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109304. * Supports definition of mesh facing forward or backward
  109305. * @param amountRight defines the distance on the right axis
  109306. * @param amountUp defines the distance on the up axis
  109307. * @param amountForward defines the distance on the forward axis
  109308. * @returns the new displacement vector
  109309. */
  109310. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  109311. /**
  109312. * Perform relative rotation change from the point of view of behind the front of the mesh.
  109313. * Supports definition of mesh facing forward or backward
  109314. * @param flipBack defines the flip
  109315. * @param twirlClockwise defines the twirl
  109316. * @param tiltRight defines the tilt
  109317. * @returns the current mesh
  109318. */
  109319. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  109320. /**
  109321. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  109322. * Supports definition of mesh facing forward or backward.
  109323. * @param flipBack defines the flip
  109324. * @param twirlClockwise defines the twirl
  109325. * @param tiltRight defines the tilt
  109326. * @returns the new rotation vector
  109327. */
  109328. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  109329. /**
  109330. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109331. * This means the mesh underlying bounding box and sphere are recomputed.
  109332. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109333. * @returns the current mesh
  109334. */
  109335. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  109336. /** @hidden */
  109337. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  109338. /** @hidden */
  109339. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  109340. /** @hidden */
  109341. _updateBoundingInfo(): AbstractMesh;
  109342. /** @hidden */
  109343. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  109344. /** @hidden */
  109345. protected _afterComputeWorldMatrix(): void;
  109346. /** @hidden */
  109347. get _effectiveMesh(): AbstractMesh;
  109348. /**
  109349. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109350. * A mesh is in the frustum if its bounding box intersects the frustum
  109351. * @param frustumPlanes defines the frustum to test
  109352. * @returns true if the mesh is in the frustum planes
  109353. */
  109354. isInFrustum(frustumPlanes: Plane[]): boolean;
  109355. /**
  109356. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  109357. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  109358. * @param frustumPlanes defines the frustum to test
  109359. * @returns true if the mesh is completely in the frustum planes
  109360. */
  109361. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  109362. /**
  109363. * True if the mesh intersects another mesh or a SolidParticle object
  109364. * @param mesh defines a target mesh or SolidParticle to test
  109365. * @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)
  109366. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  109367. * @returns true if there is an intersection
  109368. */
  109369. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  109370. /**
  109371. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  109372. * @param point defines the point to test
  109373. * @returns true if there is an intersection
  109374. */
  109375. intersectsPoint(point: Vector3): boolean;
  109376. /**
  109377. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  109378. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109379. */
  109380. get checkCollisions(): boolean;
  109381. set checkCollisions(collisionEnabled: boolean);
  109382. /**
  109383. * Gets Collider object used to compute collisions (not physics)
  109384. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109385. */
  109386. get collider(): Nullable<Collider>;
  109387. /**
  109388. * Move the mesh using collision engine
  109389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109390. * @param displacement defines the requested displacement vector
  109391. * @returns the current mesh
  109392. */
  109393. moveWithCollisions(displacement: Vector3): AbstractMesh;
  109394. private _onCollisionPositionChange;
  109395. /** @hidden */
  109396. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  109397. /** @hidden */
  109398. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  109399. /** @hidden */
  109400. _checkCollision(collider: Collider): AbstractMesh;
  109401. /** @hidden */
  109402. _generatePointsArray(): boolean;
  109403. /**
  109404. * Checks if the passed Ray intersects with the mesh
  109405. * @param ray defines the ray to use
  109406. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  109407. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109408. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  109409. * @returns the picking info
  109410. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  109411. */
  109412. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  109413. /**
  109414. * Clones the current mesh
  109415. * @param name defines the mesh name
  109416. * @param newParent defines the new mesh parent
  109417. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  109418. * @returns the new mesh
  109419. */
  109420. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  109421. /**
  109422. * Disposes all the submeshes of the current meshnp
  109423. * @returns the current mesh
  109424. */
  109425. releaseSubMeshes(): AbstractMesh;
  109426. /**
  109427. * Releases resources associated with this abstract mesh.
  109428. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109429. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109430. */
  109431. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109432. /**
  109433. * Adds the passed mesh as a child to the current mesh
  109434. * @param mesh defines the child mesh
  109435. * @returns the current mesh
  109436. */
  109437. addChild(mesh: AbstractMesh): AbstractMesh;
  109438. /**
  109439. * Removes the passed mesh from the current mesh children list
  109440. * @param mesh defines the child mesh
  109441. * @returns the current mesh
  109442. */
  109443. removeChild(mesh: AbstractMesh): AbstractMesh;
  109444. /** @hidden */
  109445. private _initFacetData;
  109446. /**
  109447. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  109448. * This method can be called within the render loop.
  109449. * 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
  109450. * @returns the current mesh
  109451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109452. */
  109453. updateFacetData(): AbstractMesh;
  109454. /**
  109455. * Returns the facetLocalNormals array.
  109456. * The normals are expressed in the mesh local spac
  109457. * @returns an array of Vector3
  109458. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109459. */
  109460. getFacetLocalNormals(): Vector3[];
  109461. /**
  109462. * Returns the facetLocalPositions array.
  109463. * The facet positions are expressed in the mesh local space
  109464. * @returns an array of Vector3
  109465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109466. */
  109467. getFacetLocalPositions(): Vector3[];
  109468. /**
  109469. * Returns the facetLocalPartioning array
  109470. * @returns an array of array of numbers
  109471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109472. */
  109473. getFacetLocalPartitioning(): number[][];
  109474. /**
  109475. * Returns the i-th facet position in the world system.
  109476. * This method allocates a new Vector3 per call
  109477. * @param i defines the facet index
  109478. * @returns a new Vector3
  109479. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109480. */
  109481. getFacetPosition(i: number): Vector3;
  109482. /**
  109483. * Sets the reference Vector3 with the i-th facet position in the world system
  109484. * @param i defines the facet index
  109485. * @param ref defines the target vector
  109486. * @returns the current mesh
  109487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109488. */
  109489. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  109490. /**
  109491. * Returns the i-th facet normal in the world system.
  109492. * This method allocates a new Vector3 per call
  109493. * @param i defines the facet index
  109494. * @returns a new Vector3
  109495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109496. */
  109497. getFacetNormal(i: number): Vector3;
  109498. /**
  109499. * Sets the reference Vector3 with the i-th facet normal in the world system
  109500. * @param i defines the facet index
  109501. * @param ref defines the target vector
  109502. * @returns the current mesh
  109503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109504. */
  109505. getFacetNormalToRef(i: number, ref: Vector3): this;
  109506. /**
  109507. * 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)
  109508. * @param x defines x coordinate
  109509. * @param y defines y coordinate
  109510. * @param z defines z coordinate
  109511. * @returns the array of facet indexes
  109512. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109513. */
  109514. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  109515. /**
  109516. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  109517. * @param projected sets as the (x,y,z) world projection on the facet
  109518. * @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
  109519. * @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
  109520. * @param x defines x coordinate
  109521. * @param y defines y coordinate
  109522. * @param z defines z coordinate
  109523. * @returns the face index if found (or null instead)
  109524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109525. */
  109526. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109527. /**
  109528. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  109529. * @param projected sets as the (x,y,z) local projection on the facet
  109530. * @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
  109531. * @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
  109532. * @param x defines x coordinate
  109533. * @param y defines y coordinate
  109534. * @param z defines z coordinate
  109535. * @returns the face index if found (or null instead)
  109536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109537. */
  109538. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109539. /**
  109540. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  109541. * @returns the parameters
  109542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109543. */
  109544. getFacetDataParameters(): any;
  109545. /**
  109546. * Disables the feature FacetData and frees the related memory
  109547. * @returns the current mesh
  109548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109549. */
  109550. disableFacetData(): AbstractMesh;
  109551. /**
  109552. * Updates the AbstractMesh indices array
  109553. * @param indices defines the data source
  109554. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109555. * @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)
  109556. * @returns the current mesh
  109557. */
  109558. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109559. /**
  109560. * Creates new normals data for the mesh
  109561. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  109562. * @returns the current mesh
  109563. */
  109564. createNormals(updatable: boolean): AbstractMesh;
  109565. /**
  109566. * Align the mesh with a normal
  109567. * @param normal defines the normal to use
  109568. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  109569. * @returns the current mesh
  109570. */
  109571. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  109572. /** @hidden */
  109573. _checkOcclusionQuery(): boolean;
  109574. /**
  109575. * Disables the mesh edge rendering mode
  109576. * @returns the currentAbstractMesh
  109577. */
  109578. disableEdgesRendering(): AbstractMesh;
  109579. /**
  109580. * Enables the edge rendering mode on the mesh.
  109581. * This mode makes the mesh edges visible
  109582. * @param epsilon defines the maximal distance between two angles to detect a face
  109583. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109584. * @returns the currentAbstractMesh
  109585. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109586. */
  109587. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109588. }
  109589. }
  109590. declare module BABYLON {
  109591. /**
  109592. * Interface used to define ActionEvent
  109593. */
  109594. export interface IActionEvent {
  109595. /** The mesh or sprite that triggered the action */
  109596. source: any;
  109597. /** The X mouse cursor position at the time of the event */
  109598. pointerX: number;
  109599. /** The Y mouse cursor position at the time of the event */
  109600. pointerY: number;
  109601. /** The mesh that is currently pointed at (can be null) */
  109602. meshUnderPointer: Nullable<AbstractMesh>;
  109603. /** the original (browser) event that triggered the ActionEvent */
  109604. sourceEvent?: any;
  109605. /** additional data for the event */
  109606. additionalData?: any;
  109607. }
  109608. /**
  109609. * ActionEvent is the event being sent when an action is triggered.
  109610. */
  109611. export class ActionEvent implements IActionEvent {
  109612. /** The mesh or sprite that triggered the action */
  109613. source: any;
  109614. /** The X mouse cursor position at the time of the event */
  109615. pointerX: number;
  109616. /** The Y mouse cursor position at the time of the event */
  109617. pointerY: number;
  109618. /** The mesh that is currently pointed at (can be null) */
  109619. meshUnderPointer: Nullable<AbstractMesh>;
  109620. /** the original (browser) event that triggered the ActionEvent */
  109621. sourceEvent?: any;
  109622. /** additional data for the event */
  109623. additionalData?: any;
  109624. /**
  109625. * Creates a new ActionEvent
  109626. * @param source The mesh or sprite that triggered the action
  109627. * @param pointerX The X mouse cursor position at the time of the event
  109628. * @param pointerY The Y mouse cursor position at the time of the event
  109629. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  109630. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  109631. * @param additionalData additional data for the event
  109632. */
  109633. constructor(
  109634. /** The mesh or sprite that triggered the action */
  109635. source: any,
  109636. /** The X mouse cursor position at the time of the event */
  109637. pointerX: number,
  109638. /** The Y mouse cursor position at the time of the event */
  109639. pointerY: number,
  109640. /** The mesh that is currently pointed at (can be null) */
  109641. meshUnderPointer: Nullable<AbstractMesh>,
  109642. /** the original (browser) event that triggered the ActionEvent */
  109643. sourceEvent?: any,
  109644. /** additional data for the event */
  109645. additionalData?: any);
  109646. /**
  109647. * Helper function to auto-create an ActionEvent from a source mesh.
  109648. * @param source The source mesh that triggered the event
  109649. * @param evt The original (browser) event
  109650. * @param additionalData additional data for the event
  109651. * @returns the new ActionEvent
  109652. */
  109653. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  109654. /**
  109655. * Helper function to auto-create an ActionEvent from a source sprite
  109656. * @param source The source sprite that triggered the event
  109657. * @param scene Scene associated with the sprite
  109658. * @param evt The original (browser) event
  109659. * @param additionalData additional data for the event
  109660. * @returns the new ActionEvent
  109661. */
  109662. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  109663. /**
  109664. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  109665. * @param scene the scene where the event occurred
  109666. * @param evt The original (browser) event
  109667. * @returns the new ActionEvent
  109668. */
  109669. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  109670. /**
  109671. * Helper function to auto-create an ActionEvent from a primitive
  109672. * @param prim defines the target primitive
  109673. * @param pointerPos defines the pointer position
  109674. * @param evt The original (browser) event
  109675. * @param additionalData additional data for the event
  109676. * @returns the new ActionEvent
  109677. */
  109678. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  109679. }
  109680. }
  109681. declare module BABYLON {
  109682. /**
  109683. * Abstract class used to decouple action Manager from scene and meshes.
  109684. * Do not instantiate.
  109685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109686. */
  109687. export abstract class AbstractActionManager implements IDisposable {
  109688. /** Gets the list of active triggers */
  109689. static Triggers: {
  109690. [key: string]: number;
  109691. };
  109692. /** Gets the cursor to use when hovering items */
  109693. hoverCursor: string;
  109694. /** Gets the list of actions */
  109695. actions: IAction[];
  109696. /**
  109697. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  109698. */
  109699. isRecursive: boolean;
  109700. /**
  109701. * Releases all associated resources
  109702. */
  109703. abstract dispose(): void;
  109704. /**
  109705. * Does this action manager has pointer triggers
  109706. */
  109707. abstract get hasPointerTriggers(): boolean;
  109708. /**
  109709. * Does this action manager has pick triggers
  109710. */
  109711. abstract get hasPickTriggers(): boolean;
  109712. /**
  109713. * Process a specific trigger
  109714. * @param trigger defines the trigger to process
  109715. * @param evt defines the event details to be processed
  109716. */
  109717. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  109718. /**
  109719. * Does this action manager handles actions of any of the given triggers
  109720. * @param triggers defines the triggers to be tested
  109721. * @return a boolean indicating whether one (or more) of the triggers is handled
  109722. */
  109723. abstract hasSpecificTriggers(triggers: number[]): boolean;
  109724. /**
  109725. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  109726. * speed.
  109727. * @param triggerA defines the trigger to be tested
  109728. * @param triggerB defines the trigger to be tested
  109729. * @return a boolean indicating whether one (or more) of the triggers is handled
  109730. */
  109731. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  109732. /**
  109733. * Does this action manager handles actions of a given trigger
  109734. * @param trigger defines the trigger to be tested
  109735. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  109736. * @return whether the trigger is handled
  109737. */
  109738. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  109739. /**
  109740. * Serialize this manager to a JSON object
  109741. * @param name defines the property name to store this manager
  109742. * @returns a JSON representation of this manager
  109743. */
  109744. abstract serialize(name: string): any;
  109745. /**
  109746. * Registers an action to this action manager
  109747. * @param action defines the action to be registered
  109748. * @return the action amended (prepared) after registration
  109749. */
  109750. abstract registerAction(action: IAction): Nullable<IAction>;
  109751. /**
  109752. * Unregisters an action to this action manager
  109753. * @param action defines the action to be unregistered
  109754. * @return a boolean indicating whether the action has been unregistered
  109755. */
  109756. abstract unregisterAction(action: IAction): Boolean;
  109757. /**
  109758. * Does exist one action manager with at least one trigger
  109759. **/
  109760. static get HasTriggers(): boolean;
  109761. /**
  109762. * Does exist one action manager with at least one pick trigger
  109763. **/
  109764. static get HasPickTriggers(): boolean;
  109765. /**
  109766. * Does exist one action manager that handles actions of a given trigger
  109767. * @param trigger defines the trigger to be tested
  109768. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  109769. **/
  109770. static HasSpecificTrigger(trigger: number): boolean;
  109771. }
  109772. }
  109773. declare module BABYLON {
  109774. /**
  109775. * Defines how a node can be built from a string name.
  109776. */
  109777. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  109778. /**
  109779. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  109780. */
  109781. export class Node implements IBehaviorAware<Node> {
  109782. /** @hidden */
  109783. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  109784. private static _NodeConstructors;
  109785. /**
  109786. * Add a new node constructor
  109787. * @param type defines the type name of the node to construct
  109788. * @param constructorFunc defines the constructor function
  109789. */
  109790. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  109791. /**
  109792. * Returns a node constructor based on type name
  109793. * @param type defines the type name
  109794. * @param name defines the new node name
  109795. * @param scene defines the hosting scene
  109796. * @param options defines optional options to transmit to constructors
  109797. * @returns the new constructor or null
  109798. */
  109799. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  109800. /**
  109801. * Gets or sets the name of the node
  109802. */
  109803. name: string;
  109804. /**
  109805. * Gets or sets the id of the node
  109806. */
  109807. id: string;
  109808. /**
  109809. * Gets or sets the unique id of the node
  109810. */
  109811. uniqueId: number;
  109812. /**
  109813. * Gets or sets a string used to store user defined state for the node
  109814. */
  109815. state: string;
  109816. /**
  109817. * Gets or sets an object used to store user defined information for the node
  109818. */
  109819. metadata: any;
  109820. /**
  109821. * For internal use only. Please do not use.
  109822. */
  109823. reservedDataStore: any;
  109824. /**
  109825. * List of inspectable custom properties (used by the Inspector)
  109826. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109827. */
  109828. inspectableCustomProperties: IInspectable[];
  109829. private _doNotSerialize;
  109830. /**
  109831. * Gets or sets a boolean used to define if the node must be serialized
  109832. */
  109833. get doNotSerialize(): boolean;
  109834. set doNotSerialize(value: boolean);
  109835. /** @hidden */
  109836. _isDisposed: boolean;
  109837. /**
  109838. * Gets a list of Animations associated with the node
  109839. */
  109840. animations: Animation[];
  109841. protected _ranges: {
  109842. [name: string]: Nullable<AnimationRange>;
  109843. };
  109844. /**
  109845. * Callback raised when the node is ready to be used
  109846. */
  109847. onReady: Nullable<(node: Node) => void>;
  109848. private _isEnabled;
  109849. private _isParentEnabled;
  109850. private _isReady;
  109851. /** @hidden */
  109852. _currentRenderId: number;
  109853. private _parentUpdateId;
  109854. /** @hidden */
  109855. _childUpdateId: number;
  109856. /** @hidden */
  109857. _waitingParentId: Nullable<string>;
  109858. /** @hidden */
  109859. _scene: Scene;
  109860. /** @hidden */
  109861. _cache: any;
  109862. private _parentNode;
  109863. private _children;
  109864. /** @hidden */
  109865. _worldMatrix: Matrix;
  109866. /** @hidden */
  109867. _worldMatrixDeterminant: number;
  109868. /** @hidden */
  109869. _worldMatrixDeterminantIsDirty: boolean;
  109870. /** @hidden */
  109871. private _sceneRootNodesIndex;
  109872. /**
  109873. * Gets a boolean indicating if the node has been disposed
  109874. * @returns true if the node was disposed
  109875. */
  109876. isDisposed(): boolean;
  109877. /**
  109878. * Gets or sets the parent of the node (without keeping the current position in the scene)
  109879. * @see https://doc.babylonjs.com/how_to/parenting
  109880. */
  109881. set parent(parent: Nullable<Node>);
  109882. get parent(): Nullable<Node>;
  109883. /** @hidden */
  109884. _addToSceneRootNodes(): void;
  109885. /** @hidden */
  109886. _removeFromSceneRootNodes(): void;
  109887. private _animationPropertiesOverride;
  109888. /**
  109889. * Gets or sets the animation properties override
  109890. */
  109891. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109892. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109893. /**
  109894. * Gets a string idenfifying the name of the class
  109895. * @returns "Node" string
  109896. */
  109897. getClassName(): string;
  109898. /** @hidden */
  109899. readonly _isNode: boolean;
  109900. /**
  109901. * An event triggered when the mesh is disposed
  109902. */
  109903. onDisposeObservable: Observable<Node>;
  109904. private _onDisposeObserver;
  109905. /**
  109906. * Sets a callback that will be raised when the node will be disposed
  109907. */
  109908. set onDispose(callback: () => void);
  109909. /**
  109910. * Creates a new Node
  109911. * @param name the name and id to be given to this node
  109912. * @param scene the scene this node will be added to
  109913. */
  109914. constructor(name: string, scene?: Nullable<Scene>);
  109915. /**
  109916. * Gets the scene of the node
  109917. * @returns a scene
  109918. */
  109919. getScene(): Scene;
  109920. /**
  109921. * Gets the engine of the node
  109922. * @returns a Engine
  109923. */
  109924. getEngine(): Engine;
  109925. private _behaviors;
  109926. /**
  109927. * Attach a behavior to the node
  109928. * @see http://doc.babylonjs.com/features/behaviour
  109929. * @param behavior defines the behavior to attach
  109930. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  109931. * @returns the current Node
  109932. */
  109933. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  109934. /**
  109935. * Remove an attached behavior
  109936. * @see http://doc.babylonjs.com/features/behaviour
  109937. * @param behavior defines the behavior to attach
  109938. * @returns the current Node
  109939. */
  109940. removeBehavior(behavior: Behavior<Node>): Node;
  109941. /**
  109942. * Gets the list of attached behaviors
  109943. * @see http://doc.babylonjs.com/features/behaviour
  109944. */
  109945. get behaviors(): Behavior<Node>[];
  109946. /**
  109947. * Gets an attached behavior by name
  109948. * @param name defines the name of the behavior to look for
  109949. * @see http://doc.babylonjs.com/features/behaviour
  109950. * @returns null if behavior was not found else the requested behavior
  109951. */
  109952. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  109953. /**
  109954. * Returns the latest update of the World matrix
  109955. * @returns a Matrix
  109956. */
  109957. getWorldMatrix(): Matrix;
  109958. /** @hidden */
  109959. _getWorldMatrixDeterminant(): number;
  109960. /**
  109961. * Returns directly the latest state of the mesh World matrix.
  109962. * A Matrix is returned.
  109963. */
  109964. get worldMatrixFromCache(): Matrix;
  109965. /** @hidden */
  109966. _initCache(): void;
  109967. /** @hidden */
  109968. updateCache(force?: boolean): void;
  109969. /** @hidden */
  109970. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109971. /** @hidden */
  109972. _updateCache(ignoreParentClass?: boolean): void;
  109973. /** @hidden */
  109974. _isSynchronized(): boolean;
  109975. /** @hidden */
  109976. _markSyncedWithParent(): void;
  109977. /** @hidden */
  109978. isSynchronizedWithParent(): boolean;
  109979. /** @hidden */
  109980. isSynchronized(): boolean;
  109981. /**
  109982. * Is this node ready to be used/rendered
  109983. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109984. * @return true if the node is ready
  109985. */
  109986. isReady(completeCheck?: boolean): boolean;
  109987. /**
  109988. * Is this node enabled?
  109989. * 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
  109990. * @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
  109991. * @return whether this node (and its parent) is enabled
  109992. */
  109993. isEnabled(checkAncestors?: boolean): boolean;
  109994. /** @hidden */
  109995. protected _syncParentEnabledState(): void;
  109996. /**
  109997. * Set the enabled state of this node
  109998. * @param value defines the new enabled state
  109999. */
  110000. setEnabled(value: boolean): void;
  110001. /**
  110002. * Is this node a descendant of the given node?
  110003. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  110004. * @param ancestor defines the parent node to inspect
  110005. * @returns a boolean indicating if this node is a descendant of the given node
  110006. */
  110007. isDescendantOf(ancestor: Node): boolean;
  110008. /** @hidden */
  110009. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  110010. /**
  110011. * Will return all nodes that have this node as ascendant
  110012. * @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
  110013. * @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
  110014. * @return all children nodes of all types
  110015. */
  110016. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  110017. /**
  110018. * Get all child-meshes of this node
  110019. * @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)
  110020. * @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
  110021. * @returns an array of AbstractMesh
  110022. */
  110023. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  110024. /**
  110025. * Get all direct children of this node
  110026. * @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
  110027. * @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)
  110028. * @returns an array of Node
  110029. */
  110030. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  110031. /** @hidden */
  110032. _setReady(state: boolean): void;
  110033. /**
  110034. * Get an animation by name
  110035. * @param name defines the name of the animation to look for
  110036. * @returns null if not found else the requested animation
  110037. */
  110038. getAnimationByName(name: string): Nullable<Animation>;
  110039. /**
  110040. * Creates an animation range for this node
  110041. * @param name defines the name of the range
  110042. * @param from defines the starting key
  110043. * @param to defines the end key
  110044. */
  110045. createAnimationRange(name: string, from: number, to: number): void;
  110046. /**
  110047. * Delete a specific animation range
  110048. * @param name defines the name of the range to delete
  110049. * @param deleteFrames defines if animation frames from the range must be deleted as well
  110050. */
  110051. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110052. /**
  110053. * Get an animation range by name
  110054. * @param name defines the name of the animation range to look for
  110055. * @returns null if not found else the requested animation range
  110056. */
  110057. getAnimationRange(name: string): Nullable<AnimationRange>;
  110058. /**
  110059. * Gets the list of all animation ranges defined on this node
  110060. * @returns an array
  110061. */
  110062. getAnimationRanges(): Nullable<AnimationRange>[];
  110063. /**
  110064. * Will start the animation sequence
  110065. * @param name defines the range frames for animation sequence
  110066. * @param loop defines if the animation should loop (false by default)
  110067. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  110068. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  110069. * @returns the object created for this animation. If range does not exist, it will return null
  110070. */
  110071. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110072. /**
  110073. * Serialize animation ranges into a JSON compatible object
  110074. * @returns serialization object
  110075. */
  110076. serializeAnimationRanges(): any;
  110077. /**
  110078. * Computes the world matrix of the node
  110079. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  110080. * @returns the world matrix
  110081. */
  110082. computeWorldMatrix(force?: boolean): Matrix;
  110083. /**
  110084. * Releases resources associated with this node.
  110085. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110086. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110087. */
  110088. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110089. /**
  110090. * Parse animation range data from a serialization object and store them into a given node
  110091. * @param node defines where to store the animation ranges
  110092. * @param parsedNode defines the serialization object to read data from
  110093. * @param scene defines the hosting scene
  110094. */
  110095. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  110096. /**
  110097. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  110098. * @param includeDescendants Include bounding info from descendants as well (true by default)
  110099. * @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
  110100. * @returns the new bounding vectors
  110101. */
  110102. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110103. min: Vector3;
  110104. max: Vector3;
  110105. };
  110106. }
  110107. }
  110108. declare module BABYLON {
  110109. /**
  110110. * @hidden
  110111. */
  110112. export class _IAnimationState {
  110113. key: number;
  110114. repeatCount: number;
  110115. workValue?: any;
  110116. loopMode?: number;
  110117. offsetValue?: any;
  110118. highLimitValue?: any;
  110119. }
  110120. /**
  110121. * Class used to store any kind of animation
  110122. */
  110123. export class Animation {
  110124. /**Name of the animation */
  110125. name: string;
  110126. /**Property to animate */
  110127. targetProperty: string;
  110128. /**The frames per second of the animation */
  110129. framePerSecond: number;
  110130. /**The data type of the animation */
  110131. dataType: number;
  110132. /**The loop mode of the animation */
  110133. loopMode?: number | undefined;
  110134. /**Specifies if blending should be enabled */
  110135. enableBlending?: boolean | undefined;
  110136. /**
  110137. * Use matrix interpolation instead of using direct key value when animating matrices
  110138. */
  110139. static AllowMatricesInterpolation: boolean;
  110140. /**
  110141. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110142. */
  110143. static AllowMatrixDecomposeForInterpolation: boolean;
  110144. /** Define the Url to load snippets */
  110145. static SnippetUrl: string;
  110146. /** Snippet ID if the animation was created from the snippet server */
  110147. snippetId: string;
  110148. /**
  110149. * Stores the key frames of the animation
  110150. */
  110151. private _keys;
  110152. /**
  110153. * Stores the easing function of the animation
  110154. */
  110155. private _easingFunction;
  110156. /**
  110157. * @hidden Internal use only
  110158. */
  110159. _runtimeAnimations: RuntimeAnimation[];
  110160. /**
  110161. * The set of event that will be linked to this animation
  110162. */
  110163. private _events;
  110164. /**
  110165. * Stores an array of target property paths
  110166. */
  110167. targetPropertyPath: string[];
  110168. /**
  110169. * Stores the blending speed of the animation
  110170. */
  110171. blendingSpeed: number;
  110172. /**
  110173. * Stores the animation ranges for the animation
  110174. */
  110175. private _ranges;
  110176. /**
  110177. * @hidden Internal use
  110178. */
  110179. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110180. /**
  110181. * Sets up an animation
  110182. * @param property The property to animate
  110183. * @param animationType The animation type to apply
  110184. * @param framePerSecond The frames per second of the animation
  110185. * @param easingFunction The easing function used in the animation
  110186. * @returns The created animation
  110187. */
  110188. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110189. /**
  110190. * Create and start an animation on a node
  110191. * @param name defines the name of the global animation that will be run on all nodes
  110192. * @param node defines the root node where the animation will take place
  110193. * @param targetProperty defines property to animate
  110194. * @param framePerSecond defines the number of frame per second yo use
  110195. * @param totalFrame defines the number of frames in total
  110196. * @param from defines the initial value
  110197. * @param to defines the final value
  110198. * @param loopMode defines which loop mode you want to use (off by default)
  110199. * @param easingFunction defines the easing function to use (linear by default)
  110200. * @param onAnimationEnd defines the callback to call when animation end
  110201. * @returns the animatable created for this animation
  110202. */
  110203. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110204. /**
  110205. * Create and start an animation on a node and its descendants
  110206. * @param name defines the name of the global animation that will be run on all nodes
  110207. * @param node defines the root node where the animation will take place
  110208. * @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
  110209. * @param targetProperty defines property to animate
  110210. * @param framePerSecond defines the number of frame per second to use
  110211. * @param totalFrame defines the number of frames in total
  110212. * @param from defines the initial value
  110213. * @param to defines the final value
  110214. * @param loopMode defines which loop mode you want to use (off by default)
  110215. * @param easingFunction defines the easing function to use (linear by default)
  110216. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110217. * @returns the list of animatables created for all nodes
  110218. * @example https://www.babylonjs-playground.com/#MH0VLI
  110219. */
  110220. 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[]>;
  110221. /**
  110222. * Creates a new animation, merges it with the existing animations and starts it
  110223. * @param name Name of the animation
  110224. * @param node Node which contains the scene that begins the animations
  110225. * @param targetProperty Specifies which property to animate
  110226. * @param framePerSecond The frames per second of the animation
  110227. * @param totalFrame The total number of frames
  110228. * @param from The frame at the beginning of the animation
  110229. * @param to The frame at the end of the animation
  110230. * @param loopMode Specifies the loop mode of the animation
  110231. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110232. * @param onAnimationEnd Callback to run once the animation is complete
  110233. * @returns Nullable animation
  110234. */
  110235. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110236. /**
  110237. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110238. * @param sourceAnimation defines the Animation containing keyframes to convert
  110239. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110240. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  110241. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  110242. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  110243. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  110244. */
  110245. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  110246. /**
  110247. * Transition property of an host to the target Value
  110248. * @param property The property to transition
  110249. * @param targetValue The target Value of the property
  110250. * @param host The object where the property to animate belongs
  110251. * @param scene Scene used to run the animation
  110252. * @param frameRate Framerate (in frame/s) to use
  110253. * @param transition The transition type we want to use
  110254. * @param duration The duration of the animation, in milliseconds
  110255. * @param onAnimationEnd Callback trigger at the end of the animation
  110256. * @returns Nullable animation
  110257. */
  110258. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  110259. /**
  110260. * Return the array of runtime animations currently using this animation
  110261. */
  110262. get runtimeAnimations(): RuntimeAnimation[];
  110263. /**
  110264. * Specifies if any of the runtime animations are currently running
  110265. */
  110266. get hasRunningRuntimeAnimations(): boolean;
  110267. /**
  110268. * Initializes the animation
  110269. * @param name Name of the animation
  110270. * @param targetProperty Property to animate
  110271. * @param framePerSecond The frames per second of the animation
  110272. * @param dataType The data type of the animation
  110273. * @param loopMode The loop mode of the animation
  110274. * @param enableBlending Specifies if blending should be enabled
  110275. */
  110276. constructor(
  110277. /**Name of the animation */
  110278. name: string,
  110279. /**Property to animate */
  110280. targetProperty: string,
  110281. /**The frames per second of the animation */
  110282. framePerSecond: number,
  110283. /**The data type of the animation */
  110284. dataType: number,
  110285. /**The loop mode of the animation */
  110286. loopMode?: number | undefined,
  110287. /**Specifies if blending should be enabled */
  110288. enableBlending?: boolean | undefined);
  110289. /**
  110290. * Converts the animation to a string
  110291. * @param fullDetails support for multiple levels of logging within scene loading
  110292. * @returns String form of the animation
  110293. */
  110294. toString(fullDetails?: boolean): string;
  110295. /**
  110296. * Add an event to this animation
  110297. * @param event Event to add
  110298. */
  110299. addEvent(event: AnimationEvent): void;
  110300. /**
  110301. * Remove all events found at the given frame
  110302. * @param frame The frame to remove events from
  110303. */
  110304. removeEvents(frame: number): void;
  110305. /**
  110306. * Retrieves all the events from the animation
  110307. * @returns Events from the animation
  110308. */
  110309. getEvents(): AnimationEvent[];
  110310. /**
  110311. * Creates an animation range
  110312. * @param name Name of the animation range
  110313. * @param from Starting frame of the animation range
  110314. * @param to Ending frame of the animation
  110315. */
  110316. createRange(name: string, from: number, to: number): void;
  110317. /**
  110318. * Deletes an animation range by name
  110319. * @param name Name of the animation range to delete
  110320. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  110321. */
  110322. deleteRange(name: string, deleteFrames?: boolean): void;
  110323. /**
  110324. * Gets the animation range by name, or null if not defined
  110325. * @param name Name of the animation range
  110326. * @returns Nullable animation range
  110327. */
  110328. getRange(name: string): Nullable<AnimationRange>;
  110329. /**
  110330. * Gets the key frames from the animation
  110331. * @returns The key frames of the animation
  110332. */
  110333. getKeys(): Array<IAnimationKey>;
  110334. /**
  110335. * Gets the highest frame rate of the animation
  110336. * @returns Highest frame rate of the animation
  110337. */
  110338. getHighestFrame(): number;
  110339. /**
  110340. * Gets the easing function of the animation
  110341. * @returns Easing function of the animation
  110342. */
  110343. getEasingFunction(): IEasingFunction;
  110344. /**
  110345. * Sets the easing function of the animation
  110346. * @param easingFunction A custom mathematical formula for animation
  110347. */
  110348. setEasingFunction(easingFunction: EasingFunction): void;
  110349. /**
  110350. * Interpolates a scalar linearly
  110351. * @param startValue Start value of the animation curve
  110352. * @param endValue End value of the animation curve
  110353. * @param gradient Scalar amount to interpolate
  110354. * @returns Interpolated scalar value
  110355. */
  110356. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  110357. /**
  110358. * Interpolates a scalar cubically
  110359. * @param startValue Start value of the animation curve
  110360. * @param outTangent End tangent of the animation
  110361. * @param endValue End value of the animation curve
  110362. * @param inTangent Start tangent of the animation curve
  110363. * @param gradient Scalar amount to interpolate
  110364. * @returns Interpolated scalar value
  110365. */
  110366. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  110367. /**
  110368. * Interpolates a quaternion using a spherical linear interpolation
  110369. * @param startValue Start value of the animation curve
  110370. * @param endValue End value of the animation curve
  110371. * @param gradient Scalar amount to interpolate
  110372. * @returns Interpolated quaternion value
  110373. */
  110374. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  110375. /**
  110376. * Interpolates a quaternion cubically
  110377. * @param startValue Start value of the animation curve
  110378. * @param outTangent End tangent of the animation curve
  110379. * @param endValue End value of the animation curve
  110380. * @param inTangent Start tangent of the animation curve
  110381. * @param gradient Scalar amount to interpolate
  110382. * @returns Interpolated quaternion value
  110383. */
  110384. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  110385. /**
  110386. * Interpolates a Vector3 linearl
  110387. * @param startValue Start value of the animation curve
  110388. * @param endValue End value of the animation curve
  110389. * @param gradient Scalar amount to interpolate
  110390. * @returns Interpolated scalar value
  110391. */
  110392. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  110393. /**
  110394. * Interpolates a Vector3 cubically
  110395. * @param startValue Start value of the animation curve
  110396. * @param outTangent End tangent of the animation
  110397. * @param endValue End value of the animation curve
  110398. * @param inTangent Start tangent of the animation curve
  110399. * @param gradient Scalar amount to interpolate
  110400. * @returns InterpolatedVector3 value
  110401. */
  110402. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  110403. /**
  110404. * Interpolates a Vector2 linearly
  110405. * @param startValue Start value of the animation curve
  110406. * @param endValue End value of the animation curve
  110407. * @param gradient Scalar amount to interpolate
  110408. * @returns Interpolated Vector2 value
  110409. */
  110410. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  110411. /**
  110412. * Interpolates a Vector2 cubically
  110413. * @param startValue Start value of the animation curve
  110414. * @param outTangent End tangent of the animation
  110415. * @param endValue End value of the animation curve
  110416. * @param inTangent Start tangent of the animation curve
  110417. * @param gradient Scalar amount to interpolate
  110418. * @returns Interpolated Vector2 value
  110419. */
  110420. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  110421. /**
  110422. * Interpolates a size linearly
  110423. * @param startValue Start value of the animation curve
  110424. * @param endValue End value of the animation curve
  110425. * @param gradient Scalar amount to interpolate
  110426. * @returns Interpolated Size value
  110427. */
  110428. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  110429. /**
  110430. * Interpolates a Color3 linearly
  110431. * @param startValue Start value of the animation curve
  110432. * @param endValue End value of the animation curve
  110433. * @param gradient Scalar amount to interpolate
  110434. * @returns Interpolated Color3 value
  110435. */
  110436. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  110437. /**
  110438. * Interpolates a Color4 linearly
  110439. * @param startValue Start value of the animation curve
  110440. * @param endValue End value of the animation curve
  110441. * @param gradient Scalar amount to interpolate
  110442. * @returns Interpolated Color3 value
  110443. */
  110444. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  110445. /**
  110446. * @hidden Internal use only
  110447. */
  110448. _getKeyValue(value: any): any;
  110449. /**
  110450. * @hidden Internal use only
  110451. */
  110452. _interpolate(currentFrame: number, state: _IAnimationState): any;
  110453. /**
  110454. * Defines the function to use to interpolate matrices
  110455. * @param startValue defines the start matrix
  110456. * @param endValue defines the end matrix
  110457. * @param gradient defines the gradient between both matrices
  110458. * @param result defines an optional target matrix where to store the interpolation
  110459. * @returns the interpolated matrix
  110460. */
  110461. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  110462. /**
  110463. * Makes a copy of the animation
  110464. * @returns Cloned animation
  110465. */
  110466. clone(): Animation;
  110467. /**
  110468. * Sets the key frames of the animation
  110469. * @param values The animation key frames to set
  110470. */
  110471. setKeys(values: Array<IAnimationKey>): void;
  110472. /**
  110473. * Serializes the animation to an object
  110474. * @returns Serialized object
  110475. */
  110476. serialize(): any;
  110477. /**
  110478. * Float animation type
  110479. */
  110480. static readonly ANIMATIONTYPE_FLOAT: number;
  110481. /**
  110482. * Vector3 animation type
  110483. */
  110484. static readonly ANIMATIONTYPE_VECTOR3: number;
  110485. /**
  110486. * Quaternion animation type
  110487. */
  110488. static readonly ANIMATIONTYPE_QUATERNION: number;
  110489. /**
  110490. * Matrix animation type
  110491. */
  110492. static readonly ANIMATIONTYPE_MATRIX: number;
  110493. /**
  110494. * Color3 animation type
  110495. */
  110496. static readonly ANIMATIONTYPE_COLOR3: number;
  110497. /**
  110498. * Color3 animation type
  110499. */
  110500. static readonly ANIMATIONTYPE_COLOR4: number;
  110501. /**
  110502. * Vector2 animation type
  110503. */
  110504. static readonly ANIMATIONTYPE_VECTOR2: number;
  110505. /**
  110506. * Size animation type
  110507. */
  110508. static readonly ANIMATIONTYPE_SIZE: number;
  110509. /**
  110510. * Relative Loop Mode
  110511. */
  110512. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  110513. /**
  110514. * Cycle Loop Mode
  110515. */
  110516. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  110517. /**
  110518. * Constant Loop Mode
  110519. */
  110520. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  110521. /** @hidden */
  110522. static _UniversalLerp(left: any, right: any, amount: number): any;
  110523. /**
  110524. * Parses an animation object and creates an animation
  110525. * @param parsedAnimation Parsed animation object
  110526. * @returns Animation object
  110527. */
  110528. static Parse(parsedAnimation: any): Animation;
  110529. /**
  110530. * Appends the serialized animations from the source animations
  110531. * @param source Source containing the animations
  110532. * @param destination Target to store the animations
  110533. */
  110534. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110535. /**
  110536. * Creates a new animation or an array of animations from a snippet saved in a remote file
  110537. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  110538. * @param url defines the url to load from
  110539. * @returns a promise that will resolve to the new animation or an array of animations
  110540. */
  110541. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  110542. /**
  110543. * Creates an animation or an array of animations from a snippet saved by the Inspector
  110544. * @param snippetId defines the snippet to load
  110545. * @returns a promise that will resolve to the new animation or a new array of animations
  110546. */
  110547. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  110548. }
  110549. }
  110550. declare module BABYLON {
  110551. /**
  110552. * Interface containing an array of animations
  110553. */
  110554. export interface IAnimatable {
  110555. /**
  110556. * Array of animations
  110557. */
  110558. animations: Nullable<Array<Animation>>;
  110559. }
  110560. }
  110561. declare module BABYLON {
  110562. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  110563. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110564. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110565. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110566. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110567. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110568. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110569. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110570. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110571. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110572. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110573. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110574. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110575. /**
  110576. * Decorator used to define property that can be serialized as reference to a camera
  110577. * @param sourceName defines the name of the property to decorate
  110578. */
  110579. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110580. /**
  110581. * Class used to help serialization objects
  110582. */
  110583. export class SerializationHelper {
  110584. /** @hidden */
  110585. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  110586. /** @hidden */
  110587. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  110588. /** @hidden */
  110589. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  110590. /** @hidden */
  110591. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  110592. /**
  110593. * Appends the serialized animations from the source animations
  110594. * @param source Source containing the animations
  110595. * @param destination Target to store the animations
  110596. */
  110597. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110598. /**
  110599. * Static function used to serialized a specific entity
  110600. * @param entity defines the entity to serialize
  110601. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  110602. * @returns a JSON compatible object representing the serialization of the entity
  110603. */
  110604. static Serialize<T>(entity: T, serializationObject?: any): any;
  110605. /**
  110606. * Creates a new entity from a serialization data object
  110607. * @param creationFunction defines a function used to instanciated the new entity
  110608. * @param source defines the source serialization data
  110609. * @param scene defines the hosting scene
  110610. * @param rootUrl defines the root url for resources
  110611. * @returns a new entity
  110612. */
  110613. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  110614. /**
  110615. * Clones an object
  110616. * @param creationFunction defines the function used to instanciate the new object
  110617. * @param source defines the source object
  110618. * @returns the cloned object
  110619. */
  110620. static Clone<T>(creationFunction: () => T, source: T): T;
  110621. /**
  110622. * Instanciates a new object based on a source one (some data will be shared between both object)
  110623. * @param creationFunction defines the function used to instanciate the new object
  110624. * @param source defines the source object
  110625. * @returns the new object
  110626. */
  110627. static Instanciate<T>(creationFunction: () => T, source: T): T;
  110628. }
  110629. }
  110630. declare module BABYLON {
  110631. /**
  110632. * Base class of all the textures in babylon.
  110633. * It groups all the common properties the materials, post process, lights... might need
  110634. * in order to make a correct use of the texture.
  110635. */
  110636. export class BaseTexture implements IAnimatable {
  110637. /**
  110638. * Default anisotropic filtering level for the application.
  110639. * It is set to 4 as a good tradeoff between perf and quality.
  110640. */
  110641. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  110642. /**
  110643. * Gets or sets the unique id of the texture
  110644. */
  110645. uniqueId: number;
  110646. /**
  110647. * Define the name of the texture.
  110648. */
  110649. name: string;
  110650. /**
  110651. * Gets or sets an object used to store user defined information.
  110652. */
  110653. metadata: any;
  110654. /**
  110655. * For internal use only. Please do not use.
  110656. */
  110657. reservedDataStore: any;
  110658. private _hasAlpha;
  110659. /**
  110660. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  110661. */
  110662. set hasAlpha(value: boolean);
  110663. get hasAlpha(): boolean;
  110664. /**
  110665. * Defines if the alpha value should be determined via the rgb values.
  110666. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  110667. */
  110668. getAlphaFromRGB: boolean;
  110669. /**
  110670. * Intensity or strength of the texture.
  110671. * It is commonly used by materials to fine tune the intensity of the texture
  110672. */
  110673. level: number;
  110674. /**
  110675. * Define the UV chanel to use starting from 0 and defaulting to 0.
  110676. * This is part of the texture as textures usually maps to one uv set.
  110677. */
  110678. coordinatesIndex: number;
  110679. private _coordinatesMode;
  110680. /**
  110681. * How a texture is mapped.
  110682. *
  110683. * | Value | Type | Description |
  110684. * | ----- | ----------------------------------- | ----------- |
  110685. * | 0 | EXPLICIT_MODE | |
  110686. * | 1 | SPHERICAL_MODE | |
  110687. * | 2 | PLANAR_MODE | |
  110688. * | 3 | CUBIC_MODE | |
  110689. * | 4 | PROJECTION_MODE | |
  110690. * | 5 | SKYBOX_MODE | |
  110691. * | 6 | INVCUBIC_MODE | |
  110692. * | 7 | EQUIRECTANGULAR_MODE | |
  110693. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  110694. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  110695. */
  110696. set coordinatesMode(value: number);
  110697. get coordinatesMode(): number;
  110698. /**
  110699. * | Value | Type | Description |
  110700. * | ----- | ------------------ | ----------- |
  110701. * | 0 | CLAMP_ADDRESSMODE | |
  110702. * | 1 | WRAP_ADDRESSMODE | |
  110703. * | 2 | MIRROR_ADDRESSMODE | |
  110704. */
  110705. wrapU: number;
  110706. /**
  110707. * | Value | Type | Description |
  110708. * | ----- | ------------------ | ----------- |
  110709. * | 0 | CLAMP_ADDRESSMODE | |
  110710. * | 1 | WRAP_ADDRESSMODE | |
  110711. * | 2 | MIRROR_ADDRESSMODE | |
  110712. */
  110713. wrapV: number;
  110714. /**
  110715. * | Value | Type | Description |
  110716. * | ----- | ------------------ | ----------- |
  110717. * | 0 | CLAMP_ADDRESSMODE | |
  110718. * | 1 | WRAP_ADDRESSMODE | |
  110719. * | 2 | MIRROR_ADDRESSMODE | |
  110720. */
  110721. wrapR: number;
  110722. /**
  110723. * With compliant hardware and browser (supporting anisotropic filtering)
  110724. * this defines the level of anisotropic filtering in the texture.
  110725. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  110726. */
  110727. anisotropicFilteringLevel: number;
  110728. /**
  110729. * Define if the texture is a cube texture or if false a 2d texture.
  110730. */
  110731. get isCube(): boolean;
  110732. set isCube(value: boolean);
  110733. /**
  110734. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  110735. */
  110736. get is3D(): boolean;
  110737. set is3D(value: boolean);
  110738. /**
  110739. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  110740. */
  110741. get is2DArray(): boolean;
  110742. set is2DArray(value: boolean);
  110743. /**
  110744. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  110745. * HDR texture are usually stored in linear space.
  110746. * This only impacts the PBR and Background materials
  110747. */
  110748. gammaSpace: boolean;
  110749. /**
  110750. * Gets or sets whether or not the texture contains RGBD data.
  110751. */
  110752. get isRGBD(): boolean;
  110753. set isRGBD(value: boolean);
  110754. /**
  110755. * Is Z inverted in the texture (useful in a cube texture).
  110756. */
  110757. invertZ: boolean;
  110758. /**
  110759. * Are mip maps generated for this texture or not.
  110760. */
  110761. get noMipmap(): boolean;
  110762. /**
  110763. * @hidden
  110764. */
  110765. lodLevelInAlpha: boolean;
  110766. /**
  110767. * With prefiltered texture, defined the offset used during the prefiltering steps.
  110768. */
  110769. get lodGenerationOffset(): number;
  110770. set lodGenerationOffset(value: number);
  110771. /**
  110772. * With prefiltered texture, defined the scale used during the prefiltering steps.
  110773. */
  110774. get lodGenerationScale(): number;
  110775. set lodGenerationScale(value: number);
  110776. /**
  110777. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  110778. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  110779. * average roughness values.
  110780. */
  110781. get linearSpecularLOD(): boolean;
  110782. set linearSpecularLOD(value: boolean);
  110783. /**
  110784. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  110785. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  110786. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  110787. */
  110788. get irradianceTexture(): Nullable<BaseTexture>;
  110789. set irradianceTexture(value: Nullable<BaseTexture>);
  110790. /**
  110791. * Define if the texture is a render target.
  110792. */
  110793. isRenderTarget: boolean;
  110794. /**
  110795. * Define the unique id of the texture in the scene.
  110796. */
  110797. get uid(): string;
  110798. /** @hidden */
  110799. _prefiltered: boolean;
  110800. /**
  110801. * Return a string representation of the texture.
  110802. * @returns the texture as a string
  110803. */
  110804. toString(): string;
  110805. /**
  110806. * Get the class name of the texture.
  110807. * @returns "BaseTexture"
  110808. */
  110809. getClassName(): string;
  110810. /**
  110811. * Define the list of animation attached to the texture.
  110812. */
  110813. animations: Animation[];
  110814. /**
  110815. * An event triggered when the texture is disposed.
  110816. */
  110817. onDisposeObservable: Observable<BaseTexture>;
  110818. private _onDisposeObserver;
  110819. /**
  110820. * Callback triggered when the texture has been disposed.
  110821. * Kept for back compatibility, you can use the onDisposeObservable instead.
  110822. */
  110823. set onDispose(callback: () => void);
  110824. /**
  110825. * Define the current state of the loading sequence when in delayed load mode.
  110826. */
  110827. delayLoadState: number;
  110828. private _scene;
  110829. private _engine;
  110830. /** @hidden */
  110831. _texture: Nullable<InternalTexture>;
  110832. private _uid;
  110833. /**
  110834. * Define if the texture is preventinga material to render or not.
  110835. * If not and the texture is not ready, the engine will use a default black texture instead.
  110836. */
  110837. get isBlocking(): boolean;
  110838. /**
  110839. * Instantiates a new BaseTexture.
  110840. * Base class of all the textures in babylon.
  110841. * It groups all the common properties the materials, post process, lights... might need
  110842. * in order to make a correct use of the texture.
  110843. * @param sceneOrEngine Define the scene or engine the texture blongs to
  110844. */
  110845. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  110846. /**
  110847. * Get the scene the texture belongs to.
  110848. * @returns the scene or null if undefined
  110849. */
  110850. getScene(): Nullable<Scene>;
  110851. /** @hidden */
  110852. protected _getEngine(): Nullable<ThinEngine>;
  110853. /**
  110854. * Get the texture transform matrix used to offset tile the texture for istance.
  110855. * @returns the transformation matrix
  110856. */
  110857. getTextureMatrix(): Matrix;
  110858. /**
  110859. * Get the texture reflection matrix used to rotate/transform the reflection.
  110860. * @returns the reflection matrix
  110861. */
  110862. getReflectionTextureMatrix(): Matrix;
  110863. /**
  110864. * Get the underlying lower level texture from Babylon.
  110865. * @returns the insternal texture
  110866. */
  110867. getInternalTexture(): Nullable<InternalTexture>;
  110868. /**
  110869. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  110870. * @returns true if ready or not blocking
  110871. */
  110872. isReadyOrNotBlocking(): boolean;
  110873. /**
  110874. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  110875. * @returns true if fully ready
  110876. */
  110877. isReady(): boolean;
  110878. private _cachedSize;
  110879. /**
  110880. * Get the size of the texture.
  110881. * @returns the texture size.
  110882. */
  110883. getSize(): ISize;
  110884. /**
  110885. * Get the base size of the texture.
  110886. * It can be different from the size if the texture has been resized for POT for instance
  110887. * @returns the base size
  110888. */
  110889. getBaseSize(): ISize;
  110890. /**
  110891. * Update the sampling mode of the texture.
  110892. * Default is Trilinear mode.
  110893. *
  110894. * | Value | Type | Description |
  110895. * | ----- | ------------------ | ----------- |
  110896. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  110897. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  110898. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  110899. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  110900. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  110901. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  110902. * | 7 | NEAREST_LINEAR | |
  110903. * | 8 | NEAREST_NEAREST | |
  110904. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  110905. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  110906. * | 11 | LINEAR_LINEAR | |
  110907. * | 12 | LINEAR_NEAREST | |
  110908. *
  110909. * > _mag_: magnification filter (close to the viewer)
  110910. * > _min_: minification filter (far from the viewer)
  110911. * > _mip_: filter used between mip map levels
  110912. *@param samplingMode Define the new sampling mode of the texture
  110913. */
  110914. updateSamplingMode(samplingMode: number): void;
  110915. /**
  110916. * Scales the texture if is `canRescale()`
  110917. * @param ratio the resize factor we want to use to rescale
  110918. */
  110919. scale(ratio: number): void;
  110920. /**
  110921. * Get if the texture can rescale.
  110922. */
  110923. get canRescale(): boolean;
  110924. /** @hidden */
  110925. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  110926. /** @hidden */
  110927. _rebuild(): void;
  110928. /**
  110929. * Triggers the load sequence in delayed load mode.
  110930. */
  110931. delayLoad(): void;
  110932. /**
  110933. * Clones the texture.
  110934. * @returns the cloned texture
  110935. */
  110936. clone(): Nullable<BaseTexture>;
  110937. /**
  110938. * Get the texture underlying type (INT, FLOAT...)
  110939. */
  110940. get textureType(): number;
  110941. /**
  110942. * Get the texture underlying format (RGB, RGBA...)
  110943. */
  110944. get textureFormat(): number;
  110945. /**
  110946. * Indicates that textures need to be re-calculated for all materials
  110947. */
  110948. protected _markAllSubMeshesAsTexturesDirty(): void;
  110949. /**
  110950. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  110951. * This will returns an RGBA array buffer containing either in values (0-255) or
  110952. * float values (0-1) depending of the underlying buffer type.
  110953. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  110954. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  110955. * @param buffer defines a user defined buffer to fill with data (can be null)
  110956. * @returns The Array buffer containing the pixels data.
  110957. */
  110958. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  110959. /**
  110960. * Release and destroy the underlying lower level texture aka internalTexture.
  110961. */
  110962. releaseInternalTexture(): void;
  110963. /** @hidden */
  110964. get _lodTextureHigh(): Nullable<BaseTexture>;
  110965. /** @hidden */
  110966. get _lodTextureMid(): Nullable<BaseTexture>;
  110967. /** @hidden */
  110968. get _lodTextureLow(): Nullable<BaseTexture>;
  110969. /**
  110970. * Dispose the texture and release its associated resources.
  110971. */
  110972. dispose(): void;
  110973. /**
  110974. * Serialize the texture into a JSON representation that can be parsed later on.
  110975. * @returns the JSON representation of the texture
  110976. */
  110977. serialize(): any;
  110978. /**
  110979. * Helper function to be called back once a list of texture contains only ready textures.
  110980. * @param textures Define the list of textures to wait for
  110981. * @param callback Define the callback triggered once the entire list will be ready
  110982. */
  110983. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  110984. private static _isScene;
  110985. }
  110986. }
  110987. declare module BABYLON {
  110988. /**
  110989. * Options to be used when creating an effect.
  110990. */
  110991. export interface IEffectCreationOptions {
  110992. /**
  110993. * Atrributes that will be used in the shader.
  110994. */
  110995. attributes: string[];
  110996. /**
  110997. * Uniform varible names that will be set in the shader.
  110998. */
  110999. uniformsNames: string[];
  111000. /**
  111001. * Uniform buffer variable names that will be set in the shader.
  111002. */
  111003. uniformBuffersNames: string[];
  111004. /**
  111005. * Sampler texture variable names that will be set in the shader.
  111006. */
  111007. samplers: string[];
  111008. /**
  111009. * Define statements that will be set in the shader.
  111010. */
  111011. defines: any;
  111012. /**
  111013. * Possible fallbacks for this effect to improve performance when needed.
  111014. */
  111015. fallbacks: Nullable<IEffectFallbacks>;
  111016. /**
  111017. * Callback that will be called when the shader is compiled.
  111018. */
  111019. onCompiled: Nullable<(effect: Effect) => void>;
  111020. /**
  111021. * Callback that will be called if an error occurs during shader compilation.
  111022. */
  111023. onError: Nullable<(effect: Effect, errors: string) => void>;
  111024. /**
  111025. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111026. */
  111027. indexParameters?: any;
  111028. /**
  111029. * Max number of lights that can be used in the shader.
  111030. */
  111031. maxSimultaneousLights?: number;
  111032. /**
  111033. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  111034. */
  111035. transformFeedbackVaryings?: Nullable<string[]>;
  111036. /**
  111037. * 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
  111038. */
  111039. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  111040. }
  111041. /**
  111042. * Effect containing vertex and fragment shader that can be executed on an object.
  111043. */
  111044. export class Effect implements IDisposable {
  111045. /**
  111046. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111047. */
  111048. static ShadersRepository: string;
  111049. /**
  111050. * Enable logging of the shader code when a compilation error occurs
  111051. */
  111052. static LogShaderCodeOnCompilationError: boolean;
  111053. /**
  111054. * Name of the effect.
  111055. */
  111056. name: any;
  111057. /**
  111058. * String container all the define statements that should be set on the shader.
  111059. */
  111060. defines: string;
  111061. /**
  111062. * Callback that will be called when the shader is compiled.
  111063. */
  111064. onCompiled: Nullable<(effect: Effect) => void>;
  111065. /**
  111066. * Callback that will be called if an error occurs during shader compilation.
  111067. */
  111068. onError: Nullable<(effect: Effect, errors: string) => void>;
  111069. /**
  111070. * Callback that will be called when effect is bound.
  111071. */
  111072. onBind: Nullable<(effect: Effect) => void>;
  111073. /**
  111074. * Unique ID of the effect.
  111075. */
  111076. uniqueId: number;
  111077. /**
  111078. * Observable that will be called when the shader is compiled.
  111079. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  111080. */
  111081. onCompileObservable: Observable<Effect>;
  111082. /**
  111083. * Observable that will be called if an error occurs during shader compilation.
  111084. */
  111085. onErrorObservable: Observable<Effect>;
  111086. /** @hidden */
  111087. _onBindObservable: Nullable<Observable<Effect>>;
  111088. /**
  111089. * @hidden
  111090. * Specifies if the effect was previously ready
  111091. */
  111092. _wasPreviouslyReady: boolean;
  111093. /**
  111094. * Observable that will be called when effect is bound.
  111095. */
  111096. get onBindObservable(): Observable<Effect>;
  111097. /** @hidden */
  111098. _bonesComputationForcedToCPU: boolean;
  111099. private static _uniqueIdSeed;
  111100. private _engine;
  111101. private _uniformBuffersNames;
  111102. private _uniformBuffersNamesList;
  111103. private _uniformsNames;
  111104. private _samplerList;
  111105. private _samplers;
  111106. private _isReady;
  111107. private _compilationError;
  111108. private _allFallbacksProcessed;
  111109. private _attributesNames;
  111110. private _attributes;
  111111. private _attributeLocationByName;
  111112. private _uniforms;
  111113. /**
  111114. * Key for the effect.
  111115. * @hidden
  111116. */
  111117. _key: string;
  111118. private _indexParameters;
  111119. private _fallbacks;
  111120. private _vertexSourceCode;
  111121. private _fragmentSourceCode;
  111122. private _vertexSourceCodeOverride;
  111123. private _fragmentSourceCodeOverride;
  111124. private _transformFeedbackVaryings;
  111125. /**
  111126. * Compiled shader to webGL program.
  111127. * @hidden
  111128. */
  111129. _pipelineContext: Nullable<IPipelineContext>;
  111130. private _valueCache;
  111131. private static _baseCache;
  111132. /**
  111133. * Instantiates an effect.
  111134. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111135. * @param baseName Name of the effect.
  111136. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111137. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111138. * @param samplers List of sampler variables that will be passed to the shader.
  111139. * @param engine Engine to be used to render the effect
  111140. * @param defines Define statements to be added to the shader.
  111141. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111142. * @param onCompiled Callback that will be called when the shader is compiled.
  111143. * @param onError Callback that will be called if an error occurs during shader compilation.
  111144. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111145. */
  111146. 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);
  111147. private _useFinalCode;
  111148. /**
  111149. * Unique key for this effect
  111150. */
  111151. get key(): string;
  111152. /**
  111153. * If the effect has been compiled and prepared.
  111154. * @returns if the effect is compiled and prepared.
  111155. */
  111156. isReady(): boolean;
  111157. private _isReadyInternal;
  111158. /**
  111159. * The engine the effect was initialized with.
  111160. * @returns the engine.
  111161. */
  111162. getEngine(): Engine;
  111163. /**
  111164. * The pipeline context for this effect
  111165. * @returns the associated pipeline context
  111166. */
  111167. getPipelineContext(): Nullable<IPipelineContext>;
  111168. /**
  111169. * The set of names of attribute variables for the shader.
  111170. * @returns An array of attribute names.
  111171. */
  111172. getAttributesNames(): string[];
  111173. /**
  111174. * Returns the attribute at the given index.
  111175. * @param index The index of the attribute.
  111176. * @returns The location of the attribute.
  111177. */
  111178. getAttributeLocation(index: number): number;
  111179. /**
  111180. * Returns the attribute based on the name of the variable.
  111181. * @param name of the attribute to look up.
  111182. * @returns the attribute location.
  111183. */
  111184. getAttributeLocationByName(name: string): number;
  111185. /**
  111186. * The number of attributes.
  111187. * @returns the numnber of attributes.
  111188. */
  111189. getAttributesCount(): number;
  111190. /**
  111191. * Gets the index of a uniform variable.
  111192. * @param uniformName of the uniform to look up.
  111193. * @returns the index.
  111194. */
  111195. getUniformIndex(uniformName: string): number;
  111196. /**
  111197. * Returns the attribute based on the name of the variable.
  111198. * @param uniformName of the uniform to look up.
  111199. * @returns the location of the uniform.
  111200. */
  111201. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111202. /**
  111203. * Returns an array of sampler variable names
  111204. * @returns The array of sampler variable names.
  111205. */
  111206. getSamplers(): string[];
  111207. /**
  111208. * Returns an array of uniform variable names
  111209. * @returns The array of uniform variable names.
  111210. */
  111211. getUniformNames(): string[];
  111212. /**
  111213. * Returns an array of uniform buffer variable names
  111214. * @returns The array of uniform buffer variable names.
  111215. */
  111216. getUniformBuffersNames(): string[];
  111217. /**
  111218. * Returns the index parameters used to create the effect
  111219. * @returns The index parameters object
  111220. */
  111221. getIndexParameters(): any;
  111222. /**
  111223. * The error from the last compilation.
  111224. * @returns the error string.
  111225. */
  111226. getCompilationError(): string;
  111227. /**
  111228. * Gets a boolean indicating that all fallbacks were used during compilation
  111229. * @returns true if all fallbacks were used
  111230. */
  111231. allFallbacksProcessed(): boolean;
  111232. /**
  111233. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  111234. * @param func The callback to be used.
  111235. */
  111236. executeWhenCompiled(func: (effect: Effect) => void): void;
  111237. private _checkIsReady;
  111238. private _loadShader;
  111239. /**
  111240. * Gets the vertex shader source code of this effect
  111241. */
  111242. get vertexSourceCode(): string;
  111243. /**
  111244. * Gets the fragment shader source code of this effect
  111245. */
  111246. get fragmentSourceCode(): string;
  111247. /**
  111248. * Recompiles the webGL program
  111249. * @param vertexSourceCode The source code for the vertex shader.
  111250. * @param fragmentSourceCode The source code for the fragment shader.
  111251. * @param onCompiled Callback called when completed.
  111252. * @param onError Callback called on error.
  111253. * @hidden
  111254. */
  111255. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  111256. /**
  111257. * Prepares the effect
  111258. * @hidden
  111259. */
  111260. _prepareEffect(): void;
  111261. private _getShaderCodeAndErrorLine;
  111262. private _processCompilationErrors;
  111263. /**
  111264. * Checks if the effect is supported. (Must be called after compilation)
  111265. */
  111266. get isSupported(): boolean;
  111267. /**
  111268. * Binds a texture to the engine to be used as output of the shader.
  111269. * @param channel Name of the output variable.
  111270. * @param texture Texture to bind.
  111271. * @hidden
  111272. */
  111273. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  111274. /**
  111275. * Sets a texture on the engine to be used in the shader.
  111276. * @param channel Name of the sampler variable.
  111277. * @param texture Texture to set.
  111278. */
  111279. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  111280. /**
  111281. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  111282. * @param channel Name of the sampler variable.
  111283. * @param texture Texture to set.
  111284. */
  111285. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  111286. /**
  111287. * Sets an array of textures on the engine to be used in the shader.
  111288. * @param channel Name of the variable.
  111289. * @param textures Textures to set.
  111290. */
  111291. setTextureArray(channel: string, textures: BaseTexture[]): void;
  111292. /**
  111293. * 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)
  111294. * @param channel Name of the sampler variable.
  111295. * @param postProcess Post process to get the input texture from.
  111296. */
  111297. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  111298. /**
  111299. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  111300. * 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)
  111301. * @param channel Name of the sampler variable.
  111302. * @param postProcess Post process to get the output texture from.
  111303. */
  111304. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  111305. /** @hidden */
  111306. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  111307. /** @hidden */
  111308. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  111309. /** @hidden */
  111310. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  111311. /** @hidden */
  111312. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  111313. /**
  111314. * Binds a buffer to a uniform.
  111315. * @param buffer Buffer to bind.
  111316. * @param name Name of the uniform variable to bind to.
  111317. */
  111318. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  111319. /**
  111320. * Binds block to a uniform.
  111321. * @param blockName Name of the block to bind.
  111322. * @param index Index to bind.
  111323. */
  111324. bindUniformBlock(blockName: string, index: number): void;
  111325. /**
  111326. * Sets an interger value on a uniform variable.
  111327. * @param uniformName Name of the variable.
  111328. * @param value Value to be set.
  111329. * @returns this effect.
  111330. */
  111331. setInt(uniformName: string, value: number): Effect;
  111332. /**
  111333. * Sets an int array on a uniform variable.
  111334. * @param uniformName Name of the variable.
  111335. * @param array array to be set.
  111336. * @returns this effect.
  111337. */
  111338. setIntArray(uniformName: string, array: Int32Array): Effect;
  111339. /**
  111340. * 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)
  111341. * @param uniformName Name of the variable.
  111342. * @param array array to be set.
  111343. * @returns this effect.
  111344. */
  111345. setIntArray2(uniformName: string, array: Int32Array): Effect;
  111346. /**
  111347. * 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)
  111348. * @param uniformName Name of the variable.
  111349. * @param array array to be set.
  111350. * @returns this effect.
  111351. */
  111352. setIntArray3(uniformName: string, array: Int32Array): Effect;
  111353. /**
  111354. * 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)
  111355. * @param uniformName Name of the variable.
  111356. * @param array array to be set.
  111357. * @returns this effect.
  111358. */
  111359. setIntArray4(uniformName: string, array: Int32Array): Effect;
  111360. /**
  111361. * Sets an float array on a uniform variable.
  111362. * @param uniformName Name of the variable.
  111363. * @param array array to be set.
  111364. * @returns this effect.
  111365. */
  111366. setFloatArray(uniformName: string, array: Float32Array): Effect;
  111367. /**
  111368. * 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)
  111369. * @param uniformName Name of the variable.
  111370. * @param array array to be set.
  111371. * @returns this effect.
  111372. */
  111373. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  111374. /**
  111375. * 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)
  111376. * @param uniformName Name of the variable.
  111377. * @param array array to be set.
  111378. * @returns this effect.
  111379. */
  111380. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  111381. /**
  111382. * 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)
  111383. * @param uniformName Name of the variable.
  111384. * @param array array to be set.
  111385. * @returns this effect.
  111386. */
  111387. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  111388. /**
  111389. * Sets an array on a uniform variable.
  111390. * @param uniformName Name of the variable.
  111391. * @param array array to be set.
  111392. * @returns this effect.
  111393. */
  111394. setArray(uniformName: string, array: number[]): Effect;
  111395. /**
  111396. * 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)
  111397. * @param uniformName Name of the variable.
  111398. * @param array array to be set.
  111399. * @returns this effect.
  111400. */
  111401. setArray2(uniformName: string, array: number[]): Effect;
  111402. /**
  111403. * 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)
  111404. * @param uniformName Name of the variable.
  111405. * @param array array to be set.
  111406. * @returns this effect.
  111407. */
  111408. setArray3(uniformName: string, array: number[]): Effect;
  111409. /**
  111410. * 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)
  111411. * @param uniformName Name of the variable.
  111412. * @param array array to be set.
  111413. * @returns this effect.
  111414. */
  111415. setArray4(uniformName: string, array: number[]): Effect;
  111416. /**
  111417. * Sets matrices on a uniform variable.
  111418. * @param uniformName Name of the variable.
  111419. * @param matrices matrices to be set.
  111420. * @returns this effect.
  111421. */
  111422. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  111423. /**
  111424. * Sets matrix on a uniform variable.
  111425. * @param uniformName Name of the variable.
  111426. * @param matrix matrix to be set.
  111427. * @returns this effect.
  111428. */
  111429. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  111430. /**
  111431. * 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)
  111432. * @param uniformName Name of the variable.
  111433. * @param matrix matrix to be set.
  111434. * @returns this effect.
  111435. */
  111436. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  111437. /**
  111438. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  111439. * @param uniformName Name of the variable.
  111440. * @param matrix matrix to be set.
  111441. * @returns this effect.
  111442. */
  111443. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  111444. /**
  111445. * Sets a float on a uniform variable.
  111446. * @param uniformName Name of the variable.
  111447. * @param value value to be set.
  111448. * @returns this effect.
  111449. */
  111450. setFloat(uniformName: string, value: number): Effect;
  111451. /**
  111452. * Sets a boolean on a uniform variable.
  111453. * @param uniformName Name of the variable.
  111454. * @param bool value to be set.
  111455. * @returns this effect.
  111456. */
  111457. setBool(uniformName: string, bool: boolean): Effect;
  111458. /**
  111459. * Sets a Vector2 on a uniform variable.
  111460. * @param uniformName Name of the variable.
  111461. * @param vector2 vector2 to be set.
  111462. * @returns this effect.
  111463. */
  111464. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  111465. /**
  111466. * Sets a float2 on a uniform variable.
  111467. * @param uniformName Name of the variable.
  111468. * @param x First float in float2.
  111469. * @param y Second float in float2.
  111470. * @returns this effect.
  111471. */
  111472. setFloat2(uniformName: string, x: number, y: number): Effect;
  111473. /**
  111474. * Sets a Vector3 on a uniform variable.
  111475. * @param uniformName Name of the variable.
  111476. * @param vector3 Value to be set.
  111477. * @returns this effect.
  111478. */
  111479. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  111480. /**
  111481. * Sets a float3 on a uniform variable.
  111482. * @param uniformName Name of the variable.
  111483. * @param x First float in float3.
  111484. * @param y Second float in float3.
  111485. * @param z Third float in float3.
  111486. * @returns this effect.
  111487. */
  111488. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  111489. /**
  111490. * Sets a Vector4 on a uniform variable.
  111491. * @param uniformName Name of the variable.
  111492. * @param vector4 Value to be set.
  111493. * @returns this effect.
  111494. */
  111495. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  111496. /**
  111497. * Sets a float4 on a uniform variable.
  111498. * @param uniformName Name of the variable.
  111499. * @param x First float in float4.
  111500. * @param y Second float in float4.
  111501. * @param z Third float in float4.
  111502. * @param w Fourth float in float4.
  111503. * @returns this effect.
  111504. */
  111505. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  111506. /**
  111507. * Sets a Color3 on a uniform variable.
  111508. * @param uniformName Name of the variable.
  111509. * @param color3 Value to be set.
  111510. * @returns this effect.
  111511. */
  111512. setColor3(uniformName: string, color3: IColor3Like): Effect;
  111513. /**
  111514. * Sets a Color4 on a uniform variable.
  111515. * @param uniformName Name of the variable.
  111516. * @param color3 Value to be set.
  111517. * @param alpha Alpha value to be set.
  111518. * @returns this effect.
  111519. */
  111520. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  111521. /**
  111522. * Sets a Color4 on a uniform variable
  111523. * @param uniformName defines the name of the variable
  111524. * @param color4 defines the value to be set
  111525. * @returns this effect.
  111526. */
  111527. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  111528. /** Release all associated resources */
  111529. dispose(): void;
  111530. /**
  111531. * This function will add a new shader to the shader store
  111532. * @param name the name of the shader
  111533. * @param pixelShader optional pixel shader content
  111534. * @param vertexShader optional vertex shader content
  111535. */
  111536. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  111537. /**
  111538. * Store of each shader (The can be looked up using effect.key)
  111539. */
  111540. static ShadersStore: {
  111541. [key: string]: string;
  111542. };
  111543. /**
  111544. * Store of each included file for a shader (The can be looked up using effect.key)
  111545. */
  111546. static IncludesShadersStore: {
  111547. [key: string]: string;
  111548. };
  111549. /**
  111550. * Resets the cache of effects.
  111551. */
  111552. static ResetCache(): void;
  111553. }
  111554. }
  111555. declare module BABYLON {
  111556. /**
  111557. * Interface used to describe the capabilities of the engine relatively to the current browser
  111558. */
  111559. export interface EngineCapabilities {
  111560. /** Maximum textures units per fragment shader */
  111561. maxTexturesImageUnits: number;
  111562. /** Maximum texture units per vertex shader */
  111563. maxVertexTextureImageUnits: number;
  111564. /** Maximum textures units in the entire pipeline */
  111565. maxCombinedTexturesImageUnits: number;
  111566. /** Maximum texture size */
  111567. maxTextureSize: number;
  111568. /** Maximum texture samples */
  111569. maxSamples?: number;
  111570. /** Maximum cube texture size */
  111571. maxCubemapTextureSize: number;
  111572. /** Maximum render texture size */
  111573. maxRenderTextureSize: number;
  111574. /** Maximum number of vertex attributes */
  111575. maxVertexAttribs: number;
  111576. /** Maximum number of varyings */
  111577. maxVaryingVectors: number;
  111578. /** Maximum number of uniforms per vertex shader */
  111579. maxVertexUniformVectors: number;
  111580. /** Maximum number of uniforms per fragment shader */
  111581. maxFragmentUniformVectors: number;
  111582. /** Defines if standard derivates (dx/dy) are supported */
  111583. standardDerivatives: boolean;
  111584. /** Defines if s3tc texture compression is supported */
  111585. s3tc?: WEBGL_compressed_texture_s3tc;
  111586. /** Defines if pvrtc texture compression is supported */
  111587. pvrtc: any;
  111588. /** Defines if etc1 texture compression is supported */
  111589. etc1: any;
  111590. /** Defines if etc2 texture compression is supported */
  111591. etc2: any;
  111592. /** Defines if astc texture compression is supported */
  111593. astc: any;
  111594. /** Defines if float textures are supported */
  111595. textureFloat: boolean;
  111596. /** Defines if vertex array objects are supported */
  111597. vertexArrayObject: boolean;
  111598. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  111599. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  111600. /** Gets the maximum level of anisotropy supported */
  111601. maxAnisotropy: number;
  111602. /** Defines if instancing is supported */
  111603. instancedArrays: boolean;
  111604. /** Defines if 32 bits indices are supported */
  111605. uintIndices: boolean;
  111606. /** Defines if high precision shaders are supported */
  111607. highPrecisionShaderSupported: boolean;
  111608. /** Defines if depth reading in the fragment shader is supported */
  111609. fragmentDepthSupported: boolean;
  111610. /** Defines if float texture linear filtering is supported*/
  111611. textureFloatLinearFiltering: boolean;
  111612. /** Defines if rendering to float textures is supported */
  111613. textureFloatRender: boolean;
  111614. /** Defines if half float textures are supported*/
  111615. textureHalfFloat: boolean;
  111616. /** Defines if half float texture linear filtering is supported*/
  111617. textureHalfFloatLinearFiltering: boolean;
  111618. /** Defines if rendering to half float textures is supported */
  111619. textureHalfFloatRender: boolean;
  111620. /** Defines if textureLOD shader command is supported */
  111621. textureLOD: boolean;
  111622. /** Defines if draw buffers extension is supported */
  111623. drawBuffersExtension: boolean;
  111624. /** Defines if depth textures are supported */
  111625. depthTextureExtension: boolean;
  111626. /** Defines if float color buffer are supported */
  111627. colorBufferFloat: boolean;
  111628. /** Gets disjoint timer query extension (null if not supported) */
  111629. timerQuery?: EXT_disjoint_timer_query;
  111630. /** Defines if timestamp can be used with timer query */
  111631. canUseTimestampForTimerQuery: boolean;
  111632. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  111633. multiview?: any;
  111634. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  111635. oculusMultiview?: any;
  111636. /** Function used to let the system compiles shaders in background */
  111637. parallelShaderCompile?: {
  111638. COMPLETION_STATUS_KHR: number;
  111639. };
  111640. /** Max number of texture samples for MSAA */
  111641. maxMSAASamples: number;
  111642. /** Defines if the blend min max extension is supported */
  111643. blendMinMax: boolean;
  111644. }
  111645. }
  111646. declare module BABYLON {
  111647. /**
  111648. * @hidden
  111649. **/
  111650. export class DepthCullingState {
  111651. private _isDepthTestDirty;
  111652. private _isDepthMaskDirty;
  111653. private _isDepthFuncDirty;
  111654. private _isCullFaceDirty;
  111655. private _isCullDirty;
  111656. private _isZOffsetDirty;
  111657. private _isFrontFaceDirty;
  111658. private _depthTest;
  111659. private _depthMask;
  111660. private _depthFunc;
  111661. private _cull;
  111662. private _cullFace;
  111663. private _zOffset;
  111664. private _frontFace;
  111665. /**
  111666. * Initializes the state.
  111667. */
  111668. constructor();
  111669. get isDirty(): boolean;
  111670. get zOffset(): number;
  111671. set zOffset(value: number);
  111672. get cullFace(): Nullable<number>;
  111673. set cullFace(value: Nullable<number>);
  111674. get cull(): Nullable<boolean>;
  111675. set cull(value: Nullable<boolean>);
  111676. get depthFunc(): Nullable<number>;
  111677. set depthFunc(value: Nullable<number>);
  111678. get depthMask(): boolean;
  111679. set depthMask(value: boolean);
  111680. get depthTest(): boolean;
  111681. set depthTest(value: boolean);
  111682. get frontFace(): Nullable<number>;
  111683. set frontFace(value: Nullable<number>);
  111684. reset(): void;
  111685. apply(gl: WebGLRenderingContext): void;
  111686. }
  111687. }
  111688. declare module BABYLON {
  111689. /**
  111690. * @hidden
  111691. **/
  111692. export class StencilState {
  111693. /** 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 */
  111694. static readonly ALWAYS: number;
  111695. /** Passed to stencilOperation to specify that stencil value must be kept */
  111696. static readonly KEEP: number;
  111697. /** Passed to stencilOperation to specify that stencil value must be replaced */
  111698. static readonly REPLACE: number;
  111699. private _isStencilTestDirty;
  111700. private _isStencilMaskDirty;
  111701. private _isStencilFuncDirty;
  111702. private _isStencilOpDirty;
  111703. private _stencilTest;
  111704. private _stencilMask;
  111705. private _stencilFunc;
  111706. private _stencilFuncRef;
  111707. private _stencilFuncMask;
  111708. private _stencilOpStencilFail;
  111709. private _stencilOpDepthFail;
  111710. private _stencilOpStencilDepthPass;
  111711. get isDirty(): boolean;
  111712. get stencilFunc(): number;
  111713. set stencilFunc(value: number);
  111714. get stencilFuncRef(): number;
  111715. set stencilFuncRef(value: number);
  111716. get stencilFuncMask(): number;
  111717. set stencilFuncMask(value: number);
  111718. get stencilOpStencilFail(): number;
  111719. set stencilOpStencilFail(value: number);
  111720. get stencilOpDepthFail(): number;
  111721. set stencilOpDepthFail(value: number);
  111722. get stencilOpStencilDepthPass(): number;
  111723. set stencilOpStencilDepthPass(value: number);
  111724. get stencilMask(): number;
  111725. set stencilMask(value: number);
  111726. get stencilTest(): boolean;
  111727. set stencilTest(value: boolean);
  111728. constructor();
  111729. reset(): void;
  111730. apply(gl: WebGLRenderingContext): void;
  111731. }
  111732. }
  111733. declare module BABYLON {
  111734. /**
  111735. * @hidden
  111736. **/
  111737. export class AlphaState {
  111738. private _isAlphaBlendDirty;
  111739. private _isBlendFunctionParametersDirty;
  111740. private _isBlendEquationParametersDirty;
  111741. private _isBlendConstantsDirty;
  111742. private _alphaBlend;
  111743. private _blendFunctionParameters;
  111744. private _blendEquationParameters;
  111745. private _blendConstants;
  111746. /**
  111747. * Initializes the state.
  111748. */
  111749. constructor();
  111750. get isDirty(): boolean;
  111751. get alphaBlend(): boolean;
  111752. set alphaBlend(value: boolean);
  111753. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  111754. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  111755. setAlphaEquationParameters(rgb: number, alpha: number): void;
  111756. reset(): void;
  111757. apply(gl: WebGLRenderingContext): void;
  111758. }
  111759. }
  111760. declare module BABYLON {
  111761. /** @hidden */
  111762. export class WebGL2ShaderProcessor implements IShaderProcessor {
  111763. attributeProcessor(attribute: string): string;
  111764. varyingProcessor(varying: string, isFragment: boolean): string;
  111765. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111766. }
  111767. }
  111768. declare module BABYLON {
  111769. /**
  111770. * Interface for attribute information associated with buffer instanciation
  111771. */
  111772. export interface InstancingAttributeInfo {
  111773. /**
  111774. * Name of the GLSL attribute
  111775. * if attribute index is not specified, this is used to retrieve the index from the effect
  111776. */
  111777. attributeName: string;
  111778. /**
  111779. * Index/offset of the attribute in the vertex shader
  111780. * if not specified, this will be computes from the name.
  111781. */
  111782. index?: number;
  111783. /**
  111784. * size of the attribute, 1, 2, 3 or 4
  111785. */
  111786. attributeSize: number;
  111787. /**
  111788. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  111789. */
  111790. offset: number;
  111791. /**
  111792. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  111793. * default to 1
  111794. */
  111795. divisor?: number;
  111796. /**
  111797. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  111798. * default is FLOAT
  111799. */
  111800. attributeType?: number;
  111801. /**
  111802. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  111803. */
  111804. normalized?: boolean;
  111805. }
  111806. }
  111807. declare module BABYLON {
  111808. interface ThinEngine {
  111809. /**
  111810. * Update a video texture
  111811. * @param texture defines the texture to update
  111812. * @param video defines the video element to use
  111813. * @param invertY defines if data must be stored with Y axis inverted
  111814. */
  111815. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  111816. }
  111817. }
  111818. declare module BABYLON {
  111819. /**
  111820. * Settings for finer control over video usage
  111821. */
  111822. export interface VideoTextureSettings {
  111823. /**
  111824. * Applies `autoplay` to video, if specified
  111825. */
  111826. autoPlay?: boolean;
  111827. /**
  111828. * Applies `loop` to video, if specified
  111829. */
  111830. loop?: boolean;
  111831. /**
  111832. * Automatically updates internal texture from video at every frame in the render loop
  111833. */
  111834. autoUpdateTexture: boolean;
  111835. /**
  111836. * Image src displayed during the video loading or until the user interacts with the video.
  111837. */
  111838. poster?: string;
  111839. }
  111840. /**
  111841. * If you want to display a video in your scene, this is the special texture for that.
  111842. * This special texture works similar to other textures, with the exception of a few parameters.
  111843. * @see https://doc.babylonjs.com/how_to/video_texture
  111844. */
  111845. export class VideoTexture extends Texture {
  111846. /**
  111847. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  111848. */
  111849. readonly autoUpdateTexture: boolean;
  111850. /**
  111851. * The video instance used by the texture internally
  111852. */
  111853. readonly video: HTMLVideoElement;
  111854. private _onUserActionRequestedObservable;
  111855. /**
  111856. * Event triggerd when a dom action is required by the user to play the video.
  111857. * This happens due to recent changes in browser policies preventing video to auto start.
  111858. */
  111859. get onUserActionRequestedObservable(): Observable<Texture>;
  111860. private _generateMipMaps;
  111861. private _stillImageCaptured;
  111862. private _displayingPosterTexture;
  111863. private _settings;
  111864. private _createInternalTextureOnEvent;
  111865. private _frameId;
  111866. private _currentSrc;
  111867. /**
  111868. * Creates a video texture.
  111869. * If you want to display a video in your scene, this is the special texture for that.
  111870. * This special texture works similar to other textures, with the exception of a few parameters.
  111871. * @see https://doc.babylonjs.com/how_to/video_texture
  111872. * @param name optional name, will detect from video source, if not defined
  111873. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  111874. * @param scene is obviously the current scene.
  111875. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  111876. * @param invertY is false by default but can be used to invert video on Y axis
  111877. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  111878. * @param settings allows finer control over video usage
  111879. */
  111880. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  111881. private _getName;
  111882. private _getVideo;
  111883. private _createInternalTexture;
  111884. private reset;
  111885. /**
  111886. * @hidden Internal method to initiate `update`.
  111887. */
  111888. _rebuild(): void;
  111889. /**
  111890. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  111891. */
  111892. update(): void;
  111893. /**
  111894. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  111895. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  111896. */
  111897. updateTexture(isVisible: boolean): void;
  111898. protected _updateInternalTexture: () => void;
  111899. /**
  111900. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  111901. * @param url New url.
  111902. */
  111903. updateURL(url: string): void;
  111904. /**
  111905. * Clones the texture.
  111906. * @returns the cloned texture
  111907. */
  111908. clone(): VideoTexture;
  111909. /**
  111910. * Dispose the texture and release its associated resources.
  111911. */
  111912. dispose(): void;
  111913. /**
  111914. * Creates a video texture straight from a stream.
  111915. * @param scene Define the scene the texture should be created in
  111916. * @param stream Define the stream the texture should be created from
  111917. * @returns The created video texture as a promise
  111918. */
  111919. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  111920. /**
  111921. * Creates a video texture straight from your WebCam video feed.
  111922. * @param scene Define the scene the texture should be created in
  111923. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111924. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111925. * @returns The created video texture as a promise
  111926. */
  111927. static CreateFromWebCamAsync(scene: Scene, constraints: {
  111928. minWidth: number;
  111929. maxWidth: number;
  111930. minHeight: number;
  111931. maxHeight: number;
  111932. deviceId: string;
  111933. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  111934. /**
  111935. * Creates a video texture straight from your WebCam video feed.
  111936. * @param scene Define the scene the texture should be created in
  111937. * @param onReady Define a callback to triggered once the texture will be ready
  111938. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111939. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111940. */
  111941. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  111942. minWidth: number;
  111943. maxWidth: number;
  111944. minHeight: number;
  111945. maxHeight: number;
  111946. deviceId: string;
  111947. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  111948. }
  111949. }
  111950. declare module BABYLON {
  111951. /**
  111952. * Defines the interface used by objects working like Scene
  111953. * @hidden
  111954. */
  111955. export interface ISceneLike {
  111956. _addPendingData(data: any): void;
  111957. _removePendingData(data: any): void;
  111958. offlineProvider: IOfflineProvider;
  111959. }
  111960. /** Interface defining initialization parameters for Engine class */
  111961. export interface EngineOptions extends WebGLContextAttributes {
  111962. /**
  111963. * Defines if the engine should no exceed a specified device ratio
  111964. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  111965. */
  111966. limitDeviceRatio?: number;
  111967. /**
  111968. * Defines if webvr should be enabled automatically
  111969. * @see http://doc.babylonjs.com/how_to/webvr_camera
  111970. */
  111971. autoEnableWebVR?: boolean;
  111972. /**
  111973. * Defines if webgl2 should be turned off even if supported
  111974. * @see http://doc.babylonjs.com/features/webgl2
  111975. */
  111976. disableWebGL2Support?: boolean;
  111977. /**
  111978. * Defines if webaudio should be initialized as well
  111979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111980. */
  111981. audioEngine?: boolean;
  111982. /**
  111983. * Defines if animations should run using a deterministic lock step
  111984. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111985. */
  111986. deterministicLockstep?: boolean;
  111987. /** Defines the maximum steps to use with deterministic lock step mode */
  111988. lockstepMaxSteps?: number;
  111989. /** Defines the seconds between each deterministic lock step */
  111990. timeStep?: number;
  111991. /**
  111992. * Defines that engine should ignore context lost events
  111993. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  111994. */
  111995. doNotHandleContextLost?: boolean;
  111996. /**
  111997. * Defines that engine should ignore modifying touch action attribute and style
  111998. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  111999. */
  112000. doNotHandleTouchAction?: boolean;
  112001. /**
  112002. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  112003. */
  112004. useHighPrecisionFloats?: boolean;
  112005. /**
  112006. * Make the canvas XR Compatible for XR sessions
  112007. */
  112008. xrCompatible?: boolean;
  112009. }
  112010. /**
  112011. * The base engine class (root of all engines)
  112012. */
  112013. export class ThinEngine {
  112014. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  112015. static ExceptionList: ({
  112016. key: string;
  112017. capture: string;
  112018. captureConstraint: number;
  112019. targets: string[];
  112020. } | {
  112021. key: string;
  112022. capture: null;
  112023. captureConstraint: null;
  112024. targets: string[];
  112025. })[];
  112026. /** @hidden */
  112027. static _TextureLoaders: IInternalTextureLoader[];
  112028. /**
  112029. * Returns the current npm package of the sdk
  112030. */
  112031. static get NpmPackage(): string;
  112032. /**
  112033. * Returns the current version of the framework
  112034. */
  112035. static get Version(): string;
  112036. /**
  112037. * Returns a string describing the current engine
  112038. */
  112039. get description(): string;
  112040. /**
  112041. * Gets or sets the epsilon value used by collision engine
  112042. */
  112043. static CollisionsEpsilon: number;
  112044. /**
  112045. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112046. */
  112047. static get ShadersRepository(): string;
  112048. static set ShadersRepository(value: string);
  112049. /** @hidden */
  112050. _shaderProcessor: IShaderProcessor;
  112051. /**
  112052. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  112053. */
  112054. forcePOTTextures: boolean;
  112055. /**
  112056. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  112057. */
  112058. isFullscreen: boolean;
  112059. /**
  112060. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  112061. */
  112062. cullBackFaces: boolean;
  112063. /**
  112064. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  112065. */
  112066. renderEvenInBackground: boolean;
  112067. /**
  112068. * Gets or sets a boolean indicating that cache can be kept between frames
  112069. */
  112070. preventCacheWipeBetweenFrames: boolean;
  112071. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  112072. validateShaderPrograms: boolean;
  112073. /**
  112074. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  112075. * This can provide greater z depth for distant objects.
  112076. */
  112077. useReverseDepthBuffer: boolean;
  112078. /**
  112079. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112080. */
  112081. disableUniformBuffers: boolean;
  112082. /** @hidden */
  112083. _uniformBuffers: UniformBuffer[];
  112084. /**
  112085. * Gets a boolean indicating that the engine supports uniform buffers
  112086. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112087. */
  112088. get supportsUniformBuffers(): boolean;
  112089. /** @hidden */
  112090. _gl: WebGLRenderingContext;
  112091. /** @hidden */
  112092. _webGLVersion: number;
  112093. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112094. protected _windowIsBackground: boolean;
  112095. protected _creationOptions: EngineOptions;
  112096. protected _highPrecisionShadersAllowed: boolean;
  112097. /** @hidden */
  112098. get _shouldUseHighPrecisionShader(): boolean;
  112099. /**
  112100. * Gets a boolean indicating that only power of 2 textures are supported
  112101. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112102. */
  112103. get needPOTTextures(): boolean;
  112104. /** @hidden */
  112105. _badOS: boolean;
  112106. /** @hidden */
  112107. _badDesktopOS: boolean;
  112108. private _hardwareScalingLevel;
  112109. /** @hidden */
  112110. _caps: EngineCapabilities;
  112111. private _isStencilEnable;
  112112. private _glVersion;
  112113. private _glRenderer;
  112114. private _glVendor;
  112115. /** @hidden */
  112116. _videoTextureSupported: boolean;
  112117. protected _renderingQueueLaunched: boolean;
  112118. protected _activeRenderLoops: (() => void)[];
  112119. /**
  112120. * Observable signaled when a context lost event is raised
  112121. */
  112122. onContextLostObservable: Observable<ThinEngine>;
  112123. /**
  112124. * Observable signaled when a context restored event is raised
  112125. */
  112126. onContextRestoredObservable: Observable<ThinEngine>;
  112127. private _onContextLost;
  112128. private _onContextRestored;
  112129. protected _contextWasLost: boolean;
  112130. /** @hidden */
  112131. _doNotHandleContextLost: boolean;
  112132. /**
  112133. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112134. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112135. */
  112136. get doNotHandleContextLost(): boolean;
  112137. set doNotHandleContextLost(value: boolean);
  112138. /**
  112139. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112140. */
  112141. disableVertexArrayObjects: boolean;
  112142. /** @hidden */
  112143. protected _colorWrite: boolean;
  112144. /** @hidden */
  112145. protected _colorWriteChanged: boolean;
  112146. /** @hidden */
  112147. protected _depthCullingState: DepthCullingState;
  112148. /** @hidden */
  112149. protected _stencilState: StencilState;
  112150. /** @hidden */
  112151. _alphaState: AlphaState;
  112152. /** @hidden */
  112153. _alphaMode: number;
  112154. /** @hidden */
  112155. _alphaEquation: number;
  112156. /** @hidden */
  112157. _internalTexturesCache: InternalTexture[];
  112158. /** @hidden */
  112159. protected _activeChannel: number;
  112160. private _currentTextureChannel;
  112161. /** @hidden */
  112162. protected _boundTexturesCache: {
  112163. [key: string]: Nullable<InternalTexture>;
  112164. };
  112165. /** @hidden */
  112166. protected _currentEffect: Nullable<Effect>;
  112167. /** @hidden */
  112168. protected _currentProgram: Nullable<WebGLProgram>;
  112169. private _compiledEffects;
  112170. private _vertexAttribArraysEnabled;
  112171. /** @hidden */
  112172. protected _cachedViewport: Nullable<IViewportLike>;
  112173. private _cachedVertexArrayObject;
  112174. /** @hidden */
  112175. protected _cachedVertexBuffers: any;
  112176. /** @hidden */
  112177. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112178. /** @hidden */
  112179. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112180. /** @hidden */
  112181. _currentRenderTarget: Nullable<InternalTexture>;
  112182. private _uintIndicesCurrentlySet;
  112183. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112184. /** @hidden */
  112185. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112186. /** @hidden */
  112187. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112188. private _currentBufferPointers;
  112189. private _currentInstanceLocations;
  112190. private _currentInstanceBuffers;
  112191. private _textureUnits;
  112192. /** @hidden */
  112193. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112194. /** @hidden */
  112195. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112196. /** @hidden */
  112197. _boundRenderFunction: any;
  112198. private _vaoRecordInProgress;
  112199. private _mustWipeVertexAttributes;
  112200. private _emptyTexture;
  112201. private _emptyCubeTexture;
  112202. private _emptyTexture3D;
  112203. private _emptyTexture2DArray;
  112204. /** @hidden */
  112205. _frameHandler: number;
  112206. private _nextFreeTextureSlots;
  112207. private _maxSimultaneousTextures;
  112208. private _activeRequests;
  112209. /** @hidden */
  112210. _transformTextureUrl: Nullable<(url: string) => string>;
  112211. protected get _supportsHardwareTextureRescaling(): boolean;
  112212. private _framebufferDimensionsObject;
  112213. /**
  112214. * sets the object from which width and height will be taken from when getting render width and height
  112215. * Will fallback to the gl object
  112216. * @param dimensions the framebuffer width and height that will be used.
  112217. */
  112218. set framebufferDimensionsObject(dimensions: Nullable<{
  112219. framebufferWidth: number;
  112220. framebufferHeight: number;
  112221. }>);
  112222. /**
  112223. * Gets the current viewport
  112224. */
  112225. get currentViewport(): Nullable<IViewportLike>;
  112226. /**
  112227. * Gets the default empty texture
  112228. */
  112229. get emptyTexture(): InternalTexture;
  112230. /**
  112231. * Gets the default empty 3D texture
  112232. */
  112233. get emptyTexture3D(): InternalTexture;
  112234. /**
  112235. * Gets the default empty 2D array texture
  112236. */
  112237. get emptyTexture2DArray(): InternalTexture;
  112238. /**
  112239. * Gets the default empty cube texture
  112240. */
  112241. get emptyCubeTexture(): InternalTexture;
  112242. /**
  112243. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  112244. */
  112245. readonly premultipliedAlpha: boolean;
  112246. /**
  112247. * Observable event triggered before each texture is initialized
  112248. */
  112249. onBeforeTextureInitObservable: Observable<Texture>;
  112250. /**
  112251. * Creates a new engine
  112252. * @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
  112253. * @param antialias defines enable antialiasing (default: false)
  112254. * @param options defines further options to be sent to the getContext() function
  112255. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  112256. */
  112257. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  112258. private _rebuildInternalTextures;
  112259. private _rebuildEffects;
  112260. /**
  112261. * Gets a boolean indicating if all created effects are ready
  112262. * @returns true if all effects are ready
  112263. */
  112264. areAllEffectsReady(): boolean;
  112265. protected _rebuildBuffers(): void;
  112266. protected _initGLContext(): void;
  112267. /**
  112268. * Gets version of the current webGL context
  112269. */
  112270. get webGLVersion(): number;
  112271. /**
  112272. * Gets a string idenfifying the name of the class
  112273. * @returns "Engine" string
  112274. */
  112275. getClassName(): string;
  112276. /**
  112277. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  112278. */
  112279. get isStencilEnable(): boolean;
  112280. /** @hidden */
  112281. _prepareWorkingCanvas(): void;
  112282. /**
  112283. * Reset the texture cache to empty state
  112284. */
  112285. resetTextureCache(): void;
  112286. /**
  112287. * Gets an object containing information about the current webGL context
  112288. * @returns an object containing the vender, the renderer and the version of the current webGL context
  112289. */
  112290. getGlInfo(): {
  112291. vendor: string;
  112292. renderer: string;
  112293. version: string;
  112294. };
  112295. /**
  112296. * Defines the hardware scaling level.
  112297. * By default the hardware scaling level is computed from the window device ratio.
  112298. * 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.
  112299. * @param level defines the level to use
  112300. */
  112301. setHardwareScalingLevel(level: number): void;
  112302. /**
  112303. * Gets the current hardware scaling level.
  112304. * By default the hardware scaling level is computed from the window device ratio.
  112305. * 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.
  112306. * @returns a number indicating the current hardware scaling level
  112307. */
  112308. getHardwareScalingLevel(): number;
  112309. /**
  112310. * Gets the list of loaded textures
  112311. * @returns an array containing all loaded textures
  112312. */
  112313. getLoadedTexturesCache(): InternalTexture[];
  112314. /**
  112315. * Gets the object containing all engine capabilities
  112316. * @returns the EngineCapabilities object
  112317. */
  112318. getCaps(): EngineCapabilities;
  112319. /**
  112320. * stop executing a render loop function and remove it from the execution array
  112321. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  112322. */
  112323. stopRenderLoop(renderFunction?: () => void): void;
  112324. /** @hidden */
  112325. _renderLoop(): void;
  112326. /**
  112327. * Gets the HTML canvas attached with the current webGL context
  112328. * @returns a HTML canvas
  112329. */
  112330. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  112331. /**
  112332. * Gets host window
  112333. * @returns the host window object
  112334. */
  112335. getHostWindow(): Nullable<Window>;
  112336. /**
  112337. * Gets the current render width
  112338. * @param useScreen defines if screen size must be used (or the current render target if any)
  112339. * @returns a number defining the current render width
  112340. */
  112341. getRenderWidth(useScreen?: boolean): number;
  112342. /**
  112343. * Gets the current render height
  112344. * @param useScreen defines if screen size must be used (or the current render target if any)
  112345. * @returns a number defining the current render height
  112346. */
  112347. getRenderHeight(useScreen?: boolean): number;
  112348. /**
  112349. * Can be used to override the current requestAnimationFrame requester.
  112350. * @hidden
  112351. */
  112352. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112353. /**
  112354. * Register and execute a render loop. The engine can have more than one render function
  112355. * @param renderFunction defines the function to continuously execute
  112356. */
  112357. runRenderLoop(renderFunction: () => void): void;
  112358. /**
  112359. * Clear the current render buffer or the current render target (if any is set up)
  112360. * @param color defines the color to use
  112361. * @param backBuffer defines if the back buffer must be cleared
  112362. * @param depth defines if the depth buffer must be cleared
  112363. * @param stencil defines if the stencil buffer must be cleared
  112364. */
  112365. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112366. private _viewportCached;
  112367. /** @hidden */
  112368. _viewport(x: number, y: number, width: number, height: number): void;
  112369. /**
  112370. * Set the WebGL's viewport
  112371. * @param viewport defines the viewport element to be used
  112372. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112373. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112374. */
  112375. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112376. /**
  112377. * Begin a new frame
  112378. */
  112379. beginFrame(): void;
  112380. /**
  112381. * Enf the current frame
  112382. */
  112383. endFrame(): void;
  112384. /**
  112385. * Resize the view according to the canvas' size
  112386. */
  112387. resize(): void;
  112388. /**
  112389. * Force a specific size of the canvas
  112390. * @param width defines the new canvas' width
  112391. * @param height defines the new canvas' height
  112392. */
  112393. setSize(width: number, height: number): void;
  112394. /**
  112395. * Binds the frame buffer to the specified texture.
  112396. * @param texture The texture to render to or null for the default canvas
  112397. * @param faceIndex The face of the texture to render to in case of cube texture
  112398. * @param requiredWidth The width of the target to render to
  112399. * @param requiredHeight The height of the target to render to
  112400. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112401. * @param lodLevel defines the lod level to bind to the frame buffer
  112402. * @param layer defines the 2d array index to bind to frame buffer to
  112403. */
  112404. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  112405. /** @hidden */
  112406. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112407. /**
  112408. * Unbind the current render target texture from the webGL context
  112409. * @param texture defines the render target texture to unbind
  112410. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112411. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112412. */
  112413. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112414. /**
  112415. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  112416. */
  112417. flushFramebuffer(): void;
  112418. /**
  112419. * Unbind the current render target and bind the default framebuffer
  112420. */
  112421. restoreDefaultFramebuffer(): void;
  112422. /** @hidden */
  112423. protected _resetVertexBufferBinding(): void;
  112424. /**
  112425. * Creates a vertex buffer
  112426. * @param data the data for the vertex buffer
  112427. * @returns the new WebGL static buffer
  112428. */
  112429. createVertexBuffer(data: DataArray): DataBuffer;
  112430. private _createVertexBuffer;
  112431. /**
  112432. * Creates a dynamic vertex buffer
  112433. * @param data the data for the dynamic vertex buffer
  112434. * @returns the new WebGL dynamic buffer
  112435. */
  112436. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112437. protected _resetIndexBufferBinding(): void;
  112438. /**
  112439. * Creates a new index buffer
  112440. * @param indices defines the content of the index buffer
  112441. * @param updatable defines if the index buffer must be updatable
  112442. * @returns a new webGL buffer
  112443. */
  112444. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  112445. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  112446. /**
  112447. * Bind a webGL buffer to the webGL context
  112448. * @param buffer defines the buffer to bind
  112449. */
  112450. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  112451. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  112452. private bindBuffer;
  112453. /**
  112454. * update the bound buffer with the given data
  112455. * @param data defines the data to update
  112456. */
  112457. updateArrayBuffer(data: Float32Array): void;
  112458. private _vertexAttribPointer;
  112459. /** @hidden */
  112460. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  112461. private _bindVertexBuffersAttributes;
  112462. /**
  112463. * Records a vertex array object
  112464. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112465. * @param vertexBuffers defines the list of vertex buffers to store
  112466. * @param indexBuffer defines the index buffer to store
  112467. * @param effect defines the effect to store
  112468. * @returns the new vertex array object
  112469. */
  112470. recordVertexArrayObject(vertexBuffers: {
  112471. [key: string]: VertexBuffer;
  112472. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112473. /**
  112474. * Bind a specific vertex array object
  112475. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112476. * @param vertexArrayObject defines the vertex array object to bind
  112477. * @param indexBuffer defines the index buffer to bind
  112478. */
  112479. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  112480. /**
  112481. * Bind webGl buffers directly to the webGL context
  112482. * @param vertexBuffer defines the vertex buffer to bind
  112483. * @param indexBuffer defines the index buffer to bind
  112484. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112485. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112486. * @param effect defines the effect associated with the vertex buffer
  112487. */
  112488. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  112489. private _unbindVertexArrayObject;
  112490. /**
  112491. * Bind a list of vertex buffers to the webGL context
  112492. * @param vertexBuffers defines the list of vertex buffers to bind
  112493. * @param indexBuffer defines the index buffer to bind
  112494. * @param effect defines the effect associated with the vertex buffers
  112495. */
  112496. bindBuffers(vertexBuffers: {
  112497. [key: string]: Nullable<VertexBuffer>;
  112498. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  112499. /**
  112500. * Unbind all instance attributes
  112501. */
  112502. unbindInstanceAttributes(): void;
  112503. /**
  112504. * Release and free the memory of a vertex array object
  112505. * @param vao defines the vertex array object to delete
  112506. */
  112507. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  112508. /** @hidden */
  112509. _releaseBuffer(buffer: DataBuffer): boolean;
  112510. protected _deleteBuffer(buffer: DataBuffer): void;
  112511. /**
  112512. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  112513. * @param instancesBuffer defines the webGL buffer to update and bind
  112514. * @param data defines the data to store in the buffer
  112515. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  112516. */
  112517. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  112518. /**
  112519. * Bind the content of a webGL buffer used with instantiation
  112520. * @param instancesBuffer defines the webGL buffer to bind
  112521. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  112522. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  112523. */
  112524. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  112525. /**
  112526. * Disable the instance attribute corresponding to the name in parameter
  112527. * @param name defines the name of the attribute to disable
  112528. */
  112529. disableInstanceAttributeByName(name: string): void;
  112530. /**
  112531. * Disable the instance attribute corresponding to the location in parameter
  112532. * @param attributeLocation defines the attribute location of the attribute to disable
  112533. */
  112534. disableInstanceAttribute(attributeLocation: number): void;
  112535. /**
  112536. * Disable the attribute corresponding to the location in parameter
  112537. * @param attributeLocation defines the attribute location of the attribute to disable
  112538. */
  112539. disableAttributeByIndex(attributeLocation: number): void;
  112540. /**
  112541. * Send a draw order
  112542. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112543. * @param indexStart defines the starting index
  112544. * @param indexCount defines the number of index to draw
  112545. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112546. */
  112547. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112548. /**
  112549. * Draw a list of points
  112550. * @param verticesStart defines the index of first vertex to draw
  112551. * @param verticesCount defines the count of vertices to draw
  112552. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112553. */
  112554. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112555. /**
  112556. * Draw a list of unindexed primitives
  112557. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112558. * @param verticesStart defines the index of first vertex to draw
  112559. * @param verticesCount defines the count of vertices to draw
  112560. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112561. */
  112562. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112563. /**
  112564. * Draw a list of indexed primitives
  112565. * @param fillMode defines the primitive to use
  112566. * @param indexStart defines the starting index
  112567. * @param indexCount defines the number of index to draw
  112568. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112569. */
  112570. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112571. /**
  112572. * Draw a list of unindexed primitives
  112573. * @param fillMode defines the primitive to use
  112574. * @param verticesStart defines the index of first vertex to draw
  112575. * @param verticesCount defines the count of vertices to draw
  112576. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112577. */
  112578. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112579. private _drawMode;
  112580. /** @hidden */
  112581. protected _reportDrawCall(): void;
  112582. /** @hidden */
  112583. _releaseEffect(effect: Effect): void;
  112584. /** @hidden */
  112585. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112586. /**
  112587. * Create a new effect (used to store vertex/fragment shaders)
  112588. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  112589. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  112590. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  112591. * @param samplers defines an array of string used to represent textures
  112592. * @param defines defines the string containing the defines to use to compile the shaders
  112593. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  112594. * @param onCompiled defines a function to call when the effect creation is successful
  112595. * @param onError defines a function to call when the effect creation has failed
  112596. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  112597. * @returns the new Effect
  112598. */
  112599. 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;
  112600. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  112601. private _compileShader;
  112602. private _compileRawShader;
  112603. /** @hidden */
  112604. _getShaderSource(shader: WebGLShader): Nullable<string>;
  112605. /**
  112606. * Directly creates a webGL program
  112607. * @param pipelineContext defines the pipeline context to attach to
  112608. * @param vertexCode defines the vertex shader code to use
  112609. * @param fragmentCode defines the fragment shader code to use
  112610. * @param context defines the webGL context to use (if not set, the current one will be used)
  112611. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112612. * @returns the new webGL program
  112613. */
  112614. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112615. /**
  112616. * Creates a webGL program
  112617. * @param pipelineContext defines the pipeline context to attach to
  112618. * @param vertexCode defines the vertex shader code to use
  112619. * @param fragmentCode defines the fragment shader code to use
  112620. * @param defines defines the string containing the defines to use to compile the shaders
  112621. * @param context defines the webGL context to use (if not set, the current one will be used)
  112622. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112623. * @returns the new webGL program
  112624. */
  112625. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112626. /**
  112627. * Creates a new pipeline context
  112628. * @returns the new pipeline
  112629. */
  112630. createPipelineContext(): IPipelineContext;
  112631. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112632. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  112633. /** @hidden */
  112634. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112635. /** @hidden */
  112636. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112637. /** @hidden */
  112638. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112639. /**
  112640. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112641. * @param pipelineContext defines the pipeline context to use
  112642. * @param uniformsNames defines the list of uniform names
  112643. * @returns an array of webGL uniform locations
  112644. */
  112645. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112646. /**
  112647. * Gets the lsit of active attributes for a given webGL program
  112648. * @param pipelineContext defines the pipeline context to use
  112649. * @param attributesNames defines the list of attribute names to get
  112650. * @returns an array of indices indicating the offset of each attribute
  112651. */
  112652. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112653. /**
  112654. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112655. * @param effect defines the effect to activate
  112656. */
  112657. enableEffect(effect: Nullable<Effect>): void;
  112658. /**
  112659. * Set the value of an uniform to a number (int)
  112660. * @param uniform defines the webGL uniform location where to store the value
  112661. * @param value defines the int number to store
  112662. */
  112663. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112664. /**
  112665. * Set the value of an uniform to an array of int32
  112666. * @param uniform defines the webGL uniform location where to store the value
  112667. * @param array defines the array of int32 to store
  112668. */
  112669. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112670. /**
  112671. * Set the value of an uniform to an array of int32 (stored as vec2)
  112672. * @param uniform defines the webGL uniform location where to store the value
  112673. * @param array defines the array of int32 to store
  112674. */
  112675. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112676. /**
  112677. * Set the value of an uniform to an array of int32 (stored as vec3)
  112678. * @param uniform defines the webGL uniform location where to store the value
  112679. * @param array defines the array of int32 to store
  112680. */
  112681. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112682. /**
  112683. * Set the value of an uniform to an array of int32 (stored as vec4)
  112684. * @param uniform defines the webGL uniform location where to store the value
  112685. * @param array defines the array of int32 to store
  112686. */
  112687. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112688. /**
  112689. * Set the value of an uniform to an array of number
  112690. * @param uniform defines the webGL uniform location where to store the value
  112691. * @param array defines the array of number to store
  112692. */
  112693. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112694. /**
  112695. * Set the value of an uniform to an array of number (stored as vec2)
  112696. * @param uniform defines the webGL uniform location where to store the value
  112697. * @param array defines the array of number to store
  112698. */
  112699. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112700. /**
  112701. * Set the value of an uniform to an array of number (stored as vec3)
  112702. * @param uniform defines the webGL uniform location where to store the value
  112703. * @param array defines the array of number to store
  112704. */
  112705. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112706. /**
  112707. * Set the value of an uniform to an array of number (stored as vec4)
  112708. * @param uniform defines the webGL uniform location where to store the value
  112709. * @param array defines the array of number to store
  112710. */
  112711. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112712. /**
  112713. * Set the value of an uniform to an array of float32 (stored as matrices)
  112714. * @param uniform defines the webGL uniform location where to store the value
  112715. * @param matrices defines the array of float32 to store
  112716. */
  112717. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  112718. /**
  112719. * Set the value of an uniform to a matrix (3x3)
  112720. * @param uniform defines the webGL uniform location where to store the value
  112721. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112722. */
  112723. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112724. /**
  112725. * Set the value of an uniform to a matrix (2x2)
  112726. * @param uniform defines the webGL uniform location where to store the value
  112727. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112728. */
  112729. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112730. /**
  112731. * Set the value of an uniform to a number (float)
  112732. * @param uniform defines the webGL uniform location where to store the value
  112733. * @param value defines the float number to store
  112734. */
  112735. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112736. /**
  112737. * Set the value of an uniform to a vec2
  112738. * @param uniform defines the webGL uniform location where to store the value
  112739. * @param x defines the 1st component of the value
  112740. * @param y defines the 2nd component of the value
  112741. */
  112742. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  112743. /**
  112744. * Set the value of an uniform to a vec3
  112745. * @param uniform defines the webGL uniform location where to store the value
  112746. * @param x defines the 1st component of the value
  112747. * @param y defines the 2nd component of the value
  112748. * @param z defines the 3rd component of the value
  112749. */
  112750. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  112751. /**
  112752. * Set the value of an uniform to a vec4
  112753. * @param uniform defines the webGL uniform location where to store the value
  112754. * @param x defines the 1st component of the value
  112755. * @param y defines the 2nd component of the value
  112756. * @param z defines the 3rd component of the value
  112757. * @param w defines the 4th component of the value
  112758. */
  112759. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  112760. /**
  112761. * Apply all cached states (depth, culling, stencil and alpha)
  112762. */
  112763. applyStates(): void;
  112764. /**
  112765. * Enable or disable color writing
  112766. * @param enable defines the state to set
  112767. */
  112768. setColorWrite(enable: boolean): void;
  112769. /**
  112770. * Gets a boolean indicating if color writing is enabled
  112771. * @returns the current color writing state
  112772. */
  112773. getColorWrite(): boolean;
  112774. /**
  112775. * Gets the depth culling state manager
  112776. */
  112777. get depthCullingState(): DepthCullingState;
  112778. /**
  112779. * Gets the alpha state manager
  112780. */
  112781. get alphaState(): AlphaState;
  112782. /**
  112783. * Gets the stencil state manager
  112784. */
  112785. get stencilState(): StencilState;
  112786. /**
  112787. * Clears the list of texture accessible through engine.
  112788. * This can help preventing texture load conflict due to name collision.
  112789. */
  112790. clearInternalTexturesCache(): void;
  112791. /**
  112792. * Force the entire cache to be cleared
  112793. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112794. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112795. */
  112796. wipeCaches(bruteForce?: boolean): void;
  112797. /** @hidden */
  112798. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  112799. min: number;
  112800. mag: number;
  112801. };
  112802. /** @hidden */
  112803. _createTexture(): WebGLTexture;
  112804. /**
  112805. * Usually called from Texture.ts.
  112806. * Passed information to create a WebGLTexture
  112807. * @param url defines a value which contains one of the following:
  112808. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112809. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112810. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112811. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112812. * @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)
  112813. * @param scene needed for loading to the correct scene
  112814. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112815. * @param onLoad optional callback to be called upon successful completion
  112816. * @param onError optional callback to be called upon failure
  112817. * @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
  112818. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112819. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112820. * @param forcedExtension defines the extension to use to pick the right loader
  112821. * @param mimeType defines an optional mime type
  112822. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112823. */
  112824. 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;
  112825. /**
  112826. * Loads an image as an HTMLImageElement.
  112827. * @param input url string, ArrayBuffer, or Blob to load
  112828. * @param onLoad callback called when the image successfully loads
  112829. * @param onError callback called when the image fails to load
  112830. * @param offlineProvider offline provider for caching
  112831. * @param mimeType optional mime type
  112832. * @returns the HTMLImageElement of the loaded image
  112833. * @hidden
  112834. */
  112835. 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>;
  112836. /**
  112837. * @hidden
  112838. */
  112839. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  112840. private _unpackFlipYCached;
  112841. /**
  112842. * In case you are sharing the context with other applications, it might
  112843. * be interested to not cache the unpack flip y state to ensure a consistent
  112844. * value would be set.
  112845. */
  112846. enableUnpackFlipYCached: boolean;
  112847. /** @hidden */
  112848. _unpackFlipY(value: boolean): void;
  112849. /** @hidden */
  112850. _getUnpackAlignement(): number;
  112851. private _getTextureTarget;
  112852. /**
  112853. * Update the sampling mode of a given texture
  112854. * @param samplingMode defines the required sampling mode
  112855. * @param texture defines the texture to update
  112856. * @param generateMipMaps defines whether to generate mipmaps for the texture
  112857. */
  112858. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  112859. /**
  112860. * Update the sampling mode of a given texture
  112861. * @param texture defines the texture to update
  112862. * @param wrapU defines the texture wrap mode of the u coordinates
  112863. * @param wrapV defines the texture wrap mode of the v coordinates
  112864. * @param wrapR defines the texture wrap mode of the r coordinates
  112865. */
  112866. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  112867. /** @hidden */
  112868. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  112869. width: number;
  112870. height: number;
  112871. layers?: number;
  112872. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  112873. /** @hidden */
  112874. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112875. /** @hidden */
  112876. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  112877. /**
  112878. * Update a portion of an internal texture
  112879. * @param texture defines the texture to update
  112880. * @param imageData defines the data to store into the texture
  112881. * @param xOffset defines the x coordinates of the update rectangle
  112882. * @param yOffset defines the y coordinates of the update rectangle
  112883. * @param width defines the width of the update rectangle
  112884. * @param height defines the height of the update rectangle
  112885. * @param faceIndex defines the face index if texture is a cube (0 by default)
  112886. * @param lod defines the lod level to update (0 by default)
  112887. */
  112888. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  112889. /** @hidden */
  112890. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112891. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  112892. private _prepareWebGLTexture;
  112893. /** @hidden */
  112894. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  112895. private _getDepthStencilBuffer;
  112896. /** @hidden */
  112897. _releaseFramebufferObjects(texture: InternalTexture): void;
  112898. /** @hidden */
  112899. _releaseTexture(texture: InternalTexture): void;
  112900. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112901. protected _setProgram(program: WebGLProgram): void;
  112902. protected _boundUniforms: {
  112903. [key: number]: WebGLUniformLocation;
  112904. };
  112905. /**
  112906. * Binds an effect to the webGL context
  112907. * @param effect defines the effect to bind
  112908. */
  112909. bindSamplers(effect: Effect): void;
  112910. private _activateCurrentTexture;
  112911. /** @hidden */
  112912. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  112913. /** @hidden */
  112914. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  112915. /**
  112916. * Unbind all textures from the webGL context
  112917. */
  112918. unbindAllTextures(): void;
  112919. /**
  112920. * Sets a texture to the according uniform.
  112921. * @param channel The texture channel
  112922. * @param uniform The uniform to set
  112923. * @param texture The texture to apply
  112924. */
  112925. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  112926. private _bindSamplerUniformToChannel;
  112927. private _getTextureWrapMode;
  112928. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112929. /**
  112930. * Sets an array of texture to the webGL context
  112931. * @param channel defines the channel where the texture array must be set
  112932. * @param uniform defines the associated uniform location
  112933. * @param textures defines the array of textures to bind
  112934. */
  112935. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  112936. /** @hidden */
  112937. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  112938. private _setTextureParameterFloat;
  112939. private _setTextureParameterInteger;
  112940. /**
  112941. * Unbind all vertex attributes from the webGL context
  112942. */
  112943. unbindAllAttributes(): void;
  112944. /**
  112945. * 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
  112946. */
  112947. releaseEffects(): void;
  112948. /**
  112949. * Dispose and release all associated resources
  112950. */
  112951. dispose(): void;
  112952. /**
  112953. * Attach a new callback raised when context lost event is fired
  112954. * @param callback defines the callback to call
  112955. */
  112956. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112957. /**
  112958. * Attach a new callback raised when context restored event is fired
  112959. * @param callback defines the callback to call
  112960. */
  112961. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112962. /**
  112963. * Get the current error code of the webGL context
  112964. * @returns the error code
  112965. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112966. */
  112967. getError(): number;
  112968. private _canRenderToFloatFramebuffer;
  112969. private _canRenderToHalfFloatFramebuffer;
  112970. private _canRenderToFramebuffer;
  112971. /** @hidden */
  112972. _getWebGLTextureType(type: number): number;
  112973. /** @hidden */
  112974. _getInternalFormat(format: number): number;
  112975. /** @hidden */
  112976. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  112977. /** @hidden */
  112978. _getRGBAMultiSampleBufferFormat(type: number): number;
  112979. /** @hidden */
  112980. _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;
  112981. /**
  112982. * Loads a file from a url
  112983. * @param url url to load
  112984. * @param onSuccess callback called when the file successfully loads
  112985. * @param onProgress callback called while file is loading (if the server supports this mode)
  112986. * @param offlineProvider defines the offline provider for caching
  112987. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  112988. * @param onError callback called when the file fails to load
  112989. * @returns a file request object
  112990. * @hidden
  112991. */
  112992. 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;
  112993. /**
  112994. * Reads pixels from the current frame buffer. Please note that this function can be slow
  112995. * @param x defines the x coordinate of the rectangle where pixels must be read
  112996. * @param y defines the y coordinate of the rectangle where pixels must be read
  112997. * @param width defines the width of the rectangle where pixels must be read
  112998. * @param height defines the height of the rectangle where pixels must be read
  112999. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  113000. * @returns a Uint8Array containing RGBA colors
  113001. */
  113002. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  113003. private static _isSupported;
  113004. /**
  113005. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  113006. * @returns true if the engine can be created
  113007. * @ignorenaming
  113008. */
  113009. static isSupported(): boolean;
  113010. /**
  113011. * Find the next highest power of two.
  113012. * @param x Number to start search from.
  113013. * @return Next highest power of two.
  113014. */
  113015. static CeilingPOT(x: number): number;
  113016. /**
  113017. * Find the next lowest power of two.
  113018. * @param x Number to start search from.
  113019. * @return Next lowest power of two.
  113020. */
  113021. static FloorPOT(x: number): number;
  113022. /**
  113023. * Find the nearest power of two.
  113024. * @param x Number to start search from.
  113025. * @return Next nearest power of two.
  113026. */
  113027. static NearestPOT(x: number): number;
  113028. /**
  113029. * Get the closest exponent of two
  113030. * @param value defines the value to approximate
  113031. * @param max defines the maximum value to return
  113032. * @param mode defines how to define the closest value
  113033. * @returns closest exponent of two of the given value
  113034. */
  113035. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  113036. /**
  113037. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  113038. * @param func - the function to be called
  113039. * @param requester - the object that will request the next frame. Falls back to window.
  113040. * @returns frame number
  113041. */
  113042. static QueueNewFrame(func: () => void, requester?: any): number;
  113043. /**
  113044. * Gets host document
  113045. * @returns the host document object
  113046. */
  113047. getHostDocument(): Nullable<Document>;
  113048. }
  113049. }
  113050. declare module BABYLON {
  113051. /**
  113052. * Class representing spherical harmonics coefficients to the 3rd degree
  113053. */
  113054. export class SphericalHarmonics {
  113055. /**
  113056. * Defines whether or not the harmonics have been prescaled for rendering.
  113057. */
  113058. preScaled: boolean;
  113059. /**
  113060. * The l0,0 coefficients of the spherical harmonics
  113061. */
  113062. l00: Vector3;
  113063. /**
  113064. * The l1,-1 coefficients of the spherical harmonics
  113065. */
  113066. l1_1: Vector3;
  113067. /**
  113068. * The l1,0 coefficients of the spherical harmonics
  113069. */
  113070. l10: Vector3;
  113071. /**
  113072. * The l1,1 coefficients of the spherical harmonics
  113073. */
  113074. l11: Vector3;
  113075. /**
  113076. * The l2,-2 coefficients of the spherical harmonics
  113077. */
  113078. l2_2: Vector3;
  113079. /**
  113080. * The l2,-1 coefficients of the spherical harmonics
  113081. */
  113082. l2_1: Vector3;
  113083. /**
  113084. * The l2,0 coefficients of the spherical harmonics
  113085. */
  113086. l20: Vector3;
  113087. /**
  113088. * The l2,1 coefficients of the spherical harmonics
  113089. */
  113090. l21: Vector3;
  113091. /**
  113092. * The l2,2 coefficients of the spherical harmonics
  113093. */
  113094. l22: Vector3;
  113095. /**
  113096. * Adds a light to the spherical harmonics
  113097. * @param direction the direction of the light
  113098. * @param color the color of the light
  113099. * @param deltaSolidAngle the delta solid angle of the light
  113100. */
  113101. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113102. /**
  113103. * Scales the spherical harmonics by the given amount
  113104. * @param scale the amount to scale
  113105. */
  113106. scaleInPlace(scale: number): void;
  113107. /**
  113108. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113109. *
  113110. * ```
  113111. * E_lm = A_l * L_lm
  113112. * ```
  113113. *
  113114. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113115. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113116. * the scaling factors are given in equation 9.
  113117. */
  113118. convertIncidentRadianceToIrradiance(): void;
  113119. /**
  113120. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113121. *
  113122. * ```
  113123. * L = (1/pi) * E * rho
  113124. * ```
  113125. *
  113126. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113127. */
  113128. convertIrradianceToLambertianRadiance(): void;
  113129. /**
  113130. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113131. * required operations at run time.
  113132. *
  113133. * This is simply done by scaling back the SH with Ylm constants parameter.
  113134. * The trigonometric part being applied by the shader at run time.
  113135. */
  113136. preScaleForRendering(): void;
  113137. /**
  113138. * Constructs a spherical harmonics from an array.
  113139. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113140. * @returns the spherical harmonics
  113141. */
  113142. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113143. /**
  113144. * Gets the spherical harmonics from polynomial
  113145. * @param polynomial the spherical polynomial
  113146. * @returns the spherical harmonics
  113147. */
  113148. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113149. }
  113150. /**
  113151. * Class representing spherical polynomial coefficients to the 3rd degree
  113152. */
  113153. export class SphericalPolynomial {
  113154. private _harmonics;
  113155. /**
  113156. * The spherical harmonics used to create the polynomials.
  113157. */
  113158. get preScaledHarmonics(): SphericalHarmonics;
  113159. /**
  113160. * The x coefficients of the spherical polynomial
  113161. */
  113162. x: Vector3;
  113163. /**
  113164. * The y coefficients of the spherical polynomial
  113165. */
  113166. y: Vector3;
  113167. /**
  113168. * The z coefficients of the spherical polynomial
  113169. */
  113170. z: Vector3;
  113171. /**
  113172. * The xx coefficients of the spherical polynomial
  113173. */
  113174. xx: Vector3;
  113175. /**
  113176. * The yy coefficients of the spherical polynomial
  113177. */
  113178. yy: Vector3;
  113179. /**
  113180. * The zz coefficients of the spherical polynomial
  113181. */
  113182. zz: Vector3;
  113183. /**
  113184. * The xy coefficients of the spherical polynomial
  113185. */
  113186. xy: Vector3;
  113187. /**
  113188. * The yz coefficients of the spherical polynomial
  113189. */
  113190. yz: Vector3;
  113191. /**
  113192. * The zx coefficients of the spherical polynomial
  113193. */
  113194. zx: Vector3;
  113195. /**
  113196. * Adds an ambient color to the spherical polynomial
  113197. * @param color the color to add
  113198. */
  113199. addAmbient(color: Color3): void;
  113200. /**
  113201. * Scales the spherical polynomial by the given amount
  113202. * @param scale the amount to scale
  113203. */
  113204. scaleInPlace(scale: number): void;
  113205. /**
  113206. * Gets the spherical polynomial from harmonics
  113207. * @param harmonics the spherical harmonics
  113208. * @returns the spherical polynomial
  113209. */
  113210. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  113211. /**
  113212. * Constructs a spherical polynomial from an array.
  113213. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  113214. * @returns the spherical polynomial
  113215. */
  113216. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  113217. }
  113218. }
  113219. declare module BABYLON {
  113220. /**
  113221. * Defines the source of the internal texture
  113222. */
  113223. export enum InternalTextureSource {
  113224. /**
  113225. * The source of the texture data is unknown
  113226. */
  113227. Unknown = 0,
  113228. /**
  113229. * Texture data comes from an URL
  113230. */
  113231. Url = 1,
  113232. /**
  113233. * Texture data is only used for temporary storage
  113234. */
  113235. Temp = 2,
  113236. /**
  113237. * Texture data comes from raw data (ArrayBuffer)
  113238. */
  113239. Raw = 3,
  113240. /**
  113241. * Texture content is dynamic (video or dynamic texture)
  113242. */
  113243. Dynamic = 4,
  113244. /**
  113245. * Texture content is generated by rendering to it
  113246. */
  113247. RenderTarget = 5,
  113248. /**
  113249. * Texture content is part of a multi render target process
  113250. */
  113251. MultiRenderTarget = 6,
  113252. /**
  113253. * Texture data comes from a cube data file
  113254. */
  113255. Cube = 7,
  113256. /**
  113257. * Texture data comes from a raw cube data
  113258. */
  113259. CubeRaw = 8,
  113260. /**
  113261. * Texture data come from a prefiltered cube data file
  113262. */
  113263. CubePrefiltered = 9,
  113264. /**
  113265. * Texture content is raw 3D data
  113266. */
  113267. Raw3D = 10,
  113268. /**
  113269. * Texture content is raw 2D array data
  113270. */
  113271. Raw2DArray = 11,
  113272. /**
  113273. * Texture content is a depth texture
  113274. */
  113275. Depth = 12,
  113276. /**
  113277. * Texture data comes from a raw cube data encoded with RGBD
  113278. */
  113279. CubeRawRGBD = 13
  113280. }
  113281. /**
  113282. * Class used to store data associated with WebGL texture data for the engine
  113283. * This class should not be used directly
  113284. */
  113285. export class InternalTexture {
  113286. /** @hidden */
  113287. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  113288. /**
  113289. * Defines if the texture is ready
  113290. */
  113291. isReady: boolean;
  113292. /**
  113293. * Defines if the texture is a cube texture
  113294. */
  113295. isCube: boolean;
  113296. /**
  113297. * Defines if the texture contains 3D data
  113298. */
  113299. is3D: boolean;
  113300. /**
  113301. * Defines if the texture contains 2D array data
  113302. */
  113303. is2DArray: boolean;
  113304. /**
  113305. * Defines if the texture contains multiview data
  113306. */
  113307. isMultiview: boolean;
  113308. /**
  113309. * Gets the URL used to load this texture
  113310. */
  113311. url: string;
  113312. /**
  113313. * Gets the sampling mode of the texture
  113314. */
  113315. samplingMode: number;
  113316. /**
  113317. * Gets a boolean indicating if the texture needs mipmaps generation
  113318. */
  113319. generateMipMaps: boolean;
  113320. /**
  113321. * Gets the number of samples used by the texture (WebGL2+ only)
  113322. */
  113323. samples: number;
  113324. /**
  113325. * Gets the type of the texture (int, float...)
  113326. */
  113327. type: number;
  113328. /**
  113329. * Gets the format of the texture (RGB, RGBA...)
  113330. */
  113331. format: number;
  113332. /**
  113333. * Observable called when the texture is loaded
  113334. */
  113335. onLoadedObservable: Observable<InternalTexture>;
  113336. /**
  113337. * Gets the width of the texture
  113338. */
  113339. width: number;
  113340. /**
  113341. * Gets the height of the texture
  113342. */
  113343. height: number;
  113344. /**
  113345. * Gets the depth of the texture
  113346. */
  113347. depth: number;
  113348. /**
  113349. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  113350. */
  113351. baseWidth: number;
  113352. /**
  113353. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  113354. */
  113355. baseHeight: number;
  113356. /**
  113357. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  113358. */
  113359. baseDepth: number;
  113360. /**
  113361. * Gets a boolean indicating if the texture is inverted on Y axis
  113362. */
  113363. invertY: boolean;
  113364. /** @hidden */
  113365. _invertVScale: boolean;
  113366. /** @hidden */
  113367. _associatedChannel: number;
  113368. /** @hidden */
  113369. _source: InternalTextureSource;
  113370. /** @hidden */
  113371. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  113372. /** @hidden */
  113373. _bufferView: Nullable<ArrayBufferView>;
  113374. /** @hidden */
  113375. _bufferViewArray: Nullable<ArrayBufferView[]>;
  113376. /** @hidden */
  113377. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  113378. /** @hidden */
  113379. _size: number;
  113380. /** @hidden */
  113381. _extension: string;
  113382. /** @hidden */
  113383. _files: Nullable<string[]>;
  113384. /** @hidden */
  113385. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113386. /** @hidden */
  113387. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113388. /** @hidden */
  113389. _framebuffer: Nullable<WebGLFramebuffer>;
  113390. /** @hidden */
  113391. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  113392. /** @hidden */
  113393. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  113394. /** @hidden */
  113395. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  113396. /** @hidden */
  113397. _attachments: Nullable<number[]>;
  113398. /** @hidden */
  113399. _cachedCoordinatesMode: Nullable<number>;
  113400. /** @hidden */
  113401. _cachedWrapU: Nullable<number>;
  113402. /** @hidden */
  113403. _cachedWrapV: Nullable<number>;
  113404. /** @hidden */
  113405. _cachedWrapR: Nullable<number>;
  113406. /** @hidden */
  113407. _cachedAnisotropicFilteringLevel: Nullable<number>;
  113408. /** @hidden */
  113409. _isDisabled: boolean;
  113410. /** @hidden */
  113411. _compression: Nullable<string>;
  113412. /** @hidden */
  113413. _generateStencilBuffer: boolean;
  113414. /** @hidden */
  113415. _generateDepthBuffer: boolean;
  113416. /** @hidden */
  113417. _comparisonFunction: number;
  113418. /** @hidden */
  113419. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  113420. /** @hidden */
  113421. _lodGenerationScale: number;
  113422. /** @hidden */
  113423. _lodGenerationOffset: number;
  113424. /** @hidden */
  113425. _depthStencilTexture: Nullable<InternalTexture>;
  113426. /** @hidden */
  113427. _colorTextureArray: Nullable<WebGLTexture>;
  113428. /** @hidden */
  113429. _depthStencilTextureArray: Nullable<WebGLTexture>;
  113430. /** @hidden */
  113431. _lodTextureHigh: Nullable<BaseTexture>;
  113432. /** @hidden */
  113433. _lodTextureMid: Nullable<BaseTexture>;
  113434. /** @hidden */
  113435. _lodTextureLow: Nullable<BaseTexture>;
  113436. /** @hidden */
  113437. _isRGBD: boolean;
  113438. /** @hidden */
  113439. _linearSpecularLOD: boolean;
  113440. /** @hidden */
  113441. _irradianceTexture: Nullable<BaseTexture>;
  113442. /** @hidden */
  113443. _webGLTexture: Nullable<WebGLTexture>;
  113444. /** @hidden */
  113445. _references: number;
  113446. private _engine;
  113447. /**
  113448. * Gets the Engine the texture belongs to.
  113449. * @returns The babylon engine
  113450. */
  113451. getEngine(): ThinEngine;
  113452. /**
  113453. * Gets the data source type of the texture
  113454. */
  113455. get source(): InternalTextureSource;
  113456. /**
  113457. * Creates a new InternalTexture
  113458. * @param engine defines the engine to use
  113459. * @param source defines the type of data that will be used
  113460. * @param delayAllocation if the texture allocation should be delayed (default: false)
  113461. */
  113462. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  113463. /**
  113464. * Increments the number of references (ie. the number of Texture that point to it)
  113465. */
  113466. incrementReferences(): void;
  113467. /**
  113468. * Change the size of the texture (not the size of the content)
  113469. * @param width defines the new width
  113470. * @param height defines the new height
  113471. * @param depth defines the new depth (1 by default)
  113472. */
  113473. updateSize(width: int, height: int, depth?: int): void;
  113474. /** @hidden */
  113475. _rebuild(): void;
  113476. /** @hidden */
  113477. _swapAndDie(target: InternalTexture): void;
  113478. /**
  113479. * Dispose the current allocated resources
  113480. */
  113481. dispose(): void;
  113482. }
  113483. }
  113484. declare module BABYLON {
  113485. /**
  113486. * Class used to work with sound analyzer using fast fourier transform (FFT)
  113487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113488. */
  113489. export class Analyser {
  113490. /**
  113491. * Gets or sets the smoothing
  113492. * @ignorenaming
  113493. */
  113494. SMOOTHING: number;
  113495. /**
  113496. * Gets or sets the FFT table size
  113497. * @ignorenaming
  113498. */
  113499. FFT_SIZE: number;
  113500. /**
  113501. * Gets or sets the bar graph amplitude
  113502. * @ignorenaming
  113503. */
  113504. BARGRAPHAMPLITUDE: number;
  113505. /**
  113506. * Gets or sets the position of the debug canvas
  113507. * @ignorenaming
  113508. */
  113509. DEBUGCANVASPOS: {
  113510. x: number;
  113511. y: number;
  113512. };
  113513. /**
  113514. * Gets or sets the debug canvas size
  113515. * @ignorenaming
  113516. */
  113517. DEBUGCANVASSIZE: {
  113518. width: number;
  113519. height: number;
  113520. };
  113521. private _byteFreqs;
  113522. private _byteTime;
  113523. private _floatFreqs;
  113524. private _webAudioAnalyser;
  113525. private _debugCanvas;
  113526. private _debugCanvasContext;
  113527. private _scene;
  113528. private _registerFunc;
  113529. private _audioEngine;
  113530. /**
  113531. * Creates a new analyser
  113532. * @param scene defines hosting scene
  113533. */
  113534. constructor(scene: Scene);
  113535. /**
  113536. * Get the number of data values you will have to play with for the visualization
  113537. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  113538. * @returns a number
  113539. */
  113540. getFrequencyBinCount(): number;
  113541. /**
  113542. * Gets the current frequency data as a byte array
  113543. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113544. * @returns a Uint8Array
  113545. */
  113546. getByteFrequencyData(): Uint8Array;
  113547. /**
  113548. * Gets the current waveform as a byte array
  113549. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  113550. * @returns a Uint8Array
  113551. */
  113552. getByteTimeDomainData(): Uint8Array;
  113553. /**
  113554. * Gets the current frequency data as a float array
  113555. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113556. * @returns a Float32Array
  113557. */
  113558. getFloatFrequencyData(): Float32Array;
  113559. /**
  113560. * Renders the debug canvas
  113561. */
  113562. drawDebugCanvas(): void;
  113563. /**
  113564. * Stops rendering the debug canvas and removes it
  113565. */
  113566. stopDebugCanvas(): void;
  113567. /**
  113568. * Connects two audio nodes
  113569. * @param inputAudioNode defines first node to connect
  113570. * @param outputAudioNode defines second node to connect
  113571. */
  113572. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  113573. /**
  113574. * Releases all associated resources
  113575. */
  113576. dispose(): void;
  113577. }
  113578. }
  113579. declare module BABYLON {
  113580. /**
  113581. * This represents an audio engine and it is responsible
  113582. * to play, synchronize and analyse sounds throughout the application.
  113583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113584. */
  113585. export interface IAudioEngine extends IDisposable {
  113586. /**
  113587. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113588. */
  113589. readonly canUseWebAudio: boolean;
  113590. /**
  113591. * Gets the current AudioContext if available.
  113592. */
  113593. readonly audioContext: Nullable<AudioContext>;
  113594. /**
  113595. * The master gain node defines the global audio volume of your audio engine.
  113596. */
  113597. readonly masterGain: GainNode;
  113598. /**
  113599. * Gets whether or not mp3 are supported by your browser.
  113600. */
  113601. readonly isMP3supported: boolean;
  113602. /**
  113603. * Gets whether or not ogg are supported by your browser.
  113604. */
  113605. readonly isOGGsupported: boolean;
  113606. /**
  113607. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113608. * @ignoreNaming
  113609. */
  113610. WarnedWebAudioUnsupported: boolean;
  113611. /**
  113612. * Defines if the audio engine relies on a custom unlocked button.
  113613. * In this case, the embedded button will not be displayed.
  113614. */
  113615. useCustomUnlockedButton: boolean;
  113616. /**
  113617. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  113618. */
  113619. readonly unlocked: boolean;
  113620. /**
  113621. * Event raised when audio has been unlocked on the browser.
  113622. */
  113623. onAudioUnlockedObservable: Observable<AudioEngine>;
  113624. /**
  113625. * Event raised when audio has been locked on the browser.
  113626. */
  113627. onAudioLockedObservable: Observable<AudioEngine>;
  113628. /**
  113629. * Flags the audio engine in Locked state.
  113630. * This happens due to new browser policies preventing audio to autoplay.
  113631. */
  113632. lock(): void;
  113633. /**
  113634. * Unlocks the audio engine once a user action has been done on the dom.
  113635. * This is helpful to resume play once browser policies have been satisfied.
  113636. */
  113637. unlock(): void;
  113638. /**
  113639. * Gets the global volume sets on the master gain.
  113640. * @returns the global volume if set or -1 otherwise
  113641. */
  113642. getGlobalVolume(): number;
  113643. /**
  113644. * Sets the global volume of your experience (sets on the master gain).
  113645. * @param newVolume Defines the new global volume of the application
  113646. */
  113647. setGlobalVolume(newVolume: number): void;
  113648. /**
  113649. * Connect the audio engine to an audio analyser allowing some amazing
  113650. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113652. * @param analyser The analyser to connect to the engine
  113653. */
  113654. connectToAnalyser(analyser: Analyser): void;
  113655. }
  113656. /**
  113657. * This represents the default audio engine used in babylon.
  113658. * It is responsible to play, synchronize and analyse sounds throughout the application.
  113659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113660. */
  113661. export class AudioEngine implements IAudioEngine {
  113662. private _audioContext;
  113663. private _audioContextInitialized;
  113664. private _muteButton;
  113665. private _hostElement;
  113666. /**
  113667. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113668. */
  113669. canUseWebAudio: boolean;
  113670. /**
  113671. * The master gain node defines the global audio volume of your audio engine.
  113672. */
  113673. masterGain: GainNode;
  113674. /**
  113675. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113676. * @ignoreNaming
  113677. */
  113678. WarnedWebAudioUnsupported: boolean;
  113679. /**
  113680. * Gets whether or not mp3 are supported by your browser.
  113681. */
  113682. isMP3supported: boolean;
  113683. /**
  113684. * Gets whether or not ogg are supported by your browser.
  113685. */
  113686. isOGGsupported: boolean;
  113687. /**
  113688. * Gets whether audio has been unlocked on the device.
  113689. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  113690. * a user interaction has happened.
  113691. */
  113692. unlocked: boolean;
  113693. /**
  113694. * Defines if the audio engine relies on a custom unlocked button.
  113695. * In this case, the embedded button will not be displayed.
  113696. */
  113697. useCustomUnlockedButton: boolean;
  113698. /**
  113699. * Event raised when audio has been unlocked on the browser.
  113700. */
  113701. onAudioUnlockedObservable: Observable<AudioEngine>;
  113702. /**
  113703. * Event raised when audio has been locked on the browser.
  113704. */
  113705. onAudioLockedObservable: Observable<AudioEngine>;
  113706. /**
  113707. * Gets the current AudioContext if available.
  113708. */
  113709. get audioContext(): Nullable<AudioContext>;
  113710. private _connectedAnalyser;
  113711. /**
  113712. * Instantiates a new audio engine.
  113713. *
  113714. * There should be only one per page as some browsers restrict the number
  113715. * of audio contexts you can create.
  113716. * @param hostElement defines the host element where to display the mute icon if necessary
  113717. */
  113718. constructor(hostElement?: Nullable<HTMLElement>);
  113719. /**
  113720. * Flags the audio engine in Locked state.
  113721. * This happens due to new browser policies preventing audio to autoplay.
  113722. */
  113723. lock(): void;
  113724. /**
  113725. * Unlocks the audio engine once a user action has been done on the dom.
  113726. * This is helpful to resume play once browser policies have been satisfied.
  113727. */
  113728. unlock(): void;
  113729. private _resumeAudioContext;
  113730. private _initializeAudioContext;
  113731. private _tryToRun;
  113732. private _triggerRunningState;
  113733. private _triggerSuspendedState;
  113734. private _displayMuteButton;
  113735. private _moveButtonToTopLeft;
  113736. private _onResize;
  113737. private _hideMuteButton;
  113738. /**
  113739. * Destroy and release the resources associated with the audio ccontext.
  113740. */
  113741. dispose(): void;
  113742. /**
  113743. * Gets the global volume sets on the master gain.
  113744. * @returns the global volume if set or -1 otherwise
  113745. */
  113746. getGlobalVolume(): number;
  113747. /**
  113748. * Sets the global volume of your experience (sets on the master gain).
  113749. * @param newVolume Defines the new global volume of the application
  113750. */
  113751. setGlobalVolume(newVolume: number): void;
  113752. /**
  113753. * Connect the audio engine to an audio analyser allowing some amazing
  113754. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113756. * @param analyser The analyser to connect to the engine
  113757. */
  113758. connectToAnalyser(analyser: Analyser): void;
  113759. }
  113760. }
  113761. declare module BABYLON {
  113762. /**
  113763. * Interface used to present a loading screen while loading a scene
  113764. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113765. */
  113766. export interface ILoadingScreen {
  113767. /**
  113768. * Function called to display the loading screen
  113769. */
  113770. displayLoadingUI: () => void;
  113771. /**
  113772. * Function called to hide the loading screen
  113773. */
  113774. hideLoadingUI: () => void;
  113775. /**
  113776. * Gets or sets the color to use for the background
  113777. */
  113778. loadingUIBackgroundColor: string;
  113779. /**
  113780. * Gets or sets the text to display while loading
  113781. */
  113782. loadingUIText: string;
  113783. }
  113784. /**
  113785. * Class used for the default loading screen
  113786. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113787. */
  113788. export class DefaultLoadingScreen implements ILoadingScreen {
  113789. private _renderingCanvas;
  113790. private _loadingText;
  113791. private _loadingDivBackgroundColor;
  113792. private _loadingDiv;
  113793. private _loadingTextDiv;
  113794. /** Gets or sets the logo url to use for the default loading screen */
  113795. static DefaultLogoUrl: string;
  113796. /** Gets or sets the spinner url to use for the default loading screen */
  113797. static DefaultSpinnerUrl: string;
  113798. /**
  113799. * Creates a new default loading screen
  113800. * @param _renderingCanvas defines the canvas used to render the scene
  113801. * @param _loadingText defines the default text to display
  113802. * @param _loadingDivBackgroundColor defines the default background color
  113803. */
  113804. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  113805. /**
  113806. * Function called to display the loading screen
  113807. */
  113808. displayLoadingUI(): void;
  113809. /**
  113810. * Function called to hide the loading screen
  113811. */
  113812. hideLoadingUI(): void;
  113813. /**
  113814. * Gets or sets the text to display while loading
  113815. */
  113816. set loadingUIText(text: string);
  113817. get loadingUIText(): string;
  113818. /**
  113819. * Gets or sets the color to use for the background
  113820. */
  113821. get loadingUIBackgroundColor(): string;
  113822. set loadingUIBackgroundColor(color: string);
  113823. private _resizeLoadingUI;
  113824. }
  113825. }
  113826. declare module BABYLON {
  113827. /**
  113828. * Interface for any object that can request an animation frame
  113829. */
  113830. export interface ICustomAnimationFrameRequester {
  113831. /**
  113832. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  113833. */
  113834. renderFunction?: Function;
  113835. /**
  113836. * Called to request the next frame to render to
  113837. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  113838. */
  113839. requestAnimationFrame: Function;
  113840. /**
  113841. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  113842. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  113843. */
  113844. requestID?: number;
  113845. }
  113846. }
  113847. declare module BABYLON {
  113848. /**
  113849. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  113850. */
  113851. export class PerformanceMonitor {
  113852. private _enabled;
  113853. private _rollingFrameTime;
  113854. private _lastFrameTimeMs;
  113855. /**
  113856. * constructor
  113857. * @param frameSampleSize The number of samples required to saturate the sliding window
  113858. */
  113859. constructor(frameSampleSize?: number);
  113860. /**
  113861. * Samples current frame
  113862. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  113863. */
  113864. sampleFrame(timeMs?: number): void;
  113865. /**
  113866. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113867. */
  113868. get averageFrameTime(): number;
  113869. /**
  113870. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113871. */
  113872. get averageFrameTimeVariance(): number;
  113873. /**
  113874. * Returns the frame time of the most recent frame
  113875. */
  113876. get instantaneousFrameTime(): number;
  113877. /**
  113878. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  113879. */
  113880. get averageFPS(): number;
  113881. /**
  113882. * Returns the average framerate in frames per second using the most recent frame time
  113883. */
  113884. get instantaneousFPS(): number;
  113885. /**
  113886. * Returns true if enough samples have been taken to completely fill the sliding window
  113887. */
  113888. get isSaturated(): boolean;
  113889. /**
  113890. * Enables contributions to the sliding window sample set
  113891. */
  113892. enable(): void;
  113893. /**
  113894. * Disables contributions to the sliding window sample set
  113895. * Samples will not be interpolated over the disabled period
  113896. */
  113897. disable(): void;
  113898. /**
  113899. * Returns true if sampling is enabled
  113900. */
  113901. get isEnabled(): boolean;
  113902. /**
  113903. * Resets performance monitor
  113904. */
  113905. reset(): void;
  113906. }
  113907. /**
  113908. * RollingAverage
  113909. *
  113910. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  113911. */
  113912. export class RollingAverage {
  113913. /**
  113914. * Current average
  113915. */
  113916. average: number;
  113917. /**
  113918. * Current variance
  113919. */
  113920. variance: number;
  113921. protected _samples: Array<number>;
  113922. protected _sampleCount: number;
  113923. protected _pos: number;
  113924. protected _m2: number;
  113925. /**
  113926. * constructor
  113927. * @param length The number of samples required to saturate the sliding window
  113928. */
  113929. constructor(length: number);
  113930. /**
  113931. * Adds a sample to the sample set
  113932. * @param v The sample value
  113933. */
  113934. add(v: number): void;
  113935. /**
  113936. * Returns previously added values or null if outside of history or outside the sliding window domain
  113937. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  113938. * @return Value previously recorded with add() or null if outside of range
  113939. */
  113940. history(i: number): number;
  113941. /**
  113942. * Returns true if enough samples have been taken to completely fill the sliding window
  113943. * @return true if sample-set saturated
  113944. */
  113945. isSaturated(): boolean;
  113946. /**
  113947. * Resets the rolling average (equivalent to 0 samples taken so far)
  113948. */
  113949. reset(): void;
  113950. /**
  113951. * Wraps a value around the sample range boundaries
  113952. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  113953. * @return Wrapped position in sample range
  113954. */
  113955. protected _wrapPosition(i: number): number;
  113956. }
  113957. }
  113958. declare module BABYLON {
  113959. /**
  113960. * This class is used to track a performance counter which is number based.
  113961. * The user has access to many properties which give statistics of different nature.
  113962. *
  113963. * The implementer can track two kinds of Performance Counter: time and count.
  113964. * 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.
  113965. * 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.
  113966. */
  113967. export class PerfCounter {
  113968. /**
  113969. * Gets or sets a global boolean to turn on and off all the counters
  113970. */
  113971. static Enabled: boolean;
  113972. /**
  113973. * Returns the smallest value ever
  113974. */
  113975. get min(): number;
  113976. /**
  113977. * Returns the biggest value ever
  113978. */
  113979. get max(): number;
  113980. /**
  113981. * Returns the average value since the performance counter is running
  113982. */
  113983. get average(): number;
  113984. /**
  113985. * Returns the average value of the last second the counter was monitored
  113986. */
  113987. get lastSecAverage(): number;
  113988. /**
  113989. * Returns the current value
  113990. */
  113991. get current(): number;
  113992. /**
  113993. * Gets the accumulated total
  113994. */
  113995. get total(): number;
  113996. /**
  113997. * Gets the total value count
  113998. */
  113999. get count(): number;
  114000. /**
  114001. * Creates a new counter
  114002. */
  114003. constructor();
  114004. /**
  114005. * Call this method to start monitoring a new frame.
  114006. * 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.
  114007. */
  114008. fetchNewFrame(): void;
  114009. /**
  114010. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  114011. * @param newCount the count value to add to the monitored count
  114012. * @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.
  114013. */
  114014. addCount(newCount: number, fetchResult: boolean): void;
  114015. /**
  114016. * Start monitoring this performance counter
  114017. */
  114018. beginMonitoring(): void;
  114019. /**
  114020. * Compute the time lapsed since the previous beginMonitoring() call.
  114021. * @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
  114022. */
  114023. endMonitoring(newFrame?: boolean): void;
  114024. private _fetchResult;
  114025. private _startMonitoringTime;
  114026. private _min;
  114027. private _max;
  114028. private _average;
  114029. private _current;
  114030. private _totalValueCount;
  114031. private _totalAccumulated;
  114032. private _lastSecAverage;
  114033. private _lastSecAccumulated;
  114034. private _lastSecTime;
  114035. private _lastSecValueCount;
  114036. }
  114037. }
  114038. declare module BABYLON {
  114039. interface ThinEngine {
  114040. /**
  114041. * Sets alpha constants used by some alpha blending modes
  114042. * @param r defines the red component
  114043. * @param g defines the green component
  114044. * @param b defines the blue component
  114045. * @param a defines the alpha component
  114046. */
  114047. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114048. /**
  114049. * Sets the current alpha mode
  114050. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114051. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114052. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114053. */
  114054. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114055. /**
  114056. * Gets the current alpha mode
  114057. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114058. * @returns the current alpha mode
  114059. */
  114060. getAlphaMode(): number;
  114061. /**
  114062. * Sets the current alpha equation
  114063. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  114064. */
  114065. setAlphaEquation(equation: number): void;
  114066. /**
  114067. * Gets the current alpha equation.
  114068. * @returns the current alpha equation
  114069. */
  114070. getAlphaEquation(): number;
  114071. }
  114072. }
  114073. declare module BABYLON {
  114074. interface ThinEngine {
  114075. /** @hidden */
  114076. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114077. }
  114078. }
  114079. declare module BABYLON {
  114080. /**
  114081. * Defines the interface used by display changed events
  114082. */
  114083. export interface IDisplayChangedEventArgs {
  114084. /** Gets the vrDisplay object (if any) */
  114085. vrDisplay: Nullable<any>;
  114086. /** Gets a boolean indicating if webVR is supported */
  114087. vrSupported: boolean;
  114088. }
  114089. /**
  114090. * Defines the interface used by objects containing a viewport (like a camera)
  114091. */
  114092. interface IViewportOwnerLike {
  114093. /**
  114094. * Gets or sets the viewport
  114095. */
  114096. viewport: IViewportLike;
  114097. }
  114098. /**
  114099. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114100. */
  114101. export class Engine extends ThinEngine {
  114102. /** Defines that alpha blending is disabled */
  114103. static readonly ALPHA_DISABLE: number;
  114104. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114105. static readonly ALPHA_ADD: number;
  114106. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114107. static readonly ALPHA_COMBINE: number;
  114108. /** Defines that alpha blending to DEST - SRC * DEST */
  114109. static readonly ALPHA_SUBTRACT: number;
  114110. /** Defines that alpha blending to SRC * DEST */
  114111. static readonly ALPHA_MULTIPLY: number;
  114112. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114113. static readonly ALPHA_MAXIMIZED: number;
  114114. /** Defines that alpha blending to SRC + DEST */
  114115. static readonly ALPHA_ONEONE: number;
  114116. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114117. static readonly ALPHA_PREMULTIPLIED: number;
  114118. /**
  114119. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114120. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114121. */
  114122. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114123. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114124. static readonly ALPHA_INTERPOLATE: number;
  114125. /**
  114126. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114127. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114128. */
  114129. static readonly ALPHA_SCREENMODE: number;
  114130. /** Defines that the ressource is not delayed*/
  114131. static readonly DELAYLOADSTATE_NONE: number;
  114132. /** Defines that the ressource was successfully delay loaded */
  114133. static readonly DELAYLOADSTATE_LOADED: number;
  114134. /** Defines that the ressource is currently delay loading */
  114135. static readonly DELAYLOADSTATE_LOADING: number;
  114136. /** Defines that the ressource is delayed and has not started loading */
  114137. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114139. static readonly NEVER: number;
  114140. /** 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 */
  114141. static readonly ALWAYS: number;
  114142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114143. static readonly LESS: number;
  114144. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114145. static readonly EQUAL: number;
  114146. /** 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 */
  114147. static readonly LEQUAL: number;
  114148. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114149. static readonly GREATER: number;
  114150. /** 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 */
  114151. static readonly GEQUAL: number;
  114152. /** 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 */
  114153. static readonly NOTEQUAL: number;
  114154. /** Passed to stencilOperation to specify that stencil value must be kept */
  114155. static readonly KEEP: number;
  114156. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114157. static readonly REPLACE: number;
  114158. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114159. static readonly INCR: number;
  114160. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114161. static readonly DECR: number;
  114162. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114163. static readonly INVERT: number;
  114164. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114165. static readonly INCR_WRAP: number;
  114166. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114167. static readonly DECR_WRAP: number;
  114168. /** Texture is not repeating outside of 0..1 UVs */
  114169. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114170. /** Texture is repeating outside of 0..1 UVs */
  114171. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114172. /** Texture is repeating and mirrored */
  114173. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114174. /** ALPHA */
  114175. static readonly TEXTUREFORMAT_ALPHA: number;
  114176. /** LUMINANCE */
  114177. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114178. /** LUMINANCE_ALPHA */
  114179. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114180. /** RGB */
  114181. static readonly TEXTUREFORMAT_RGB: number;
  114182. /** RGBA */
  114183. static readonly TEXTUREFORMAT_RGBA: number;
  114184. /** RED */
  114185. static readonly TEXTUREFORMAT_RED: number;
  114186. /** RED (2nd reference) */
  114187. static readonly TEXTUREFORMAT_R: number;
  114188. /** RG */
  114189. static readonly TEXTUREFORMAT_RG: number;
  114190. /** RED_INTEGER */
  114191. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114192. /** RED_INTEGER (2nd reference) */
  114193. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114194. /** RG_INTEGER */
  114195. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114196. /** RGB_INTEGER */
  114197. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114198. /** RGBA_INTEGER */
  114199. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  114200. /** UNSIGNED_BYTE */
  114201. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  114202. /** UNSIGNED_BYTE (2nd reference) */
  114203. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  114204. /** FLOAT */
  114205. static readonly TEXTURETYPE_FLOAT: number;
  114206. /** HALF_FLOAT */
  114207. static readonly TEXTURETYPE_HALF_FLOAT: number;
  114208. /** BYTE */
  114209. static readonly TEXTURETYPE_BYTE: number;
  114210. /** SHORT */
  114211. static readonly TEXTURETYPE_SHORT: number;
  114212. /** UNSIGNED_SHORT */
  114213. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  114214. /** INT */
  114215. static readonly TEXTURETYPE_INT: number;
  114216. /** UNSIGNED_INT */
  114217. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  114218. /** UNSIGNED_SHORT_4_4_4_4 */
  114219. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  114220. /** UNSIGNED_SHORT_5_5_5_1 */
  114221. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  114222. /** UNSIGNED_SHORT_5_6_5 */
  114223. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  114224. /** UNSIGNED_INT_2_10_10_10_REV */
  114225. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  114226. /** UNSIGNED_INT_24_8 */
  114227. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  114228. /** UNSIGNED_INT_10F_11F_11F_REV */
  114229. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  114230. /** UNSIGNED_INT_5_9_9_9_REV */
  114231. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  114232. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  114233. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114234. /** nearest is mag = nearest and min = nearest and mip = linear */
  114235. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  114236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114237. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  114238. /** Trilinear is mag = linear and min = linear and mip = linear */
  114239. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  114240. /** nearest is mag = nearest and min = nearest and mip = linear */
  114241. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  114242. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114243. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  114244. /** Trilinear is mag = linear and min = linear and mip = linear */
  114245. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  114246. /** mag = nearest and min = nearest and mip = nearest */
  114247. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  114248. /** mag = nearest and min = linear and mip = nearest */
  114249. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  114250. /** mag = nearest and min = linear and mip = linear */
  114251. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  114252. /** mag = nearest and min = linear and mip = none */
  114253. static readonly TEXTURE_NEAREST_LINEAR: number;
  114254. /** mag = nearest and min = nearest and mip = none */
  114255. static readonly TEXTURE_NEAREST_NEAREST: number;
  114256. /** mag = linear and min = nearest and mip = nearest */
  114257. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  114258. /** mag = linear and min = nearest and mip = linear */
  114259. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  114260. /** mag = linear and min = linear and mip = none */
  114261. static readonly TEXTURE_LINEAR_LINEAR: number;
  114262. /** mag = linear and min = nearest and mip = none */
  114263. static readonly TEXTURE_LINEAR_NEAREST: number;
  114264. /** Explicit coordinates mode */
  114265. static readonly TEXTURE_EXPLICIT_MODE: number;
  114266. /** Spherical coordinates mode */
  114267. static readonly TEXTURE_SPHERICAL_MODE: number;
  114268. /** Planar coordinates mode */
  114269. static readonly TEXTURE_PLANAR_MODE: number;
  114270. /** Cubic coordinates mode */
  114271. static readonly TEXTURE_CUBIC_MODE: number;
  114272. /** Projection coordinates mode */
  114273. static readonly TEXTURE_PROJECTION_MODE: number;
  114274. /** Skybox coordinates mode */
  114275. static readonly TEXTURE_SKYBOX_MODE: number;
  114276. /** Inverse Cubic coordinates mode */
  114277. static readonly TEXTURE_INVCUBIC_MODE: number;
  114278. /** Equirectangular coordinates mode */
  114279. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  114280. /** Equirectangular Fixed coordinates mode */
  114281. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  114282. /** Equirectangular Fixed Mirrored coordinates mode */
  114283. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  114284. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  114285. static readonly SCALEMODE_FLOOR: number;
  114286. /** Defines that texture rescaling will look for the nearest power of 2 size */
  114287. static readonly SCALEMODE_NEAREST: number;
  114288. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  114289. static readonly SCALEMODE_CEILING: number;
  114290. /**
  114291. * Returns the current npm package of the sdk
  114292. */
  114293. static get NpmPackage(): string;
  114294. /**
  114295. * Returns the current version of the framework
  114296. */
  114297. static get Version(): string;
  114298. /** Gets the list of created engines */
  114299. static get Instances(): Engine[];
  114300. /**
  114301. * Gets the latest created engine
  114302. */
  114303. static get LastCreatedEngine(): Nullable<Engine>;
  114304. /**
  114305. * Gets the latest created scene
  114306. */
  114307. static get LastCreatedScene(): Nullable<Scene>;
  114308. /**
  114309. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  114310. * @param flag defines which part of the materials must be marked as dirty
  114311. * @param predicate defines a predicate used to filter which materials should be affected
  114312. */
  114313. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  114314. /**
  114315. * Method called to create the default loading screen.
  114316. * This can be overriden in your own app.
  114317. * @param canvas The rendering canvas element
  114318. * @returns The loading screen
  114319. */
  114320. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  114321. /**
  114322. * Method called to create the default rescale post process on each engine.
  114323. */
  114324. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  114325. /**
  114326. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  114327. **/
  114328. enableOfflineSupport: boolean;
  114329. /**
  114330. * 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)
  114331. **/
  114332. disableManifestCheck: boolean;
  114333. /**
  114334. * Gets the list of created scenes
  114335. */
  114336. scenes: Scene[];
  114337. /**
  114338. * Event raised when a new scene is created
  114339. */
  114340. onNewSceneAddedObservable: Observable<Scene>;
  114341. /**
  114342. * Gets the list of created postprocesses
  114343. */
  114344. postProcesses: PostProcess[];
  114345. /**
  114346. * Gets a boolean indicating if the pointer is currently locked
  114347. */
  114348. isPointerLock: boolean;
  114349. /**
  114350. * Observable event triggered each time the rendering canvas is resized
  114351. */
  114352. onResizeObservable: Observable<Engine>;
  114353. /**
  114354. * Observable event triggered each time the canvas loses focus
  114355. */
  114356. onCanvasBlurObservable: Observable<Engine>;
  114357. /**
  114358. * Observable event triggered each time the canvas gains focus
  114359. */
  114360. onCanvasFocusObservable: Observable<Engine>;
  114361. /**
  114362. * Observable event triggered each time the canvas receives pointerout event
  114363. */
  114364. onCanvasPointerOutObservable: Observable<PointerEvent>;
  114365. /**
  114366. * Observable raised when the engine begins a new frame
  114367. */
  114368. onBeginFrameObservable: Observable<Engine>;
  114369. /**
  114370. * If set, will be used to request the next animation frame for the render loop
  114371. */
  114372. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  114373. /**
  114374. * Observable raised when the engine ends the current frame
  114375. */
  114376. onEndFrameObservable: Observable<Engine>;
  114377. /**
  114378. * Observable raised when the engine is about to compile a shader
  114379. */
  114380. onBeforeShaderCompilationObservable: Observable<Engine>;
  114381. /**
  114382. * Observable raised when the engine has jsut compiled a shader
  114383. */
  114384. onAfterShaderCompilationObservable: Observable<Engine>;
  114385. /**
  114386. * Gets the audio engine
  114387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114388. * @ignorenaming
  114389. */
  114390. static audioEngine: IAudioEngine;
  114391. /**
  114392. * Default AudioEngine factory responsible of creating the Audio Engine.
  114393. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  114394. */
  114395. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  114396. /**
  114397. * Default offline support factory responsible of creating a tool used to store data locally.
  114398. * By default, this will create a Database object if the workload has been embedded.
  114399. */
  114400. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  114401. private _loadingScreen;
  114402. private _pointerLockRequested;
  114403. private _rescalePostProcess;
  114404. private _deterministicLockstep;
  114405. private _lockstepMaxSteps;
  114406. private _timeStep;
  114407. protected get _supportsHardwareTextureRescaling(): boolean;
  114408. private _fps;
  114409. private _deltaTime;
  114410. /** @hidden */
  114411. _drawCalls: PerfCounter;
  114412. /** 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 */
  114413. canvasTabIndex: number;
  114414. /**
  114415. * Turn this value on if you want to pause FPS computation when in background
  114416. */
  114417. disablePerformanceMonitorInBackground: boolean;
  114418. private _performanceMonitor;
  114419. /**
  114420. * Gets the performance monitor attached to this engine
  114421. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114422. */
  114423. get performanceMonitor(): PerformanceMonitor;
  114424. private _onFocus;
  114425. private _onBlur;
  114426. private _onCanvasPointerOut;
  114427. private _onCanvasBlur;
  114428. private _onCanvasFocus;
  114429. private _onFullscreenChange;
  114430. private _onPointerLockChange;
  114431. /**
  114432. * Gets the HTML element used to attach event listeners
  114433. * @returns a HTML element
  114434. */
  114435. getInputElement(): Nullable<HTMLElement>;
  114436. /**
  114437. * Creates a new engine
  114438. * @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
  114439. * @param antialias defines enable antialiasing (default: false)
  114440. * @param options defines further options to be sent to the getContext() function
  114441. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114442. */
  114443. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114444. /**
  114445. * Gets current aspect ratio
  114446. * @param viewportOwner defines the camera to use to get the aspect ratio
  114447. * @param useScreen defines if screen size must be used (or the current render target if any)
  114448. * @returns a number defining the aspect ratio
  114449. */
  114450. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  114451. /**
  114452. * Gets current screen aspect ratio
  114453. * @returns a number defining the aspect ratio
  114454. */
  114455. getScreenAspectRatio(): number;
  114456. /**
  114457. * Gets the client rect of the HTML canvas attached with the current webGL context
  114458. * @returns a client rectanglee
  114459. */
  114460. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  114461. /**
  114462. * Gets the client rect of the HTML element used for events
  114463. * @returns a client rectanglee
  114464. */
  114465. getInputElementClientRect(): Nullable<ClientRect>;
  114466. /**
  114467. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114468. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114469. * @returns true if engine is in deterministic lock step mode
  114470. */
  114471. isDeterministicLockStep(): boolean;
  114472. /**
  114473. * Gets the max steps when engine is running in deterministic lock step
  114474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114475. * @returns the max steps
  114476. */
  114477. getLockstepMaxSteps(): number;
  114478. /**
  114479. * Returns the time in ms between steps when using deterministic lock step.
  114480. * @returns time step in (ms)
  114481. */
  114482. getTimeStep(): number;
  114483. /**
  114484. * Force the mipmap generation for the given render target texture
  114485. * @param texture defines the render target texture to use
  114486. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  114487. */
  114488. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  114489. /** States */
  114490. /**
  114491. * Set various states to the webGL context
  114492. * @param culling defines backface culling state
  114493. * @param zOffset defines the value to apply to zOffset (0 by default)
  114494. * @param force defines if states must be applied even if cache is up to date
  114495. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114496. */
  114497. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114498. /**
  114499. * Set the z offset to apply to current rendering
  114500. * @param value defines the offset to apply
  114501. */
  114502. setZOffset(value: number): void;
  114503. /**
  114504. * Gets the current value of the zOffset
  114505. * @returns the current zOffset state
  114506. */
  114507. getZOffset(): number;
  114508. /**
  114509. * Enable or disable depth buffering
  114510. * @param enable defines the state to set
  114511. */
  114512. setDepthBuffer(enable: boolean): void;
  114513. /**
  114514. * Gets a boolean indicating if depth writing is enabled
  114515. * @returns the current depth writing state
  114516. */
  114517. getDepthWrite(): boolean;
  114518. /**
  114519. * Enable or disable depth writing
  114520. * @param enable defines the state to set
  114521. */
  114522. setDepthWrite(enable: boolean): void;
  114523. /**
  114524. * Gets a boolean indicating if stencil buffer is enabled
  114525. * @returns the current stencil buffer state
  114526. */
  114527. getStencilBuffer(): boolean;
  114528. /**
  114529. * Enable or disable the stencil buffer
  114530. * @param enable defines if the stencil buffer must be enabled or disabled
  114531. */
  114532. setStencilBuffer(enable: boolean): void;
  114533. /**
  114534. * Gets the current stencil mask
  114535. * @returns a number defining the new stencil mask to use
  114536. */
  114537. getStencilMask(): number;
  114538. /**
  114539. * Sets the current stencil mask
  114540. * @param mask defines the new stencil mask to use
  114541. */
  114542. setStencilMask(mask: number): void;
  114543. /**
  114544. * Gets the current stencil function
  114545. * @returns a number defining the stencil function to use
  114546. */
  114547. getStencilFunction(): number;
  114548. /**
  114549. * Gets the current stencil reference value
  114550. * @returns a number defining the stencil reference value to use
  114551. */
  114552. getStencilFunctionReference(): number;
  114553. /**
  114554. * Gets the current stencil mask
  114555. * @returns a number defining the stencil mask to use
  114556. */
  114557. getStencilFunctionMask(): number;
  114558. /**
  114559. * Sets the current stencil function
  114560. * @param stencilFunc defines the new stencil function to use
  114561. */
  114562. setStencilFunction(stencilFunc: number): void;
  114563. /**
  114564. * Sets the current stencil reference
  114565. * @param reference defines the new stencil reference to use
  114566. */
  114567. setStencilFunctionReference(reference: number): void;
  114568. /**
  114569. * Sets the current stencil mask
  114570. * @param mask defines the new stencil mask to use
  114571. */
  114572. setStencilFunctionMask(mask: number): void;
  114573. /**
  114574. * Gets the current stencil operation when stencil fails
  114575. * @returns a number defining stencil operation to use when stencil fails
  114576. */
  114577. getStencilOperationFail(): number;
  114578. /**
  114579. * Gets the current stencil operation when depth fails
  114580. * @returns a number defining stencil operation to use when depth fails
  114581. */
  114582. getStencilOperationDepthFail(): number;
  114583. /**
  114584. * Gets the current stencil operation when stencil passes
  114585. * @returns a number defining stencil operation to use when stencil passes
  114586. */
  114587. getStencilOperationPass(): number;
  114588. /**
  114589. * Sets the stencil operation to use when stencil fails
  114590. * @param operation defines the stencil operation to use when stencil fails
  114591. */
  114592. setStencilOperationFail(operation: number): void;
  114593. /**
  114594. * Sets the stencil operation to use when depth fails
  114595. * @param operation defines the stencil operation to use when depth fails
  114596. */
  114597. setStencilOperationDepthFail(operation: number): void;
  114598. /**
  114599. * Sets the stencil operation to use when stencil passes
  114600. * @param operation defines the stencil operation to use when stencil passes
  114601. */
  114602. setStencilOperationPass(operation: number): void;
  114603. /**
  114604. * Sets a boolean indicating if the dithering state is enabled or disabled
  114605. * @param value defines the dithering state
  114606. */
  114607. setDitheringState(value: boolean): void;
  114608. /**
  114609. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  114610. * @param value defines the rasterizer state
  114611. */
  114612. setRasterizerState(value: boolean): void;
  114613. /**
  114614. * Gets the current depth function
  114615. * @returns a number defining the depth function
  114616. */
  114617. getDepthFunction(): Nullable<number>;
  114618. /**
  114619. * Sets the current depth function
  114620. * @param depthFunc defines the function to use
  114621. */
  114622. setDepthFunction(depthFunc: number): void;
  114623. /**
  114624. * Sets the current depth function to GREATER
  114625. */
  114626. setDepthFunctionToGreater(): void;
  114627. /**
  114628. * Sets the current depth function to GEQUAL
  114629. */
  114630. setDepthFunctionToGreaterOrEqual(): void;
  114631. /**
  114632. * Sets the current depth function to LESS
  114633. */
  114634. setDepthFunctionToLess(): void;
  114635. /**
  114636. * Sets the current depth function to LEQUAL
  114637. */
  114638. setDepthFunctionToLessOrEqual(): void;
  114639. private _cachedStencilBuffer;
  114640. private _cachedStencilFunction;
  114641. private _cachedStencilMask;
  114642. private _cachedStencilOperationPass;
  114643. private _cachedStencilOperationFail;
  114644. private _cachedStencilOperationDepthFail;
  114645. private _cachedStencilReference;
  114646. /**
  114647. * Caches the the state of the stencil buffer
  114648. */
  114649. cacheStencilState(): void;
  114650. /**
  114651. * Restores the state of the stencil buffer
  114652. */
  114653. restoreStencilState(): void;
  114654. /**
  114655. * Directly set the WebGL Viewport
  114656. * @param x defines the x coordinate of the viewport (in screen space)
  114657. * @param y defines the y coordinate of the viewport (in screen space)
  114658. * @param width defines the width of the viewport (in screen space)
  114659. * @param height defines the height of the viewport (in screen space)
  114660. * @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
  114661. */
  114662. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  114663. /**
  114664. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  114665. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114666. * @param y defines the y-coordinate of the corner of the clear rectangle
  114667. * @param width defines the width of the clear rectangle
  114668. * @param height defines the height of the clear rectangle
  114669. * @param clearColor defines the clear color
  114670. */
  114671. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  114672. /**
  114673. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  114674. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114675. * @param y defines the y-coordinate of the corner of the clear rectangle
  114676. * @param width defines the width of the clear rectangle
  114677. * @param height defines the height of the clear rectangle
  114678. */
  114679. enableScissor(x: number, y: number, width: number, height: number): void;
  114680. /**
  114681. * Disable previously set scissor test rectangle
  114682. */
  114683. disableScissor(): void;
  114684. protected _reportDrawCall(): void;
  114685. /**
  114686. * Initializes a webVR display and starts listening to display change events
  114687. * The onVRDisplayChangedObservable will be notified upon these changes
  114688. * @returns The onVRDisplayChangedObservable
  114689. */
  114690. initWebVR(): Observable<IDisplayChangedEventArgs>;
  114691. /** @hidden */
  114692. _prepareVRComponent(): void;
  114693. /** @hidden */
  114694. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  114695. /** @hidden */
  114696. _submitVRFrame(): void;
  114697. /**
  114698. * Call this function to leave webVR mode
  114699. * Will do nothing if webVR is not supported or if there is no webVR device
  114700. * @see http://doc.babylonjs.com/how_to/webvr_camera
  114701. */
  114702. disableVR(): void;
  114703. /**
  114704. * Gets a boolean indicating that the system is in VR mode and is presenting
  114705. * @returns true if VR mode is engaged
  114706. */
  114707. isVRPresenting(): boolean;
  114708. /** @hidden */
  114709. _requestVRFrame(): void;
  114710. /** @hidden */
  114711. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  114712. /**
  114713. * Gets the source code of the vertex shader associated with a specific webGL program
  114714. * @param program defines the program to use
  114715. * @returns a string containing the source code of the vertex shader associated with the program
  114716. */
  114717. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  114718. /**
  114719. * Gets the source code of the fragment shader associated with a specific webGL program
  114720. * @param program defines the program to use
  114721. * @returns a string containing the source code of the fragment shader associated with the program
  114722. */
  114723. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  114724. /**
  114725. * Sets a depth stencil texture from a render target to the according uniform.
  114726. * @param channel The texture channel
  114727. * @param uniform The uniform to set
  114728. * @param texture The render target texture containing the depth stencil texture to apply
  114729. */
  114730. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  114731. /**
  114732. * Sets a texture to the webGL context from a postprocess
  114733. * @param channel defines the channel to use
  114734. * @param postProcess defines the source postprocess
  114735. */
  114736. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  114737. /**
  114738. * Binds the output of the passed in post process to the texture channel specified
  114739. * @param channel The channel the texture should be bound to
  114740. * @param postProcess The post process which's output should be bound
  114741. */
  114742. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  114743. protected _rebuildBuffers(): void;
  114744. /** @hidden */
  114745. _renderFrame(): void;
  114746. _renderLoop(): void;
  114747. /** @hidden */
  114748. _renderViews(): boolean;
  114749. /**
  114750. * Toggle full screen mode
  114751. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114752. */
  114753. switchFullscreen(requestPointerLock: boolean): void;
  114754. /**
  114755. * Enters full screen mode
  114756. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114757. */
  114758. enterFullscreen(requestPointerLock: boolean): void;
  114759. /**
  114760. * Exits full screen mode
  114761. */
  114762. exitFullscreen(): void;
  114763. /**
  114764. * Enters Pointerlock mode
  114765. */
  114766. enterPointerlock(): void;
  114767. /**
  114768. * Exits Pointerlock mode
  114769. */
  114770. exitPointerlock(): void;
  114771. /**
  114772. * Begin a new frame
  114773. */
  114774. beginFrame(): void;
  114775. /**
  114776. * Enf the current frame
  114777. */
  114778. endFrame(): void;
  114779. resize(): void;
  114780. /**
  114781. * Force a specific size of the canvas
  114782. * @param width defines the new canvas' width
  114783. * @param height defines the new canvas' height
  114784. */
  114785. setSize(width: number, height: number): void;
  114786. /**
  114787. * Updates a dynamic vertex buffer.
  114788. * @param vertexBuffer the vertex buffer to update
  114789. * @param data the data used to update the vertex buffer
  114790. * @param byteOffset the byte offset of the data
  114791. * @param byteLength the byte length of the data
  114792. */
  114793. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114794. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114795. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114796. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114797. _releaseTexture(texture: InternalTexture): void;
  114798. /**
  114799. * @hidden
  114800. * Rescales a texture
  114801. * @param source input texutre
  114802. * @param destination destination texture
  114803. * @param scene scene to use to render the resize
  114804. * @param internalFormat format to use when resizing
  114805. * @param onComplete callback to be called when resize has completed
  114806. */
  114807. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114808. /**
  114809. * Gets the current framerate
  114810. * @returns a number representing the framerate
  114811. */
  114812. getFps(): number;
  114813. /**
  114814. * Gets the time spent between current and previous frame
  114815. * @returns a number representing the delta time in ms
  114816. */
  114817. getDeltaTime(): number;
  114818. private _measureFps;
  114819. /** @hidden */
  114820. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  114821. /**
  114822. * Update a dynamic index buffer
  114823. * @param indexBuffer defines the target index buffer
  114824. * @param indices defines the data to update
  114825. * @param offset defines the offset in the target index buffer where update should start
  114826. */
  114827. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114828. /**
  114829. * Updates the sample count of a render target texture
  114830. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114831. * @param texture defines the texture to update
  114832. * @param samples defines the sample count to set
  114833. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114834. */
  114835. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  114836. /**
  114837. * Updates a depth texture Comparison Mode and Function.
  114838. * If the comparison Function is equal to 0, the mode will be set to none.
  114839. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  114840. * @param texture The texture to set the comparison function for
  114841. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  114842. */
  114843. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  114844. /**
  114845. * Creates a webGL buffer to use with instanciation
  114846. * @param capacity defines the size of the buffer
  114847. * @returns the webGL buffer
  114848. */
  114849. createInstancesBuffer(capacity: number): DataBuffer;
  114850. /**
  114851. * Delete a webGL buffer used with instanciation
  114852. * @param buffer defines the webGL buffer to delete
  114853. */
  114854. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  114855. private _clientWaitAsync;
  114856. /** @hidden */
  114857. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  114858. dispose(): void;
  114859. private _disableTouchAction;
  114860. /**
  114861. * Display the loading screen
  114862. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114863. */
  114864. displayLoadingUI(): void;
  114865. /**
  114866. * Hide the loading screen
  114867. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114868. */
  114869. hideLoadingUI(): void;
  114870. /**
  114871. * Gets the current loading screen object
  114872. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114873. */
  114874. get loadingScreen(): ILoadingScreen;
  114875. /**
  114876. * Sets the current loading screen object
  114877. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114878. */
  114879. set loadingScreen(loadingScreen: ILoadingScreen);
  114880. /**
  114881. * Sets the current loading screen text
  114882. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114883. */
  114884. set loadingUIText(text: string);
  114885. /**
  114886. * Sets the current loading screen background color
  114887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114888. */
  114889. set loadingUIBackgroundColor(color: string);
  114890. /** Pointerlock and fullscreen */
  114891. /**
  114892. * Ask the browser to promote the current element to pointerlock mode
  114893. * @param element defines the DOM element to promote
  114894. */
  114895. static _RequestPointerlock(element: HTMLElement): void;
  114896. /**
  114897. * Asks the browser to exit pointerlock mode
  114898. */
  114899. static _ExitPointerlock(): void;
  114900. /**
  114901. * Ask the browser to promote the current element to fullscreen rendering mode
  114902. * @param element defines the DOM element to promote
  114903. */
  114904. static _RequestFullscreen(element: HTMLElement): void;
  114905. /**
  114906. * Asks the browser to exit fullscreen mode
  114907. */
  114908. static _ExitFullscreen(): void;
  114909. }
  114910. }
  114911. declare module BABYLON {
  114912. /**
  114913. * The engine store class is responsible to hold all the instances of Engine and Scene created
  114914. * during the life time of the application.
  114915. */
  114916. export class EngineStore {
  114917. /** Gets the list of created engines */
  114918. static Instances: Engine[];
  114919. /** @hidden */
  114920. static _LastCreatedScene: Nullable<Scene>;
  114921. /**
  114922. * Gets the latest created engine
  114923. */
  114924. static get LastCreatedEngine(): Nullable<Engine>;
  114925. /**
  114926. * Gets the latest created scene
  114927. */
  114928. static get LastCreatedScene(): Nullable<Scene>;
  114929. /**
  114930. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114931. * @ignorenaming
  114932. */
  114933. static UseFallbackTexture: boolean;
  114934. /**
  114935. * Texture content used if a texture cannot loaded
  114936. * @ignorenaming
  114937. */
  114938. static FallbackTexture: string;
  114939. }
  114940. }
  114941. declare module BABYLON {
  114942. /**
  114943. * Helper class that provides a small promise polyfill
  114944. */
  114945. export class PromisePolyfill {
  114946. /**
  114947. * Static function used to check if the polyfill is required
  114948. * If this is the case then the function will inject the polyfill to window.Promise
  114949. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  114950. */
  114951. static Apply(force?: boolean): void;
  114952. }
  114953. }
  114954. declare module BABYLON {
  114955. /**
  114956. * Interface for screenshot methods with describe argument called `size` as object with options
  114957. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  114958. */
  114959. export interface IScreenshotSize {
  114960. /**
  114961. * number in pixels for canvas height
  114962. */
  114963. height?: number;
  114964. /**
  114965. * multiplier allowing render at a higher or lower resolution
  114966. * If value is defined then height and width will be ignored and taken from camera
  114967. */
  114968. precision?: number;
  114969. /**
  114970. * number in pixels for canvas width
  114971. */
  114972. width?: number;
  114973. }
  114974. }
  114975. declare module BABYLON {
  114976. interface IColor4Like {
  114977. r: float;
  114978. g: float;
  114979. b: float;
  114980. a: float;
  114981. }
  114982. /**
  114983. * Class containing a set of static utilities functions
  114984. */
  114985. export class Tools {
  114986. /**
  114987. * Gets or sets the base URL to use to load assets
  114988. */
  114989. static get BaseUrl(): string;
  114990. static set BaseUrl(value: string);
  114991. /**
  114992. * Enable/Disable Custom HTTP Request Headers globally.
  114993. * default = false
  114994. * @see CustomRequestHeaders
  114995. */
  114996. static UseCustomRequestHeaders: boolean;
  114997. /**
  114998. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  114999. * i.e. when loading files, where the server/service expects an Authorization header
  115000. */
  115001. static CustomRequestHeaders: {
  115002. [key: string]: string;
  115003. };
  115004. /**
  115005. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115006. */
  115007. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  115008. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  115009. /**
  115010. * Default behaviour for cors in the application.
  115011. * It can be a string if the expected behavior is identical in the entire app.
  115012. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  115013. */
  115014. static get CorsBehavior(): string | ((url: string | string[]) => string);
  115015. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  115016. /**
  115017. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115018. * @ignorenaming
  115019. */
  115020. static get UseFallbackTexture(): boolean;
  115021. static set UseFallbackTexture(value: boolean);
  115022. /**
  115023. * Use this object to register external classes like custom textures or material
  115024. * to allow the laoders to instantiate them
  115025. */
  115026. static get RegisteredExternalClasses(): {
  115027. [key: string]: Object;
  115028. };
  115029. static set RegisteredExternalClasses(classes: {
  115030. [key: string]: Object;
  115031. });
  115032. /**
  115033. * Texture content used if a texture cannot loaded
  115034. * @ignorenaming
  115035. */
  115036. static get fallbackTexture(): string;
  115037. static set fallbackTexture(value: string);
  115038. /**
  115039. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115040. * @param u defines the coordinate on X axis
  115041. * @param v defines the coordinate on Y axis
  115042. * @param width defines the width of the source data
  115043. * @param height defines the height of the source data
  115044. * @param pixels defines the source byte array
  115045. * @param color defines the output color
  115046. */
  115047. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  115048. /**
  115049. * Interpolates between a and b via alpha
  115050. * @param a The lower value (returned when alpha = 0)
  115051. * @param b The upper value (returned when alpha = 1)
  115052. * @param alpha The interpolation-factor
  115053. * @return The mixed value
  115054. */
  115055. static Mix(a: number, b: number, alpha: number): number;
  115056. /**
  115057. * Tries to instantiate a new object from a given class name
  115058. * @param className defines the class name to instantiate
  115059. * @returns the new object or null if the system was not able to do the instantiation
  115060. */
  115061. static Instantiate(className: string): any;
  115062. /**
  115063. * Provides a slice function that will work even on IE
  115064. * @param data defines the array to slice
  115065. * @param start defines the start of the data (optional)
  115066. * @param end defines the end of the data (optional)
  115067. * @returns the new sliced array
  115068. */
  115069. static Slice<T>(data: T, start?: number, end?: number): T;
  115070. /**
  115071. * Polyfill for setImmediate
  115072. * @param action defines the action to execute after the current execution block
  115073. */
  115074. static SetImmediate(action: () => void): void;
  115075. /**
  115076. * Function indicating if a number is an exponent of 2
  115077. * @param value defines the value to test
  115078. * @returns true if the value is an exponent of 2
  115079. */
  115080. static IsExponentOfTwo(value: number): boolean;
  115081. private static _tmpFloatArray;
  115082. /**
  115083. * Returns the nearest 32-bit single precision float representation of a Number
  115084. * @param value A Number. If the parameter is of a different type, it will get converted
  115085. * to a number or to NaN if it cannot be converted
  115086. * @returns number
  115087. */
  115088. static FloatRound(value: number): number;
  115089. /**
  115090. * Extracts the filename from a path
  115091. * @param path defines the path to use
  115092. * @returns the filename
  115093. */
  115094. static GetFilename(path: string): string;
  115095. /**
  115096. * Extracts the "folder" part of a path (everything before the filename).
  115097. * @param uri The URI to extract the info from
  115098. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115099. * @returns The "folder" part of the path
  115100. */
  115101. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115102. /**
  115103. * Extracts text content from a DOM element hierarchy
  115104. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115105. */
  115106. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115107. /**
  115108. * Convert an angle in radians to degrees
  115109. * @param angle defines the angle to convert
  115110. * @returns the angle in degrees
  115111. */
  115112. static ToDegrees(angle: number): number;
  115113. /**
  115114. * Convert an angle in degrees to radians
  115115. * @param angle defines the angle to convert
  115116. * @returns the angle in radians
  115117. */
  115118. static ToRadians(angle: number): number;
  115119. /**
  115120. * Returns an array if obj is not an array
  115121. * @param obj defines the object to evaluate as an array
  115122. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115123. * @returns either obj directly if obj is an array or a new array containing obj
  115124. */
  115125. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115126. /**
  115127. * Gets the pointer prefix to use
  115128. * @param engine defines the engine we are finding the prefix for
  115129. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115130. */
  115131. static GetPointerPrefix(engine: Engine): string;
  115132. /**
  115133. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115134. * @param url define the url we are trying
  115135. * @param element define the dom element where to configure the cors policy
  115136. */
  115137. static SetCorsBehavior(url: string | string[], element: {
  115138. crossOrigin: string | null;
  115139. }): void;
  115140. /**
  115141. * Removes unwanted characters from an url
  115142. * @param url defines the url to clean
  115143. * @returns the cleaned url
  115144. */
  115145. static CleanUrl(url: string): string;
  115146. /**
  115147. * Gets or sets a function used to pre-process url before using them to load assets
  115148. */
  115149. static get PreprocessUrl(): (url: string) => string;
  115150. static set PreprocessUrl(processor: (url: string) => string);
  115151. /**
  115152. * Loads an image as an HTMLImageElement.
  115153. * @param input url string, ArrayBuffer, or Blob to load
  115154. * @param onLoad callback called when the image successfully loads
  115155. * @param onError callback called when the image fails to load
  115156. * @param offlineProvider offline provider for caching
  115157. * @param mimeType optional mime type
  115158. * @returns the HTMLImageElement of the loaded image
  115159. */
  115160. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115161. /**
  115162. * Loads a file from a url
  115163. * @param url url string, ArrayBuffer, or Blob to load
  115164. * @param onSuccess callback called when the file successfully loads
  115165. * @param onProgress callback called while file is loading (if the server supports this mode)
  115166. * @param offlineProvider defines the offline provider for caching
  115167. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115168. * @param onError callback called when the file fails to load
  115169. * @returns a file request object
  115170. */
  115171. 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;
  115172. /**
  115173. * Loads a file from a url
  115174. * @param url the file url to load
  115175. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115176. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115177. */
  115178. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115179. /**
  115180. * Load a script (identified by an url). When the url returns, the
  115181. * content of this file is added into a new script element, attached to the DOM (body element)
  115182. * @param scriptUrl defines the url of the script to laod
  115183. * @param onSuccess defines the callback called when the script is loaded
  115184. * @param onError defines the callback to call if an error occurs
  115185. * @param scriptId defines the id of the script element
  115186. */
  115187. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115188. /**
  115189. * Load an asynchronous script (identified by an url). When the url returns, the
  115190. * content of this file is added into a new script element, attached to the DOM (body element)
  115191. * @param scriptUrl defines the url of the script to laod
  115192. * @param scriptId defines the id of the script element
  115193. * @returns a promise request object
  115194. */
  115195. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115196. /**
  115197. * Loads a file from a blob
  115198. * @param fileToLoad defines the blob to use
  115199. * @param callback defines the callback to call when data is loaded
  115200. * @param progressCallback defines the callback to call during loading process
  115201. * @returns a file request object
  115202. */
  115203. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  115204. /**
  115205. * Reads a file from a File object
  115206. * @param file defines the file to load
  115207. * @param onSuccess defines the callback to call when data is loaded
  115208. * @param onProgress defines the callback to call during loading process
  115209. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115210. * @param onError defines the callback to call when an error occurs
  115211. * @returns a file request object
  115212. */
  115213. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  115214. /**
  115215. * Creates a data url from a given string content
  115216. * @param content defines the content to convert
  115217. * @returns the new data url link
  115218. */
  115219. static FileAsURL(content: string): string;
  115220. /**
  115221. * Format the given number to a specific decimal format
  115222. * @param value defines the number to format
  115223. * @param decimals defines the number of decimals to use
  115224. * @returns the formatted string
  115225. */
  115226. static Format(value: number, decimals?: number): string;
  115227. /**
  115228. * Tries to copy an object by duplicating every property
  115229. * @param source defines the source object
  115230. * @param destination defines the target object
  115231. * @param doNotCopyList defines a list of properties to avoid
  115232. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115233. */
  115234. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  115235. /**
  115236. * Gets a boolean indicating if the given object has no own property
  115237. * @param obj defines the object to test
  115238. * @returns true if object has no own property
  115239. */
  115240. static IsEmpty(obj: any): boolean;
  115241. /**
  115242. * Function used to register events at window level
  115243. * @param windowElement defines the Window object to use
  115244. * @param events defines the events to register
  115245. */
  115246. static RegisterTopRootEvents(windowElement: Window, events: {
  115247. name: string;
  115248. handler: Nullable<(e: FocusEvent) => any>;
  115249. }[]): void;
  115250. /**
  115251. * Function used to unregister events from window level
  115252. * @param windowElement defines the Window object to use
  115253. * @param events defines the events to unregister
  115254. */
  115255. static UnregisterTopRootEvents(windowElement: Window, events: {
  115256. name: string;
  115257. handler: Nullable<(e: FocusEvent) => any>;
  115258. }[]): void;
  115259. /**
  115260. * @ignore
  115261. */
  115262. static _ScreenshotCanvas: HTMLCanvasElement;
  115263. /**
  115264. * Dumps the current bound framebuffer
  115265. * @param width defines the rendering width
  115266. * @param height defines the rendering height
  115267. * @param engine defines the hosting engine
  115268. * @param successCallback defines the callback triggered once the data are available
  115269. * @param mimeType defines the mime type of the result
  115270. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  115271. */
  115272. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115273. /**
  115274. * Converts the canvas data to blob.
  115275. * This acts as a polyfill for browsers not supporting the to blob function.
  115276. * @param canvas Defines the canvas to extract the data from
  115277. * @param successCallback Defines the callback triggered once the data are available
  115278. * @param mimeType Defines the mime type of the result
  115279. */
  115280. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  115281. /**
  115282. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115283. * @param successCallback defines the callback triggered once the data are available
  115284. * @param mimeType defines the mime type of the result
  115285. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115286. */
  115287. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115288. /**
  115289. * Downloads a blob in the browser
  115290. * @param blob defines the blob to download
  115291. * @param fileName defines the name of the downloaded file
  115292. */
  115293. static Download(blob: Blob, fileName: string): void;
  115294. /**
  115295. * Captures a screenshot of the current rendering
  115296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115297. * @param engine defines the rendering engine
  115298. * @param camera defines the source camera
  115299. * @param size This parameter can be set to a single number or to an object with the
  115300. * following (optional) properties: precision, width, height. If a single number is passed,
  115301. * it will be used for both width and height. If an object is passed, the screenshot size
  115302. * will be derived from the parameters. The precision property is a multiplier allowing
  115303. * rendering at a higher or lower resolution
  115304. * @param successCallback defines the callback receives a single parameter which contains the
  115305. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115306. * src parameter of an <img> to display it
  115307. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115308. * Check your browser for supported MIME types
  115309. */
  115310. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  115311. /**
  115312. * Captures a screenshot of the current rendering
  115313. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115314. * @param engine defines the rendering engine
  115315. * @param camera defines the source camera
  115316. * @param size This parameter can be set to a single number or to an object with the
  115317. * following (optional) properties: precision, width, height. If a single number is passed,
  115318. * it will be used for both width and height. If an object is passed, the screenshot size
  115319. * will be derived from the parameters. The precision property is a multiplier allowing
  115320. * rendering at a higher or lower resolution
  115321. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115322. * Check your browser for supported MIME types
  115323. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115324. * to the src parameter of an <img> to display it
  115325. */
  115326. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  115327. /**
  115328. * Generates an image screenshot from the specified camera.
  115329. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115330. * @param engine The engine to use for rendering
  115331. * @param camera The camera to use for rendering
  115332. * @param size This parameter can be set to a single number or to an object with the
  115333. * following (optional) properties: precision, width, height. If a single number is passed,
  115334. * it will be used for both width and height. If an object is passed, the screenshot size
  115335. * will be derived from the parameters. The precision property is a multiplier allowing
  115336. * rendering at a higher or lower resolution
  115337. * @param successCallback The callback receives a single parameter which contains the
  115338. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115339. * src parameter of an <img> to display it
  115340. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115341. * Check your browser for supported MIME types
  115342. * @param samples Texture samples (default: 1)
  115343. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115344. * @param fileName A name for for the downloaded file.
  115345. */
  115346. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115347. /**
  115348. * Generates an image screenshot from the specified camera.
  115349. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115350. * @param engine The engine to use for rendering
  115351. * @param camera The camera to use for rendering
  115352. * @param size This parameter can be set to a single number or to an object with the
  115353. * following (optional) properties: precision, width, height. If a single number is passed,
  115354. * it will be used for both width and height. If an object is passed, the screenshot size
  115355. * will be derived from the parameters. The precision property is a multiplier allowing
  115356. * rendering at a higher or lower resolution
  115357. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115358. * Check your browser for supported MIME types
  115359. * @param samples Texture samples (default: 1)
  115360. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115361. * @param fileName A name for for the downloaded file.
  115362. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115363. * to the src parameter of an <img> to display it
  115364. */
  115365. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  115366. /**
  115367. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115368. * Be aware Math.random() could cause collisions, but:
  115369. * "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"
  115370. * @returns a pseudo random id
  115371. */
  115372. static RandomId(): string;
  115373. /**
  115374. * Test if the given uri is a base64 string
  115375. * @param uri The uri to test
  115376. * @return True if the uri is a base64 string or false otherwise
  115377. */
  115378. static IsBase64(uri: string): boolean;
  115379. /**
  115380. * Decode the given base64 uri.
  115381. * @param uri The uri to decode
  115382. * @return The decoded base64 data.
  115383. */
  115384. static DecodeBase64(uri: string): ArrayBuffer;
  115385. /**
  115386. * Gets the absolute url.
  115387. * @param url the input url
  115388. * @return the absolute url
  115389. */
  115390. static GetAbsoluteUrl(url: string): string;
  115391. /**
  115392. * No log
  115393. */
  115394. static readonly NoneLogLevel: number;
  115395. /**
  115396. * Only message logs
  115397. */
  115398. static readonly MessageLogLevel: number;
  115399. /**
  115400. * Only warning logs
  115401. */
  115402. static readonly WarningLogLevel: number;
  115403. /**
  115404. * Only error logs
  115405. */
  115406. static readonly ErrorLogLevel: number;
  115407. /**
  115408. * All logs
  115409. */
  115410. static readonly AllLogLevel: number;
  115411. /**
  115412. * Gets a value indicating the number of loading errors
  115413. * @ignorenaming
  115414. */
  115415. static get errorsCount(): number;
  115416. /**
  115417. * Callback called when a new log is added
  115418. */
  115419. static OnNewCacheEntry: (entry: string) => void;
  115420. /**
  115421. * Log a message to the console
  115422. * @param message defines the message to log
  115423. */
  115424. static Log(message: string): void;
  115425. /**
  115426. * Write a warning message to the console
  115427. * @param message defines the message to log
  115428. */
  115429. static Warn(message: string): void;
  115430. /**
  115431. * Write an error message to the console
  115432. * @param message defines the message to log
  115433. */
  115434. static Error(message: string): void;
  115435. /**
  115436. * Gets current log cache (list of logs)
  115437. */
  115438. static get LogCache(): string;
  115439. /**
  115440. * Clears the log cache
  115441. */
  115442. static ClearLogCache(): void;
  115443. /**
  115444. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  115445. */
  115446. static set LogLevels(level: number);
  115447. /**
  115448. * Checks if the window object exists
  115449. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  115450. */
  115451. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  115452. /**
  115453. * No performance log
  115454. */
  115455. static readonly PerformanceNoneLogLevel: number;
  115456. /**
  115457. * Use user marks to log performance
  115458. */
  115459. static readonly PerformanceUserMarkLogLevel: number;
  115460. /**
  115461. * Log performance to the console
  115462. */
  115463. static readonly PerformanceConsoleLogLevel: number;
  115464. private static _performance;
  115465. /**
  115466. * Sets the current performance log level
  115467. */
  115468. static set PerformanceLogLevel(level: number);
  115469. private static _StartPerformanceCounterDisabled;
  115470. private static _EndPerformanceCounterDisabled;
  115471. private static _StartUserMark;
  115472. private static _EndUserMark;
  115473. private static _StartPerformanceConsole;
  115474. private static _EndPerformanceConsole;
  115475. /**
  115476. * Starts a performance counter
  115477. */
  115478. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115479. /**
  115480. * Ends a specific performance coutner
  115481. */
  115482. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115483. /**
  115484. * Gets either window.performance.now() if supported or Date.now() else
  115485. */
  115486. static get Now(): number;
  115487. /**
  115488. * This method will return the name of the class used to create the instance of the given object.
  115489. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  115490. * @param object the object to get the class name from
  115491. * @param isType defines if the object is actually a type
  115492. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  115493. */
  115494. static GetClassName(object: any, isType?: boolean): string;
  115495. /**
  115496. * Gets the first element of an array satisfying a given predicate
  115497. * @param array defines the array to browse
  115498. * @param predicate defines the predicate to use
  115499. * @returns null if not found or the element
  115500. */
  115501. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  115502. /**
  115503. * This method will return the name of the full name of the class, including its owning module (if any).
  115504. * 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).
  115505. * @param object the object to get the class name from
  115506. * @param isType defines if the object is actually a type
  115507. * @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.
  115508. * @ignorenaming
  115509. */
  115510. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  115511. /**
  115512. * Returns a promise that resolves after the given amount of time.
  115513. * @param delay Number of milliseconds to delay
  115514. * @returns Promise that resolves after the given amount of time
  115515. */
  115516. static DelayAsync(delay: number): Promise<void>;
  115517. /**
  115518. * Utility function to detect if the current user agent is Safari
  115519. * @returns whether or not the current user agent is safari
  115520. */
  115521. static IsSafari(): boolean;
  115522. }
  115523. /**
  115524. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  115525. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  115526. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  115527. * @param name The name of the class, case should be preserved
  115528. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  115529. */
  115530. export function className(name: string, module?: string): (target: Object) => void;
  115531. /**
  115532. * An implementation of a loop for asynchronous functions.
  115533. */
  115534. export class AsyncLoop {
  115535. /**
  115536. * Defines the number of iterations for the loop
  115537. */
  115538. iterations: number;
  115539. /**
  115540. * Defines the current index of the loop.
  115541. */
  115542. index: number;
  115543. private _done;
  115544. private _fn;
  115545. private _successCallback;
  115546. /**
  115547. * Constructor.
  115548. * @param iterations the number of iterations.
  115549. * @param func the function to run each iteration
  115550. * @param successCallback the callback that will be called upon succesful execution
  115551. * @param offset starting offset.
  115552. */
  115553. constructor(
  115554. /**
  115555. * Defines the number of iterations for the loop
  115556. */
  115557. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  115558. /**
  115559. * Execute the next iteration. Must be called after the last iteration was finished.
  115560. */
  115561. executeNext(): void;
  115562. /**
  115563. * Break the loop and run the success callback.
  115564. */
  115565. breakLoop(): void;
  115566. /**
  115567. * Create and run an async loop.
  115568. * @param iterations the number of iterations.
  115569. * @param fn the function to run each iteration
  115570. * @param successCallback the callback that will be called upon succesful execution
  115571. * @param offset starting offset.
  115572. * @returns the created async loop object
  115573. */
  115574. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  115575. /**
  115576. * A for-loop that will run a given number of iterations synchronous and the rest async.
  115577. * @param iterations total number of iterations
  115578. * @param syncedIterations number of synchronous iterations in each async iteration.
  115579. * @param fn the function to call each iteration.
  115580. * @param callback a success call back that will be called when iterating stops.
  115581. * @param breakFunction a break condition (optional)
  115582. * @param timeout timeout settings for the setTimeout function. default - 0.
  115583. * @returns the created async loop object
  115584. */
  115585. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  115586. }
  115587. }
  115588. declare module BABYLON {
  115589. /**
  115590. * This class implement a typical dictionary using a string as key and the generic type T as value.
  115591. * The underlying implementation relies on an associative array to ensure the best performances.
  115592. * The value can be anything including 'null' but except 'undefined'
  115593. */
  115594. export class StringDictionary<T> {
  115595. /**
  115596. * This will clear this dictionary and copy the content from the 'source' one.
  115597. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  115598. * @param source the dictionary to take the content from and copy to this dictionary
  115599. */
  115600. copyFrom(source: StringDictionary<T>): void;
  115601. /**
  115602. * Get a value based from its key
  115603. * @param key the given key to get the matching value from
  115604. * @return the value if found, otherwise undefined is returned
  115605. */
  115606. get(key: string): T | undefined;
  115607. /**
  115608. * Get a value from its key or add it if it doesn't exist.
  115609. * This method will ensure you that a given key/data will be present in the dictionary.
  115610. * @param key the given key to get the matching value from
  115611. * @param factory the factory that will create the value if the key is not present in the dictionary.
  115612. * The factory will only be invoked if there's no data for the given key.
  115613. * @return the value corresponding to the key.
  115614. */
  115615. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  115616. /**
  115617. * Get a value from its key if present in the dictionary otherwise add it
  115618. * @param key the key to get the value from
  115619. * @param val if there's no such key/value pair in the dictionary add it with this value
  115620. * @return the value corresponding to the key
  115621. */
  115622. getOrAdd(key: string, val: T): T;
  115623. /**
  115624. * Check if there's a given key in the dictionary
  115625. * @param key the key to check for
  115626. * @return true if the key is present, false otherwise
  115627. */
  115628. contains(key: string): boolean;
  115629. /**
  115630. * Add a new key and its corresponding value
  115631. * @param key the key to add
  115632. * @param value the value corresponding to the key
  115633. * @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
  115634. */
  115635. add(key: string, value: T): boolean;
  115636. /**
  115637. * Update a specific value associated to a key
  115638. * @param key defines the key to use
  115639. * @param value defines the value to store
  115640. * @returns true if the value was updated (or false if the key was not found)
  115641. */
  115642. set(key: string, value: T): boolean;
  115643. /**
  115644. * Get the element of the given key and remove it from the dictionary
  115645. * @param key defines the key to search
  115646. * @returns the value associated with the key or null if not found
  115647. */
  115648. getAndRemove(key: string): Nullable<T>;
  115649. /**
  115650. * Remove a key/value from the dictionary.
  115651. * @param key the key to remove
  115652. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  115653. */
  115654. remove(key: string): boolean;
  115655. /**
  115656. * Clear the whole content of the dictionary
  115657. */
  115658. clear(): void;
  115659. /**
  115660. * Gets the current count
  115661. */
  115662. get count(): number;
  115663. /**
  115664. * Execute a callback on each key/val of the dictionary.
  115665. * Note that you can remove any element in this dictionary in the callback implementation
  115666. * @param callback the callback to execute on a given key/value pair
  115667. */
  115668. forEach(callback: (key: string, val: T) => void): void;
  115669. /**
  115670. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  115671. * If the callback returns null or undefined the method will iterate to the next key/value pair
  115672. * Note that you can remove any element in this dictionary in the callback implementation
  115673. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  115674. * @returns the first item
  115675. */
  115676. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  115677. private _count;
  115678. private _data;
  115679. }
  115680. }
  115681. declare module BABYLON {
  115682. /** @hidden */
  115683. export interface ICollisionCoordinator {
  115684. createCollider(): Collider;
  115685. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115686. init(scene: Scene): void;
  115687. }
  115688. /** @hidden */
  115689. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  115690. private _scene;
  115691. private _scaledPosition;
  115692. private _scaledVelocity;
  115693. private _finalPosition;
  115694. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115695. createCollider(): Collider;
  115696. init(scene: Scene): void;
  115697. private _collideWithWorld;
  115698. }
  115699. }
  115700. declare module BABYLON {
  115701. /**
  115702. * Class used to manage all inputs for the scene.
  115703. */
  115704. export class InputManager {
  115705. /** The distance in pixel that you have to move to prevent some events */
  115706. static DragMovementThreshold: number;
  115707. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  115708. static LongPressDelay: number;
  115709. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  115710. static DoubleClickDelay: number;
  115711. /** If you need to check double click without raising a single click at first click, enable this flag */
  115712. static ExclusiveDoubleClickMode: boolean;
  115713. private _wheelEventName;
  115714. private _onPointerMove;
  115715. private _onPointerDown;
  115716. private _onPointerUp;
  115717. private _initClickEvent;
  115718. private _initActionManager;
  115719. private _delayedSimpleClick;
  115720. private _delayedSimpleClickTimeout;
  115721. private _previousDelayedSimpleClickTimeout;
  115722. private _meshPickProceed;
  115723. private _previousButtonPressed;
  115724. private _currentPickResult;
  115725. private _previousPickResult;
  115726. private _totalPointersPressed;
  115727. private _doubleClickOccured;
  115728. private _pointerOverMesh;
  115729. private _pickedDownMesh;
  115730. private _pickedUpMesh;
  115731. private _pointerX;
  115732. private _pointerY;
  115733. private _unTranslatedPointerX;
  115734. private _unTranslatedPointerY;
  115735. private _startingPointerPosition;
  115736. private _previousStartingPointerPosition;
  115737. private _startingPointerTime;
  115738. private _previousStartingPointerTime;
  115739. private _pointerCaptures;
  115740. private _onKeyDown;
  115741. private _onKeyUp;
  115742. private _onCanvasFocusObserver;
  115743. private _onCanvasBlurObserver;
  115744. private _scene;
  115745. /**
  115746. * Creates a new InputManager
  115747. * @param scene defines the hosting scene
  115748. */
  115749. constructor(scene: Scene);
  115750. /**
  115751. * Gets the mesh that is currently under the pointer
  115752. */
  115753. get meshUnderPointer(): Nullable<AbstractMesh>;
  115754. /**
  115755. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  115756. */
  115757. get unTranslatedPointer(): Vector2;
  115758. /**
  115759. * Gets or sets the current on-screen X position of the pointer
  115760. */
  115761. get pointerX(): number;
  115762. set pointerX(value: number);
  115763. /**
  115764. * Gets or sets the current on-screen Y position of the pointer
  115765. */
  115766. get pointerY(): number;
  115767. set pointerY(value: number);
  115768. private _updatePointerPosition;
  115769. private _processPointerMove;
  115770. private _setRayOnPointerInfo;
  115771. private _checkPrePointerObservable;
  115772. /**
  115773. * Use this method to simulate a pointer move on a mesh
  115774. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115775. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115776. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115777. */
  115778. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115779. /**
  115780. * Use this method to simulate a pointer down on a mesh
  115781. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115782. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115783. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115784. */
  115785. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115786. private _processPointerDown;
  115787. /** @hidden */
  115788. _isPointerSwiping(): boolean;
  115789. /**
  115790. * Use this method to simulate a pointer up on a mesh
  115791. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115792. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115793. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115794. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  115795. */
  115796. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  115797. private _processPointerUp;
  115798. /**
  115799. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  115800. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  115801. * @returns true if the pointer was captured
  115802. */
  115803. isPointerCaptured(pointerId?: number): boolean;
  115804. /**
  115805. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  115806. * @param attachUp defines if you want to attach events to pointerup
  115807. * @param attachDown defines if you want to attach events to pointerdown
  115808. * @param attachMove defines if you want to attach events to pointermove
  115809. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  115810. */
  115811. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  115812. /**
  115813. * Detaches all event handlers
  115814. */
  115815. detachControl(): void;
  115816. /**
  115817. * Force the value of meshUnderPointer
  115818. * @param mesh defines the mesh to use
  115819. */
  115820. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  115821. /**
  115822. * Gets the mesh under the pointer
  115823. * @returns a Mesh or null if no mesh is under the pointer
  115824. */
  115825. getPointerOverMesh(): Nullable<AbstractMesh>;
  115826. }
  115827. }
  115828. declare module BABYLON {
  115829. /**
  115830. * This class defines the direct association between an animation and a target
  115831. */
  115832. export class TargetedAnimation {
  115833. /**
  115834. * Animation to perform
  115835. */
  115836. animation: Animation;
  115837. /**
  115838. * Target to animate
  115839. */
  115840. target: any;
  115841. /**
  115842. * Returns the string "TargetedAnimation"
  115843. * @returns "TargetedAnimation"
  115844. */
  115845. getClassName(): string;
  115846. /**
  115847. * Serialize the object
  115848. * @returns the JSON object representing the current entity
  115849. */
  115850. serialize(): any;
  115851. }
  115852. /**
  115853. * Use this class to create coordinated animations on multiple targets
  115854. */
  115855. export class AnimationGroup implements IDisposable {
  115856. /** The name of the animation group */
  115857. name: string;
  115858. private _scene;
  115859. private _targetedAnimations;
  115860. private _animatables;
  115861. private _from;
  115862. private _to;
  115863. private _isStarted;
  115864. private _isPaused;
  115865. private _speedRatio;
  115866. private _loopAnimation;
  115867. private _isAdditive;
  115868. /**
  115869. * Gets or sets the unique id of the node
  115870. */
  115871. uniqueId: number;
  115872. /**
  115873. * This observable will notify when one animation have ended
  115874. */
  115875. onAnimationEndObservable: Observable<TargetedAnimation>;
  115876. /**
  115877. * Observer raised when one animation loops
  115878. */
  115879. onAnimationLoopObservable: Observable<TargetedAnimation>;
  115880. /**
  115881. * Observer raised when all animations have looped
  115882. */
  115883. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  115884. /**
  115885. * This observable will notify when all animations have ended.
  115886. */
  115887. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  115888. /**
  115889. * This observable will notify when all animations have paused.
  115890. */
  115891. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  115892. /**
  115893. * This observable will notify when all animations are playing.
  115894. */
  115895. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  115896. /**
  115897. * Gets the first frame
  115898. */
  115899. get from(): number;
  115900. /**
  115901. * Gets the last frame
  115902. */
  115903. get to(): number;
  115904. /**
  115905. * Define if the animations are started
  115906. */
  115907. get isStarted(): boolean;
  115908. /**
  115909. * Gets a value indicating that the current group is playing
  115910. */
  115911. get isPlaying(): boolean;
  115912. /**
  115913. * Gets or sets the speed ratio to use for all animations
  115914. */
  115915. get speedRatio(): number;
  115916. /**
  115917. * Gets or sets the speed ratio to use for all animations
  115918. */
  115919. set speedRatio(value: number);
  115920. /**
  115921. * Gets or sets if all animations should loop or not
  115922. */
  115923. get loopAnimation(): boolean;
  115924. set loopAnimation(value: boolean);
  115925. /**
  115926. * Gets or sets if all animations should be evaluated additively
  115927. */
  115928. get isAdditive(): boolean;
  115929. set isAdditive(value: boolean);
  115930. /**
  115931. * Gets the targeted animations for this animation group
  115932. */
  115933. get targetedAnimations(): Array<TargetedAnimation>;
  115934. /**
  115935. * returning the list of animatables controlled by this animation group.
  115936. */
  115937. get animatables(): Array<Animatable>;
  115938. /**
  115939. * Gets the list of target animations
  115940. */
  115941. get children(): TargetedAnimation[];
  115942. /**
  115943. * Instantiates a new Animation Group.
  115944. * This helps managing several animations at once.
  115945. * @see http://doc.babylonjs.com/how_to/group
  115946. * @param name Defines the name of the group
  115947. * @param scene Defines the scene the group belongs to
  115948. */
  115949. constructor(
  115950. /** The name of the animation group */
  115951. name: string, scene?: Nullable<Scene>);
  115952. /**
  115953. * Add an animation (with its target) in the group
  115954. * @param animation defines the animation we want to add
  115955. * @param target defines the target of the animation
  115956. * @returns the TargetedAnimation object
  115957. */
  115958. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  115959. /**
  115960. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  115961. * It can add constant keys at begin or end
  115962. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  115963. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  115964. * @returns the animation group
  115965. */
  115966. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  115967. private _animationLoopCount;
  115968. private _animationLoopFlags;
  115969. private _processLoop;
  115970. /**
  115971. * Start all animations on given targets
  115972. * @param loop defines if animations must loop
  115973. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  115974. * @param from defines the from key (optional)
  115975. * @param to defines the to key (optional)
  115976. * @param isAdditive defines the additive state for the resulting animatables (optional)
  115977. * @returns the current animation group
  115978. */
  115979. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  115980. /**
  115981. * Pause all animations
  115982. * @returns the animation group
  115983. */
  115984. pause(): AnimationGroup;
  115985. /**
  115986. * Play all animations to initial state
  115987. * This function will start() the animations if they were not started or will restart() them if they were paused
  115988. * @param loop defines if animations must loop
  115989. * @returns the animation group
  115990. */
  115991. play(loop?: boolean): AnimationGroup;
  115992. /**
  115993. * Reset all animations to initial state
  115994. * @returns the animation group
  115995. */
  115996. reset(): AnimationGroup;
  115997. /**
  115998. * Restart animations from key 0
  115999. * @returns the animation group
  116000. */
  116001. restart(): AnimationGroup;
  116002. /**
  116003. * Stop all animations
  116004. * @returns the animation group
  116005. */
  116006. stop(): AnimationGroup;
  116007. /**
  116008. * Set animation weight for all animatables
  116009. * @param weight defines the weight to use
  116010. * @return the animationGroup
  116011. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  116012. */
  116013. setWeightForAllAnimatables(weight: number): AnimationGroup;
  116014. /**
  116015. * Synchronize and normalize all animatables with a source animatable
  116016. * @param root defines the root animatable to synchronize with
  116017. * @return the animationGroup
  116018. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  116019. */
  116020. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  116021. /**
  116022. * Goes to a specific frame in this animation group
  116023. * @param frame the frame number to go to
  116024. * @return the animationGroup
  116025. */
  116026. goToFrame(frame: number): AnimationGroup;
  116027. /**
  116028. * Dispose all associated resources
  116029. */
  116030. dispose(): void;
  116031. private _checkAnimationGroupEnded;
  116032. /**
  116033. * Clone the current animation group and returns a copy
  116034. * @param newName defines the name of the new group
  116035. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  116036. * @returns the new aniamtion group
  116037. */
  116038. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  116039. /**
  116040. * Serializes the animationGroup to an object
  116041. * @returns Serialized object
  116042. */
  116043. serialize(): any;
  116044. /**
  116045. * Returns a new AnimationGroup object parsed from the source provided.
  116046. * @param parsedAnimationGroup defines the source
  116047. * @param scene defines the scene that will receive the animationGroup
  116048. * @returns a new AnimationGroup
  116049. */
  116050. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  116051. /**
  116052. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  116053. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  116054. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  116055. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  116056. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  116057. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  116058. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  116059. */
  116060. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  116061. /**
  116062. * Returns the string "AnimationGroup"
  116063. * @returns "AnimationGroup"
  116064. */
  116065. getClassName(): string;
  116066. /**
  116067. * Creates a detailled string about the object
  116068. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  116069. * @returns a string representing the object
  116070. */
  116071. toString(fullDetails?: boolean): string;
  116072. }
  116073. }
  116074. declare module BABYLON {
  116075. /**
  116076. * Define an interface for all classes that will hold resources
  116077. */
  116078. export interface IDisposable {
  116079. /**
  116080. * Releases all held resources
  116081. */
  116082. dispose(): void;
  116083. }
  116084. /** Interface defining initialization parameters for Scene class */
  116085. export interface SceneOptions {
  116086. /**
  116087. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116088. * It will improve performance when the number of geometries becomes important.
  116089. */
  116090. useGeometryUniqueIdsMap?: boolean;
  116091. /**
  116092. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116093. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116094. */
  116095. useMaterialMeshMap?: boolean;
  116096. /**
  116097. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116098. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116099. */
  116100. useClonedMeshMap?: boolean;
  116101. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116102. virtual?: boolean;
  116103. }
  116104. /**
  116105. * Represents a scene to be rendered by the engine.
  116106. * @see http://doc.babylonjs.com/features/scene
  116107. */
  116108. export class Scene extends AbstractScene implements IAnimatable {
  116109. /** The fog is deactivated */
  116110. static readonly FOGMODE_NONE: number;
  116111. /** The fog density is following an exponential function */
  116112. static readonly FOGMODE_EXP: number;
  116113. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116114. static readonly FOGMODE_EXP2: number;
  116115. /** The fog density is following a linear function. */
  116116. static readonly FOGMODE_LINEAR: number;
  116117. /**
  116118. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116119. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116120. */
  116121. static MinDeltaTime: number;
  116122. /**
  116123. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116125. */
  116126. static MaxDeltaTime: number;
  116127. /**
  116128. * Factory used to create the default material.
  116129. * @param name The name of the material to create
  116130. * @param scene The scene to create the material for
  116131. * @returns The default material
  116132. */
  116133. static DefaultMaterialFactory(scene: Scene): Material;
  116134. /**
  116135. * Factory used to create the a collision coordinator.
  116136. * @returns The collision coordinator
  116137. */
  116138. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116139. /** @hidden */
  116140. _inputManager: InputManager;
  116141. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116142. cameraToUseForPointers: Nullable<Camera>;
  116143. /** @hidden */
  116144. readonly _isScene: boolean;
  116145. /** @hidden */
  116146. _blockEntityCollection: boolean;
  116147. /**
  116148. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116149. */
  116150. autoClear: boolean;
  116151. /**
  116152. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116153. */
  116154. autoClearDepthAndStencil: boolean;
  116155. /**
  116156. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116157. */
  116158. clearColor: Color4;
  116159. /**
  116160. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116161. */
  116162. ambientColor: Color3;
  116163. /**
  116164. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116165. * It should only be one of the following (if not the default embedded one):
  116166. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116167. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116168. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116169. * The material properties need to be setup according to the type of texture in use.
  116170. */
  116171. environmentBRDFTexture: BaseTexture;
  116172. /** @hidden */
  116173. protected _environmentTexture: Nullable<BaseTexture>;
  116174. /**
  116175. * Texture used in all pbr material as the reflection texture.
  116176. * As in the majority of the scene they are the same (exception for multi room and so on),
  116177. * this is easier to reference from here than from all the materials.
  116178. */
  116179. get environmentTexture(): Nullable<BaseTexture>;
  116180. /**
  116181. * Texture used in all pbr material as the reflection texture.
  116182. * As in the majority of the scene they are the same (exception for multi room and so on),
  116183. * this is easier to set here than in all the materials.
  116184. */
  116185. set environmentTexture(value: Nullable<BaseTexture>);
  116186. /** @hidden */
  116187. protected _environmentIntensity: number;
  116188. /**
  116189. * Intensity of the environment in all pbr material.
  116190. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116191. * As in the majority of the scene they are the same (exception for multi room and so on),
  116192. * this is easier to reference from here than from all the materials.
  116193. */
  116194. get environmentIntensity(): number;
  116195. /**
  116196. * Intensity of the environment in all pbr material.
  116197. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116198. * As in the majority of the scene they are the same (exception for multi room and so on),
  116199. * this is easier to set here than in all the materials.
  116200. */
  116201. set environmentIntensity(value: number);
  116202. /** @hidden */
  116203. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116204. /**
  116205. * Default image processing configuration used either in the rendering
  116206. * Forward main pass or through the imageProcessingPostProcess if present.
  116207. * As in the majority of the scene they are the same (exception for multi camera),
  116208. * this is easier to reference from here than from all the materials and post process.
  116209. *
  116210. * No setter as we it is a shared configuration, you can set the values instead.
  116211. */
  116212. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116213. private _forceWireframe;
  116214. /**
  116215. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  116216. */
  116217. set forceWireframe(value: boolean);
  116218. get forceWireframe(): boolean;
  116219. private _skipFrustumClipping;
  116220. /**
  116221. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  116222. */
  116223. set skipFrustumClipping(value: boolean);
  116224. get skipFrustumClipping(): boolean;
  116225. private _forcePointsCloud;
  116226. /**
  116227. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  116228. */
  116229. set forcePointsCloud(value: boolean);
  116230. get forcePointsCloud(): boolean;
  116231. /**
  116232. * Gets or sets the active clipplane 1
  116233. */
  116234. clipPlane: Nullable<Plane>;
  116235. /**
  116236. * Gets or sets the active clipplane 2
  116237. */
  116238. clipPlane2: Nullable<Plane>;
  116239. /**
  116240. * Gets or sets the active clipplane 3
  116241. */
  116242. clipPlane3: Nullable<Plane>;
  116243. /**
  116244. * Gets or sets the active clipplane 4
  116245. */
  116246. clipPlane4: Nullable<Plane>;
  116247. /**
  116248. * Gets or sets the active clipplane 5
  116249. */
  116250. clipPlane5: Nullable<Plane>;
  116251. /**
  116252. * Gets or sets the active clipplane 6
  116253. */
  116254. clipPlane6: Nullable<Plane>;
  116255. /**
  116256. * Gets or sets a boolean indicating if animations are enabled
  116257. */
  116258. animationsEnabled: boolean;
  116259. private _animationPropertiesOverride;
  116260. /**
  116261. * Gets or sets the animation properties override
  116262. */
  116263. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116264. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116265. /**
  116266. * Gets or sets a boolean indicating if a constant deltatime has to be used
  116267. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  116268. */
  116269. useConstantAnimationDeltaTime: boolean;
  116270. /**
  116271. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  116272. * Please note that it requires to run a ray cast through the scene on every frame
  116273. */
  116274. constantlyUpdateMeshUnderPointer: boolean;
  116275. /**
  116276. * Defines the HTML cursor to use when hovering over interactive elements
  116277. */
  116278. hoverCursor: string;
  116279. /**
  116280. * Defines the HTML default cursor to use (empty by default)
  116281. */
  116282. defaultCursor: string;
  116283. /**
  116284. * Defines whether cursors are handled by the scene.
  116285. */
  116286. doNotHandleCursors: boolean;
  116287. /**
  116288. * This is used to call preventDefault() on pointer down
  116289. * in order to block unwanted artifacts like system double clicks
  116290. */
  116291. preventDefaultOnPointerDown: boolean;
  116292. /**
  116293. * This is used to call preventDefault() on pointer up
  116294. * in order to block unwanted artifacts like system double clicks
  116295. */
  116296. preventDefaultOnPointerUp: boolean;
  116297. /**
  116298. * Gets or sets user defined metadata
  116299. */
  116300. metadata: any;
  116301. /**
  116302. * For internal use only. Please do not use.
  116303. */
  116304. reservedDataStore: any;
  116305. /**
  116306. * Gets the name of the plugin used to load this scene (null by default)
  116307. */
  116308. loadingPluginName: string;
  116309. /**
  116310. * Use this array to add regular expressions used to disable offline support for specific urls
  116311. */
  116312. disableOfflineSupportExceptionRules: RegExp[];
  116313. /**
  116314. * An event triggered when the scene is disposed.
  116315. */
  116316. onDisposeObservable: Observable<Scene>;
  116317. private _onDisposeObserver;
  116318. /** Sets a function to be executed when this scene is disposed. */
  116319. set onDispose(callback: () => void);
  116320. /**
  116321. * An event triggered before rendering the scene (right after animations and physics)
  116322. */
  116323. onBeforeRenderObservable: Observable<Scene>;
  116324. private _onBeforeRenderObserver;
  116325. /** Sets a function to be executed before rendering this scene */
  116326. set beforeRender(callback: Nullable<() => void>);
  116327. /**
  116328. * An event triggered after rendering the scene
  116329. */
  116330. onAfterRenderObservable: Observable<Scene>;
  116331. /**
  116332. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  116333. */
  116334. onAfterRenderCameraObservable: Observable<Camera>;
  116335. private _onAfterRenderObserver;
  116336. /** Sets a function to be executed after rendering this scene */
  116337. set afterRender(callback: Nullable<() => void>);
  116338. /**
  116339. * An event triggered before animating the scene
  116340. */
  116341. onBeforeAnimationsObservable: Observable<Scene>;
  116342. /**
  116343. * An event triggered after animations processing
  116344. */
  116345. onAfterAnimationsObservable: Observable<Scene>;
  116346. /**
  116347. * An event triggered before draw calls are ready to be sent
  116348. */
  116349. onBeforeDrawPhaseObservable: Observable<Scene>;
  116350. /**
  116351. * An event triggered after draw calls have been sent
  116352. */
  116353. onAfterDrawPhaseObservable: Observable<Scene>;
  116354. /**
  116355. * An event triggered when the scene is ready
  116356. */
  116357. onReadyObservable: Observable<Scene>;
  116358. /**
  116359. * An event triggered before rendering a camera
  116360. */
  116361. onBeforeCameraRenderObservable: Observable<Camera>;
  116362. private _onBeforeCameraRenderObserver;
  116363. /** Sets a function to be executed before rendering a camera*/
  116364. set beforeCameraRender(callback: () => void);
  116365. /**
  116366. * An event triggered after rendering a camera
  116367. */
  116368. onAfterCameraRenderObservable: Observable<Camera>;
  116369. private _onAfterCameraRenderObserver;
  116370. /** Sets a function to be executed after rendering a camera*/
  116371. set afterCameraRender(callback: () => void);
  116372. /**
  116373. * An event triggered when active meshes evaluation is about to start
  116374. */
  116375. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  116376. /**
  116377. * An event triggered when active meshes evaluation is done
  116378. */
  116379. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  116380. /**
  116381. * An event triggered when particles rendering is about to start
  116382. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116383. */
  116384. onBeforeParticlesRenderingObservable: Observable<Scene>;
  116385. /**
  116386. * An event triggered when particles rendering is done
  116387. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116388. */
  116389. onAfterParticlesRenderingObservable: Observable<Scene>;
  116390. /**
  116391. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  116392. */
  116393. onDataLoadedObservable: Observable<Scene>;
  116394. /**
  116395. * An event triggered when a camera is created
  116396. */
  116397. onNewCameraAddedObservable: Observable<Camera>;
  116398. /**
  116399. * An event triggered when a camera is removed
  116400. */
  116401. onCameraRemovedObservable: Observable<Camera>;
  116402. /**
  116403. * An event triggered when a light is created
  116404. */
  116405. onNewLightAddedObservable: Observable<Light>;
  116406. /**
  116407. * An event triggered when a light is removed
  116408. */
  116409. onLightRemovedObservable: Observable<Light>;
  116410. /**
  116411. * An event triggered when a geometry is created
  116412. */
  116413. onNewGeometryAddedObservable: Observable<Geometry>;
  116414. /**
  116415. * An event triggered when a geometry is removed
  116416. */
  116417. onGeometryRemovedObservable: Observable<Geometry>;
  116418. /**
  116419. * An event triggered when a transform node is created
  116420. */
  116421. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  116422. /**
  116423. * An event triggered when a transform node is removed
  116424. */
  116425. onTransformNodeRemovedObservable: Observable<TransformNode>;
  116426. /**
  116427. * An event triggered when a mesh is created
  116428. */
  116429. onNewMeshAddedObservable: Observable<AbstractMesh>;
  116430. /**
  116431. * An event triggered when a mesh is removed
  116432. */
  116433. onMeshRemovedObservable: Observable<AbstractMesh>;
  116434. /**
  116435. * An event triggered when a skeleton is created
  116436. */
  116437. onNewSkeletonAddedObservable: Observable<Skeleton>;
  116438. /**
  116439. * An event triggered when a skeleton is removed
  116440. */
  116441. onSkeletonRemovedObservable: Observable<Skeleton>;
  116442. /**
  116443. * An event triggered when a material is created
  116444. */
  116445. onNewMaterialAddedObservable: Observable<Material>;
  116446. /**
  116447. * An event triggered when a material is removed
  116448. */
  116449. onMaterialRemovedObservable: Observable<Material>;
  116450. /**
  116451. * An event triggered when a texture is created
  116452. */
  116453. onNewTextureAddedObservable: Observable<BaseTexture>;
  116454. /**
  116455. * An event triggered when a texture is removed
  116456. */
  116457. onTextureRemovedObservable: Observable<BaseTexture>;
  116458. /**
  116459. * An event triggered when render targets are about to be rendered
  116460. * Can happen multiple times per frame.
  116461. */
  116462. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  116463. /**
  116464. * An event triggered when render targets were rendered.
  116465. * Can happen multiple times per frame.
  116466. */
  116467. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  116468. /**
  116469. * An event triggered before calculating deterministic simulation step
  116470. */
  116471. onBeforeStepObservable: Observable<Scene>;
  116472. /**
  116473. * An event triggered after calculating deterministic simulation step
  116474. */
  116475. onAfterStepObservable: Observable<Scene>;
  116476. /**
  116477. * An event triggered when the activeCamera property is updated
  116478. */
  116479. onActiveCameraChanged: Observable<Scene>;
  116480. /**
  116481. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  116482. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116483. * 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)
  116484. */
  116485. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116486. /**
  116487. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  116488. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116489. * 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)
  116490. */
  116491. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116492. /**
  116493. * This Observable will when a mesh has been imported into the scene.
  116494. */
  116495. onMeshImportedObservable: Observable<AbstractMesh>;
  116496. /**
  116497. * This Observable will when an animation file has been imported into the scene.
  116498. */
  116499. onAnimationFileImportedObservable: Observable<Scene>;
  116500. /**
  116501. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  116502. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  116503. */
  116504. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  116505. /** @hidden */
  116506. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  116507. /**
  116508. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  116509. */
  116510. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  116511. /**
  116512. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  116513. */
  116514. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  116515. /**
  116516. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  116517. */
  116518. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  116519. /** Callback called when a pointer move is detected */
  116520. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116521. /** Callback called when a pointer down is detected */
  116522. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116523. /** Callback called when a pointer up is detected */
  116524. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  116525. /** Callback called when a pointer pick is detected */
  116526. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  116527. /**
  116528. * 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).
  116529. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  116530. */
  116531. onPrePointerObservable: Observable<PointerInfoPre>;
  116532. /**
  116533. * Observable event triggered each time an input event is received from the rendering canvas
  116534. */
  116535. onPointerObservable: Observable<PointerInfo>;
  116536. /**
  116537. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  116538. */
  116539. get unTranslatedPointer(): Vector2;
  116540. /**
  116541. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  116542. */
  116543. static get DragMovementThreshold(): number;
  116544. static set DragMovementThreshold(value: number);
  116545. /**
  116546. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  116547. */
  116548. static get LongPressDelay(): number;
  116549. static set LongPressDelay(value: number);
  116550. /**
  116551. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  116552. */
  116553. static get DoubleClickDelay(): number;
  116554. static set DoubleClickDelay(value: number);
  116555. /** If you need to check double click without raising a single click at first click, enable this flag */
  116556. static get ExclusiveDoubleClickMode(): boolean;
  116557. static set ExclusiveDoubleClickMode(value: boolean);
  116558. /** @hidden */
  116559. _mirroredCameraPosition: Nullable<Vector3>;
  116560. /**
  116561. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  116562. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  116563. */
  116564. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  116565. /**
  116566. * Observable event triggered each time an keyboard event is received from the hosting window
  116567. */
  116568. onKeyboardObservable: Observable<KeyboardInfo>;
  116569. private _useRightHandedSystem;
  116570. /**
  116571. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  116572. */
  116573. set useRightHandedSystem(value: boolean);
  116574. get useRightHandedSystem(): boolean;
  116575. private _timeAccumulator;
  116576. private _currentStepId;
  116577. private _currentInternalStep;
  116578. /**
  116579. * Sets the step Id used by deterministic lock step
  116580. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116581. * @param newStepId defines the step Id
  116582. */
  116583. setStepId(newStepId: number): void;
  116584. /**
  116585. * Gets the step Id used by deterministic lock step
  116586. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116587. * @returns the step Id
  116588. */
  116589. getStepId(): number;
  116590. /**
  116591. * Gets the internal step used by deterministic lock step
  116592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116593. * @returns the internal step
  116594. */
  116595. getInternalStep(): number;
  116596. private _fogEnabled;
  116597. /**
  116598. * Gets or sets a boolean indicating if fog is enabled on this scene
  116599. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116600. * (Default is true)
  116601. */
  116602. set fogEnabled(value: boolean);
  116603. get fogEnabled(): boolean;
  116604. private _fogMode;
  116605. /**
  116606. * Gets or sets the fog mode to use
  116607. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116608. * | mode | value |
  116609. * | --- | --- |
  116610. * | FOGMODE_NONE | 0 |
  116611. * | FOGMODE_EXP | 1 |
  116612. * | FOGMODE_EXP2 | 2 |
  116613. * | FOGMODE_LINEAR | 3 |
  116614. */
  116615. set fogMode(value: number);
  116616. get fogMode(): number;
  116617. /**
  116618. * Gets or sets the fog color to use
  116619. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116620. * (Default is Color3(0.2, 0.2, 0.3))
  116621. */
  116622. fogColor: Color3;
  116623. /**
  116624. * Gets or sets the fog density to use
  116625. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116626. * (Default is 0.1)
  116627. */
  116628. fogDensity: number;
  116629. /**
  116630. * Gets or sets the fog start distance to use
  116631. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116632. * (Default is 0)
  116633. */
  116634. fogStart: number;
  116635. /**
  116636. * Gets or sets the fog end distance to use
  116637. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116638. * (Default is 1000)
  116639. */
  116640. fogEnd: number;
  116641. private _shadowsEnabled;
  116642. /**
  116643. * Gets or sets a boolean indicating if shadows are enabled on this scene
  116644. */
  116645. set shadowsEnabled(value: boolean);
  116646. get shadowsEnabled(): boolean;
  116647. private _lightsEnabled;
  116648. /**
  116649. * Gets or sets a boolean indicating if lights are enabled on this scene
  116650. */
  116651. set lightsEnabled(value: boolean);
  116652. get lightsEnabled(): boolean;
  116653. /** All of the active cameras added to this scene. */
  116654. activeCameras: Camera[];
  116655. /** @hidden */
  116656. _activeCamera: Nullable<Camera>;
  116657. /** Gets or sets the current active camera */
  116658. get activeCamera(): Nullable<Camera>;
  116659. set activeCamera(value: Nullable<Camera>);
  116660. private _defaultMaterial;
  116661. /** The default material used on meshes when no material is affected */
  116662. get defaultMaterial(): Material;
  116663. /** The default material used on meshes when no material is affected */
  116664. set defaultMaterial(value: Material);
  116665. private _texturesEnabled;
  116666. /**
  116667. * Gets or sets a boolean indicating if textures are enabled on this scene
  116668. */
  116669. set texturesEnabled(value: boolean);
  116670. get texturesEnabled(): boolean;
  116671. /**
  116672. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  116673. */
  116674. physicsEnabled: boolean;
  116675. /**
  116676. * Gets or sets a boolean indicating if particles are enabled on this scene
  116677. */
  116678. particlesEnabled: boolean;
  116679. /**
  116680. * Gets or sets a boolean indicating if sprites are enabled on this scene
  116681. */
  116682. spritesEnabled: boolean;
  116683. private _skeletonsEnabled;
  116684. /**
  116685. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  116686. */
  116687. set skeletonsEnabled(value: boolean);
  116688. get skeletonsEnabled(): boolean;
  116689. /**
  116690. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  116691. */
  116692. lensFlaresEnabled: boolean;
  116693. /**
  116694. * Gets or sets a boolean indicating if collisions are enabled on this scene
  116695. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116696. */
  116697. collisionsEnabled: boolean;
  116698. private _collisionCoordinator;
  116699. /** @hidden */
  116700. get collisionCoordinator(): ICollisionCoordinator;
  116701. /**
  116702. * Defines the gravity applied to this scene (used only for collisions)
  116703. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116704. */
  116705. gravity: Vector3;
  116706. /**
  116707. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  116708. */
  116709. postProcessesEnabled: boolean;
  116710. /**
  116711. * The list of postprocesses added to the scene
  116712. */
  116713. postProcesses: PostProcess[];
  116714. /**
  116715. * Gets the current postprocess manager
  116716. */
  116717. postProcessManager: PostProcessManager;
  116718. /**
  116719. * Gets or sets a boolean indicating if render targets are enabled on this scene
  116720. */
  116721. renderTargetsEnabled: boolean;
  116722. /**
  116723. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  116724. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  116725. */
  116726. dumpNextRenderTargets: boolean;
  116727. /**
  116728. * The list of user defined render targets added to the scene
  116729. */
  116730. customRenderTargets: RenderTargetTexture[];
  116731. /**
  116732. * Defines if texture loading must be delayed
  116733. * If true, textures will only be loaded when they need to be rendered
  116734. */
  116735. useDelayedTextureLoading: boolean;
  116736. /**
  116737. * Gets the list of meshes imported to the scene through SceneLoader
  116738. */
  116739. importedMeshesFiles: String[];
  116740. /**
  116741. * Gets or sets a boolean indicating if probes are enabled on this scene
  116742. */
  116743. probesEnabled: boolean;
  116744. /**
  116745. * Gets or sets the current offline provider to use to store scene data
  116746. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116747. */
  116748. offlineProvider: IOfflineProvider;
  116749. /**
  116750. * Gets or sets the action manager associated with the scene
  116751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  116752. */
  116753. actionManager: AbstractActionManager;
  116754. private _meshesForIntersections;
  116755. /**
  116756. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  116757. */
  116758. proceduralTexturesEnabled: boolean;
  116759. private _engine;
  116760. private _totalVertices;
  116761. /** @hidden */
  116762. _activeIndices: PerfCounter;
  116763. /** @hidden */
  116764. _activeParticles: PerfCounter;
  116765. /** @hidden */
  116766. _activeBones: PerfCounter;
  116767. private _animationRatio;
  116768. /** @hidden */
  116769. _animationTimeLast: number;
  116770. /** @hidden */
  116771. _animationTime: number;
  116772. /**
  116773. * Gets or sets a general scale for animation speed
  116774. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  116775. */
  116776. animationTimeScale: number;
  116777. /** @hidden */
  116778. _cachedMaterial: Nullable<Material>;
  116779. /** @hidden */
  116780. _cachedEffect: Nullable<Effect>;
  116781. /** @hidden */
  116782. _cachedVisibility: Nullable<number>;
  116783. private _renderId;
  116784. private _frameId;
  116785. private _executeWhenReadyTimeoutId;
  116786. private _intermediateRendering;
  116787. private _viewUpdateFlag;
  116788. private _projectionUpdateFlag;
  116789. /** @hidden */
  116790. _toBeDisposed: Nullable<IDisposable>[];
  116791. private _activeRequests;
  116792. /** @hidden */
  116793. _pendingData: any[];
  116794. private _isDisposed;
  116795. /**
  116796. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  116797. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  116798. */
  116799. dispatchAllSubMeshesOfActiveMeshes: boolean;
  116800. private _activeMeshes;
  116801. private _processedMaterials;
  116802. private _renderTargets;
  116803. /** @hidden */
  116804. _activeParticleSystems: SmartArray<IParticleSystem>;
  116805. private _activeSkeletons;
  116806. private _softwareSkinnedMeshes;
  116807. private _renderingManager;
  116808. /** @hidden */
  116809. _activeAnimatables: Animatable[];
  116810. private _transformMatrix;
  116811. private _sceneUbo;
  116812. /** @hidden */
  116813. _viewMatrix: Matrix;
  116814. private _projectionMatrix;
  116815. /** @hidden */
  116816. _forcedViewPosition: Nullable<Vector3>;
  116817. /** @hidden */
  116818. _frustumPlanes: Plane[];
  116819. /**
  116820. * Gets the list of frustum planes (built from the active camera)
  116821. */
  116822. get frustumPlanes(): Plane[];
  116823. /**
  116824. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  116825. * This is useful if there are more lights that the maximum simulteanous authorized
  116826. */
  116827. requireLightSorting: boolean;
  116828. /** @hidden */
  116829. readonly useMaterialMeshMap: boolean;
  116830. /** @hidden */
  116831. readonly useClonedMeshMap: boolean;
  116832. private _externalData;
  116833. private _uid;
  116834. /**
  116835. * @hidden
  116836. * Backing store of defined scene components.
  116837. */
  116838. _components: ISceneComponent[];
  116839. /**
  116840. * @hidden
  116841. * Backing store of defined scene components.
  116842. */
  116843. _serializableComponents: ISceneSerializableComponent[];
  116844. /**
  116845. * List of components to register on the next registration step.
  116846. */
  116847. private _transientComponents;
  116848. /**
  116849. * Registers the transient components if needed.
  116850. */
  116851. private _registerTransientComponents;
  116852. /**
  116853. * @hidden
  116854. * Add a component to the scene.
  116855. * Note that the ccomponent could be registered on th next frame if this is called after
  116856. * the register component stage.
  116857. * @param component Defines the component to add to the scene
  116858. */
  116859. _addComponent(component: ISceneComponent): void;
  116860. /**
  116861. * @hidden
  116862. * Gets a component from the scene.
  116863. * @param name defines the name of the component to retrieve
  116864. * @returns the component or null if not present
  116865. */
  116866. _getComponent(name: string): Nullable<ISceneComponent>;
  116867. /**
  116868. * @hidden
  116869. * Defines the actions happening before camera updates.
  116870. */
  116871. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  116872. /**
  116873. * @hidden
  116874. * Defines the actions happening before clear the canvas.
  116875. */
  116876. _beforeClearStage: Stage<SimpleStageAction>;
  116877. /**
  116878. * @hidden
  116879. * Defines the actions when collecting render targets for the frame.
  116880. */
  116881. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116882. /**
  116883. * @hidden
  116884. * Defines the actions happening for one camera in the frame.
  116885. */
  116886. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116887. /**
  116888. * @hidden
  116889. * Defines the actions happening during the per mesh ready checks.
  116890. */
  116891. _isReadyForMeshStage: Stage<MeshStageAction>;
  116892. /**
  116893. * @hidden
  116894. * Defines the actions happening before evaluate active mesh checks.
  116895. */
  116896. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  116897. /**
  116898. * @hidden
  116899. * Defines the actions happening during the evaluate sub mesh checks.
  116900. */
  116901. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  116902. /**
  116903. * @hidden
  116904. * Defines the actions happening during the active mesh stage.
  116905. */
  116906. _activeMeshStage: Stage<ActiveMeshStageAction>;
  116907. /**
  116908. * @hidden
  116909. * Defines the actions happening during the per camera render target step.
  116910. */
  116911. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  116912. /**
  116913. * @hidden
  116914. * Defines the actions happening just before the active camera is drawing.
  116915. */
  116916. _beforeCameraDrawStage: Stage<CameraStageAction>;
  116917. /**
  116918. * @hidden
  116919. * Defines the actions happening just before a render target is drawing.
  116920. */
  116921. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116922. /**
  116923. * @hidden
  116924. * Defines the actions happening just before a rendering group is drawing.
  116925. */
  116926. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116927. /**
  116928. * @hidden
  116929. * Defines the actions happening just before a mesh is drawing.
  116930. */
  116931. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116932. /**
  116933. * @hidden
  116934. * Defines the actions happening just after a mesh has been drawn.
  116935. */
  116936. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116937. /**
  116938. * @hidden
  116939. * Defines the actions happening just after a rendering group has been drawn.
  116940. */
  116941. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116942. /**
  116943. * @hidden
  116944. * Defines the actions happening just after the active camera has been drawn.
  116945. */
  116946. _afterCameraDrawStage: Stage<CameraStageAction>;
  116947. /**
  116948. * @hidden
  116949. * Defines the actions happening just after a render target has been drawn.
  116950. */
  116951. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116952. /**
  116953. * @hidden
  116954. * Defines the actions happening just after rendering all cameras and computing intersections.
  116955. */
  116956. _afterRenderStage: Stage<SimpleStageAction>;
  116957. /**
  116958. * @hidden
  116959. * Defines the actions happening when a pointer move event happens.
  116960. */
  116961. _pointerMoveStage: Stage<PointerMoveStageAction>;
  116962. /**
  116963. * @hidden
  116964. * Defines the actions happening when a pointer down event happens.
  116965. */
  116966. _pointerDownStage: Stage<PointerUpDownStageAction>;
  116967. /**
  116968. * @hidden
  116969. * Defines the actions happening when a pointer up event happens.
  116970. */
  116971. _pointerUpStage: Stage<PointerUpDownStageAction>;
  116972. /**
  116973. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  116974. */
  116975. private geometriesByUniqueId;
  116976. /**
  116977. * Creates a new Scene
  116978. * @param engine defines the engine to use to render this scene
  116979. * @param options defines the scene options
  116980. */
  116981. constructor(engine: Engine, options?: SceneOptions);
  116982. /**
  116983. * Gets a string idenfifying the name of the class
  116984. * @returns "Scene" string
  116985. */
  116986. getClassName(): string;
  116987. private _defaultMeshCandidates;
  116988. /**
  116989. * @hidden
  116990. */
  116991. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116992. private _defaultSubMeshCandidates;
  116993. /**
  116994. * @hidden
  116995. */
  116996. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116997. /**
  116998. * Sets the default candidate providers for the scene.
  116999. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  117000. * and getCollidingSubMeshCandidates to their default function
  117001. */
  117002. setDefaultCandidateProviders(): void;
  117003. /**
  117004. * Gets the mesh that is currently under the pointer
  117005. */
  117006. get meshUnderPointer(): Nullable<AbstractMesh>;
  117007. /**
  117008. * Gets or sets the current on-screen X position of the pointer
  117009. */
  117010. get pointerX(): number;
  117011. set pointerX(value: number);
  117012. /**
  117013. * Gets or sets the current on-screen Y position of the pointer
  117014. */
  117015. get pointerY(): number;
  117016. set pointerY(value: number);
  117017. /**
  117018. * Gets the cached material (ie. the latest rendered one)
  117019. * @returns the cached material
  117020. */
  117021. getCachedMaterial(): Nullable<Material>;
  117022. /**
  117023. * Gets the cached effect (ie. the latest rendered one)
  117024. * @returns the cached effect
  117025. */
  117026. getCachedEffect(): Nullable<Effect>;
  117027. /**
  117028. * Gets the cached visibility state (ie. the latest rendered one)
  117029. * @returns the cached visibility state
  117030. */
  117031. getCachedVisibility(): Nullable<number>;
  117032. /**
  117033. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  117034. * @param material defines the current material
  117035. * @param effect defines the current effect
  117036. * @param visibility defines the current visibility state
  117037. * @returns true if one parameter is not cached
  117038. */
  117039. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  117040. /**
  117041. * Gets the engine associated with the scene
  117042. * @returns an Engine
  117043. */
  117044. getEngine(): Engine;
  117045. /**
  117046. * Gets the total number of vertices rendered per frame
  117047. * @returns the total number of vertices rendered per frame
  117048. */
  117049. getTotalVertices(): number;
  117050. /**
  117051. * Gets the performance counter for total vertices
  117052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117053. */
  117054. get totalVerticesPerfCounter(): PerfCounter;
  117055. /**
  117056. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  117057. * @returns the total number of active indices rendered per frame
  117058. */
  117059. getActiveIndices(): number;
  117060. /**
  117061. * Gets the performance counter for active indices
  117062. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117063. */
  117064. get totalActiveIndicesPerfCounter(): PerfCounter;
  117065. /**
  117066. * Gets the total number of active particles rendered per frame
  117067. * @returns the total number of active particles rendered per frame
  117068. */
  117069. getActiveParticles(): number;
  117070. /**
  117071. * Gets the performance counter for active particles
  117072. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117073. */
  117074. get activeParticlesPerfCounter(): PerfCounter;
  117075. /**
  117076. * Gets the total number of active bones rendered per frame
  117077. * @returns the total number of active bones rendered per frame
  117078. */
  117079. getActiveBones(): number;
  117080. /**
  117081. * Gets the performance counter for active bones
  117082. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117083. */
  117084. get activeBonesPerfCounter(): PerfCounter;
  117085. /**
  117086. * Gets the array of active meshes
  117087. * @returns an array of AbstractMesh
  117088. */
  117089. getActiveMeshes(): SmartArray<AbstractMesh>;
  117090. /**
  117091. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117092. * @returns a number
  117093. */
  117094. getAnimationRatio(): number;
  117095. /**
  117096. * Gets an unique Id for the current render phase
  117097. * @returns a number
  117098. */
  117099. getRenderId(): number;
  117100. /**
  117101. * Gets an unique Id for the current frame
  117102. * @returns a number
  117103. */
  117104. getFrameId(): number;
  117105. /** Call this function if you want to manually increment the render Id*/
  117106. incrementRenderId(): void;
  117107. private _createUbo;
  117108. /**
  117109. * Use this method to simulate a pointer move on a mesh
  117110. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117111. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117112. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117113. * @returns the current scene
  117114. */
  117115. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117116. /**
  117117. * Use this method to simulate a pointer down on a mesh
  117118. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117119. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117120. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117121. * @returns the current scene
  117122. */
  117123. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117124. /**
  117125. * Use this method to simulate a pointer up on a mesh
  117126. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117127. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117128. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117129. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117130. * @returns the current scene
  117131. */
  117132. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117133. /**
  117134. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117135. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117136. * @returns true if the pointer was captured
  117137. */
  117138. isPointerCaptured(pointerId?: number): boolean;
  117139. /**
  117140. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117141. * @param attachUp defines if you want to attach events to pointerup
  117142. * @param attachDown defines if you want to attach events to pointerdown
  117143. * @param attachMove defines if you want to attach events to pointermove
  117144. */
  117145. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117146. /** Detaches all event handlers*/
  117147. detachControl(): void;
  117148. /**
  117149. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117150. * Delay loaded resources are not taking in account
  117151. * @return true if all required resources are ready
  117152. */
  117153. isReady(): boolean;
  117154. /** Resets all cached information relative to material (including effect and visibility) */
  117155. resetCachedMaterial(): void;
  117156. /**
  117157. * Registers a function to be called before every frame render
  117158. * @param func defines the function to register
  117159. */
  117160. registerBeforeRender(func: () => void): void;
  117161. /**
  117162. * Unregisters a function called before every frame render
  117163. * @param func defines the function to unregister
  117164. */
  117165. unregisterBeforeRender(func: () => void): void;
  117166. /**
  117167. * Registers a function to be called after every frame render
  117168. * @param func defines the function to register
  117169. */
  117170. registerAfterRender(func: () => void): void;
  117171. /**
  117172. * Unregisters a function called after every frame render
  117173. * @param func defines the function to unregister
  117174. */
  117175. unregisterAfterRender(func: () => void): void;
  117176. private _executeOnceBeforeRender;
  117177. /**
  117178. * The provided function will run before render once and will be disposed afterwards.
  117179. * A timeout delay can be provided so that the function will be executed in N ms.
  117180. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117181. * @param func The function to be executed.
  117182. * @param timeout optional delay in ms
  117183. */
  117184. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117185. /** @hidden */
  117186. _addPendingData(data: any): void;
  117187. /** @hidden */
  117188. _removePendingData(data: any): void;
  117189. /**
  117190. * Returns the number of items waiting to be loaded
  117191. * @returns the number of items waiting to be loaded
  117192. */
  117193. getWaitingItemsCount(): number;
  117194. /**
  117195. * Returns a boolean indicating if the scene is still loading data
  117196. */
  117197. get isLoading(): boolean;
  117198. /**
  117199. * Registers a function to be executed when the scene is ready
  117200. * @param {Function} func - the function to be executed
  117201. */
  117202. executeWhenReady(func: () => void): void;
  117203. /**
  117204. * Returns a promise that resolves when the scene is ready
  117205. * @returns A promise that resolves when the scene is ready
  117206. */
  117207. whenReadyAsync(): Promise<void>;
  117208. /** @hidden */
  117209. _checkIsReady(): void;
  117210. /**
  117211. * Gets all animatable attached to the scene
  117212. */
  117213. get animatables(): Animatable[];
  117214. /**
  117215. * Resets the last animation time frame.
  117216. * Useful to override when animations start running when loading a scene for the first time.
  117217. */
  117218. resetLastAnimationTimeFrame(): void;
  117219. /**
  117220. * Gets the current view matrix
  117221. * @returns a Matrix
  117222. */
  117223. getViewMatrix(): Matrix;
  117224. /**
  117225. * Gets the current projection matrix
  117226. * @returns a Matrix
  117227. */
  117228. getProjectionMatrix(): Matrix;
  117229. /**
  117230. * Gets the current transform matrix
  117231. * @returns a Matrix made of View * Projection
  117232. */
  117233. getTransformMatrix(): Matrix;
  117234. /**
  117235. * Sets the current transform matrix
  117236. * @param viewL defines the View matrix to use
  117237. * @param projectionL defines the Projection matrix to use
  117238. * @param viewR defines the right View matrix to use (if provided)
  117239. * @param projectionR defines the right Projection matrix to use (if provided)
  117240. */
  117241. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  117242. /**
  117243. * Gets the uniform buffer used to store scene data
  117244. * @returns a UniformBuffer
  117245. */
  117246. getSceneUniformBuffer(): UniformBuffer;
  117247. /**
  117248. * Gets an unique (relatively to the current scene) Id
  117249. * @returns an unique number for the scene
  117250. */
  117251. getUniqueId(): number;
  117252. /**
  117253. * Add a mesh to the list of scene's meshes
  117254. * @param newMesh defines the mesh to add
  117255. * @param recursive if all child meshes should also be added to the scene
  117256. */
  117257. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  117258. /**
  117259. * Remove a mesh for the list of scene's meshes
  117260. * @param toRemove defines the mesh to remove
  117261. * @param recursive if all child meshes should also be removed from the scene
  117262. * @returns the index where the mesh was in the mesh list
  117263. */
  117264. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  117265. /**
  117266. * Add a transform node to the list of scene's transform nodes
  117267. * @param newTransformNode defines the transform node to add
  117268. */
  117269. addTransformNode(newTransformNode: TransformNode): void;
  117270. /**
  117271. * Remove a transform node for the list of scene's transform nodes
  117272. * @param toRemove defines the transform node to remove
  117273. * @returns the index where the transform node was in the transform node list
  117274. */
  117275. removeTransformNode(toRemove: TransformNode): number;
  117276. /**
  117277. * Remove a skeleton for the list of scene's skeletons
  117278. * @param toRemove defines the skeleton to remove
  117279. * @returns the index where the skeleton was in the skeleton list
  117280. */
  117281. removeSkeleton(toRemove: Skeleton): number;
  117282. /**
  117283. * Remove a morph target for the list of scene's morph targets
  117284. * @param toRemove defines the morph target to remove
  117285. * @returns the index where the morph target was in the morph target list
  117286. */
  117287. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  117288. /**
  117289. * Remove a light for the list of scene's lights
  117290. * @param toRemove defines the light to remove
  117291. * @returns the index where the light was in the light list
  117292. */
  117293. removeLight(toRemove: Light): number;
  117294. /**
  117295. * Remove a camera for the list of scene's cameras
  117296. * @param toRemove defines the camera to remove
  117297. * @returns the index where the camera was in the camera list
  117298. */
  117299. removeCamera(toRemove: Camera): number;
  117300. /**
  117301. * Remove a particle system for the list of scene's particle systems
  117302. * @param toRemove defines the particle system to remove
  117303. * @returns the index where the particle system was in the particle system list
  117304. */
  117305. removeParticleSystem(toRemove: IParticleSystem): number;
  117306. /**
  117307. * Remove a animation for the list of scene's animations
  117308. * @param toRemove defines the animation to remove
  117309. * @returns the index where the animation was in the animation list
  117310. */
  117311. removeAnimation(toRemove: Animation): number;
  117312. /**
  117313. * Will stop the animation of the given target
  117314. * @param target - the target
  117315. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  117316. * @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)
  117317. */
  117318. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  117319. /**
  117320. * Removes the given animation group from this scene.
  117321. * @param toRemove The animation group to remove
  117322. * @returns The index of the removed animation group
  117323. */
  117324. removeAnimationGroup(toRemove: AnimationGroup): number;
  117325. /**
  117326. * Removes the given multi-material from this scene.
  117327. * @param toRemove The multi-material to remove
  117328. * @returns The index of the removed multi-material
  117329. */
  117330. removeMultiMaterial(toRemove: MultiMaterial): number;
  117331. /**
  117332. * Removes the given material from this scene.
  117333. * @param toRemove The material to remove
  117334. * @returns The index of the removed material
  117335. */
  117336. removeMaterial(toRemove: Material): number;
  117337. /**
  117338. * Removes the given action manager from this scene.
  117339. * @param toRemove The action manager to remove
  117340. * @returns The index of the removed action manager
  117341. */
  117342. removeActionManager(toRemove: AbstractActionManager): number;
  117343. /**
  117344. * Removes the given texture from this scene.
  117345. * @param toRemove The texture to remove
  117346. * @returns The index of the removed texture
  117347. */
  117348. removeTexture(toRemove: BaseTexture): number;
  117349. /**
  117350. * Adds the given light to this scene
  117351. * @param newLight The light to add
  117352. */
  117353. addLight(newLight: Light): void;
  117354. /**
  117355. * Sorts the list list based on light priorities
  117356. */
  117357. sortLightsByPriority(): void;
  117358. /**
  117359. * Adds the given camera to this scene
  117360. * @param newCamera The camera to add
  117361. */
  117362. addCamera(newCamera: Camera): void;
  117363. /**
  117364. * Adds the given skeleton to this scene
  117365. * @param newSkeleton The skeleton to add
  117366. */
  117367. addSkeleton(newSkeleton: Skeleton): void;
  117368. /**
  117369. * Adds the given particle system to this scene
  117370. * @param newParticleSystem The particle system to add
  117371. */
  117372. addParticleSystem(newParticleSystem: IParticleSystem): void;
  117373. /**
  117374. * Adds the given animation to this scene
  117375. * @param newAnimation The animation to add
  117376. */
  117377. addAnimation(newAnimation: Animation): void;
  117378. /**
  117379. * Adds the given animation group to this scene.
  117380. * @param newAnimationGroup The animation group to add
  117381. */
  117382. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  117383. /**
  117384. * Adds the given multi-material to this scene
  117385. * @param newMultiMaterial The multi-material to add
  117386. */
  117387. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  117388. /**
  117389. * Adds the given material to this scene
  117390. * @param newMaterial The material to add
  117391. */
  117392. addMaterial(newMaterial: Material): void;
  117393. /**
  117394. * Adds the given morph target to this scene
  117395. * @param newMorphTargetManager The morph target to add
  117396. */
  117397. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  117398. /**
  117399. * Adds the given geometry to this scene
  117400. * @param newGeometry The geometry to add
  117401. */
  117402. addGeometry(newGeometry: Geometry): void;
  117403. /**
  117404. * Adds the given action manager to this scene
  117405. * @param newActionManager The action manager to add
  117406. */
  117407. addActionManager(newActionManager: AbstractActionManager): void;
  117408. /**
  117409. * Adds the given texture to this scene.
  117410. * @param newTexture The texture to add
  117411. */
  117412. addTexture(newTexture: BaseTexture): void;
  117413. /**
  117414. * Switch active camera
  117415. * @param newCamera defines the new active camera
  117416. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  117417. */
  117418. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  117419. /**
  117420. * sets the active camera of the scene using its ID
  117421. * @param id defines the camera's ID
  117422. * @return the new active camera or null if none found.
  117423. */
  117424. setActiveCameraByID(id: string): Nullable<Camera>;
  117425. /**
  117426. * sets the active camera of the scene using its name
  117427. * @param name defines the camera's name
  117428. * @returns the new active camera or null if none found.
  117429. */
  117430. setActiveCameraByName(name: string): Nullable<Camera>;
  117431. /**
  117432. * get an animation group using its name
  117433. * @param name defines the material's name
  117434. * @return the animation group or null if none found.
  117435. */
  117436. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  117437. /**
  117438. * Get a material using its unique id
  117439. * @param uniqueId defines the material's unique id
  117440. * @return the material or null if none found.
  117441. */
  117442. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  117443. /**
  117444. * get a material using its id
  117445. * @param id defines the material's ID
  117446. * @return the material or null if none found.
  117447. */
  117448. getMaterialByID(id: string): Nullable<Material>;
  117449. /**
  117450. * Gets a the last added material using a given id
  117451. * @param id defines the material's ID
  117452. * @return the last material with the given id or null if none found.
  117453. */
  117454. getLastMaterialByID(id: string): Nullable<Material>;
  117455. /**
  117456. * Gets a material using its name
  117457. * @param name defines the material's name
  117458. * @return the material or null if none found.
  117459. */
  117460. getMaterialByName(name: string): Nullable<Material>;
  117461. /**
  117462. * Get a texture using its unique id
  117463. * @param uniqueId defines the texture's unique id
  117464. * @return the texture or null if none found.
  117465. */
  117466. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  117467. /**
  117468. * Gets a camera using its id
  117469. * @param id defines the id to look for
  117470. * @returns the camera or null if not found
  117471. */
  117472. getCameraByID(id: string): Nullable<Camera>;
  117473. /**
  117474. * Gets a camera using its unique id
  117475. * @param uniqueId defines the unique id to look for
  117476. * @returns the camera or null if not found
  117477. */
  117478. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  117479. /**
  117480. * Gets a camera using its name
  117481. * @param name defines the camera's name
  117482. * @return the camera or null if none found.
  117483. */
  117484. getCameraByName(name: string): Nullable<Camera>;
  117485. /**
  117486. * Gets a bone using its id
  117487. * @param id defines the bone's id
  117488. * @return the bone or null if not found
  117489. */
  117490. getBoneByID(id: string): Nullable<Bone>;
  117491. /**
  117492. * Gets a bone using its id
  117493. * @param name defines the bone's name
  117494. * @return the bone or null if not found
  117495. */
  117496. getBoneByName(name: string): Nullable<Bone>;
  117497. /**
  117498. * Gets a light node using its name
  117499. * @param name defines the the light's name
  117500. * @return the light or null if none found.
  117501. */
  117502. getLightByName(name: string): Nullable<Light>;
  117503. /**
  117504. * Gets a light node using its id
  117505. * @param id defines the light's id
  117506. * @return the light or null if none found.
  117507. */
  117508. getLightByID(id: string): Nullable<Light>;
  117509. /**
  117510. * Gets a light node using its scene-generated unique ID
  117511. * @param uniqueId defines the light's unique id
  117512. * @return the light or null if none found.
  117513. */
  117514. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  117515. /**
  117516. * Gets a particle system by id
  117517. * @param id defines the particle system id
  117518. * @return the corresponding system or null if none found
  117519. */
  117520. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  117521. /**
  117522. * Gets a geometry using its ID
  117523. * @param id defines the geometry's id
  117524. * @return the geometry or null if none found.
  117525. */
  117526. getGeometryByID(id: string): Nullable<Geometry>;
  117527. private _getGeometryByUniqueID;
  117528. /**
  117529. * Add a new geometry to this scene
  117530. * @param geometry defines the geometry to be added to the scene.
  117531. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  117532. * @return a boolean defining if the geometry was added or not
  117533. */
  117534. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  117535. /**
  117536. * Removes an existing geometry
  117537. * @param geometry defines the geometry to be removed from the scene
  117538. * @return a boolean defining if the geometry was removed or not
  117539. */
  117540. removeGeometry(geometry: Geometry): boolean;
  117541. /**
  117542. * Gets the list of geometries attached to the scene
  117543. * @returns an array of Geometry
  117544. */
  117545. getGeometries(): Geometry[];
  117546. /**
  117547. * Gets the first added mesh found of a given ID
  117548. * @param id defines the id to search for
  117549. * @return the mesh found or null if not found at all
  117550. */
  117551. getMeshByID(id: string): Nullable<AbstractMesh>;
  117552. /**
  117553. * Gets a list of meshes using their id
  117554. * @param id defines the id to search for
  117555. * @returns a list of meshes
  117556. */
  117557. getMeshesByID(id: string): Array<AbstractMesh>;
  117558. /**
  117559. * Gets the first added transform node found of a given ID
  117560. * @param id defines the id to search for
  117561. * @return the found transform node or null if not found at all.
  117562. */
  117563. getTransformNodeByID(id: string): Nullable<TransformNode>;
  117564. /**
  117565. * Gets a transform node with its auto-generated unique id
  117566. * @param uniqueId efines the unique id to search for
  117567. * @return the found transform node or null if not found at all.
  117568. */
  117569. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  117570. /**
  117571. * Gets a list of transform nodes using their id
  117572. * @param id defines the id to search for
  117573. * @returns a list of transform nodes
  117574. */
  117575. getTransformNodesByID(id: string): Array<TransformNode>;
  117576. /**
  117577. * Gets a mesh with its auto-generated unique id
  117578. * @param uniqueId defines the unique id to search for
  117579. * @return the found mesh or null if not found at all.
  117580. */
  117581. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  117582. /**
  117583. * Gets a the last added mesh using a given id
  117584. * @param id defines the id to search for
  117585. * @return the found mesh or null if not found at all.
  117586. */
  117587. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  117588. /**
  117589. * Gets a the last added node (Mesh, Camera, Light) using a given id
  117590. * @param id defines the id to search for
  117591. * @return the found node or null if not found at all
  117592. */
  117593. getLastEntryByID(id: string): Nullable<Node>;
  117594. /**
  117595. * Gets a node (Mesh, Camera, Light) using a given id
  117596. * @param id defines the id to search for
  117597. * @return the found node or null if not found at all
  117598. */
  117599. getNodeByID(id: string): Nullable<Node>;
  117600. /**
  117601. * Gets a node (Mesh, Camera, Light) using a given name
  117602. * @param name defines the name to search for
  117603. * @return the found node or null if not found at all.
  117604. */
  117605. getNodeByName(name: string): Nullable<Node>;
  117606. /**
  117607. * Gets a mesh using a given name
  117608. * @param name defines the name to search for
  117609. * @return the found mesh or null if not found at all.
  117610. */
  117611. getMeshByName(name: string): Nullable<AbstractMesh>;
  117612. /**
  117613. * Gets a transform node using a given name
  117614. * @param name defines the name to search for
  117615. * @return the found transform node or null if not found at all.
  117616. */
  117617. getTransformNodeByName(name: string): Nullable<TransformNode>;
  117618. /**
  117619. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  117620. * @param id defines the id to search for
  117621. * @return the found skeleton or null if not found at all.
  117622. */
  117623. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  117624. /**
  117625. * Gets a skeleton using a given auto generated unique id
  117626. * @param uniqueId defines the unique id to search for
  117627. * @return the found skeleton or null if not found at all.
  117628. */
  117629. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  117630. /**
  117631. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  117632. * @param id defines the id to search for
  117633. * @return the found skeleton or null if not found at all.
  117634. */
  117635. getSkeletonById(id: string): Nullable<Skeleton>;
  117636. /**
  117637. * Gets a skeleton using a given name
  117638. * @param name defines the name to search for
  117639. * @return the found skeleton or null if not found at all.
  117640. */
  117641. getSkeletonByName(name: string): Nullable<Skeleton>;
  117642. /**
  117643. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  117644. * @param id defines the id to search for
  117645. * @return the found morph target manager or null if not found at all.
  117646. */
  117647. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  117648. /**
  117649. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  117650. * @param id defines the id to search for
  117651. * @return the found morph target or null if not found at all.
  117652. */
  117653. getMorphTargetById(id: string): Nullable<MorphTarget>;
  117654. /**
  117655. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  117656. * @param name defines the name to search for
  117657. * @return the found morph target or null if not found at all.
  117658. */
  117659. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  117660. /**
  117661. * Gets a boolean indicating if the given mesh is active
  117662. * @param mesh defines the mesh to look for
  117663. * @returns true if the mesh is in the active list
  117664. */
  117665. isActiveMesh(mesh: AbstractMesh): boolean;
  117666. /**
  117667. * Return a unique id as a string which can serve as an identifier for the scene
  117668. */
  117669. get uid(): string;
  117670. /**
  117671. * Add an externaly attached data from its key.
  117672. * This method call will fail and return false, if such key already exists.
  117673. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  117674. * @param key the unique key that identifies the data
  117675. * @param data the data object to associate to the key for this Engine instance
  117676. * @return true if no such key were already present and the data was added successfully, false otherwise
  117677. */
  117678. addExternalData<T>(key: string, data: T): boolean;
  117679. /**
  117680. * Get an externaly attached data from its key
  117681. * @param key the unique key that identifies the data
  117682. * @return the associated data, if present (can be null), or undefined if not present
  117683. */
  117684. getExternalData<T>(key: string): Nullable<T>;
  117685. /**
  117686. * Get an externaly attached data from its key, create it using a factory if it's not already present
  117687. * @param key the unique key that identifies the data
  117688. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  117689. * @return the associated data, can be null if the factory returned null.
  117690. */
  117691. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  117692. /**
  117693. * Remove an externaly attached data from the Engine instance
  117694. * @param key the unique key that identifies the data
  117695. * @return true if the data was successfully removed, false if it doesn't exist
  117696. */
  117697. removeExternalData(key: string): boolean;
  117698. private _evaluateSubMesh;
  117699. /**
  117700. * Clear the processed materials smart array preventing retention point in material dispose.
  117701. */
  117702. freeProcessedMaterials(): void;
  117703. private _preventFreeActiveMeshesAndRenderingGroups;
  117704. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  117705. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  117706. * when disposing several meshes in a row or a hierarchy of meshes.
  117707. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  117708. */
  117709. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  117710. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  117711. /**
  117712. * Clear the active meshes smart array preventing retention point in mesh dispose.
  117713. */
  117714. freeActiveMeshes(): void;
  117715. /**
  117716. * Clear the info related to rendering groups preventing retention points during dispose.
  117717. */
  117718. freeRenderingGroups(): void;
  117719. /** @hidden */
  117720. _isInIntermediateRendering(): boolean;
  117721. /**
  117722. * Lambda returning the list of potentially active meshes.
  117723. */
  117724. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  117725. /**
  117726. * Lambda returning the list of potentially active sub meshes.
  117727. */
  117728. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  117729. /**
  117730. * Lambda returning the list of potentially intersecting sub meshes.
  117731. */
  117732. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  117733. /**
  117734. * Lambda returning the list of potentially colliding sub meshes.
  117735. */
  117736. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  117737. private _activeMeshesFrozen;
  117738. private _skipEvaluateActiveMeshesCompletely;
  117739. /**
  117740. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  117741. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  117742. * @returns the current scene
  117743. */
  117744. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  117745. /**
  117746. * Use this function to restart evaluating active meshes on every frame
  117747. * @returns the current scene
  117748. */
  117749. unfreezeActiveMeshes(): Scene;
  117750. private _evaluateActiveMeshes;
  117751. private _activeMesh;
  117752. /**
  117753. * Update the transform matrix to update from the current active camera
  117754. * @param force defines a boolean used to force the update even if cache is up to date
  117755. */
  117756. updateTransformMatrix(force?: boolean): void;
  117757. private _bindFrameBuffer;
  117758. /** @hidden */
  117759. _allowPostProcessClearColor: boolean;
  117760. /** @hidden */
  117761. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  117762. private _processSubCameras;
  117763. private _checkIntersections;
  117764. /** @hidden */
  117765. _advancePhysicsEngineStep(step: number): void;
  117766. /**
  117767. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  117768. */
  117769. getDeterministicFrameTime: () => number;
  117770. /** @hidden */
  117771. _animate(): void;
  117772. /** Execute all animations (for a frame) */
  117773. animate(): void;
  117774. /**
  117775. * Render the scene
  117776. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  117777. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  117778. */
  117779. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  117780. /**
  117781. * Freeze all materials
  117782. * A frozen material will not be updatable but should be faster to render
  117783. */
  117784. freezeMaterials(): void;
  117785. /**
  117786. * Unfreeze all materials
  117787. * A frozen material will not be updatable but should be faster to render
  117788. */
  117789. unfreezeMaterials(): void;
  117790. /**
  117791. * Releases all held ressources
  117792. */
  117793. dispose(): void;
  117794. /**
  117795. * Gets if the scene is already disposed
  117796. */
  117797. get isDisposed(): boolean;
  117798. /**
  117799. * Call this function to reduce memory footprint of the scene.
  117800. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  117801. */
  117802. clearCachedVertexData(): void;
  117803. /**
  117804. * This function will remove the local cached buffer data from texture.
  117805. * It will save memory but will prevent the texture from being rebuilt
  117806. */
  117807. cleanCachedTextureBuffer(): void;
  117808. /**
  117809. * Get the world extend vectors with an optional filter
  117810. *
  117811. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  117812. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  117813. */
  117814. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  117815. min: Vector3;
  117816. max: Vector3;
  117817. };
  117818. /**
  117819. * Creates a ray that can be used to pick in the scene
  117820. * @param x defines the x coordinate of the origin (on-screen)
  117821. * @param y defines the y coordinate of the origin (on-screen)
  117822. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117823. * @param camera defines the camera to use for the picking
  117824. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117825. * @returns a Ray
  117826. */
  117827. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  117828. /**
  117829. * Creates a ray that can be used to pick in the scene
  117830. * @param x defines the x coordinate of the origin (on-screen)
  117831. * @param y defines the y coordinate of the origin (on-screen)
  117832. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117833. * @param result defines the ray where to store the picking ray
  117834. * @param camera defines the camera to use for the picking
  117835. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117836. * @returns the current scene
  117837. */
  117838. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  117839. /**
  117840. * Creates a ray that can be used to pick in the scene
  117841. * @param x defines the x coordinate of the origin (on-screen)
  117842. * @param y defines the y coordinate of the origin (on-screen)
  117843. * @param camera defines the camera to use for the picking
  117844. * @returns a Ray
  117845. */
  117846. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  117847. /**
  117848. * Creates a ray that can be used to pick in the scene
  117849. * @param x defines the x coordinate of the origin (on-screen)
  117850. * @param y defines the y coordinate of the origin (on-screen)
  117851. * @param result defines the ray where to store the picking ray
  117852. * @param camera defines the camera to use for the picking
  117853. * @returns the current scene
  117854. */
  117855. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  117856. /** Launch a ray to try to pick a mesh in the scene
  117857. * @param x position on screen
  117858. * @param y position on screen
  117859. * @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
  117860. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117861. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117862. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117863. * @returns a PickingInfo
  117864. */
  117865. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117866. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  117867. * @param x position on screen
  117868. * @param y position on screen
  117869. * @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
  117870. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117871. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117872. * @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)
  117873. */
  117874. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  117875. /** Use the given ray to pick a mesh in the scene
  117876. * @param ray The ray to use to pick meshes
  117877. * @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
  117878. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117880. * @returns a PickingInfo
  117881. */
  117882. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117883. /**
  117884. * Launch a ray to try to pick a mesh in the scene
  117885. * @param x X position on screen
  117886. * @param y Y position on screen
  117887. * @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
  117888. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117889. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117890. * @returns an array of PickingInfo
  117891. */
  117892. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117893. /**
  117894. * Launch a ray to try to pick a mesh in the scene
  117895. * @param ray Ray to use
  117896. * @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
  117897. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117898. * @returns an array of PickingInfo
  117899. */
  117900. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117901. /**
  117902. * Force the value of meshUnderPointer
  117903. * @param mesh defines the mesh to use
  117904. */
  117905. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117906. /**
  117907. * Gets the mesh under the pointer
  117908. * @returns a Mesh or null if no mesh is under the pointer
  117909. */
  117910. getPointerOverMesh(): Nullable<AbstractMesh>;
  117911. /** @hidden */
  117912. _rebuildGeometries(): void;
  117913. /** @hidden */
  117914. _rebuildTextures(): void;
  117915. private _getByTags;
  117916. /**
  117917. * Get a list of meshes by tags
  117918. * @param tagsQuery defines the tags query to use
  117919. * @param forEach defines a predicate used to filter results
  117920. * @returns an array of Mesh
  117921. */
  117922. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  117923. /**
  117924. * Get a list of cameras by tags
  117925. * @param tagsQuery defines the tags query to use
  117926. * @param forEach defines a predicate used to filter results
  117927. * @returns an array of Camera
  117928. */
  117929. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  117930. /**
  117931. * Get a list of lights by tags
  117932. * @param tagsQuery defines the tags query to use
  117933. * @param forEach defines a predicate used to filter results
  117934. * @returns an array of Light
  117935. */
  117936. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  117937. /**
  117938. * Get a list of materials by tags
  117939. * @param tagsQuery defines the tags query to use
  117940. * @param forEach defines a predicate used to filter results
  117941. * @returns an array of Material
  117942. */
  117943. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  117944. /**
  117945. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  117946. * This allowed control for front to back rendering or reversly depending of the special needs.
  117947. *
  117948. * @param renderingGroupId The rendering group id corresponding to its index
  117949. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  117950. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  117951. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  117952. */
  117953. 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;
  117954. /**
  117955. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  117956. *
  117957. * @param renderingGroupId The rendering group id corresponding to its index
  117958. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117959. * @param depth Automatically clears depth between groups if true and autoClear is true.
  117960. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  117961. */
  117962. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  117963. /**
  117964. * Gets the current auto clear configuration for one rendering group of the rendering
  117965. * manager.
  117966. * @param index the rendering group index to get the information for
  117967. * @returns The auto clear setup for the requested rendering group
  117968. */
  117969. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  117970. private _blockMaterialDirtyMechanism;
  117971. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  117972. get blockMaterialDirtyMechanism(): boolean;
  117973. set blockMaterialDirtyMechanism(value: boolean);
  117974. /**
  117975. * Will flag all materials as dirty to trigger new shader compilation
  117976. * @param flag defines the flag used to specify which material part must be marked as dirty
  117977. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  117978. */
  117979. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117980. /** @hidden */
  117981. _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;
  117982. /** @hidden */
  117983. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117984. /** @hidden */
  117985. _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;
  117986. /** @hidden */
  117987. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  117988. /** @hidden */
  117989. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117990. /** @hidden */
  117991. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117992. }
  117993. }
  117994. declare module BABYLON {
  117995. /**
  117996. * Set of assets to keep when moving a scene into an asset container.
  117997. */
  117998. export class KeepAssets extends AbstractScene {
  117999. }
  118000. /**
  118001. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  118002. */
  118003. export class InstantiatedEntries {
  118004. /**
  118005. * List of new root nodes (eg. nodes with no parent)
  118006. */
  118007. rootNodes: TransformNode[];
  118008. /**
  118009. * List of new skeletons
  118010. */
  118011. skeletons: Skeleton[];
  118012. /**
  118013. * List of new animation groups
  118014. */
  118015. animationGroups: AnimationGroup[];
  118016. }
  118017. /**
  118018. * Container with a set of assets that can be added or removed from a scene.
  118019. */
  118020. export class AssetContainer extends AbstractScene {
  118021. private _wasAddedToScene;
  118022. /**
  118023. * The scene the AssetContainer belongs to.
  118024. */
  118025. scene: Scene;
  118026. /**
  118027. * Instantiates an AssetContainer.
  118028. * @param scene The scene the AssetContainer belongs to.
  118029. */
  118030. constructor(scene: Scene);
  118031. /**
  118032. * Instantiate or clone all meshes and add the new ones to the scene.
  118033. * Skeletons and animation groups will all be cloned
  118034. * @param nameFunction defines an optional function used to get new names for clones
  118035. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  118036. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  118037. */
  118038. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  118039. /**
  118040. * Adds all the assets from the container to the scene.
  118041. */
  118042. addAllToScene(): void;
  118043. /**
  118044. * Removes all the assets in the container from the scene
  118045. */
  118046. removeAllFromScene(): void;
  118047. /**
  118048. * Disposes all the assets in the container
  118049. */
  118050. dispose(): void;
  118051. private _moveAssets;
  118052. /**
  118053. * Removes all the assets contained in the scene and adds them to the container.
  118054. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  118055. */
  118056. moveAllFromScene(keepAssets?: KeepAssets): void;
  118057. /**
  118058. * 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.
  118059. * @returns the root mesh
  118060. */
  118061. createRootMesh(): Mesh;
  118062. /**
  118063. * Merge animations (direct and animation groups) from this asset container into a scene
  118064. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118065. * @param animatables set of animatables to retarget to a node from the scene
  118066. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  118067. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  118068. */
  118069. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  118070. }
  118071. }
  118072. declare module BABYLON {
  118073. /**
  118074. * Defines how the parser contract is defined.
  118075. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  118076. */
  118077. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118078. /**
  118079. * Defines how the individual parser contract is defined.
  118080. * These parser can parse an individual asset
  118081. */
  118082. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118083. /**
  118084. * Base class of the scene acting as a container for the different elements composing a scene.
  118085. * This class is dynamically extended by the different components of the scene increasing
  118086. * flexibility and reducing coupling
  118087. */
  118088. export abstract class AbstractScene {
  118089. /**
  118090. * Stores the list of available parsers in the application.
  118091. */
  118092. private static _BabylonFileParsers;
  118093. /**
  118094. * Stores the list of available individual parsers in the application.
  118095. */
  118096. private static _IndividualBabylonFileParsers;
  118097. /**
  118098. * Adds a parser in the list of available ones
  118099. * @param name Defines the name of the parser
  118100. * @param parser Defines the parser to add
  118101. */
  118102. static AddParser(name: string, parser: BabylonFileParser): void;
  118103. /**
  118104. * Gets a general parser from the list of avaialble ones
  118105. * @param name Defines the name of the parser
  118106. * @returns the requested parser or null
  118107. */
  118108. static GetParser(name: string): Nullable<BabylonFileParser>;
  118109. /**
  118110. * Adds n individual parser in the list of available ones
  118111. * @param name Defines the name of the parser
  118112. * @param parser Defines the parser to add
  118113. */
  118114. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118115. /**
  118116. * Gets an individual parser from the list of avaialble ones
  118117. * @param name Defines the name of the parser
  118118. * @returns the requested parser or null
  118119. */
  118120. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118121. /**
  118122. * Parser json data and populate both a scene and its associated container object
  118123. * @param jsonData Defines the data to parse
  118124. * @param scene Defines the scene to parse the data for
  118125. * @param container Defines the container attached to the parsing sequence
  118126. * @param rootUrl Defines the root url of the data
  118127. */
  118128. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118129. /**
  118130. * Gets the list of root nodes (ie. nodes with no parent)
  118131. */
  118132. rootNodes: Node[];
  118133. /** All of the cameras added to this scene
  118134. * @see http://doc.babylonjs.com/babylon101/cameras
  118135. */
  118136. cameras: Camera[];
  118137. /**
  118138. * All of the lights added to this scene
  118139. * @see http://doc.babylonjs.com/babylon101/lights
  118140. */
  118141. lights: Light[];
  118142. /**
  118143. * All of the (abstract) meshes added to this scene
  118144. */
  118145. meshes: AbstractMesh[];
  118146. /**
  118147. * The list of skeletons added to the scene
  118148. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118149. */
  118150. skeletons: Skeleton[];
  118151. /**
  118152. * All of the particle systems added to this scene
  118153. * @see http://doc.babylonjs.com/babylon101/particles
  118154. */
  118155. particleSystems: IParticleSystem[];
  118156. /**
  118157. * Gets a list of Animations associated with the scene
  118158. */
  118159. animations: Animation[];
  118160. /**
  118161. * All of the animation groups added to this scene
  118162. * @see http://doc.babylonjs.com/how_to/group
  118163. */
  118164. animationGroups: AnimationGroup[];
  118165. /**
  118166. * All of the multi-materials added to this scene
  118167. * @see http://doc.babylonjs.com/how_to/multi_materials
  118168. */
  118169. multiMaterials: MultiMaterial[];
  118170. /**
  118171. * All of the materials added to this scene
  118172. * In the context of a Scene, it is not supposed to be modified manually.
  118173. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118174. * Note also that the order of the Material within the array is not significant and might change.
  118175. * @see http://doc.babylonjs.com/babylon101/materials
  118176. */
  118177. materials: Material[];
  118178. /**
  118179. * The list of morph target managers added to the scene
  118180. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118181. */
  118182. morphTargetManagers: MorphTargetManager[];
  118183. /**
  118184. * The list of geometries used in the scene.
  118185. */
  118186. geometries: Geometry[];
  118187. /**
  118188. * All of the tranform nodes added to this scene
  118189. * In the context of a Scene, it is not supposed to be modified manually.
  118190. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118191. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118192. * @see http://doc.babylonjs.com/how_to/transformnode
  118193. */
  118194. transformNodes: TransformNode[];
  118195. /**
  118196. * ActionManagers available on the scene.
  118197. */
  118198. actionManagers: AbstractActionManager[];
  118199. /**
  118200. * Textures to keep.
  118201. */
  118202. textures: BaseTexture[];
  118203. /**
  118204. * Environment texture for the scene
  118205. */
  118206. environmentTexture: Nullable<BaseTexture>;
  118207. /**
  118208. * @returns all meshes, lights, cameras, transformNodes and bones
  118209. */
  118210. getNodes(): Array<Node>;
  118211. }
  118212. }
  118213. declare module BABYLON {
  118214. /**
  118215. * Interface used to define options for Sound class
  118216. */
  118217. export interface ISoundOptions {
  118218. /**
  118219. * Does the sound autoplay once loaded.
  118220. */
  118221. autoplay?: boolean;
  118222. /**
  118223. * Does the sound loop after it finishes playing once.
  118224. */
  118225. loop?: boolean;
  118226. /**
  118227. * Sound's volume
  118228. */
  118229. volume?: number;
  118230. /**
  118231. * Is it a spatial sound?
  118232. */
  118233. spatialSound?: boolean;
  118234. /**
  118235. * Maximum distance to hear that sound
  118236. */
  118237. maxDistance?: number;
  118238. /**
  118239. * Uses user defined attenuation function
  118240. */
  118241. useCustomAttenuation?: boolean;
  118242. /**
  118243. * Define the roll off factor of spatial sounds.
  118244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118245. */
  118246. rolloffFactor?: number;
  118247. /**
  118248. * Define the reference distance the sound should be heard perfectly.
  118249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118250. */
  118251. refDistance?: number;
  118252. /**
  118253. * Define the distance attenuation model the sound will follow.
  118254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118255. */
  118256. distanceModel?: string;
  118257. /**
  118258. * Defines the playback speed (1 by default)
  118259. */
  118260. playbackRate?: number;
  118261. /**
  118262. * Defines if the sound is from a streaming source
  118263. */
  118264. streaming?: boolean;
  118265. /**
  118266. * Defines an optional length (in seconds) inside the sound file
  118267. */
  118268. length?: number;
  118269. /**
  118270. * Defines an optional offset (in seconds) inside the sound file
  118271. */
  118272. offset?: number;
  118273. /**
  118274. * If true, URLs will not be required to state the audio file codec to use.
  118275. */
  118276. skipCodecCheck?: boolean;
  118277. }
  118278. /**
  118279. * Defines a sound that can be played in the application.
  118280. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  118281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118282. */
  118283. export class Sound {
  118284. /**
  118285. * The name of the sound in the scene.
  118286. */
  118287. name: string;
  118288. /**
  118289. * Does the sound autoplay once loaded.
  118290. */
  118291. autoplay: boolean;
  118292. /**
  118293. * Does the sound loop after it finishes playing once.
  118294. */
  118295. loop: boolean;
  118296. /**
  118297. * Does the sound use a custom attenuation curve to simulate the falloff
  118298. * happening when the source gets further away from the camera.
  118299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118300. */
  118301. useCustomAttenuation: boolean;
  118302. /**
  118303. * The sound track id this sound belongs to.
  118304. */
  118305. soundTrackId: number;
  118306. /**
  118307. * Is this sound currently played.
  118308. */
  118309. isPlaying: boolean;
  118310. /**
  118311. * Is this sound currently paused.
  118312. */
  118313. isPaused: boolean;
  118314. /**
  118315. * Does this sound enables spatial sound.
  118316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118317. */
  118318. spatialSound: boolean;
  118319. /**
  118320. * Define the reference distance the sound should be heard perfectly.
  118321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118322. */
  118323. refDistance: number;
  118324. /**
  118325. * Define the roll off factor of spatial sounds.
  118326. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118327. */
  118328. rolloffFactor: number;
  118329. /**
  118330. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  118331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118332. */
  118333. maxDistance: number;
  118334. /**
  118335. * Define the distance attenuation model the sound will follow.
  118336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118337. */
  118338. distanceModel: string;
  118339. /**
  118340. * @hidden
  118341. * Back Compat
  118342. **/
  118343. onended: () => any;
  118344. /**
  118345. * Gets or sets an object used to store user defined information for the sound.
  118346. */
  118347. metadata: any;
  118348. /**
  118349. * Observable event when the current playing sound finishes.
  118350. */
  118351. onEndedObservable: Observable<Sound>;
  118352. private _panningModel;
  118353. private _playbackRate;
  118354. private _streaming;
  118355. private _startTime;
  118356. private _startOffset;
  118357. private _position;
  118358. /** @hidden */
  118359. _positionInEmitterSpace: boolean;
  118360. private _localDirection;
  118361. private _volume;
  118362. private _isReadyToPlay;
  118363. private _isDirectional;
  118364. private _readyToPlayCallback;
  118365. private _audioBuffer;
  118366. private _soundSource;
  118367. private _streamingSource;
  118368. private _soundPanner;
  118369. private _soundGain;
  118370. private _inputAudioNode;
  118371. private _outputAudioNode;
  118372. private _coneInnerAngle;
  118373. private _coneOuterAngle;
  118374. private _coneOuterGain;
  118375. private _scene;
  118376. private _connectedTransformNode;
  118377. private _customAttenuationFunction;
  118378. private _registerFunc;
  118379. private _isOutputConnected;
  118380. private _htmlAudioElement;
  118381. private _urlType;
  118382. private _length?;
  118383. private _offset?;
  118384. /** @hidden */
  118385. static _SceneComponentInitialization: (scene: Scene) => void;
  118386. /**
  118387. * Create a sound and attach it to a scene
  118388. * @param name Name of your sound
  118389. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  118390. * @param scene defines the scene the sound belongs to
  118391. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  118392. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  118393. */
  118394. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  118395. /**
  118396. * Release the sound and its associated resources
  118397. */
  118398. dispose(): void;
  118399. /**
  118400. * Gets if the sounds is ready to be played or not.
  118401. * @returns true if ready, otherwise false
  118402. */
  118403. isReady(): boolean;
  118404. private _soundLoaded;
  118405. /**
  118406. * Sets the data of the sound from an audiobuffer
  118407. * @param audioBuffer The audioBuffer containing the data
  118408. */
  118409. setAudioBuffer(audioBuffer: AudioBuffer): void;
  118410. /**
  118411. * Updates the current sounds options such as maxdistance, loop...
  118412. * @param options A JSON object containing values named as the object properties
  118413. */
  118414. updateOptions(options: ISoundOptions): void;
  118415. private _createSpatialParameters;
  118416. private _updateSpatialParameters;
  118417. /**
  118418. * Switch the panning model to HRTF:
  118419. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118421. */
  118422. switchPanningModelToHRTF(): void;
  118423. /**
  118424. * Switch the panning model to Equal Power:
  118425. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118426. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118427. */
  118428. switchPanningModelToEqualPower(): void;
  118429. private _switchPanningModel;
  118430. /**
  118431. * Connect this sound to a sound track audio node like gain...
  118432. * @param soundTrackAudioNode the sound track audio node to connect to
  118433. */
  118434. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  118435. /**
  118436. * Transform this sound into a directional source
  118437. * @param coneInnerAngle Size of the inner cone in degree
  118438. * @param coneOuterAngle Size of the outer cone in degree
  118439. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  118440. */
  118441. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  118442. /**
  118443. * Gets or sets the inner angle for the directional cone.
  118444. */
  118445. get directionalConeInnerAngle(): number;
  118446. /**
  118447. * Gets or sets the inner angle for the directional cone.
  118448. */
  118449. set directionalConeInnerAngle(value: number);
  118450. /**
  118451. * Gets or sets the outer angle for the directional cone.
  118452. */
  118453. get directionalConeOuterAngle(): number;
  118454. /**
  118455. * Gets or sets the outer angle for the directional cone.
  118456. */
  118457. set directionalConeOuterAngle(value: number);
  118458. /**
  118459. * Sets the position of the emitter if spatial sound is enabled
  118460. * @param newPosition Defines the new posisiton
  118461. */
  118462. setPosition(newPosition: Vector3): void;
  118463. /**
  118464. * Sets the local direction of the emitter if spatial sound is enabled
  118465. * @param newLocalDirection Defines the new local direction
  118466. */
  118467. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  118468. private _updateDirection;
  118469. /** @hidden */
  118470. updateDistanceFromListener(): void;
  118471. /**
  118472. * Sets a new custom attenuation function for the sound.
  118473. * @param callback Defines the function used for the attenuation
  118474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118475. */
  118476. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  118477. /**
  118478. * Play the sound
  118479. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  118480. * @param offset (optional) Start the sound at a specific time in seconds
  118481. * @param length (optional) Sound duration (in seconds)
  118482. */
  118483. play(time?: number, offset?: number, length?: number): void;
  118484. private _onended;
  118485. /**
  118486. * Stop the sound
  118487. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  118488. */
  118489. stop(time?: number): void;
  118490. /**
  118491. * Put the sound in pause
  118492. */
  118493. pause(): void;
  118494. /**
  118495. * Sets a dedicated volume for this sounds
  118496. * @param newVolume Define the new volume of the sound
  118497. * @param time Define time for gradual change to new volume
  118498. */
  118499. setVolume(newVolume: number, time?: number): void;
  118500. /**
  118501. * Set the sound play back rate
  118502. * @param newPlaybackRate Define the playback rate the sound should be played at
  118503. */
  118504. setPlaybackRate(newPlaybackRate: number): void;
  118505. /**
  118506. * Gets the volume of the sound.
  118507. * @returns the volume of the sound
  118508. */
  118509. getVolume(): number;
  118510. /**
  118511. * Attach the sound to a dedicated mesh
  118512. * @param transformNode The transform node to connect the sound with
  118513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118514. */
  118515. attachToMesh(transformNode: TransformNode): void;
  118516. /**
  118517. * Detach the sound from the previously attached mesh
  118518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118519. */
  118520. detachFromMesh(): void;
  118521. private _onRegisterAfterWorldMatrixUpdate;
  118522. /**
  118523. * Clone the current sound in the scene.
  118524. * @returns the new sound clone
  118525. */
  118526. clone(): Nullable<Sound>;
  118527. /**
  118528. * Gets the current underlying audio buffer containing the data
  118529. * @returns the audio buffer
  118530. */
  118531. getAudioBuffer(): Nullable<AudioBuffer>;
  118532. /**
  118533. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  118534. * @returns the source node
  118535. */
  118536. getSoundSource(): Nullable<AudioBufferSourceNode>;
  118537. /**
  118538. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  118539. * @returns the gain node
  118540. */
  118541. getSoundGain(): Nullable<GainNode>;
  118542. /**
  118543. * Serializes the Sound in a JSON representation
  118544. * @returns the JSON representation of the sound
  118545. */
  118546. serialize(): any;
  118547. /**
  118548. * Parse a JSON representation of a sound to innstantiate in a given scene
  118549. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  118550. * @param scene Define the scene the new parsed sound should be created in
  118551. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  118552. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  118553. * @returns the newly parsed sound
  118554. */
  118555. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  118556. }
  118557. }
  118558. declare module BABYLON {
  118559. /**
  118560. * This defines an action helpful to play a defined sound on a triggered action.
  118561. */
  118562. export class PlaySoundAction extends Action {
  118563. private _sound;
  118564. /**
  118565. * Instantiate the action
  118566. * @param triggerOptions defines the trigger options
  118567. * @param sound defines the sound to play
  118568. * @param condition defines the trigger related conditions
  118569. */
  118570. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118571. /** @hidden */
  118572. _prepare(): void;
  118573. /**
  118574. * Execute the action and play the sound.
  118575. */
  118576. execute(): void;
  118577. /**
  118578. * Serializes the actions and its related information.
  118579. * @param parent defines the object to serialize in
  118580. * @returns the serialized object
  118581. */
  118582. serialize(parent: any): any;
  118583. }
  118584. /**
  118585. * This defines an action helpful to stop a defined sound on a triggered action.
  118586. */
  118587. export class StopSoundAction extends Action {
  118588. private _sound;
  118589. /**
  118590. * Instantiate the action
  118591. * @param triggerOptions defines the trigger options
  118592. * @param sound defines the sound to stop
  118593. * @param condition defines the trigger related conditions
  118594. */
  118595. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118596. /** @hidden */
  118597. _prepare(): void;
  118598. /**
  118599. * Execute the action and stop the sound.
  118600. */
  118601. execute(): void;
  118602. /**
  118603. * Serializes the actions and its related information.
  118604. * @param parent defines the object to serialize in
  118605. * @returns the serialized object
  118606. */
  118607. serialize(parent: any): any;
  118608. }
  118609. }
  118610. declare module BABYLON {
  118611. /**
  118612. * This defines an action responsible to change the value of a property
  118613. * by interpolating between its current value and the newly set one once triggered.
  118614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  118615. */
  118616. export class InterpolateValueAction extends Action {
  118617. /**
  118618. * Defines the path of the property where the value should be interpolated
  118619. */
  118620. propertyPath: string;
  118621. /**
  118622. * Defines the target value at the end of the interpolation.
  118623. */
  118624. value: any;
  118625. /**
  118626. * Defines the time it will take for the property to interpolate to the value.
  118627. */
  118628. duration: number;
  118629. /**
  118630. * Defines if the other scene animations should be stopped when the action has been triggered
  118631. */
  118632. stopOtherAnimations?: boolean;
  118633. /**
  118634. * Defines a callback raised once the interpolation animation has been done.
  118635. */
  118636. onInterpolationDone?: () => void;
  118637. /**
  118638. * Observable triggered once the interpolation animation has been done.
  118639. */
  118640. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  118641. private _target;
  118642. private _effectiveTarget;
  118643. private _property;
  118644. /**
  118645. * Instantiate the action
  118646. * @param triggerOptions defines the trigger options
  118647. * @param target defines the object containing the value to interpolate
  118648. * @param propertyPath defines the path to the property in the target object
  118649. * @param value defines the target value at the end of the interpolation
  118650. * @param duration deines the time it will take for the property to interpolate to the value.
  118651. * @param condition defines the trigger related conditions
  118652. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  118653. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  118654. */
  118655. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  118656. /** @hidden */
  118657. _prepare(): void;
  118658. /**
  118659. * Execute the action starts the value interpolation.
  118660. */
  118661. execute(): void;
  118662. /**
  118663. * Serializes the actions and its related information.
  118664. * @param parent defines the object to serialize in
  118665. * @returns the serialized object
  118666. */
  118667. serialize(parent: any): any;
  118668. }
  118669. }
  118670. declare module BABYLON {
  118671. /**
  118672. * Options allowed during the creation of a sound track.
  118673. */
  118674. export interface ISoundTrackOptions {
  118675. /**
  118676. * The volume the sound track should take during creation
  118677. */
  118678. volume?: number;
  118679. /**
  118680. * Define if the sound track is the main sound track of the scene
  118681. */
  118682. mainTrack?: boolean;
  118683. }
  118684. /**
  118685. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  118686. * It will be also used in a future release to apply effects on a specific track.
  118687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118688. */
  118689. export class SoundTrack {
  118690. /**
  118691. * The unique identifier of the sound track in the scene.
  118692. */
  118693. id: number;
  118694. /**
  118695. * The list of sounds included in the sound track.
  118696. */
  118697. soundCollection: Array<Sound>;
  118698. private _outputAudioNode;
  118699. private _scene;
  118700. private _connectedAnalyser;
  118701. private _options;
  118702. private _isInitialized;
  118703. /**
  118704. * Creates a new sound track.
  118705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118706. * @param scene Define the scene the sound track belongs to
  118707. * @param options
  118708. */
  118709. constructor(scene: Scene, options?: ISoundTrackOptions);
  118710. private _initializeSoundTrackAudioGraph;
  118711. /**
  118712. * Release the sound track and its associated resources
  118713. */
  118714. dispose(): void;
  118715. /**
  118716. * Adds a sound to this sound track
  118717. * @param sound define the cound to add
  118718. * @ignoreNaming
  118719. */
  118720. AddSound(sound: Sound): void;
  118721. /**
  118722. * Removes a sound to this sound track
  118723. * @param sound define the cound to remove
  118724. * @ignoreNaming
  118725. */
  118726. RemoveSound(sound: Sound): void;
  118727. /**
  118728. * Set a global volume for the full sound track.
  118729. * @param newVolume Define the new volume of the sound track
  118730. */
  118731. setVolume(newVolume: number): void;
  118732. /**
  118733. * Switch the panning model to HRTF:
  118734. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118735. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118736. */
  118737. switchPanningModelToHRTF(): void;
  118738. /**
  118739. * Switch the panning model to Equal Power:
  118740. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118742. */
  118743. switchPanningModelToEqualPower(): void;
  118744. /**
  118745. * Connect the sound track to an audio analyser allowing some amazing
  118746. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  118747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  118748. * @param analyser The analyser to connect to the engine
  118749. */
  118750. connectToAnalyser(analyser: Analyser): void;
  118751. }
  118752. }
  118753. declare module BABYLON {
  118754. interface AbstractScene {
  118755. /**
  118756. * The list of sounds used in the scene.
  118757. */
  118758. sounds: Nullable<Array<Sound>>;
  118759. }
  118760. interface Scene {
  118761. /**
  118762. * @hidden
  118763. * Backing field
  118764. */
  118765. _mainSoundTrack: SoundTrack;
  118766. /**
  118767. * The main sound track played by the scene.
  118768. * It cotains your primary collection of sounds.
  118769. */
  118770. mainSoundTrack: SoundTrack;
  118771. /**
  118772. * The list of sound tracks added to the scene
  118773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118774. */
  118775. soundTracks: Nullable<Array<SoundTrack>>;
  118776. /**
  118777. * Gets a sound using a given name
  118778. * @param name defines the name to search for
  118779. * @return the found sound or null if not found at all.
  118780. */
  118781. getSoundByName(name: string): Nullable<Sound>;
  118782. /**
  118783. * Gets or sets if audio support is enabled
  118784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118785. */
  118786. audioEnabled: boolean;
  118787. /**
  118788. * Gets or sets if audio will be output to headphones
  118789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118790. */
  118791. headphone: boolean;
  118792. /**
  118793. * Gets or sets custom audio listener position provider
  118794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118795. */
  118796. audioListenerPositionProvider: Nullable<() => Vector3>;
  118797. /**
  118798. * Gets or sets a refresh rate when using 3D audio positioning
  118799. */
  118800. audioPositioningRefreshRate: number;
  118801. }
  118802. /**
  118803. * Defines the sound scene component responsible to manage any sounds
  118804. * in a given scene.
  118805. */
  118806. export class AudioSceneComponent implements ISceneSerializableComponent {
  118807. /**
  118808. * The component name helpfull to identify the component in the list of scene components.
  118809. */
  118810. readonly name: string;
  118811. /**
  118812. * The scene the component belongs to.
  118813. */
  118814. scene: Scene;
  118815. private _audioEnabled;
  118816. /**
  118817. * Gets whether audio is enabled or not.
  118818. * Please use related enable/disable method to switch state.
  118819. */
  118820. get audioEnabled(): boolean;
  118821. private _headphone;
  118822. /**
  118823. * Gets whether audio is outputing to headphone or not.
  118824. * Please use the according Switch methods to change output.
  118825. */
  118826. get headphone(): boolean;
  118827. /**
  118828. * Gets or sets a refresh rate when using 3D audio positioning
  118829. */
  118830. audioPositioningRefreshRate: number;
  118831. private _audioListenerPositionProvider;
  118832. /**
  118833. * Gets the current audio listener position provider
  118834. */
  118835. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  118836. /**
  118837. * Sets a custom listener position for all sounds in the scene
  118838. * By default, this is the position of the first active camera
  118839. */
  118840. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  118841. /**
  118842. * Creates a new instance of the component for the given scene
  118843. * @param scene Defines the scene to register the component in
  118844. */
  118845. constructor(scene: Scene);
  118846. /**
  118847. * Registers the component in a given scene
  118848. */
  118849. register(): void;
  118850. /**
  118851. * Rebuilds the elements related to this component in case of
  118852. * context lost for instance.
  118853. */
  118854. rebuild(): void;
  118855. /**
  118856. * Serializes the component data to the specified json object
  118857. * @param serializationObject The object to serialize to
  118858. */
  118859. serialize(serializationObject: any): void;
  118860. /**
  118861. * Adds all the elements from the container to the scene
  118862. * @param container the container holding the elements
  118863. */
  118864. addFromContainer(container: AbstractScene): void;
  118865. /**
  118866. * Removes all the elements in the container from the scene
  118867. * @param container contains the elements to remove
  118868. * @param dispose if the removed element should be disposed (default: false)
  118869. */
  118870. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118871. /**
  118872. * Disposes the component and the associated ressources.
  118873. */
  118874. dispose(): void;
  118875. /**
  118876. * Disables audio in the associated scene.
  118877. */
  118878. disableAudio(): void;
  118879. /**
  118880. * Enables audio in the associated scene.
  118881. */
  118882. enableAudio(): void;
  118883. /**
  118884. * Switch audio to headphone output.
  118885. */
  118886. switchAudioModeForHeadphones(): void;
  118887. /**
  118888. * Switch audio to normal speakers.
  118889. */
  118890. switchAudioModeForNormalSpeakers(): void;
  118891. private _cachedCameraDirection;
  118892. private _cachedCameraPosition;
  118893. private _lastCheck;
  118894. private _afterRender;
  118895. }
  118896. }
  118897. declare module BABYLON {
  118898. /**
  118899. * Wraps one or more Sound objects and selects one with random weight for playback.
  118900. */
  118901. export class WeightedSound {
  118902. /** When true a Sound will be selected and played when the current playing Sound completes. */
  118903. loop: boolean;
  118904. private _coneInnerAngle;
  118905. private _coneOuterAngle;
  118906. private _volume;
  118907. /** A Sound is currently playing. */
  118908. isPlaying: boolean;
  118909. /** A Sound is currently paused. */
  118910. isPaused: boolean;
  118911. private _sounds;
  118912. private _weights;
  118913. private _currentIndex?;
  118914. /**
  118915. * Creates a new WeightedSound from the list of sounds given.
  118916. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  118917. * @param sounds Array of Sounds that will be selected from.
  118918. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  118919. */
  118920. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  118921. /**
  118922. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  118923. */
  118924. get directionalConeInnerAngle(): number;
  118925. /**
  118926. * The size of cone in degress for a directional sound in which there will be no attenuation.
  118927. */
  118928. set directionalConeInnerAngle(value: number);
  118929. /**
  118930. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118931. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118932. */
  118933. get directionalConeOuterAngle(): number;
  118934. /**
  118935. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118936. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118937. */
  118938. set directionalConeOuterAngle(value: number);
  118939. /**
  118940. * Playback volume.
  118941. */
  118942. get volume(): number;
  118943. /**
  118944. * Playback volume.
  118945. */
  118946. set volume(value: number);
  118947. private _onended;
  118948. /**
  118949. * Suspend playback
  118950. */
  118951. pause(): void;
  118952. /**
  118953. * Stop playback
  118954. */
  118955. stop(): void;
  118956. /**
  118957. * Start playback.
  118958. * @param startOffset Position the clip head at a specific time in seconds.
  118959. */
  118960. play(startOffset?: number): void;
  118961. }
  118962. }
  118963. declare module BABYLON {
  118964. /**
  118965. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  118966. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118967. */
  118968. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  118969. /**
  118970. * Gets the name of the behavior.
  118971. */
  118972. get name(): string;
  118973. /**
  118974. * The easing function used by animations
  118975. */
  118976. static EasingFunction: BackEase;
  118977. /**
  118978. * The easing mode used by animations
  118979. */
  118980. static EasingMode: number;
  118981. /**
  118982. * The duration of the animation, in milliseconds
  118983. */
  118984. transitionDuration: number;
  118985. /**
  118986. * Length of the distance animated by the transition when lower radius is reached
  118987. */
  118988. lowerRadiusTransitionRange: number;
  118989. /**
  118990. * Length of the distance animated by the transition when upper radius is reached
  118991. */
  118992. upperRadiusTransitionRange: number;
  118993. private _autoTransitionRange;
  118994. /**
  118995. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118996. */
  118997. get autoTransitionRange(): boolean;
  118998. /**
  118999. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119000. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  119001. */
  119002. set autoTransitionRange(value: boolean);
  119003. private _attachedCamera;
  119004. private _onAfterCheckInputsObserver;
  119005. private _onMeshTargetChangedObserver;
  119006. /**
  119007. * Initializes the behavior.
  119008. */
  119009. init(): void;
  119010. /**
  119011. * Attaches the behavior to its arc rotate camera.
  119012. * @param camera Defines the camera to attach the behavior to
  119013. */
  119014. attach(camera: ArcRotateCamera): void;
  119015. /**
  119016. * Detaches the behavior from its current arc rotate camera.
  119017. */
  119018. detach(): void;
  119019. private _radiusIsAnimating;
  119020. private _radiusBounceTransition;
  119021. private _animatables;
  119022. private _cachedWheelPrecision;
  119023. /**
  119024. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  119025. * @param radiusLimit The limit to check against.
  119026. * @return Bool to indicate if at limit.
  119027. */
  119028. private _isRadiusAtLimit;
  119029. /**
  119030. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  119031. * @param radiusDelta The delta by which to animate to. Can be negative.
  119032. */
  119033. private _applyBoundRadiusAnimation;
  119034. /**
  119035. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  119036. */
  119037. protected _clearAnimationLocks(): void;
  119038. /**
  119039. * Stops and removes all animations that have been applied to the camera
  119040. */
  119041. stopAllAnimations(): void;
  119042. }
  119043. }
  119044. declare module BABYLON {
  119045. /**
  119046. * 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.
  119047. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119048. */
  119049. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  119050. /**
  119051. * Gets the name of the behavior.
  119052. */
  119053. get name(): string;
  119054. private _mode;
  119055. private _radiusScale;
  119056. private _positionScale;
  119057. private _defaultElevation;
  119058. private _elevationReturnTime;
  119059. private _elevationReturnWaitTime;
  119060. private _zoomStopsAnimation;
  119061. private _framingTime;
  119062. /**
  119063. * The easing function used by animations
  119064. */
  119065. static EasingFunction: ExponentialEase;
  119066. /**
  119067. * The easing mode used by animations
  119068. */
  119069. static EasingMode: number;
  119070. /**
  119071. * Sets the current mode used by the behavior
  119072. */
  119073. set mode(mode: number);
  119074. /**
  119075. * Gets current mode used by the behavior.
  119076. */
  119077. get mode(): number;
  119078. /**
  119079. * Sets the scale applied to the radius (1 by default)
  119080. */
  119081. set radiusScale(radius: number);
  119082. /**
  119083. * Gets the scale applied to the radius
  119084. */
  119085. get radiusScale(): number;
  119086. /**
  119087. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119088. */
  119089. set positionScale(scale: number);
  119090. /**
  119091. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119092. */
  119093. get positionScale(): number;
  119094. /**
  119095. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119096. * behaviour is triggered, in radians.
  119097. */
  119098. set defaultElevation(elevation: number);
  119099. /**
  119100. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119101. * behaviour is triggered, in radians.
  119102. */
  119103. get defaultElevation(): number;
  119104. /**
  119105. * Sets the time (in milliseconds) taken to return to the default beta position.
  119106. * Negative value indicates camera should not return to default.
  119107. */
  119108. set elevationReturnTime(speed: number);
  119109. /**
  119110. * Gets the time (in milliseconds) taken to return to the default beta position.
  119111. * Negative value indicates camera should not return to default.
  119112. */
  119113. get elevationReturnTime(): number;
  119114. /**
  119115. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119116. */
  119117. set elevationReturnWaitTime(time: number);
  119118. /**
  119119. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119120. */
  119121. get elevationReturnWaitTime(): number;
  119122. /**
  119123. * Sets the flag that indicates if user zooming should stop animation.
  119124. */
  119125. set zoomStopsAnimation(flag: boolean);
  119126. /**
  119127. * Gets the flag that indicates if user zooming should stop animation.
  119128. */
  119129. get zoomStopsAnimation(): boolean;
  119130. /**
  119131. * Sets the transition time when framing the mesh, in milliseconds
  119132. */
  119133. set framingTime(time: number);
  119134. /**
  119135. * Gets the transition time when framing the mesh, in milliseconds
  119136. */
  119137. get framingTime(): number;
  119138. /**
  119139. * Define if the behavior should automatically change the configured
  119140. * camera limits and sensibilities.
  119141. */
  119142. autoCorrectCameraLimitsAndSensibility: boolean;
  119143. private _onPrePointerObservableObserver;
  119144. private _onAfterCheckInputsObserver;
  119145. private _onMeshTargetChangedObserver;
  119146. private _attachedCamera;
  119147. private _isPointerDown;
  119148. private _lastInteractionTime;
  119149. /**
  119150. * Initializes the behavior.
  119151. */
  119152. init(): void;
  119153. /**
  119154. * Attaches the behavior to its arc rotate camera.
  119155. * @param camera Defines the camera to attach the behavior to
  119156. */
  119157. attach(camera: ArcRotateCamera): void;
  119158. /**
  119159. * Detaches the behavior from its current arc rotate camera.
  119160. */
  119161. detach(): void;
  119162. private _animatables;
  119163. private _betaIsAnimating;
  119164. private _betaTransition;
  119165. private _radiusTransition;
  119166. private _vectorTransition;
  119167. /**
  119168. * Targets the given mesh and updates zoom level accordingly.
  119169. * @param mesh The mesh to target.
  119170. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119171. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119172. */
  119173. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119174. /**
  119175. * Targets the given mesh with its children and updates zoom level accordingly.
  119176. * @param mesh The mesh to target.
  119177. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119178. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119179. */
  119180. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119181. /**
  119182. * Targets the given meshes with their children and updates zoom level accordingly.
  119183. * @param meshes The mesh to target.
  119184. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119185. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119186. */
  119187. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119188. /**
  119189. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119190. * @param minimumWorld Determines the smaller position of the bounding box extend
  119191. * @param maximumWorld Determines the bigger position of the bounding box extend
  119192. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119193. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119194. */
  119195. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119196. /**
  119197. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  119198. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  119199. * frustum width.
  119200. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  119201. * to fully enclose the mesh in the viewing frustum.
  119202. */
  119203. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  119204. /**
  119205. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  119206. * is automatically returned to its default position (expected to be above ground plane).
  119207. */
  119208. private _maintainCameraAboveGround;
  119209. /**
  119210. * Returns the frustum slope based on the canvas ratio and camera FOV
  119211. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  119212. */
  119213. private _getFrustumSlope;
  119214. /**
  119215. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  119216. */
  119217. private _clearAnimationLocks;
  119218. /**
  119219. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119220. */
  119221. private _applyUserInteraction;
  119222. /**
  119223. * Stops and removes all animations that have been applied to the camera
  119224. */
  119225. stopAllAnimations(): void;
  119226. /**
  119227. * Gets a value indicating if the user is moving the camera
  119228. */
  119229. get isUserIsMoving(): boolean;
  119230. /**
  119231. * The camera can move all the way towards the mesh.
  119232. */
  119233. static IgnoreBoundsSizeMode: number;
  119234. /**
  119235. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  119236. */
  119237. static FitFrustumSidesMode: number;
  119238. }
  119239. }
  119240. declare module BABYLON {
  119241. /**
  119242. * Base class for Camera Pointer Inputs.
  119243. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  119244. * for example usage.
  119245. */
  119246. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  119247. /**
  119248. * Defines the camera the input is attached to.
  119249. */
  119250. abstract camera: Camera;
  119251. /**
  119252. * Whether keyboard modifier keys are pressed at time of last mouse event.
  119253. */
  119254. protected _altKey: boolean;
  119255. protected _ctrlKey: boolean;
  119256. protected _metaKey: boolean;
  119257. protected _shiftKey: boolean;
  119258. /**
  119259. * Which mouse buttons were pressed at time of last mouse event.
  119260. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  119261. */
  119262. protected _buttonsPressed: number;
  119263. /**
  119264. * Defines the buttons associated with the input to handle camera move.
  119265. */
  119266. buttons: number[];
  119267. /**
  119268. * Attach the input controls to a specific dom element to get the input from.
  119269. * @param element Defines the element the controls should be listened from
  119270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119271. */
  119272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119273. /**
  119274. * Detach the current controls from the specified dom element.
  119275. * @param element Defines the element to stop listening the inputs from
  119276. */
  119277. detachControl(element: Nullable<HTMLElement>): void;
  119278. /**
  119279. * Gets the class name of the current input.
  119280. * @returns the class name
  119281. */
  119282. getClassName(): string;
  119283. /**
  119284. * Get the friendly name associated with the input class.
  119285. * @returns the input friendly name
  119286. */
  119287. getSimpleName(): string;
  119288. /**
  119289. * Called on pointer POINTERDOUBLETAP event.
  119290. * Override this method to provide functionality on POINTERDOUBLETAP event.
  119291. */
  119292. protected onDoubleTap(type: string): void;
  119293. /**
  119294. * Called on pointer POINTERMOVE event if only a single touch is active.
  119295. * Override this method to provide functionality.
  119296. */
  119297. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119298. /**
  119299. * Called on pointer POINTERMOVE event if multiple touches are active.
  119300. * Override this method to provide functionality.
  119301. */
  119302. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119303. /**
  119304. * Called on JS contextmenu event.
  119305. * Override this method to provide functionality.
  119306. */
  119307. protected onContextMenu(evt: PointerEvent): void;
  119308. /**
  119309. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119310. * press.
  119311. * Override this method to provide functionality.
  119312. */
  119313. protected onButtonDown(evt: PointerEvent): void;
  119314. /**
  119315. * Called each time a new POINTERUP event occurs. Ie, for each button
  119316. * release.
  119317. * Override this method to provide functionality.
  119318. */
  119319. protected onButtonUp(evt: PointerEvent): void;
  119320. /**
  119321. * Called when window becomes inactive.
  119322. * Override this method to provide functionality.
  119323. */
  119324. protected onLostFocus(): void;
  119325. private _pointerInput;
  119326. private _observer;
  119327. private _onLostFocus;
  119328. private pointA;
  119329. private pointB;
  119330. }
  119331. }
  119332. declare module BABYLON {
  119333. /**
  119334. * Manage the pointers inputs to control an arc rotate camera.
  119335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119336. */
  119337. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  119338. /**
  119339. * Defines the camera the input is attached to.
  119340. */
  119341. camera: ArcRotateCamera;
  119342. /**
  119343. * Gets the class name of the current input.
  119344. * @returns the class name
  119345. */
  119346. getClassName(): string;
  119347. /**
  119348. * Defines the buttons associated with the input to handle camera move.
  119349. */
  119350. buttons: number[];
  119351. /**
  119352. * Defines the pointer angular sensibility along the X axis or how fast is
  119353. * the camera rotating.
  119354. */
  119355. angularSensibilityX: number;
  119356. /**
  119357. * Defines the pointer angular sensibility along the Y axis or how fast is
  119358. * the camera rotating.
  119359. */
  119360. angularSensibilityY: number;
  119361. /**
  119362. * Defines the pointer pinch precision or how fast is the camera zooming.
  119363. */
  119364. pinchPrecision: number;
  119365. /**
  119366. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  119367. * from 0.
  119368. * It defines the percentage of current camera.radius to use as delta when
  119369. * pinch zoom is used.
  119370. */
  119371. pinchDeltaPercentage: number;
  119372. /**
  119373. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119374. * that any object in the plane at the camera's target point will scale
  119375. * perfectly with finger motion.
  119376. * Overrides pinchDeltaPercentage and pinchPrecision.
  119377. */
  119378. useNaturalPinchZoom: boolean;
  119379. /**
  119380. * Defines the pointer panning sensibility or how fast is the camera moving.
  119381. */
  119382. panningSensibility: number;
  119383. /**
  119384. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  119385. */
  119386. multiTouchPanning: boolean;
  119387. /**
  119388. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  119389. * zoom (pinch) through multitouch.
  119390. */
  119391. multiTouchPanAndZoom: boolean;
  119392. /**
  119393. * Revers pinch action direction.
  119394. */
  119395. pinchInwards: boolean;
  119396. private _isPanClick;
  119397. private _twoFingerActivityCount;
  119398. private _isPinching;
  119399. /**
  119400. * Called on pointer POINTERMOVE event if only a single touch is active.
  119401. */
  119402. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119403. /**
  119404. * Called on pointer POINTERDOUBLETAP event.
  119405. */
  119406. protected onDoubleTap(type: string): void;
  119407. /**
  119408. * Called on pointer POINTERMOVE event if multiple touches are active.
  119409. */
  119410. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119411. /**
  119412. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119413. * press.
  119414. */
  119415. protected onButtonDown(evt: PointerEvent): void;
  119416. /**
  119417. * Called each time a new POINTERUP event occurs. Ie, for each button
  119418. * release.
  119419. */
  119420. protected onButtonUp(evt: PointerEvent): void;
  119421. /**
  119422. * Called when window becomes inactive.
  119423. */
  119424. protected onLostFocus(): void;
  119425. }
  119426. }
  119427. declare module BABYLON {
  119428. /**
  119429. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  119430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119431. */
  119432. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  119433. /**
  119434. * Defines the camera the input is attached to.
  119435. */
  119436. camera: ArcRotateCamera;
  119437. /**
  119438. * Defines the list of key codes associated with the up action (increase alpha)
  119439. */
  119440. keysUp: number[];
  119441. /**
  119442. * Defines the list of key codes associated with the down action (decrease alpha)
  119443. */
  119444. keysDown: number[];
  119445. /**
  119446. * Defines the list of key codes associated with the left action (increase beta)
  119447. */
  119448. keysLeft: number[];
  119449. /**
  119450. * Defines the list of key codes associated with the right action (decrease beta)
  119451. */
  119452. keysRight: number[];
  119453. /**
  119454. * Defines the list of key codes associated with the reset action.
  119455. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  119456. */
  119457. keysReset: number[];
  119458. /**
  119459. * Defines the panning sensibility of the inputs.
  119460. * (How fast is the camera panning)
  119461. */
  119462. panningSensibility: number;
  119463. /**
  119464. * Defines the zooming sensibility of the inputs.
  119465. * (How fast is the camera zooming)
  119466. */
  119467. zoomingSensibility: number;
  119468. /**
  119469. * Defines whether maintaining the alt key down switch the movement mode from
  119470. * orientation to zoom.
  119471. */
  119472. useAltToZoom: boolean;
  119473. /**
  119474. * Rotation speed of the camera
  119475. */
  119476. angularSpeed: number;
  119477. private _keys;
  119478. private _ctrlPressed;
  119479. private _altPressed;
  119480. private _onCanvasBlurObserver;
  119481. private _onKeyboardObserver;
  119482. private _engine;
  119483. private _scene;
  119484. /**
  119485. * Attach the input controls to a specific dom element to get the input from.
  119486. * @param element Defines the element the controls should be listened from
  119487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119488. */
  119489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119490. /**
  119491. * Detach the current controls from the specified dom element.
  119492. * @param element Defines the element to stop listening the inputs from
  119493. */
  119494. detachControl(element: Nullable<HTMLElement>): void;
  119495. /**
  119496. * Update the current camera state depending on the inputs that have been used this frame.
  119497. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119498. */
  119499. checkInputs(): void;
  119500. /**
  119501. * Gets the class name of the current intput.
  119502. * @returns the class name
  119503. */
  119504. getClassName(): string;
  119505. /**
  119506. * Get the friendly name associated with the input class.
  119507. * @returns the input friendly name
  119508. */
  119509. getSimpleName(): string;
  119510. }
  119511. }
  119512. declare module BABYLON {
  119513. /**
  119514. * Manage the mouse wheel inputs to control an arc rotate camera.
  119515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119516. */
  119517. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  119518. /**
  119519. * Defines the camera the input is attached to.
  119520. */
  119521. camera: ArcRotateCamera;
  119522. /**
  119523. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119524. */
  119525. wheelPrecision: number;
  119526. /**
  119527. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  119528. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  119529. */
  119530. wheelDeltaPercentage: number;
  119531. private _wheel;
  119532. private _observer;
  119533. private computeDeltaFromMouseWheelLegacyEvent;
  119534. /**
  119535. * Attach the input controls to a specific dom element to get the input from.
  119536. * @param element Defines the element the controls should be listened from
  119537. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119538. */
  119539. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119540. /**
  119541. * Detach the current controls from the specified dom element.
  119542. * @param element Defines the element to stop listening the inputs from
  119543. */
  119544. detachControl(element: Nullable<HTMLElement>): void;
  119545. /**
  119546. * Gets the class name of the current intput.
  119547. * @returns the class name
  119548. */
  119549. getClassName(): string;
  119550. /**
  119551. * Get the friendly name associated with the input class.
  119552. * @returns the input friendly name
  119553. */
  119554. getSimpleName(): string;
  119555. }
  119556. }
  119557. declare module BABYLON {
  119558. /**
  119559. * Default Inputs manager for the ArcRotateCamera.
  119560. * It groups all the default supported inputs for ease of use.
  119561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119562. */
  119563. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  119564. /**
  119565. * Instantiates a new ArcRotateCameraInputsManager.
  119566. * @param camera Defines the camera the inputs belong to
  119567. */
  119568. constructor(camera: ArcRotateCamera);
  119569. /**
  119570. * Add mouse wheel input support to the input manager.
  119571. * @returns the current input manager
  119572. */
  119573. addMouseWheel(): ArcRotateCameraInputsManager;
  119574. /**
  119575. * Add pointers input support to the input manager.
  119576. * @returns the current input manager
  119577. */
  119578. addPointers(): ArcRotateCameraInputsManager;
  119579. /**
  119580. * Add keyboard input support to the input manager.
  119581. * @returns the current input manager
  119582. */
  119583. addKeyboard(): ArcRotateCameraInputsManager;
  119584. }
  119585. }
  119586. declare module BABYLON {
  119587. /**
  119588. * This represents an orbital type of camera.
  119589. *
  119590. * 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.
  119591. * 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.
  119592. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  119593. */
  119594. export class ArcRotateCamera extends TargetCamera {
  119595. /**
  119596. * Defines the rotation angle of the camera along the longitudinal axis.
  119597. */
  119598. alpha: number;
  119599. /**
  119600. * Defines the rotation angle of the camera along the latitudinal axis.
  119601. */
  119602. beta: number;
  119603. /**
  119604. * Defines the radius of the camera from it s target point.
  119605. */
  119606. radius: number;
  119607. protected _target: Vector3;
  119608. protected _targetHost: Nullable<AbstractMesh>;
  119609. /**
  119610. * Defines the target point of the camera.
  119611. * The camera looks towards it form the radius distance.
  119612. */
  119613. get target(): Vector3;
  119614. set target(value: Vector3);
  119615. /**
  119616. * Define the current local position of the camera in the scene
  119617. */
  119618. get position(): Vector3;
  119619. set position(newPosition: Vector3);
  119620. protected _upVector: Vector3;
  119621. protected _upToYMatrix: Matrix;
  119622. protected _YToUpMatrix: Matrix;
  119623. /**
  119624. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  119625. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  119626. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  119627. */
  119628. set upVector(vec: Vector3);
  119629. get upVector(): Vector3;
  119630. /**
  119631. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  119632. */
  119633. setMatUp(): void;
  119634. /**
  119635. * Current inertia value on the longitudinal axis.
  119636. * The bigger this number the longer it will take for the camera to stop.
  119637. */
  119638. inertialAlphaOffset: number;
  119639. /**
  119640. * Current inertia value on the latitudinal axis.
  119641. * The bigger this number the longer it will take for the camera to stop.
  119642. */
  119643. inertialBetaOffset: number;
  119644. /**
  119645. * Current inertia value on the radius axis.
  119646. * The bigger this number the longer it will take for the camera to stop.
  119647. */
  119648. inertialRadiusOffset: number;
  119649. /**
  119650. * Minimum allowed angle on the longitudinal axis.
  119651. * This can help limiting how the Camera is able to move in the scene.
  119652. */
  119653. lowerAlphaLimit: Nullable<number>;
  119654. /**
  119655. * Maximum allowed angle on the longitudinal axis.
  119656. * This can help limiting how the Camera is able to move in the scene.
  119657. */
  119658. upperAlphaLimit: Nullable<number>;
  119659. /**
  119660. * Minimum allowed angle on the latitudinal axis.
  119661. * This can help limiting how the Camera is able to move in the scene.
  119662. */
  119663. lowerBetaLimit: number;
  119664. /**
  119665. * Maximum allowed angle on the latitudinal axis.
  119666. * This can help limiting how the Camera is able to move in the scene.
  119667. */
  119668. upperBetaLimit: number;
  119669. /**
  119670. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  119671. * This can help limiting how the Camera is able to move in the scene.
  119672. */
  119673. lowerRadiusLimit: Nullable<number>;
  119674. /**
  119675. * Maximum allowed distance of the camera to the target (The camera can not get further).
  119676. * This can help limiting how the Camera is able to move in the scene.
  119677. */
  119678. upperRadiusLimit: Nullable<number>;
  119679. /**
  119680. * Defines the current inertia value used during panning of the camera along the X axis.
  119681. */
  119682. inertialPanningX: number;
  119683. /**
  119684. * Defines the current inertia value used during panning of the camera along the Y axis.
  119685. */
  119686. inertialPanningY: number;
  119687. /**
  119688. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  119689. * Basically if your fingers moves away from more than this distance you will be considered
  119690. * in pinch mode.
  119691. */
  119692. pinchToPanMaxDistance: number;
  119693. /**
  119694. * Defines the maximum distance the camera can pan.
  119695. * This could help keeping the cammera always in your scene.
  119696. */
  119697. panningDistanceLimit: Nullable<number>;
  119698. /**
  119699. * Defines the target of the camera before paning.
  119700. */
  119701. panningOriginTarget: Vector3;
  119702. /**
  119703. * Defines the value of the inertia used during panning.
  119704. * 0 would mean stop inertia and one would mean no decelleration at all.
  119705. */
  119706. panningInertia: number;
  119707. /**
  119708. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  119709. */
  119710. get angularSensibilityX(): number;
  119711. set angularSensibilityX(value: number);
  119712. /**
  119713. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  119714. */
  119715. get angularSensibilityY(): number;
  119716. set angularSensibilityY(value: number);
  119717. /**
  119718. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  119719. */
  119720. get pinchPrecision(): number;
  119721. set pinchPrecision(value: number);
  119722. /**
  119723. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  119724. * It will be used instead of pinchDeltaPrecision if different from 0.
  119725. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119726. */
  119727. get pinchDeltaPercentage(): number;
  119728. set pinchDeltaPercentage(value: number);
  119729. /**
  119730. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  119731. * and pinch delta percentage.
  119732. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119733. * that any object in the plane at the camera's target point will scale
  119734. * perfectly with finger motion.
  119735. */
  119736. get useNaturalPinchZoom(): boolean;
  119737. set useNaturalPinchZoom(value: boolean);
  119738. /**
  119739. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  119740. */
  119741. get panningSensibility(): number;
  119742. set panningSensibility(value: number);
  119743. /**
  119744. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  119745. */
  119746. get keysUp(): number[];
  119747. set keysUp(value: number[]);
  119748. /**
  119749. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  119750. */
  119751. get keysDown(): number[];
  119752. set keysDown(value: number[]);
  119753. /**
  119754. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  119755. */
  119756. get keysLeft(): number[];
  119757. set keysLeft(value: number[]);
  119758. /**
  119759. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  119760. */
  119761. get keysRight(): number[];
  119762. set keysRight(value: number[]);
  119763. /**
  119764. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119765. */
  119766. get wheelPrecision(): number;
  119767. set wheelPrecision(value: number);
  119768. /**
  119769. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  119770. * It will be used instead of pinchDeltaPrecision if different from 0.
  119771. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119772. */
  119773. get wheelDeltaPercentage(): number;
  119774. set wheelDeltaPercentage(value: number);
  119775. /**
  119776. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  119777. */
  119778. zoomOnFactor: number;
  119779. /**
  119780. * Defines a screen offset for the camera position.
  119781. */
  119782. targetScreenOffset: Vector2;
  119783. /**
  119784. * Allows the camera to be completely reversed.
  119785. * If false the camera can not arrive upside down.
  119786. */
  119787. allowUpsideDown: boolean;
  119788. /**
  119789. * Define if double tap/click is used to restore the previously saved state of the camera.
  119790. */
  119791. useInputToRestoreState: boolean;
  119792. /** @hidden */
  119793. _viewMatrix: Matrix;
  119794. /** @hidden */
  119795. _useCtrlForPanning: boolean;
  119796. /** @hidden */
  119797. _panningMouseButton: number;
  119798. /**
  119799. * Defines the input associated to the camera.
  119800. */
  119801. inputs: ArcRotateCameraInputsManager;
  119802. /** @hidden */
  119803. _reset: () => void;
  119804. /**
  119805. * Defines the allowed panning axis.
  119806. */
  119807. panningAxis: Vector3;
  119808. protected _localDirection: Vector3;
  119809. protected _transformedDirection: Vector3;
  119810. private _bouncingBehavior;
  119811. /**
  119812. * Gets the bouncing behavior of the camera if it has been enabled.
  119813. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119814. */
  119815. get bouncingBehavior(): Nullable<BouncingBehavior>;
  119816. /**
  119817. * Defines if the bouncing behavior of the camera is enabled on the camera.
  119818. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119819. */
  119820. get useBouncingBehavior(): boolean;
  119821. set useBouncingBehavior(value: boolean);
  119822. private _framingBehavior;
  119823. /**
  119824. * Gets the framing behavior of the camera if it has been enabled.
  119825. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119826. */
  119827. get framingBehavior(): Nullable<FramingBehavior>;
  119828. /**
  119829. * Defines if the framing behavior of the camera is enabled on the camera.
  119830. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119831. */
  119832. get useFramingBehavior(): boolean;
  119833. set useFramingBehavior(value: boolean);
  119834. private _autoRotationBehavior;
  119835. /**
  119836. * Gets the auto rotation behavior of the camera if it has been enabled.
  119837. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119838. */
  119839. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  119840. /**
  119841. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  119842. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119843. */
  119844. get useAutoRotationBehavior(): boolean;
  119845. set useAutoRotationBehavior(value: boolean);
  119846. /**
  119847. * Observable triggered when the mesh target has been changed on the camera.
  119848. */
  119849. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  119850. /**
  119851. * Event raised when the camera is colliding with a mesh.
  119852. */
  119853. onCollide: (collidedMesh: AbstractMesh) => void;
  119854. /**
  119855. * Defines whether the camera should check collision with the objects oh the scene.
  119856. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  119857. */
  119858. checkCollisions: boolean;
  119859. /**
  119860. * Defines the collision radius of the camera.
  119861. * This simulates a sphere around the camera.
  119862. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119863. */
  119864. collisionRadius: Vector3;
  119865. protected _collider: Collider;
  119866. protected _previousPosition: Vector3;
  119867. protected _collisionVelocity: Vector3;
  119868. protected _newPosition: Vector3;
  119869. protected _previousAlpha: number;
  119870. protected _previousBeta: number;
  119871. protected _previousRadius: number;
  119872. protected _collisionTriggered: boolean;
  119873. protected _targetBoundingCenter: Nullable<Vector3>;
  119874. private _computationVector;
  119875. /**
  119876. * Instantiates a new ArcRotateCamera in a given scene
  119877. * @param name Defines the name of the camera
  119878. * @param alpha Defines the camera rotation along the logitudinal axis
  119879. * @param beta Defines the camera rotation along the latitudinal axis
  119880. * @param radius Defines the camera distance from its target
  119881. * @param target Defines the camera target
  119882. * @param scene Defines the scene the camera belongs to
  119883. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  119884. */
  119885. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  119886. /** @hidden */
  119887. _initCache(): void;
  119888. /** @hidden */
  119889. _updateCache(ignoreParentClass?: boolean): void;
  119890. protected _getTargetPosition(): Vector3;
  119891. private _storedAlpha;
  119892. private _storedBeta;
  119893. private _storedRadius;
  119894. private _storedTarget;
  119895. private _storedTargetScreenOffset;
  119896. /**
  119897. * Stores the current state of the camera (alpha, beta, radius and target)
  119898. * @returns the camera itself
  119899. */
  119900. storeState(): Camera;
  119901. /**
  119902. * @hidden
  119903. * Restored camera state. You must call storeState() first
  119904. */
  119905. _restoreStateValues(): boolean;
  119906. /** @hidden */
  119907. _isSynchronizedViewMatrix(): boolean;
  119908. /**
  119909. * Attached controls to the current camera.
  119910. * @param element Defines the element the controls should be listened from
  119911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119912. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  119913. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  119914. */
  119915. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  119916. /**
  119917. * Detach the current controls from the camera.
  119918. * The camera will stop reacting to inputs.
  119919. * @param element Defines the element to stop listening the inputs from
  119920. */
  119921. detachControl(element: HTMLElement): void;
  119922. /** @hidden */
  119923. _checkInputs(): void;
  119924. protected _checkLimits(): void;
  119925. /**
  119926. * Rebuilds angles (alpha, beta) and radius from the give position and target
  119927. */
  119928. rebuildAnglesAndRadius(): void;
  119929. /**
  119930. * Use a position to define the current camera related information like alpha, beta and radius
  119931. * @param position Defines the position to set the camera at
  119932. */
  119933. setPosition(position: Vector3): void;
  119934. /**
  119935. * Defines the target the camera should look at.
  119936. * This will automatically adapt alpha beta and radius to fit within the new target.
  119937. * @param target Defines the new target as a Vector or a mesh
  119938. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  119939. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  119940. */
  119941. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  119942. /** @hidden */
  119943. _getViewMatrix(): Matrix;
  119944. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  119945. /**
  119946. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  119947. * @param meshes Defines the mesh to zoom on
  119948. * @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)
  119949. */
  119950. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  119951. /**
  119952. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  119953. * The target will be changed but the radius
  119954. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  119955. * @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)
  119956. */
  119957. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  119958. min: Vector3;
  119959. max: Vector3;
  119960. distance: number;
  119961. }, doNotUpdateMaxZ?: boolean): void;
  119962. /**
  119963. * @override
  119964. * Override Camera.createRigCamera
  119965. */
  119966. createRigCamera(name: string, cameraIndex: number): Camera;
  119967. /**
  119968. * @hidden
  119969. * @override
  119970. * Override Camera._updateRigCameras
  119971. */
  119972. _updateRigCameras(): void;
  119973. /**
  119974. * Destroy the camera and release the current resources hold by it.
  119975. */
  119976. dispose(): void;
  119977. /**
  119978. * Gets the current object class name.
  119979. * @return the class name
  119980. */
  119981. getClassName(): string;
  119982. }
  119983. }
  119984. declare module BABYLON {
  119985. /**
  119986. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  119987. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119988. */
  119989. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  119990. /**
  119991. * Gets the name of the behavior.
  119992. */
  119993. get name(): string;
  119994. private _zoomStopsAnimation;
  119995. private _idleRotationSpeed;
  119996. private _idleRotationWaitTime;
  119997. private _idleRotationSpinupTime;
  119998. /**
  119999. * Sets the flag that indicates if user zooming should stop animation.
  120000. */
  120001. set zoomStopsAnimation(flag: boolean);
  120002. /**
  120003. * Gets the flag that indicates if user zooming should stop animation.
  120004. */
  120005. get zoomStopsAnimation(): boolean;
  120006. /**
  120007. * Sets the default speed at which the camera rotates around the model.
  120008. */
  120009. set idleRotationSpeed(speed: number);
  120010. /**
  120011. * Gets the default speed at which the camera rotates around the model.
  120012. */
  120013. get idleRotationSpeed(): number;
  120014. /**
  120015. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  120016. */
  120017. set idleRotationWaitTime(time: number);
  120018. /**
  120019. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  120020. */
  120021. get idleRotationWaitTime(): number;
  120022. /**
  120023. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120024. */
  120025. set idleRotationSpinupTime(time: number);
  120026. /**
  120027. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120028. */
  120029. get idleRotationSpinupTime(): number;
  120030. /**
  120031. * Gets a value indicating if the camera is currently rotating because of this behavior
  120032. */
  120033. get rotationInProgress(): boolean;
  120034. private _onPrePointerObservableObserver;
  120035. private _onAfterCheckInputsObserver;
  120036. private _attachedCamera;
  120037. private _isPointerDown;
  120038. private _lastFrameTime;
  120039. private _lastInteractionTime;
  120040. private _cameraRotationSpeed;
  120041. /**
  120042. * Initializes the behavior.
  120043. */
  120044. init(): void;
  120045. /**
  120046. * Attaches the behavior to its arc rotate camera.
  120047. * @param camera Defines the camera to attach the behavior to
  120048. */
  120049. attach(camera: ArcRotateCamera): void;
  120050. /**
  120051. * Detaches the behavior from its current arc rotate camera.
  120052. */
  120053. detach(): void;
  120054. /**
  120055. * Returns true if user is scrolling.
  120056. * @return true if user is scrolling.
  120057. */
  120058. private _userIsZooming;
  120059. private _lastFrameRadius;
  120060. private _shouldAnimationStopForInteraction;
  120061. /**
  120062. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120063. */
  120064. private _applyUserInteraction;
  120065. private _userIsMoving;
  120066. }
  120067. }
  120068. declare module BABYLON {
  120069. /**
  120070. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  120071. */
  120072. export class AttachToBoxBehavior implements Behavior<Mesh> {
  120073. private ui;
  120074. /**
  120075. * The name of the behavior
  120076. */
  120077. name: string;
  120078. /**
  120079. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120080. */
  120081. distanceAwayFromFace: number;
  120082. /**
  120083. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120084. */
  120085. distanceAwayFromBottomOfFace: number;
  120086. private _faceVectors;
  120087. private _target;
  120088. private _scene;
  120089. private _onRenderObserver;
  120090. private _tmpMatrix;
  120091. private _tmpVector;
  120092. /**
  120093. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120094. * @param ui The transform node that should be attched to the mesh
  120095. */
  120096. constructor(ui: TransformNode);
  120097. /**
  120098. * Initializes the behavior
  120099. */
  120100. init(): void;
  120101. private _closestFace;
  120102. private _zeroVector;
  120103. private _lookAtTmpMatrix;
  120104. private _lookAtToRef;
  120105. /**
  120106. * Attaches the AttachToBoxBehavior to the passed in mesh
  120107. * @param target The mesh that the specified node will be attached to
  120108. */
  120109. attach(target: Mesh): void;
  120110. /**
  120111. * Detaches the behavior from the mesh
  120112. */
  120113. detach(): void;
  120114. }
  120115. }
  120116. declare module BABYLON {
  120117. /**
  120118. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120119. */
  120120. export class FadeInOutBehavior implements Behavior<Mesh> {
  120121. /**
  120122. * Time in milliseconds to delay before fading in (Default: 0)
  120123. */
  120124. delay: number;
  120125. /**
  120126. * Time in milliseconds for the mesh to fade in (Default: 300)
  120127. */
  120128. fadeInTime: number;
  120129. private _millisecondsPerFrame;
  120130. private _hovered;
  120131. private _hoverValue;
  120132. private _ownerNode;
  120133. /**
  120134. * Instatiates the FadeInOutBehavior
  120135. */
  120136. constructor();
  120137. /**
  120138. * The name of the behavior
  120139. */
  120140. get name(): string;
  120141. /**
  120142. * Initializes the behavior
  120143. */
  120144. init(): void;
  120145. /**
  120146. * Attaches the fade behavior on the passed in mesh
  120147. * @param ownerNode The mesh that will be faded in/out once attached
  120148. */
  120149. attach(ownerNode: Mesh): void;
  120150. /**
  120151. * Detaches the behavior from the mesh
  120152. */
  120153. detach(): void;
  120154. /**
  120155. * Triggers the mesh to begin fading in or out
  120156. * @param value if the object should fade in or out (true to fade in)
  120157. */
  120158. fadeIn(value: boolean): void;
  120159. private _update;
  120160. private _setAllVisibility;
  120161. }
  120162. }
  120163. declare module BABYLON {
  120164. /**
  120165. * Class containing a set of static utilities functions for managing Pivots
  120166. * @hidden
  120167. */
  120168. export class PivotTools {
  120169. private static _PivotCached;
  120170. private static _OldPivotPoint;
  120171. private static _PivotTranslation;
  120172. private static _PivotTmpVector;
  120173. /** @hidden */
  120174. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120175. /** @hidden */
  120176. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120177. }
  120178. }
  120179. declare module BABYLON {
  120180. /**
  120181. * Class containing static functions to help procedurally build meshes
  120182. */
  120183. export class PlaneBuilder {
  120184. /**
  120185. * Creates a plane mesh
  120186. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120187. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120188. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120192. * @param name defines the name of the mesh
  120193. * @param options defines the options used to create the mesh
  120194. * @param scene defines the hosting scene
  120195. * @returns the plane mesh
  120196. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120197. */
  120198. static CreatePlane(name: string, options: {
  120199. size?: number;
  120200. width?: number;
  120201. height?: number;
  120202. sideOrientation?: number;
  120203. frontUVs?: Vector4;
  120204. backUVs?: Vector4;
  120205. updatable?: boolean;
  120206. sourcePlane?: Plane;
  120207. }, scene?: Nullable<Scene>): Mesh;
  120208. }
  120209. }
  120210. declare module BABYLON {
  120211. /**
  120212. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  120213. */
  120214. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  120215. private static _AnyMouseID;
  120216. /**
  120217. * Abstract mesh the behavior is set on
  120218. */
  120219. attachedNode: AbstractMesh;
  120220. private _dragPlane;
  120221. private _scene;
  120222. private _pointerObserver;
  120223. private _beforeRenderObserver;
  120224. private static _planeScene;
  120225. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  120226. /**
  120227. * 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)
  120228. */
  120229. maxDragAngle: number;
  120230. /**
  120231. * @hidden
  120232. */
  120233. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  120234. /**
  120235. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120236. */
  120237. currentDraggingPointerID: number;
  120238. /**
  120239. * The last position where the pointer hit the drag plane in world space
  120240. */
  120241. lastDragPosition: Vector3;
  120242. /**
  120243. * If the behavior is currently in a dragging state
  120244. */
  120245. dragging: boolean;
  120246. /**
  120247. * 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)
  120248. */
  120249. dragDeltaRatio: number;
  120250. /**
  120251. * If the drag plane orientation should be updated during the dragging (Default: true)
  120252. */
  120253. updateDragPlane: boolean;
  120254. private _debugMode;
  120255. private _moving;
  120256. /**
  120257. * Fires each time the attached mesh is dragged with the pointer
  120258. * * delta between last drag position and current drag position in world space
  120259. * * dragDistance along the drag axis
  120260. * * dragPlaneNormal normal of the current drag plane used during the drag
  120261. * * dragPlanePoint in world space where the drag intersects the drag plane
  120262. */
  120263. onDragObservable: Observable<{
  120264. delta: Vector3;
  120265. dragPlanePoint: Vector3;
  120266. dragPlaneNormal: Vector3;
  120267. dragDistance: number;
  120268. pointerId: number;
  120269. }>;
  120270. /**
  120271. * Fires each time a drag begins (eg. mouse down on mesh)
  120272. */
  120273. onDragStartObservable: Observable<{
  120274. dragPlanePoint: Vector3;
  120275. pointerId: number;
  120276. }>;
  120277. /**
  120278. * Fires each time a drag ends (eg. mouse release after drag)
  120279. */
  120280. onDragEndObservable: Observable<{
  120281. dragPlanePoint: Vector3;
  120282. pointerId: number;
  120283. }>;
  120284. /**
  120285. * If the attached mesh should be moved when dragged
  120286. */
  120287. moveAttached: boolean;
  120288. /**
  120289. * If the drag behavior will react to drag events (Default: true)
  120290. */
  120291. enabled: boolean;
  120292. /**
  120293. * If pointer events should start and release the drag (Default: true)
  120294. */
  120295. startAndReleaseDragOnPointerEvents: boolean;
  120296. /**
  120297. * If camera controls should be detached during the drag
  120298. */
  120299. detachCameraControls: boolean;
  120300. /**
  120301. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  120302. */
  120303. useObjectOrientationForDragging: boolean;
  120304. private _options;
  120305. /**
  120306. * Gets the options used by the behavior
  120307. */
  120308. get options(): {
  120309. dragAxis?: Vector3;
  120310. dragPlaneNormal?: Vector3;
  120311. };
  120312. /**
  120313. * Sets the options used by the behavior
  120314. */
  120315. set options(options: {
  120316. dragAxis?: Vector3;
  120317. dragPlaneNormal?: Vector3;
  120318. });
  120319. /**
  120320. * Creates a pointer drag behavior that can be attached to a mesh
  120321. * @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)
  120322. */
  120323. constructor(options?: {
  120324. dragAxis?: Vector3;
  120325. dragPlaneNormal?: Vector3;
  120326. });
  120327. /**
  120328. * Predicate to determine if it is valid to move the object to a new position when it is moved
  120329. */
  120330. validateDrag: (targetPosition: Vector3) => boolean;
  120331. /**
  120332. * The name of the behavior
  120333. */
  120334. get name(): string;
  120335. /**
  120336. * Initializes the behavior
  120337. */
  120338. init(): void;
  120339. private _tmpVector;
  120340. private _alternatePickedPoint;
  120341. private _worldDragAxis;
  120342. private _targetPosition;
  120343. private _attachedElement;
  120344. /**
  120345. * Attaches the drag behavior the passed in mesh
  120346. * @param ownerNode The mesh that will be dragged around once attached
  120347. * @param predicate Predicate to use for pick filtering
  120348. */
  120349. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  120350. /**
  120351. * Force relase the drag action by code.
  120352. */
  120353. releaseDrag(): void;
  120354. private _startDragRay;
  120355. private _lastPointerRay;
  120356. /**
  120357. * Simulates the start of a pointer drag event on the behavior
  120358. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  120359. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  120360. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  120361. */
  120362. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  120363. private _startDrag;
  120364. private _dragDelta;
  120365. private _moveDrag;
  120366. private _pickWithRayOnDragPlane;
  120367. private _pointA;
  120368. private _pointB;
  120369. private _pointC;
  120370. private _lineA;
  120371. private _lineB;
  120372. private _localAxis;
  120373. private _lookAt;
  120374. private _updateDragPlanePosition;
  120375. /**
  120376. * Detaches the behavior from the mesh
  120377. */
  120378. detach(): void;
  120379. }
  120380. }
  120381. declare module BABYLON {
  120382. /**
  120383. * A behavior that when attached to a mesh will allow the mesh to be scaled
  120384. */
  120385. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  120386. private _dragBehaviorA;
  120387. private _dragBehaviorB;
  120388. private _startDistance;
  120389. private _initialScale;
  120390. private _targetScale;
  120391. private _ownerNode;
  120392. private _sceneRenderObserver;
  120393. /**
  120394. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  120395. */
  120396. constructor();
  120397. /**
  120398. * The name of the behavior
  120399. */
  120400. get name(): string;
  120401. /**
  120402. * Initializes the behavior
  120403. */
  120404. init(): void;
  120405. private _getCurrentDistance;
  120406. /**
  120407. * Attaches the scale behavior the passed in mesh
  120408. * @param ownerNode The mesh that will be scaled around once attached
  120409. */
  120410. attach(ownerNode: Mesh): void;
  120411. /**
  120412. * Detaches the behavior from the mesh
  120413. */
  120414. detach(): void;
  120415. }
  120416. }
  120417. declare module BABYLON {
  120418. /**
  120419. * 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
  120420. */
  120421. export class SixDofDragBehavior implements Behavior<Mesh> {
  120422. private static _virtualScene;
  120423. private _ownerNode;
  120424. private _sceneRenderObserver;
  120425. private _scene;
  120426. private _targetPosition;
  120427. private _virtualOriginMesh;
  120428. private _virtualDragMesh;
  120429. private _pointerObserver;
  120430. private _moving;
  120431. private _startingOrientation;
  120432. private _attachedElement;
  120433. /**
  120434. * 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)
  120435. */
  120436. private zDragFactor;
  120437. /**
  120438. * If the object should rotate to face the drag origin
  120439. */
  120440. rotateDraggedObject: boolean;
  120441. /**
  120442. * If the behavior is currently in a dragging state
  120443. */
  120444. dragging: boolean;
  120445. /**
  120446. * 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)
  120447. */
  120448. dragDeltaRatio: number;
  120449. /**
  120450. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120451. */
  120452. currentDraggingPointerID: number;
  120453. /**
  120454. * If camera controls should be detached during the drag
  120455. */
  120456. detachCameraControls: boolean;
  120457. /**
  120458. * Fires each time a drag starts
  120459. */
  120460. onDragStartObservable: Observable<{}>;
  120461. /**
  120462. * Fires each time a drag ends (eg. mouse release after drag)
  120463. */
  120464. onDragEndObservable: Observable<{}>;
  120465. /**
  120466. * 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
  120467. */
  120468. constructor();
  120469. /**
  120470. * The name of the behavior
  120471. */
  120472. get name(): string;
  120473. /**
  120474. * Initializes the behavior
  120475. */
  120476. init(): void;
  120477. /**
  120478. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  120479. */
  120480. private get _pointerCamera();
  120481. /**
  120482. * Attaches the scale behavior the passed in mesh
  120483. * @param ownerNode The mesh that will be scaled around once attached
  120484. */
  120485. attach(ownerNode: Mesh): void;
  120486. /**
  120487. * Detaches the behavior from the mesh
  120488. */
  120489. detach(): void;
  120490. }
  120491. }
  120492. declare module BABYLON {
  120493. /**
  120494. * Class used to apply inverse kinematics to bones
  120495. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  120496. */
  120497. export class BoneIKController {
  120498. private static _tmpVecs;
  120499. private static _tmpQuat;
  120500. private static _tmpMats;
  120501. /**
  120502. * Gets or sets the target mesh
  120503. */
  120504. targetMesh: AbstractMesh;
  120505. /** Gets or sets the mesh used as pole */
  120506. poleTargetMesh: AbstractMesh;
  120507. /**
  120508. * Gets or sets the bone used as pole
  120509. */
  120510. poleTargetBone: Nullable<Bone>;
  120511. /**
  120512. * Gets or sets the target position
  120513. */
  120514. targetPosition: Vector3;
  120515. /**
  120516. * Gets or sets the pole target position
  120517. */
  120518. poleTargetPosition: Vector3;
  120519. /**
  120520. * Gets or sets the pole target local offset
  120521. */
  120522. poleTargetLocalOffset: Vector3;
  120523. /**
  120524. * Gets or sets the pole angle
  120525. */
  120526. poleAngle: number;
  120527. /**
  120528. * Gets or sets the mesh associated with the controller
  120529. */
  120530. mesh: AbstractMesh;
  120531. /**
  120532. * 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)
  120533. */
  120534. slerpAmount: number;
  120535. private _bone1Quat;
  120536. private _bone1Mat;
  120537. private _bone2Ang;
  120538. private _bone1;
  120539. private _bone2;
  120540. private _bone1Length;
  120541. private _bone2Length;
  120542. private _maxAngle;
  120543. private _maxReach;
  120544. private _rightHandedSystem;
  120545. private _bendAxis;
  120546. private _slerping;
  120547. private _adjustRoll;
  120548. /**
  120549. * Gets or sets maximum allowed angle
  120550. */
  120551. get maxAngle(): number;
  120552. set maxAngle(value: number);
  120553. /**
  120554. * Creates a new BoneIKController
  120555. * @param mesh defines the mesh to control
  120556. * @param bone defines the bone to control
  120557. * @param options defines options to set up the controller
  120558. */
  120559. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  120560. targetMesh?: AbstractMesh;
  120561. poleTargetMesh?: AbstractMesh;
  120562. poleTargetBone?: Bone;
  120563. poleTargetLocalOffset?: Vector3;
  120564. poleAngle?: number;
  120565. bendAxis?: Vector3;
  120566. maxAngle?: number;
  120567. slerpAmount?: number;
  120568. });
  120569. private _setMaxAngle;
  120570. /**
  120571. * Force the controller to update the bones
  120572. */
  120573. update(): void;
  120574. }
  120575. }
  120576. declare module BABYLON {
  120577. /**
  120578. * Class used to make a bone look toward a point in space
  120579. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  120580. */
  120581. export class BoneLookController {
  120582. private static _tmpVecs;
  120583. private static _tmpQuat;
  120584. private static _tmpMats;
  120585. /**
  120586. * The target Vector3 that the bone will look at
  120587. */
  120588. target: Vector3;
  120589. /**
  120590. * The mesh that the bone is attached to
  120591. */
  120592. mesh: AbstractMesh;
  120593. /**
  120594. * The bone that will be looking to the target
  120595. */
  120596. bone: Bone;
  120597. /**
  120598. * The up axis of the coordinate system that is used when the bone is rotated
  120599. */
  120600. upAxis: Vector3;
  120601. /**
  120602. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  120603. */
  120604. upAxisSpace: Space;
  120605. /**
  120606. * Used to make an adjustment to the yaw of the bone
  120607. */
  120608. adjustYaw: number;
  120609. /**
  120610. * Used to make an adjustment to the pitch of the bone
  120611. */
  120612. adjustPitch: number;
  120613. /**
  120614. * Used to make an adjustment to the roll of the bone
  120615. */
  120616. adjustRoll: number;
  120617. /**
  120618. * 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)
  120619. */
  120620. slerpAmount: number;
  120621. private _minYaw;
  120622. private _maxYaw;
  120623. private _minPitch;
  120624. private _maxPitch;
  120625. private _minYawSin;
  120626. private _minYawCos;
  120627. private _maxYawSin;
  120628. private _maxYawCos;
  120629. private _midYawConstraint;
  120630. private _minPitchTan;
  120631. private _maxPitchTan;
  120632. private _boneQuat;
  120633. private _slerping;
  120634. private _transformYawPitch;
  120635. private _transformYawPitchInv;
  120636. private _firstFrameSkipped;
  120637. private _yawRange;
  120638. private _fowardAxis;
  120639. /**
  120640. * Gets or sets the minimum yaw angle that the bone can look to
  120641. */
  120642. get minYaw(): number;
  120643. set minYaw(value: number);
  120644. /**
  120645. * Gets or sets the maximum yaw angle that the bone can look to
  120646. */
  120647. get maxYaw(): number;
  120648. set maxYaw(value: number);
  120649. /**
  120650. * Gets or sets the minimum pitch angle that the bone can look to
  120651. */
  120652. get minPitch(): number;
  120653. set minPitch(value: number);
  120654. /**
  120655. * Gets or sets the maximum pitch angle that the bone can look to
  120656. */
  120657. get maxPitch(): number;
  120658. set maxPitch(value: number);
  120659. /**
  120660. * Create a BoneLookController
  120661. * @param mesh the mesh that the bone belongs to
  120662. * @param bone the bone that will be looking to the target
  120663. * @param target the target Vector3 to look at
  120664. * @param options optional settings:
  120665. * * maxYaw: the maximum angle the bone will yaw to
  120666. * * minYaw: the minimum angle the bone will yaw to
  120667. * * maxPitch: the maximum angle the bone will pitch to
  120668. * * minPitch: the minimum angle the bone will yaw to
  120669. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  120670. * * upAxis: the up axis of the coordinate system
  120671. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  120672. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  120673. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  120674. * * adjustYaw: used to make an adjustment to the yaw of the bone
  120675. * * adjustPitch: used to make an adjustment to the pitch of the bone
  120676. * * adjustRoll: used to make an adjustment to the roll of the bone
  120677. **/
  120678. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  120679. maxYaw?: number;
  120680. minYaw?: number;
  120681. maxPitch?: number;
  120682. minPitch?: number;
  120683. slerpAmount?: number;
  120684. upAxis?: Vector3;
  120685. upAxisSpace?: Space;
  120686. yawAxis?: Vector3;
  120687. pitchAxis?: Vector3;
  120688. adjustYaw?: number;
  120689. adjustPitch?: number;
  120690. adjustRoll?: number;
  120691. });
  120692. /**
  120693. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  120694. */
  120695. update(): void;
  120696. private _getAngleDiff;
  120697. private _getAngleBetween;
  120698. private _isAngleBetween;
  120699. }
  120700. }
  120701. declare module BABYLON {
  120702. /**
  120703. * Manage the gamepad inputs to control an arc rotate camera.
  120704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120705. */
  120706. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  120707. /**
  120708. * Defines the camera the input is attached to.
  120709. */
  120710. camera: ArcRotateCamera;
  120711. /**
  120712. * Defines the gamepad the input is gathering event from.
  120713. */
  120714. gamepad: Nullable<Gamepad>;
  120715. /**
  120716. * Defines the gamepad rotation sensiblity.
  120717. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120718. */
  120719. gamepadRotationSensibility: number;
  120720. /**
  120721. * Defines the gamepad move sensiblity.
  120722. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120723. */
  120724. gamepadMoveSensibility: number;
  120725. private _yAxisScale;
  120726. /**
  120727. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120728. */
  120729. get invertYAxis(): boolean;
  120730. set invertYAxis(value: boolean);
  120731. private _onGamepadConnectedObserver;
  120732. private _onGamepadDisconnectedObserver;
  120733. /**
  120734. * Attach the input controls to a specific dom element to get the input from.
  120735. * @param element Defines the element the controls should be listened from
  120736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120737. */
  120738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120739. /**
  120740. * Detach the current controls from the specified dom element.
  120741. * @param element Defines the element to stop listening the inputs from
  120742. */
  120743. detachControl(element: Nullable<HTMLElement>): void;
  120744. /**
  120745. * Update the current camera state depending on the inputs that have been used this frame.
  120746. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120747. */
  120748. checkInputs(): void;
  120749. /**
  120750. * Gets the class name of the current intput.
  120751. * @returns the class name
  120752. */
  120753. getClassName(): string;
  120754. /**
  120755. * Get the friendly name associated with the input class.
  120756. * @returns the input friendly name
  120757. */
  120758. getSimpleName(): string;
  120759. }
  120760. }
  120761. declare module BABYLON {
  120762. interface ArcRotateCameraInputsManager {
  120763. /**
  120764. * Add orientation input support to the input manager.
  120765. * @returns the current input manager
  120766. */
  120767. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  120768. }
  120769. /**
  120770. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  120771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120772. */
  120773. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  120774. /**
  120775. * Defines the camera the input is attached to.
  120776. */
  120777. camera: ArcRotateCamera;
  120778. /**
  120779. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  120780. */
  120781. alphaCorrection: number;
  120782. /**
  120783. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  120784. */
  120785. gammaCorrection: number;
  120786. private _alpha;
  120787. private _gamma;
  120788. private _dirty;
  120789. private _deviceOrientationHandler;
  120790. /**
  120791. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  120792. */
  120793. constructor();
  120794. /**
  120795. * Attach the input controls to a specific dom element to get the input from.
  120796. * @param element Defines the element the controls should be listened from
  120797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120798. */
  120799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120800. /** @hidden */
  120801. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  120802. /**
  120803. * Update the current camera state depending on the inputs that have been used this frame.
  120804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120805. */
  120806. checkInputs(): void;
  120807. /**
  120808. * Detach the current controls from the specified dom element.
  120809. * @param element Defines the element to stop listening the inputs from
  120810. */
  120811. detachControl(element: Nullable<HTMLElement>): void;
  120812. /**
  120813. * Gets the class name of the current intput.
  120814. * @returns the class name
  120815. */
  120816. getClassName(): string;
  120817. /**
  120818. * Get the friendly name associated with the input class.
  120819. * @returns the input friendly name
  120820. */
  120821. getSimpleName(): string;
  120822. }
  120823. }
  120824. declare module BABYLON {
  120825. /**
  120826. * Listen to mouse events to control the camera.
  120827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120828. */
  120829. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  120830. /**
  120831. * Defines the camera the input is attached to.
  120832. */
  120833. camera: FlyCamera;
  120834. /**
  120835. * Defines if touch is enabled. (Default is true.)
  120836. */
  120837. touchEnabled: boolean;
  120838. /**
  120839. * Defines the buttons associated with the input to handle camera rotation.
  120840. */
  120841. buttons: number[];
  120842. /**
  120843. * Assign buttons for Yaw control.
  120844. */
  120845. buttonsYaw: number[];
  120846. /**
  120847. * Assign buttons for Pitch control.
  120848. */
  120849. buttonsPitch: number[];
  120850. /**
  120851. * Assign buttons for Roll control.
  120852. */
  120853. buttonsRoll: number[];
  120854. /**
  120855. * Detect if any button is being pressed while mouse is moved.
  120856. * -1 = Mouse locked.
  120857. * 0 = Left button.
  120858. * 1 = Middle Button.
  120859. * 2 = Right Button.
  120860. */
  120861. activeButton: number;
  120862. /**
  120863. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  120864. * Higher values reduce its sensitivity.
  120865. */
  120866. angularSensibility: number;
  120867. private _mousemoveCallback;
  120868. private _observer;
  120869. private _rollObserver;
  120870. private previousPosition;
  120871. private noPreventDefault;
  120872. private element;
  120873. /**
  120874. * Listen to mouse events to control the camera.
  120875. * @param touchEnabled Define if touch is enabled. (Default is true.)
  120876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120877. */
  120878. constructor(touchEnabled?: boolean);
  120879. /**
  120880. * Attach the mouse control to the HTML DOM element.
  120881. * @param element Defines the element that listens to the input events.
  120882. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  120883. */
  120884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120885. /**
  120886. * Detach the current controls from the specified dom element.
  120887. * @param element Defines the element to stop listening the inputs from
  120888. */
  120889. detachControl(element: Nullable<HTMLElement>): void;
  120890. /**
  120891. * Gets the class name of the current input.
  120892. * @returns the class name.
  120893. */
  120894. getClassName(): string;
  120895. /**
  120896. * Get the friendly name associated with the input class.
  120897. * @returns the input's friendly name.
  120898. */
  120899. getSimpleName(): string;
  120900. private _pointerInput;
  120901. private _onMouseMove;
  120902. /**
  120903. * Rotate camera by mouse offset.
  120904. */
  120905. private rotateCamera;
  120906. }
  120907. }
  120908. declare module BABYLON {
  120909. /**
  120910. * Default Inputs manager for the FlyCamera.
  120911. * It groups all the default supported inputs for ease of use.
  120912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120913. */
  120914. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  120915. /**
  120916. * Instantiates a new FlyCameraInputsManager.
  120917. * @param camera Defines the camera the inputs belong to.
  120918. */
  120919. constructor(camera: FlyCamera);
  120920. /**
  120921. * Add keyboard input support to the input manager.
  120922. * @returns the new FlyCameraKeyboardMoveInput().
  120923. */
  120924. addKeyboard(): FlyCameraInputsManager;
  120925. /**
  120926. * Add mouse input support to the input manager.
  120927. * @param touchEnabled Enable touch screen support.
  120928. * @returns the new FlyCameraMouseInput().
  120929. */
  120930. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  120931. }
  120932. }
  120933. declare module BABYLON {
  120934. /**
  120935. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120936. * such as in a 3D Space Shooter or a Flight Simulator.
  120937. */
  120938. export class FlyCamera extends TargetCamera {
  120939. /**
  120940. * Define the collision ellipsoid of the camera.
  120941. * This is helpful for simulating a camera body, like a player's body.
  120942. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120943. */
  120944. ellipsoid: Vector3;
  120945. /**
  120946. * Define an offset for the position of the ellipsoid around the camera.
  120947. * This can be helpful if the camera is attached away from the player's body center,
  120948. * such as at its head.
  120949. */
  120950. ellipsoidOffset: Vector3;
  120951. /**
  120952. * Enable or disable collisions of the camera with the rest of the scene objects.
  120953. */
  120954. checkCollisions: boolean;
  120955. /**
  120956. * Enable or disable gravity on the camera.
  120957. */
  120958. applyGravity: boolean;
  120959. /**
  120960. * Define the current direction the camera is moving to.
  120961. */
  120962. cameraDirection: Vector3;
  120963. /**
  120964. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  120965. * This overrides and empties cameraRotation.
  120966. */
  120967. rotationQuaternion: Quaternion;
  120968. /**
  120969. * Track Roll to maintain the wanted Rolling when looking around.
  120970. */
  120971. _trackRoll: number;
  120972. /**
  120973. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  120974. */
  120975. rollCorrect: number;
  120976. /**
  120977. * Mimic a banked turn, Rolling the camera when Yawing.
  120978. * It's recommended to use rollCorrect = 10 for faster banking correction.
  120979. */
  120980. bankedTurn: boolean;
  120981. /**
  120982. * Limit in radians for how much Roll banking will add. (Default: 90°)
  120983. */
  120984. bankedTurnLimit: number;
  120985. /**
  120986. * Value of 0 disables the banked Roll.
  120987. * Value of 1 is equal to the Yaw angle in radians.
  120988. */
  120989. bankedTurnMultiplier: number;
  120990. /**
  120991. * The inputs manager loads all the input sources, such as keyboard and mouse.
  120992. */
  120993. inputs: FlyCameraInputsManager;
  120994. /**
  120995. * Gets the input sensibility for mouse input.
  120996. * Higher values reduce sensitivity.
  120997. */
  120998. get angularSensibility(): number;
  120999. /**
  121000. * Sets the input sensibility for a mouse input.
  121001. * Higher values reduce sensitivity.
  121002. */
  121003. set angularSensibility(value: number);
  121004. /**
  121005. * Get the keys for camera movement forward.
  121006. */
  121007. get keysForward(): number[];
  121008. /**
  121009. * Set the keys for camera movement forward.
  121010. */
  121011. set keysForward(value: number[]);
  121012. /**
  121013. * Get the keys for camera movement backward.
  121014. */
  121015. get keysBackward(): number[];
  121016. set keysBackward(value: number[]);
  121017. /**
  121018. * Get the keys for camera movement up.
  121019. */
  121020. get keysUp(): number[];
  121021. /**
  121022. * Set the keys for camera movement up.
  121023. */
  121024. set keysUp(value: number[]);
  121025. /**
  121026. * Get the keys for camera movement down.
  121027. */
  121028. get keysDown(): number[];
  121029. /**
  121030. * Set the keys for camera movement down.
  121031. */
  121032. set keysDown(value: number[]);
  121033. /**
  121034. * Get the keys for camera movement left.
  121035. */
  121036. get keysLeft(): number[];
  121037. /**
  121038. * Set the keys for camera movement left.
  121039. */
  121040. set keysLeft(value: number[]);
  121041. /**
  121042. * Set the keys for camera movement right.
  121043. */
  121044. get keysRight(): number[];
  121045. /**
  121046. * Set the keys for camera movement right.
  121047. */
  121048. set keysRight(value: number[]);
  121049. /**
  121050. * Event raised when the camera collides with a mesh in the scene.
  121051. */
  121052. onCollide: (collidedMesh: AbstractMesh) => void;
  121053. private _collider;
  121054. private _needMoveForGravity;
  121055. private _oldPosition;
  121056. private _diffPosition;
  121057. private _newPosition;
  121058. /** @hidden */
  121059. _localDirection: Vector3;
  121060. /** @hidden */
  121061. _transformedDirection: Vector3;
  121062. /**
  121063. * Instantiates a FlyCamera.
  121064. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121065. * such as in a 3D Space Shooter or a Flight Simulator.
  121066. * @param name Define the name of the camera in the scene.
  121067. * @param position Define the starting position of the camera in the scene.
  121068. * @param scene Define the scene the camera belongs to.
  121069. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  121070. */
  121071. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121072. /**
  121073. * Attach a control to the HTML DOM element.
  121074. * @param element Defines the element that listens to the input events.
  121075. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  121076. */
  121077. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121078. /**
  121079. * Detach a control from the HTML DOM element.
  121080. * The camera will stop reacting to that input.
  121081. * @param element Defines the element that listens to the input events.
  121082. */
  121083. detachControl(element: HTMLElement): void;
  121084. private _collisionMask;
  121085. /**
  121086. * Get the mask that the camera ignores in collision events.
  121087. */
  121088. get collisionMask(): number;
  121089. /**
  121090. * Set the mask that the camera ignores in collision events.
  121091. */
  121092. set collisionMask(mask: number);
  121093. /** @hidden */
  121094. _collideWithWorld(displacement: Vector3): void;
  121095. /** @hidden */
  121096. private _onCollisionPositionChange;
  121097. /** @hidden */
  121098. _checkInputs(): void;
  121099. /** @hidden */
  121100. _decideIfNeedsToMove(): boolean;
  121101. /** @hidden */
  121102. _updatePosition(): void;
  121103. /**
  121104. * Restore the Roll to its target value at the rate specified.
  121105. * @param rate - Higher means slower restoring.
  121106. * @hidden
  121107. */
  121108. restoreRoll(rate: number): void;
  121109. /**
  121110. * Destroy the camera and release the current resources held by it.
  121111. */
  121112. dispose(): void;
  121113. /**
  121114. * Get the current object class name.
  121115. * @returns the class name.
  121116. */
  121117. getClassName(): string;
  121118. }
  121119. }
  121120. declare module BABYLON {
  121121. /**
  121122. * Listen to keyboard events to control the camera.
  121123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121124. */
  121125. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121126. /**
  121127. * Defines the camera the input is attached to.
  121128. */
  121129. camera: FlyCamera;
  121130. /**
  121131. * The list of keyboard keys used to control the forward move of the camera.
  121132. */
  121133. keysForward: number[];
  121134. /**
  121135. * The list of keyboard keys used to control the backward move of the camera.
  121136. */
  121137. keysBackward: number[];
  121138. /**
  121139. * The list of keyboard keys used to control the forward move of the camera.
  121140. */
  121141. keysUp: number[];
  121142. /**
  121143. * The list of keyboard keys used to control the backward move of the camera.
  121144. */
  121145. keysDown: number[];
  121146. /**
  121147. * The list of keyboard keys used to control the right strafe move of the camera.
  121148. */
  121149. keysRight: number[];
  121150. /**
  121151. * The list of keyboard keys used to control the left strafe move of the camera.
  121152. */
  121153. keysLeft: number[];
  121154. private _keys;
  121155. private _onCanvasBlurObserver;
  121156. private _onKeyboardObserver;
  121157. private _engine;
  121158. private _scene;
  121159. /**
  121160. * Attach the input controls to a specific dom element to get the input from.
  121161. * @param element Defines the element the controls should be listened from
  121162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121163. */
  121164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121165. /**
  121166. * Detach the current controls from the specified dom element.
  121167. * @param element Defines the element to stop listening the inputs from
  121168. */
  121169. detachControl(element: Nullable<HTMLElement>): void;
  121170. /**
  121171. * Gets the class name of the current intput.
  121172. * @returns the class name
  121173. */
  121174. getClassName(): string;
  121175. /** @hidden */
  121176. _onLostFocus(e: FocusEvent): void;
  121177. /**
  121178. * Get the friendly name associated with the input class.
  121179. * @returns the input friendly name
  121180. */
  121181. getSimpleName(): string;
  121182. /**
  121183. * Update the current camera state depending on the inputs that have been used this frame.
  121184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121185. */
  121186. checkInputs(): void;
  121187. }
  121188. }
  121189. declare module BABYLON {
  121190. /**
  121191. * Manage the mouse wheel inputs to control a follow camera.
  121192. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121193. */
  121194. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  121195. /**
  121196. * Defines the camera the input is attached to.
  121197. */
  121198. camera: FollowCamera;
  121199. /**
  121200. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  121201. */
  121202. axisControlRadius: boolean;
  121203. /**
  121204. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  121205. */
  121206. axisControlHeight: boolean;
  121207. /**
  121208. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  121209. */
  121210. axisControlRotation: boolean;
  121211. /**
  121212. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  121213. * relation to mouseWheel events.
  121214. */
  121215. wheelPrecision: number;
  121216. /**
  121217. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121218. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121219. */
  121220. wheelDeltaPercentage: number;
  121221. private _wheel;
  121222. private _observer;
  121223. /**
  121224. * Attach the input controls to a specific dom element to get the input from.
  121225. * @param element Defines the element the controls should be listened from
  121226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121227. */
  121228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121229. /**
  121230. * Detach the current controls from the specified dom element.
  121231. * @param element Defines the element to stop listening the inputs from
  121232. */
  121233. detachControl(element: Nullable<HTMLElement>): void;
  121234. /**
  121235. * Gets the class name of the current intput.
  121236. * @returns the class name
  121237. */
  121238. getClassName(): string;
  121239. /**
  121240. * Get the friendly name associated with the input class.
  121241. * @returns the input friendly name
  121242. */
  121243. getSimpleName(): string;
  121244. }
  121245. }
  121246. declare module BABYLON {
  121247. /**
  121248. * Manage the pointers inputs to control an follow camera.
  121249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121250. */
  121251. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  121252. /**
  121253. * Defines the camera the input is attached to.
  121254. */
  121255. camera: FollowCamera;
  121256. /**
  121257. * Gets the class name of the current input.
  121258. * @returns the class name
  121259. */
  121260. getClassName(): string;
  121261. /**
  121262. * Defines the pointer angular sensibility along the X axis or how fast is
  121263. * the camera rotating.
  121264. * A negative number will reverse the axis direction.
  121265. */
  121266. angularSensibilityX: number;
  121267. /**
  121268. * Defines the pointer angular sensibility along the Y axis or how fast is
  121269. * the camera rotating.
  121270. * A negative number will reverse the axis direction.
  121271. */
  121272. angularSensibilityY: number;
  121273. /**
  121274. * Defines the pointer pinch precision or how fast is the camera zooming.
  121275. * A negative number will reverse the axis direction.
  121276. */
  121277. pinchPrecision: number;
  121278. /**
  121279. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121280. * from 0.
  121281. * It defines the percentage of current camera.radius to use as delta when
  121282. * pinch zoom is used.
  121283. */
  121284. pinchDeltaPercentage: number;
  121285. /**
  121286. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  121287. */
  121288. axisXControlRadius: boolean;
  121289. /**
  121290. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  121291. */
  121292. axisXControlHeight: boolean;
  121293. /**
  121294. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  121295. */
  121296. axisXControlRotation: boolean;
  121297. /**
  121298. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  121299. */
  121300. axisYControlRadius: boolean;
  121301. /**
  121302. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  121303. */
  121304. axisYControlHeight: boolean;
  121305. /**
  121306. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  121307. */
  121308. axisYControlRotation: boolean;
  121309. /**
  121310. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  121311. */
  121312. axisPinchControlRadius: boolean;
  121313. /**
  121314. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  121315. */
  121316. axisPinchControlHeight: boolean;
  121317. /**
  121318. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  121319. */
  121320. axisPinchControlRotation: boolean;
  121321. /**
  121322. * Log error messages if basic misconfiguration has occurred.
  121323. */
  121324. warningEnable: boolean;
  121325. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121326. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121327. private _warningCounter;
  121328. private _warning;
  121329. }
  121330. }
  121331. declare module BABYLON {
  121332. /**
  121333. * Default Inputs manager for the FollowCamera.
  121334. * It groups all the default supported inputs for ease of use.
  121335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121336. */
  121337. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  121338. /**
  121339. * Instantiates a new FollowCameraInputsManager.
  121340. * @param camera Defines the camera the inputs belong to
  121341. */
  121342. constructor(camera: FollowCamera);
  121343. /**
  121344. * Add keyboard input support to the input manager.
  121345. * @returns the current input manager
  121346. */
  121347. addKeyboard(): FollowCameraInputsManager;
  121348. /**
  121349. * Add mouse wheel input support to the input manager.
  121350. * @returns the current input manager
  121351. */
  121352. addMouseWheel(): FollowCameraInputsManager;
  121353. /**
  121354. * Add pointers input support to the input manager.
  121355. * @returns the current input manager
  121356. */
  121357. addPointers(): FollowCameraInputsManager;
  121358. /**
  121359. * Add orientation input support to the input manager.
  121360. * @returns the current input manager
  121361. */
  121362. addVRDeviceOrientation(): FollowCameraInputsManager;
  121363. }
  121364. }
  121365. declare module BABYLON {
  121366. /**
  121367. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  121368. * an arc rotate version arcFollowCamera are available.
  121369. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121370. */
  121371. export class FollowCamera extends TargetCamera {
  121372. /**
  121373. * Distance the follow camera should follow an object at
  121374. */
  121375. radius: number;
  121376. /**
  121377. * Minimum allowed distance of the camera to the axis of rotation
  121378. * (The camera can not get closer).
  121379. * This can help limiting how the Camera is able to move in the scene.
  121380. */
  121381. lowerRadiusLimit: Nullable<number>;
  121382. /**
  121383. * Maximum allowed distance of the camera to the axis of rotation
  121384. * (The camera can not get further).
  121385. * This can help limiting how the Camera is able to move in the scene.
  121386. */
  121387. upperRadiusLimit: Nullable<number>;
  121388. /**
  121389. * Define a rotation offset between the camera and the object it follows
  121390. */
  121391. rotationOffset: number;
  121392. /**
  121393. * Minimum allowed angle to camera position relative to target object.
  121394. * This can help limiting how the Camera is able to move in the scene.
  121395. */
  121396. lowerRotationOffsetLimit: Nullable<number>;
  121397. /**
  121398. * Maximum allowed angle to camera position relative to target object.
  121399. * This can help limiting how the Camera is able to move in the scene.
  121400. */
  121401. upperRotationOffsetLimit: Nullable<number>;
  121402. /**
  121403. * Define a height offset between the camera and the object it follows.
  121404. * It can help following an object from the top (like a car chaing a plane)
  121405. */
  121406. heightOffset: number;
  121407. /**
  121408. * Minimum allowed height of camera position relative to target object.
  121409. * This can help limiting how the Camera is able to move in the scene.
  121410. */
  121411. lowerHeightOffsetLimit: Nullable<number>;
  121412. /**
  121413. * Maximum allowed height of camera position relative to target object.
  121414. * This can help limiting how the Camera is able to move in the scene.
  121415. */
  121416. upperHeightOffsetLimit: Nullable<number>;
  121417. /**
  121418. * Define how fast the camera can accelerate to follow it s target.
  121419. */
  121420. cameraAcceleration: number;
  121421. /**
  121422. * Define the speed limit of the camera following an object.
  121423. */
  121424. maxCameraSpeed: number;
  121425. /**
  121426. * Define the target of the camera.
  121427. */
  121428. lockedTarget: Nullable<AbstractMesh>;
  121429. /**
  121430. * Defines the input associated with the camera.
  121431. */
  121432. inputs: FollowCameraInputsManager;
  121433. /**
  121434. * Instantiates the follow camera.
  121435. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121436. * @param name Define the name of the camera in the scene
  121437. * @param position Define the position of the camera
  121438. * @param scene Define the scene the camera belong to
  121439. * @param lockedTarget Define the target of the camera
  121440. */
  121441. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  121442. private _follow;
  121443. /**
  121444. * Attached controls to the current camera.
  121445. * @param element Defines the element the controls should be listened from
  121446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121447. */
  121448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121449. /**
  121450. * Detach the current controls from the camera.
  121451. * The camera will stop reacting to inputs.
  121452. * @param element Defines the element to stop listening the inputs from
  121453. */
  121454. detachControl(element: HTMLElement): void;
  121455. /** @hidden */
  121456. _checkInputs(): void;
  121457. private _checkLimits;
  121458. /**
  121459. * Gets the camera class name.
  121460. * @returns the class name
  121461. */
  121462. getClassName(): string;
  121463. }
  121464. /**
  121465. * Arc Rotate version of the follow camera.
  121466. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  121467. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121468. */
  121469. export class ArcFollowCamera extends TargetCamera {
  121470. /** The longitudinal angle of the camera */
  121471. alpha: number;
  121472. /** The latitudinal angle of the camera */
  121473. beta: number;
  121474. /** The radius of the camera from its target */
  121475. radius: number;
  121476. /** Define the camera target (the mesh it should follow) */
  121477. target: Nullable<AbstractMesh>;
  121478. private _cartesianCoordinates;
  121479. /**
  121480. * Instantiates a new ArcFollowCamera
  121481. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121482. * @param name Define the name of the camera
  121483. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  121484. * @param beta Define the rotation angle of the camera around the elevation axis
  121485. * @param radius Define the radius of the camera from its target point
  121486. * @param target Define the target of the camera
  121487. * @param scene Define the scene the camera belongs to
  121488. */
  121489. constructor(name: string,
  121490. /** The longitudinal angle of the camera */
  121491. alpha: number,
  121492. /** The latitudinal angle of the camera */
  121493. beta: number,
  121494. /** The radius of the camera from its target */
  121495. radius: number,
  121496. /** Define the camera target (the mesh it should follow) */
  121497. target: Nullable<AbstractMesh>, scene: Scene);
  121498. private _follow;
  121499. /** @hidden */
  121500. _checkInputs(): void;
  121501. /**
  121502. * Returns the class name of the object.
  121503. * It is mostly used internally for serialization purposes.
  121504. */
  121505. getClassName(): string;
  121506. }
  121507. }
  121508. declare module BABYLON {
  121509. /**
  121510. * Manage the keyboard inputs to control the movement of a follow camera.
  121511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121512. */
  121513. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  121514. /**
  121515. * Defines the camera the input is attached to.
  121516. */
  121517. camera: FollowCamera;
  121518. /**
  121519. * Defines the list of key codes associated with the up action (increase heightOffset)
  121520. */
  121521. keysHeightOffsetIncr: number[];
  121522. /**
  121523. * Defines the list of key codes associated with the down action (decrease heightOffset)
  121524. */
  121525. keysHeightOffsetDecr: number[];
  121526. /**
  121527. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  121528. */
  121529. keysHeightOffsetModifierAlt: boolean;
  121530. /**
  121531. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  121532. */
  121533. keysHeightOffsetModifierCtrl: boolean;
  121534. /**
  121535. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  121536. */
  121537. keysHeightOffsetModifierShift: boolean;
  121538. /**
  121539. * Defines the list of key codes associated with the left action (increase rotationOffset)
  121540. */
  121541. keysRotationOffsetIncr: number[];
  121542. /**
  121543. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  121544. */
  121545. keysRotationOffsetDecr: number[];
  121546. /**
  121547. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  121548. */
  121549. keysRotationOffsetModifierAlt: boolean;
  121550. /**
  121551. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  121552. */
  121553. keysRotationOffsetModifierCtrl: boolean;
  121554. /**
  121555. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  121556. */
  121557. keysRotationOffsetModifierShift: boolean;
  121558. /**
  121559. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  121560. */
  121561. keysRadiusIncr: number[];
  121562. /**
  121563. * Defines the list of key codes associated with the zoom-out action (increase radius)
  121564. */
  121565. keysRadiusDecr: number[];
  121566. /**
  121567. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  121568. */
  121569. keysRadiusModifierAlt: boolean;
  121570. /**
  121571. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  121572. */
  121573. keysRadiusModifierCtrl: boolean;
  121574. /**
  121575. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  121576. */
  121577. keysRadiusModifierShift: boolean;
  121578. /**
  121579. * Defines the rate of change of heightOffset.
  121580. */
  121581. heightSensibility: number;
  121582. /**
  121583. * Defines the rate of change of rotationOffset.
  121584. */
  121585. rotationSensibility: number;
  121586. /**
  121587. * Defines the rate of change of radius.
  121588. */
  121589. radiusSensibility: number;
  121590. private _keys;
  121591. private _ctrlPressed;
  121592. private _altPressed;
  121593. private _shiftPressed;
  121594. private _onCanvasBlurObserver;
  121595. private _onKeyboardObserver;
  121596. private _engine;
  121597. private _scene;
  121598. /**
  121599. * Attach the input controls to a specific dom element to get the input from.
  121600. * @param element Defines the element the controls should be listened from
  121601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121602. */
  121603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121604. /**
  121605. * Detach the current controls from the specified dom element.
  121606. * @param element Defines the element to stop listening the inputs from
  121607. */
  121608. detachControl(element: Nullable<HTMLElement>): void;
  121609. /**
  121610. * Update the current camera state depending on the inputs that have been used this frame.
  121611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121612. */
  121613. checkInputs(): void;
  121614. /**
  121615. * Gets the class name of the current input.
  121616. * @returns the class name
  121617. */
  121618. getClassName(): string;
  121619. /**
  121620. * Get the friendly name associated with the input class.
  121621. * @returns the input friendly name
  121622. */
  121623. getSimpleName(): string;
  121624. /**
  121625. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121626. * allow modification of the heightOffset value.
  121627. */
  121628. private _modifierHeightOffset;
  121629. /**
  121630. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121631. * allow modification of the rotationOffset value.
  121632. */
  121633. private _modifierRotationOffset;
  121634. /**
  121635. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121636. * allow modification of the radius value.
  121637. */
  121638. private _modifierRadius;
  121639. }
  121640. }
  121641. declare module BABYLON {
  121642. interface FreeCameraInputsManager {
  121643. /**
  121644. * @hidden
  121645. */
  121646. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  121647. /**
  121648. * Add orientation input support to the input manager.
  121649. * @returns the current input manager
  121650. */
  121651. addDeviceOrientation(): FreeCameraInputsManager;
  121652. }
  121653. /**
  121654. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  121655. * Screen rotation is taken into account.
  121656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121657. */
  121658. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  121659. private _camera;
  121660. private _screenOrientationAngle;
  121661. private _constantTranform;
  121662. private _screenQuaternion;
  121663. private _alpha;
  121664. private _beta;
  121665. private _gamma;
  121666. /**
  121667. * Can be used to detect if a device orientation sensor is available on a device
  121668. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  121669. * @returns a promise that will resolve on orientation change
  121670. */
  121671. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  121672. /**
  121673. * @hidden
  121674. */
  121675. _onDeviceOrientationChangedObservable: Observable<void>;
  121676. /**
  121677. * Instantiates a new input
  121678. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121679. */
  121680. constructor();
  121681. /**
  121682. * Define the camera controlled by the input.
  121683. */
  121684. get camera(): FreeCamera;
  121685. set camera(camera: FreeCamera);
  121686. /**
  121687. * Attach the input controls to a specific dom element to get the input from.
  121688. * @param element Defines the element the controls should be listened from
  121689. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121690. */
  121691. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121692. private _orientationChanged;
  121693. private _deviceOrientation;
  121694. /**
  121695. * Detach the current controls from the specified dom element.
  121696. * @param element Defines the element to stop listening the inputs from
  121697. */
  121698. detachControl(element: Nullable<HTMLElement>): void;
  121699. /**
  121700. * Update the current camera state depending on the inputs that have been used this frame.
  121701. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121702. */
  121703. checkInputs(): void;
  121704. /**
  121705. * Gets the class name of the current intput.
  121706. * @returns the class name
  121707. */
  121708. getClassName(): string;
  121709. /**
  121710. * Get the friendly name associated with the input class.
  121711. * @returns the input friendly name
  121712. */
  121713. getSimpleName(): string;
  121714. }
  121715. }
  121716. declare module BABYLON {
  121717. /**
  121718. * Manage the gamepad inputs to control a free camera.
  121719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121720. */
  121721. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  121722. /**
  121723. * Define the camera the input is attached to.
  121724. */
  121725. camera: FreeCamera;
  121726. /**
  121727. * Define the Gamepad controlling the input
  121728. */
  121729. gamepad: Nullable<Gamepad>;
  121730. /**
  121731. * Defines the gamepad rotation sensiblity.
  121732. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121733. */
  121734. gamepadAngularSensibility: number;
  121735. /**
  121736. * Defines the gamepad move sensiblity.
  121737. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121738. */
  121739. gamepadMoveSensibility: number;
  121740. private _yAxisScale;
  121741. /**
  121742. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121743. */
  121744. get invertYAxis(): boolean;
  121745. set invertYAxis(value: boolean);
  121746. private _onGamepadConnectedObserver;
  121747. private _onGamepadDisconnectedObserver;
  121748. private _cameraTransform;
  121749. private _deltaTransform;
  121750. private _vector3;
  121751. private _vector2;
  121752. /**
  121753. * Attach the input controls to a specific dom element to get the input from.
  121754. * @param element Defines the element the controls should be listened from
  121755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121756. */
  121757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121758. /**
  121759. * Detach the current controls from the specified dom element.
  121760. * @param element Defines the element to stop listening the inputs from
  121761. */
  121762. detachControl(element: Nullable<HTMLElement>): void;
  121763. /**
  121764. * Update the current camera state depending on the inputs that have been used this frame.
  121765. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121766. */
  121767. checkInputs(): void;
  121768. /**
  121769. * Gets the class name of the current intput.
  121770. * @returns the class name
  121771. */
  121772. getClassName(): string;
  121773. /**
  121774. * Get the friendly name associated with the input class.
  121775. * @returns the input friendly name
  121776. */
  121777. getSimpleName(): string;
  121778. }
  121779. }
  121780. declare module BABYLON {
  121781. /**
  121782. * Defines the potential axis of a Joystick
  121783. */
  121784. export enum JoystickAxis {
  121785. /** X axis */
  121786. X = 0,
  121787. /** Y axis */
  121788. Y = 1,
  121789. /** Z axis */
  121790. Z = 2
  121791. }
  121792. /**
  121793. * Class used to define virtual joystick (used in touch mode)
  121794. */
  121795. export class VirtualJoystick {
  121796. /**
  121797. * Gets or sets a boolean indicating that left and right values must be inverted
  121798. */
  121799. reverseLeftRight: boolean;
  121800. /**
  121801. * Gets or sets a boolean indicating that up and down values must be inverted
  121802. */
  121803. reverseUpDown: boolean;
  121804. /**
  121805. * Gets the offset value for the position (ie. the change of the position value)
  121806. */
  121807. deltaPosition: Vector3;
  121808. /**
  121809. * Gets a boolean indicating if the virtual joystick was pressed
  121810. */
  121811. pressed: boolean;
  121812. /**
  121813. * Canvas the virtual joystick will render onto, default z-index of this is 5
  121814. */
  121815. static Canvas: Nullable<HTMLCanvasElement>;
  121816. private static _globalJoystickIndex;
  121817. private static vjCanvasContext;
  121818. private static vjCanvasWidth;
  121819. private static vjCanvasHeight;
  121820. private static halfWidth;
  121821. private _action;
  121822. private _axisTargetedByLeftAndRight;
  121823. private _axisTargetedByUpAndDown;
  121824. private _joystickSensibility;
  121825. private _inversedSensibility;
  121826. private _joystickPointerID;
  121827. private _joystickColor;
  121828. private _joystickPointerPos;
  121829. private _joystickPreviousPointerPos;
  121830. private _joystickPointerStartPos;
  121831. private _deltaJoystickVector;
  121832. private _leftJoystick;
  121833. private _touches;
  121834. private _onPointerDownHandlerRef;
  121835. private _onPointerMoveHandlerRef;
  121836. private _onPointerUpHandlerRef;
  121837. private _onResize;
  121838. /**
  121839. * Creates a new virtual joystick
  121840. * @param leftJoystick defines that the joystick is for left hand (false by default)
  121841. */
  121842. constructor(leftJoystick?: boolean);
  121843. /**
  121844. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  121845. * @param newJoystickSensibility defines the new sensibility
  121846. */
  121847. setJoystickSensibility(newJoystickSensibility: number): void;
  121848. private _onPointerDown;
  121849. private _onPointerMove;
  121850. private _onPointerUp;
  121851. /**
  121852. * Change the color of the virtual joystick
  121853. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  121854. */
  121855. setJoystickColor(newColor: string): void;
  121856. /**
  121857. * Defines a callback to call when the joystick is touched
  121858. * @param action defines the callback
  121859. */
  121860. setActionOnTouch(action: () => any): void;
  121861. /**
  121862. * Defines which axis you'd like to control for left & right
  121863. * @param axis defines the axis to use
  121864. */
  121865. setAxisForLeftRight(axis: JoystickAxis): void;
  121866. /**
  121867. * Defines which axis you'd like to control for up & down
  121868. * @param axis defines the axis to use
  121869. */
  121870. setAxisForUpDown(axis: JoystickAxis): void;
  121871. private _drawVirtualJoystick;
  121872. /**
  121873. * Release internal HTML canvas
  121874. */
  121875. releaseCanvas(): void;
  121876. }
  121877. }
  121878. declare module BABYLON {
  121879. interface FreeCameraInputsManager {
  121880. /**
  121881. * Add virtual joystick input support to the input manager.
  121882. * @returns the current input manager
  121883. */
  121884. addVirtualJoystick(): FreeCameraInputsManager;
  121885. }
  121886. /**
  121887. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  121888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121889. */
  121890. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  121891. /**
  121892. * Defines the camera the input is attached to.
  121893. */
  121894. camera: FreeCamera;
  121895. private _leftjoystick;
  121896. private _rightjoystick;
  121897. /**
  121898. * Gets the left stick of the virtual joystick.
  121899. * @returns The virtual Joystick
  121900. */
  121901. getLeftJoystick(): VirtualJoystick;
  121902. /**
  121903. * Gets the right stick of the virtual joystick.
  121904. * @returns The virtual Joystick
  121905. */
  121906. getRightJoystick(): VirtualJoystick;
  121907. /**
  121908. * Update the current camera state depending on the inputs that have been used this frame.
  121909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121910. */
  121911. checkInputs(): void;
  121912. /**
  121913. * Attach the input controls to a specific dom element to get the input from.
  121914. * @param element Defines the element the controls should be listened from
  121915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121916. */
  121917. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121918. /**
  121919. * Detach the current controls from the specified dom element.
  121920. * @param element Defines the element to stop listening the inputs from
  121921. */
  121922. detachControl(element: Nullable<HTMLElement>): void;
  121923. /**
  121924. * Gets the class name of the current intput.
  121925. * @returns the class name
  121926. */
  121927. getClassName(): string;
  121928. /**
  121929. * Get the friendly name associated with the input class.
  121930. * @returns the input friendly name
  121931. */
  121932. getSimpleName(): string;
  121933. }
  121934. }
  121935. declare module BABYLON {
  121936. /**
  121937. * This represents a FPS type of camera controlled by touch.
  121938. * This is like a universal camera minus the Gamepad controls.
  121939. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121940. */
  121941. export class TouchCamera extends FreeCamera {
  121942. /**
  121943. * Defines the touch sensibility for rotation.
  121944. * The higher the faster.
  121945. */
  121946. get touchAngularSensibility(): number;
  121947. set touchAngularSensibility(value: number);
  121948. /**
  121949. * Defines the touch sensibility for move.
  121950. * The higher the faster.
  121951. */
  121952. get touchMoveSensibility(): number;
  121953. set touchMoveSensibility(value: number);
  121954. /**
  121955. * Instantiates a new touch camera.
  121956. * This represents a FPS type of camera controlled by touch.
  121957. * This is like a universal camera minus the Gamepad controls.
  121958. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121959. * @param name Define the name of the camera in the scene
  121960. * @param position Define the start position of the camera in the scene
  121961. * @param scene Define the scene the camera belongs to
  121962. */
  121963. constructor(name: string, position: Vector3, scene: Scene);
  121964. /**
  121965. * Gets the current object class name.
  121966. * @return the class name
  121967. */
  121968. getClassName(): string;
  121969. /** @hidden */
  121970. _setupInputs(): void;
  121971. }
  121972. }
  121973. declare module BABYLON {
  121974. /**
  121975. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  121976. * being tilted forward or back and left or right.
  121977. */
  121978. export class DeviceOrientationCamera extends FreeCamera {
  121979. private _initialQuaternion;
  121980. private _quaternionCache;
  121981. private _tmpDragQuaternion;
  121982. private _disablePointerInputWhenUsingDeviceOrientation;
  121983. /**
  121984. * Creates a new device orientation camera
  121985. * @param name The name of the camera
  121986. * @param position The start position camera
  121987. * @param scene The scene the camera belongs to
  121988. */
  121989. constructor(name: string, position: Vector3, scene: Scene);
  121990. /**
  121991. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  121992. */
  121993. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  121994. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  121995. private _dragFactor;
  121996. /**
  121997. * Enabled turning on the y axis when the orientation sensor is active
  121998. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  121999. */
  122000. enableHorizontalDragging(dragFactor?: number): void;
  122001. /**
  122002. * Gets the current instance class name ("DeviceOrientationCamera").
  122003. * This helps avoiding instanceof at run time.
  122004. * @returns the class name
  122005. */
  122006. getClassName(): string;
  122007. /**
  122008. * @hidden
  122009. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  122010. */
  122011. _checkInputs(): void;
  122012. /**
  122013. * Reset the camera to its default orientation on the specified axis only.
  122014. * @param axis The axis to reset
  122015. */
  122016. resetToCurrentRotation(axis?: Axis): void;
  122017. }
  122018. }
  122019. declare module BABYLON {
  122020. /**
  122021. * Defines supported buttons for XBox360 compatible gamepads
  122022. */
  122023. export enum Xbox360Button {
  122024. /** A */
  122025. A = 0,
  122026. /** B */
  122027. B = 1,
  122028. /** X */
  122029. X = 2,
  122030. /** Y */
  122031. Y = 3,
  122032. /** Left button */
  122033. LB = 4,
  122034. /** Right button */
  122035. RB = 5,
  122036. /** Back */
  122037. Back = 8,
  122038. /** Start */
  122039. Start = 9,
  122040. /** Left stick */
  122041. LeftStick = 10,
  122042. /** Right stick */
  122043. RightStick = 11
  122044. }
  122045. /** Defines values for XBox360 DPad */
  122046. export enum Xbox360Dpad {
  122047. /** Up */
  122048. Up = 12,
  122049. /** Down */
  122050. Down = 13,
  122051. /** Left */
  122052. Left = 14,
  122053. /** Right */
  122054. Right = 15
  122055. }
  122056. /**
  122057. * Defines a XBox360 gamepad
  122058. */
  122059. export class Xbox360Pad extends Gamepad {
  122060. private _leftTrigger;
  122061. private _rightTrigger;
  122062. private _onlefttriggerchanged;
  122063. private _onrighttriggerchanged;
  122064. private _onbuttondown;
  122065. private _onbuttonup;
  122066. private _ondpaddown;
  122067. private _ondpadup;
  122068. /** Observable raised when a button is pressed */
  122069. onButtonDownObservable: Observable<Xbox360Button>;
  122070. /** Observable raised when a button is released */
  122071. onButtonUpObservable: Observable<Xbox360Button>;
  122072. /** Observable raised when a pad is pressed */
  122073. onPadDownObservable: Observable<Xbox360Dpad>;
  122074. /** Observable raised when a pad is released */
  122075. onPadUpObservable: Observable<Xbox360Dpad>;
  122076. private _buttonA;
  122077. private _buttonB;
  122078. private _buttonX;
  122079. private _buttonY;
  122080. private _buttonBack;
  122081. private _buttonStart;
  122082. private _buttonLB;
  122083. private _buttonRB;
  122084. private _buttonLeftStick;
  122085. private _buttonRightStick;
  122086. private _dPadUp;
  122087. private _dPadDown;
  122088. private _dPadLeft;
  122089. private _dPadRight;
  122090. private _isXboxOnePad;
  122091. /**
  122092. * Creates a new XBox360 gamepad object
  122093. * @param id defines the id of this gamepad
  122094. * @param index defines its index
  122095. * @param gamepad defines the internal HTML gamepad object
  122096. * @param xboxOne defines if it is a XBox One gamepad
  122097. */
  122098. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  122099. /**
  122100. * Defines the callback to call when left trigger is pressed
  122101. * @param callback defines the callback to use
  122102. */
  122103. onlefttriggerchanged(callback: (value: number) => void): void;
  122104. /**
  122105. * Defines the callback to call when right trigger is pressed
  122106. * @param callback defines the callback to use
  122107. */
  122108. onrighttriggerchanged(callback: (value: number) => void): void;
  122109. /**
  122110. * Gets the left trigger value
  122111. */
  122112. get leftTrigger(): number;
  122113. /**
  122114. * Sets the left trigger value
  122115. */
  122116. set leftTrigger(newValue: number);
  122117. /**
  122118. * Gets the right trigger value
  122119. */
  122120. get rightTrigger(): number;
  122121. /**
  122122. * Sets the right trigger value
  122123. */
  122124. set rightTrigger(newValue: number);
  122125. /**
  122126. * Defines the callback to call when a button is pressed
  122127. * @param callback defines the callback to use
  122128. */
  122129. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  122130. /**
  122131. * Defines the callback to call when a button is released
  122132. * @param callback defines the callback to use
  122133. */
  122134. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  122135. /**
  122136. * Defines the callback to call when a pad is pressed
  122137. * @param callback defines the callback to use
  122138. */
  122139. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  122140. /**
  122141. * Defines the callback to call when a pad is released
  122142. * @param callback defines the callback to use
  122143. */
  122144. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  122145. private _setButtonValue;
  122146. private _setDPadValue;
  122147. /**
  122148. * Gets the value of the `A` button
  122149. */
  122150. get buttonA(): number;
  122151. /**
  122152. * Sets the value of the `A` button
  122153. */
  122154. set buttonA(value: number);
  122155. /**
  122156. * Gets the value of the `B` button
  122157. */
  122158. get buttonB(): number;
  122159. /**
  122160. * Sets the value of the `B` button
  122161. */
  122162. set buttonB(value: number);
  122163. /**
  122164. * Gets the value of the `X` button
  122165. */
  122166. get buttonX(): number;
  122167. /**
  122168. * Sets the value of the `X` button
  122169. */
  122170. set buttonX(value: number);
  122171. /**
  122172. * Gets the value of the `Y` button
  122173. */
  122174. get buttonY(): number;
  122175. /**
  122176. * Sets the value of the `Y` button
  122177. */
  122178. set buttonY(value: number);
  122179. /**
  122180. * Gets the value of the `Start` button
  122181. */
  122182. get buttonStart(): number;
  122183. /**
  122184. * Sets the value of the `Start` button
  122185. */
  122186. set buttonStart(value: number);
  122187. /**
  122188. * Gets the value of the `Back` button
  122189. */
  122190. get buttonBack(): number;
  122191. /**
  122192. * Sets the value of the `Back` button
  122193. */
  122194. set buttonBack(value: number);
  122195. /**
  122196. * Gets the value of the `Left` button
  122197. */
  122198. get buttonLB(): number;
  122199. /**
  122200. * Sets the value of the `Left` button
  122201. */
  122202. set buttonLB(value: number);
  122203. /**
  122204. * Gets the value of the `Right` button
  122205. */
  122206. get buttonRB(): number;
  122207. /**
  122208. * Sets the value of the `Right` button
  122209. */
  122210. set buttonRB(value: number);
  122211. /**
  122212. * Gets the value of the Left joystick
  122213. */
  122214. get buttonLeftStick(): number;
  122215. /**
  122216. * Sets the value of the Left joystick
  122217. */
  122218. set buttonLeftStick(value: number);
  122219. /**
  122220. * Gets the value of the Right joystick
  122221. */
  122222. get buttonRightStick(): number;
  122223. /**
  122224. * Sets the value of the Right joystick
  122225. */
  122226. set buttonRightStick(value: number);
  122227. /**
  122228. * Gets the value of D-pad up
  122229. */
  122230. get dPadUp(): number;
  122231. /**
  122232. * Sets the value of D-pad up
  122233. */
  122234. set dPadUp(value: number);
  122235. /**
  122236. * Gets the value of D-pad down
  122237. */
  122238. get dPadDown(): number;
  122239. /**
  122240. * Sets the value of D-pad down
  122241. */
  122242. set dPadDown(value: number);
  122243. /**
  122244. * Gets the value of D-pad left
  122245. */
  122246. get dPadLeft(): number;
  122247. /**
  122248. * Sets the value of D-pad left
  122249. */
  122250. set dPadLeft(value: number);
  122251. /**
  122252. * Gets the value of D-pad right
  122253. */
  122254. get dPadRight(): number;
  122255. /**
  122256. * Sets the value of D-pad right
  122257. */
  122258. set dPadRight(value: number);
  122259. /**
  122260. * Force the gamepad to synchronize with device values
  122261. */
  122262. update(): void;
  122263. /**
  122264. * Disposes the gamepad
  122265. */
  122266. dispose(): void;
  122267. }
  122268. }
  122269. declare module BABYLON {
  122270. /**
  122271. * Defines supported buttons for DualShock compatible gamepads
  122272. */
  122273. export enum DualShockButton {
  122274. /** Cross */
  122275. Cross = 0,
  122276. /** Circle */
  122277. Circle = 1,
  122278. /** Square */
  122279. Square = 2,
  122280. /** Triangle */
  122281. Triangle = 3,
  122282. /** L1 */
  122283. L1 = 4,
  122284. /** R1 */
  122285. R1 = 5,
  122286. /** Share */
  122287. Share = 8,
  122288. /** Options */
  122289. Options = 9,
  122290. /** Left stick */
  122291. LeftStick = 10,
  122292. /** Right stick */
  122293. RightStick = 11
  122294. }
  122295. /** Defines values for DualShock DPad */
  122296. export enum DualShockDpad {
  122297. /** Up */
  122298. Up = 12,
  122299. /** Down */
  122300. Down = 13,
  122301. /** Left */
  122302. Left = 14,
  122303. /** Right */
  122304. Right = 15
  122305. }
  122306. /**
  122307. * Defines a DualShock gamepad
  122308. */
  122309. export class DualShockPad extends Gamepad {
  122310. private _leftTrigger;
  122311. private _rightTrigger;
  122312. private _onlefttriggerchanged;
  122313. private _onrighttriggerchanged;
  122314. private _onbuttondown;
  122315. private _onbuttonup;
  122316. private _ondpaddown;
  122317. private _ondpadup;
  122318. /** Observable raised when a button is pressed */
  122319. onButtonDownObservable: Observable<DualShockButton>;
  122320. /** Observable raised when a button is released */
  122321. onButtonUpObservable: Observable<DualShockButton>;
  122322. /** Observable raised when a pad is pressed */
  122323. onPadDownObservable: Observable<DualShockDpad>;
  122324. /** Observable raised when a pad is released */
  122325. onPadUpObservable: Observable<DualShockDpad>;
  122326. private _buttonCross;
  122327. private _buttonCircle;
  122328. private _buttonSquare;
  122329. private _buttonTriangle;
  122330. private _buttonShare;
  122331. private _buttonOptions;
  122332. private _buttonL1;
  122333. private _buttonR1;
  122334. private _buttonLeftStick;
  122335. private _buttonRightStick;
  122336. private _dPadUp;
  122337. private _dPadDown;
  122338. private _dPadLeft;
  122339. private _dPadRight;
  122340. /**
  122341. * Creates a new DualShock gamepad object
  122342. * @param id defines the id of this gamepad
  122343. * @param index defines its index
  122344. * @param gamepad defines the internal HTML gamepad object
  122345. */
  122346. constructor(id: string, index: number, gamepad: any);
  122347. /**
  122348. * Defines the callback to call when left trigger is pressed
  122349. * @param callback defines the callback to use
  122350. */
  122351. onlefttriggerchanged(callback: (value: number) => void): void;
  122352. /**
  122353. * Defines the callback to call when right trigger is pressed
  122354. * @param callback defines the callback to use
  122355. */
  122356. onrighttriggerchanged(callback: (value: number) => void): void;
  122357. /**
  122358. * Gets the left trigger value
  122359. */
  122360. get leftTrigger(): number;
  122361. /**
  122362. * Sets the left trigger value
  122363. */
  122364. set leftTrigger(newValue: number);
  122365. /**
  122366. * Gets the right trigger value
  122367. */
  122368. get rightTrigger(): number;
  122369. /**
  122370. * Sets the right trigger value
  122371. */
  122372. set rightTrigger(newValue: number);
  122373. /**
  122374. * Defines the callback to call when a button is pressed
  122375. * @param callback defines the callback to use
  122376. */
  122377. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  122378. /**
  122379. * Defines the callback to call when a button is released
  122380. * @param callback defines the callback to use
  122381. */
  122382. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  122383. /**
  122384. * Defines the callback to call when a pad is pressed
  122385. * @param callback defines the callback to use
  122386. */
  122387. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  122388. /**
  122389. * Defines the callback to call when a pad is released
  122390. * @param callback defines the callback to use
  122391. */
  122392. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  122393. private _setButtonValue;
  122394. private _setDPadValue;
  122395. /**
  122396. * Gets the value of the `Cross` button
  122397. */
  122398. get buttonCross(): number;
  122399. /**
  122400. * Sets the value of the `Cross` button
  122401. */
  122402. set buttonCross(value: number);
  122403. /**
  122404. * Gets the value of the `Circle` button
  122405. */
  122406. get buttonCircle(): number;
  122407. /**
  122408. * Sets the value of the `Circle` button
  122409. */
  122410. set buttonCircle(value: number);
  122411. /**
  122412. * Gets the value of the `Square` button
  122413. */
  122414. get buttonSquare(): number;
  122415. /**
  122416. * Sets the value of the `Square` button
  122417. */
  122418. set buttonSquare(value: number);
  122419. /**
  122420. * Gets the value of the `Triangle` button
  122421. */
  122422. get buttonTriangle(): number;
  122423. /**
  122424. * Sets the value of the `Triangle` button
  122425. */
  122426. set buttonTriangle(value: number);
  122427. /**
  122428. * Gets the value of the `Options` button
  122429. */
  122430. get buttonOptions(): number;
  122431. /**
  122432. * Sets the value of the `Options` button
  122433. */
  122434. set buttonOptions(value: number);
  122435. /**
  122436. * Gets the value of the `Share` button
  122437. */
  122438. get buttonShare(): number;
  122439. /**
  122440. * Sets the value of the `Share` button
  122441. */
  122442. set buttonShare(value: number);
  122443. /**
  122444. * Gets the value of the `L1` button
  122445. */
  122446. get buttonL1(): number;
  122447. /**
  122448. * Sets the value of the `L1` button
  122449. */
  122450. set buttonL1(value: number);
  122451. /**
  122452. * Gets the value of the `R1` button
  122453. */
  122454. get buttonR1(): number;
  122455. /**
  122456. * Sets the value of the `R1` button
  122457. */
  122458. set buttonR1(value: number);
  122459. /**
  122460. * Gets the value of the Left joystick
  122461. */
  122462. get buttonLeftStick(): number;
  122463. /**
  122464. * Sets the value of the Left joystick
  122465. */
  122466. set buttonLeftStick(value: number);
  122467. /**
  122468. * Gets the value of the Right joystick
  122469. */
  122470. get buttonRightStick(): number;
  122471. /**
  122472. * Sets the value of the Right joystick
  122473. */
  122474. set buttonRightStick(value: number);
  122475. /**
  122476. * Gets the value of D-pad up
  122477. */
  122478. get dPadUp(): number;
  122479. /**
  122480. * Sets the value of D-pad up
  122481. */
  122482. set dPadUp(value: number);
  122483. /**
  122484. * Gets the value of D-pad down
  122485. */
  122486. get dPadDown(): number;
  122487. /**
  122488. * Sets the value of D-pad down
  122489. */
  122490. set dPadDown(value: number);
  122491. /**
  122492. * Gets the value of D-pad left
  122493. */
  122494. get dPadLeft(): number;
  122495. /**
  122496. * Sets the value of D-pad left
  122497. */
  122498. set dPadLeft(value: number);
  122499. /**
  122500. * Gets the value of D-pad right
  122501. */
  122502. get dPadRight(): number;
  122503. /**
  122504. * Sets the value of D-pad right
  122505. */
  122506. set dPadRight(value: number);
  122507. /**
  122508. * Force the gamepad to synchronize with device values
  122509. */
  122510. update(): void;
  122511. /**
  122512. * Disposes the gamepad
  122513. */
  122514. dispose(): void;
  122515. }
  122516. }
  122517. declare module BABYLON {
  122518. /**
  122519. * Manager for handling gamepads
  122520. */
  122521. export class GamepadManager {
  122522. private _scene?;
  122523. private _babylonGamepads;
  122524. private _oneGamepadConnected;
  122525. /** @hidden */
  122526. _isMonitoring: boolean;
  122527. private _gamepadEventSupported;
  122528. private _gamepadSupport?;
  122529. /**
  122530. * observable to be triggered when the gamepad controller has been connected
  122531. */
  122532. onGamepadConnectedObservable: Observable<Gamepad>;
  122533. /**
  122534. * observable to be triggered when the gamepad controller has been disconnected
  122535. */
  122536. onGamepadDisconnectedObservable: Observable<Gamepad>;
  122537. private _onGamepadConnectedEvent;
  122538. private _onGamepadDisconnectedEvent;
  122539. /**
  122540. * Initializes the gamepad manager
  122541. * @param _scene BabylonJS scene
  122542. */
  122543. constructor(_scene?: Scene | undefined);
  122544. /**
  122545. * The gamepads in the game pad manager
  122546. */
  122547. get gamepads(): Gamepad[];
  122548. /**
  122549. * Get the gamepad controllers based on type
  122550. * @param type The type of gamepad controller
  122551. * @returns Nullable gamepad
  122552. */
  122553. getGamepadByType(type?: number): Nullable<Gamepad>;
  122554. /**
  122555. * Disposes the gamepad manager
  122556. */
  122557. dispose(): void;
  122558. private _addNewGamepad;
  122559. private _startMonitoringGamepads;
  122560. private _stopMonitoringGamepads;
  122561. /** @hidden */
  122562. _checkGamepadsStatus(): void;
  122563. private _updateGamepadObjects;
  122564. }
  122565. }
  122566. declare module BABYLON {
  122567. interface Scene {
  122568. /** @hidden */
  122569. _gamepadManager: Nullable<GamepadManager>;
  122570. /**
  122571. * Gets the gamepad manager associated with the scene
  122572. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  122573. */
  122574. gamepadManager: GamepadManager;
  122575. }
  122576. /**
  122577. * Interface representing a free camera inputs manager
  122578. */
  122579. interface FreeCameraInputsManager {
  122580. /**
  122581. * Adds gamepad input support to the FreeCameraInputsManager.
  122582. * @returns the FreeCameraInputsManager
  122583. */
  122584. addGamepad(): FreeCameraInputsManager;
  122585. }
  122586. /**
  122587. * Interface representing an arc rotate camera inputs manager
  122588. */
  122589. interface ArcRotateCameraInputsManager {
  122590. /**
  122591. * Adds gamepad input support to the ArcRotateCamera InputManager.
  122592. * @returns the camera inputs manager
  122593. */
  122594. addGamepad(): ArcRotateCameraInputsManager;
  122595. }
  122596. /**
  122597. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  122598. */
  122599. export class GamepadSystemSceneComponent implements ISceneComponent {
  122600. /**
  122601. * The component name helpfull to identify the component in the list of scene components.
  122602. */
  122603. readonly name: string;
  122604. /**
  122605. * The scene the component belongs to.
  122606. */
  122607. scene: Scene;
  122608. /**
  122609. * Creates a new instance of the component for the given scene
  122610. * @param scene Defines the scene to register the component in
  122611. */
  122612. constructor(scene: Scene);
  122613. /**
  122614. * Registers the component in a given scene
  122615. */
  122616. register(): void;
  122617. /**
  122618. * Rebuilds the elements related to this component in case of
  122619. * context lost for instance.
  122620. */
  122621. rebuild(): void;
  122622. /**
  122623. * Disposes the component and the associated ressources
  122624. */
  122625. dispose(): void;
  122626. private _beforeCameraUpdate;
  122627. }
  122628. }
  122629. declare module BABYLON {
  122630. /**
  122631. * 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,
  122632. * which still works and will still be found in many Playgrounds.
  122633. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122634. */
  122635. export class UniversalCamera extends TouchCamera {
  122636. /**
  122637. * Defines the gamepad rotation sensiblity.
  122638. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122639. */
  122640. get gamepadAngularSensibility(): number;
  122641. set gamepadAngularSensibility(value: number);
  122642. /**
  122643. * Defines the gamepad move sensiblity.
  122644. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122645. */
  122646. get gamepadMoveSensibility(): number;
  122647. set gamepadMoveSensibility(value: number);
  122648. /**
  122649. * 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,
  122650. * which still works and will still be found in many Playgrounds.
  122651. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122652. * @param name Define the name of the camera in the scene
  122653. * @param position Define the start position of the camera in the scene
  122654. * @param scene Define the scene the camera belongs to
  122655. */
  122656. constructor(name: string, position: Vector3, scene: Scene);
  122657. /**
  122658. * Gets the current object class name.
  122659. * @return the class name
  122660. */
  122661. getClassName(): string;
  122662. }
  122663. }
  122664. declare module BABYLON {
  122665. /**
  122666. * This represents a FPS type of camera. This is only here for back compat purpose.
  122667. * Please use the UniversalCamera instead as both are identical.
  122668. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122669. */
  122670. export class GamepadCamera extends UniversalCamera {
  122671. /**
  122672. * Instantiates a new Gamepad Camera
  122673. * This represents a FPS type of camera. This is only here for back compat purpose.
  122674. * Please use the UniversalCamera instead as both are identical.
  122675. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122676. * @param name Define the name of the camera in the scene
  122677. * @param position Define the start position of the camera in the scene
  122678. * @param scene Define the scene the camera belongs to
  122679. */
  122680. constructor(name: string, position: Vector3, scene: Scene);
  122681. /**
  122682. * Gets the current object class name.
  122683. * @return the class name
  122684. */
  122685. getClassName(): string;
  122686. }
  122687. }
  122688. declare module BABYLON {
  122689. /** @hidden */
  122690. export var passPixelShader: {
  122691. name: string;
  122692. shader: string;
  122693. };
  122694. }
  122695. declare module BABYLON {
  122696. /** @hidden */
  122697. export var passCubePixelShader: {
  122698. name: string;
  122699. shader: string;
  122700. };
  122701. }
  122702. declare module BABYLON {
  122703. /**
  122704. * PassPostProcess which produces an output the same as it's input
  122705. */
  122706. export class PassPostProcess extends PostProcess {
  122707. /**
  122708. * Creates the PassPostProcess
  122709. * @param name The name of the effect.
  122710. * @param options The required width/height ratio to downsize to before computing the render pass.
  122711. * @param camera The camera to apply the render pass to.
  122712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122713. * @param engine The engine which the post process will be applied. (default: current engine)
  122714. * @param reusable If the post process can be reused on the same frame. (default: false)
  122715. * @param textureType The type of texture to be used when performing the post processing.
  122716. * @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)
  122717. */
  122718. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122719. }
  122720. /**
  122721. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  122722. */
  122723. export class PassCubePostProcess extends PostProcess {
  122724. private _face;
  122725. /**
  122726. * Gets or sets the cube face to display.
  122727. * * 0 is +X
  122728. * * 1 is -X
  122729. * * 2 is +Y
  122730. * * 3 is -Y
  122731. * * 4 is +Z
  122732. * * 5 is -Z
  122733. */
  122734. get face(): number;
  122735. set face(value: number);
  122736. /**
  122737. * Creates the PassCubePostProcess
  122738. * @param name The name of the effect.
  122739. * @param options The required width/height ratio to downsize to before computing the render pass.
  122740. * @param camera The camera to apply the render pass to.
  122741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122742. * @param engine The engine which the post process will be applied. (default: current engine)
  122743. * @param reusable If the post process can be reused on the same frame. (default: false)
  122744. * @param textureType The type of texture to be used when performing the post processing.
  122745. * @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)
  122746. */
  122747. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122748. }
  122749. }
  122750. declare module BABYLON {
  122751. /** @hidden */
  122752. export var anaglyphPixelShader: {
  122753. name: string;
  122754. shader: string;
  122755. };
  122756. }
  122757. declare module BABYLON {
  122758. /**
  122759. * Postprocess used to generate anaglyphic rendering
  122760. */
  122761. export class AnaglyphPostProcess extends PostProcess {
  122762. private _passedProcess;
  122763. /**
  122764. * Creates a new AnaglyphPostProcess
  122765. * @param name defines postprocess name
  122766. * @param options defines creation options or target ratio scale
  122767. * @param rigCameras defines cameras using this postprocess
  122768. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  122769. * @param engine defines hosting engine
  122770. * @param reusable defines if the postprocess will be reused multiple times per frame
  122771. */
  122772. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  122773. }
  122774. }
  122775. declare module BABYLON {
  122776. /**
  122777. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  122778. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122779. */
  122780. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  122781. /**
  122782. * Creates a new AnaglyphArcRotateCamera
  122783. * @param name defines camera name
  122784. * @param alpha defines alpha angle (in radians)
  122785. * @param beta defines beta angle (in radians)
  122786. * @param radius defines radius
  122787. * @param target defines camera target
  122788. * @param interaxialDistance defines distance between each color axis
  122789. * @param scene defines the hosting scene
  122790. */
  122791. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  122792. /**
  122793. * Gets camera class name
  122794. * @returns AnaglyphArcRotateCamera
  122795. */
  122796. getClassName(): string;
  122797. }
  122798. }
  122799. declare module BABYLON {
  122800. /**
  122801. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  122802. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122803. */
  122804. export class AnaglyphFreeCamera extends FreeCamera {
  122805. /**
  122806. * Creates a new AnaglyphFreeCamera
  122807. * @param name defines camera name
  122808. * @param position defines initial position
  122809. * @param interaxialDistance defines distance between each color axis
  122810. * @param scene defines the hosting scene
  122811. */
  122812. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122813. /**
  122814. * Gets camera class name
  122815. * @returns AnaglyphFreeCamera
  122816. */
  122817. getClassName(): string;
  122818. }
  122819. }
  122820. declare module BABYLON {
  122821. /**
  122822. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  122823. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122824. */
  122825. export class AnaglyphGamepadCamera extends GamepadCamera {
  122826. /**
  122827. * Creates a new AnaglyphGamepadCamera
  122828. * @param name defines camera name
  122829. * @param position defines initial position
  122830. * @param interaxialDistance defines distance between each color axis
  122831. * @param scene defines the hosting scene
  122832. */
  122833. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122834. /**
  122835. * Gets camera class name
  122836. * @returns AnaglyphGamepadCamera
  122837. */
  122838. getClassName(): string;
  122839. }
  122840. }
  122841. declare module BABYLON {
  122842. /**
  122843. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  122844. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122845. */
  122846. export class AnaglyphUniversalCamera extends UniversalCamera {
  122847. /**
  122848. * Creates a new AnaglyphUniversalCamera
  122849. * @param name defines camera name
  122850. * @param position defines initial position
  122851. * @param interaxialDistance defines distance between each color axis
  122852. * @param scene defines the hosting scene
  122853. */
  122854. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122855. /**
  122856. * Gets camera class name
  122857. * @returns AnaglyphUniversalCamera
  122858. */
  122859. getClassName(): string;
  122860. }
  122861. }
  122862. declare module BABYLON {
  122863. /**
  122864. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  122865. * @see http://doc.babylonjs.com/features/cameras
  122866. */
  122867. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  122868. /**
  122869. * Creates a new StereoscopicArcRotateCamera
  122870. * @param name defines camera name
  122871. * @param alpha defines alpha angle (in radians)
  122872. * @param beta defines beta angle (in radians)
  122873. * @param radius defines radius
  122874. * @param target defines camera target
  122875. * @param interaxialDistance defines distance between each color axis
  122876. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122877. * @param scene defines the hosting scene
  122878. */
  122879. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122880. /**
  122881. * Gets camera class name
  122882. * @returns StereoscopicArcRotateCamera
  122883. */
  122884. getClassName(): string;
  122885. }
  122886. }
  122887. declare module BABYLON {
  122888. /**
  122889. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  122890. * @see http://doc.babylonjs.com/features/cameras
  122891. */
  122892. export class StereoscopicFreeCamera extends FreeCamera {
  122893. /**
  122894. * Creates a new StereoscopicFreeCamera
  122895. * @param name defines camera name
  122896. * @param position defines initial position
  122897. * @param interaxialDistance defines distance between each color axis
  122898. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122899. * @param scene defines the hosting scene
  122900. */
  122901. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122902. /**
  122903. * Gets camera class name
  122904. * @returns StereoscopicFreeCamera
  122905. */
  122906. getClassName(): string;
  122907. }
  122908. }
  122909. declare module BABYLON {
  122910. /**
  122911. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  122912. * @see http://doc.babylonjs.com/features/cameras
  122913. */
  122914. export class StereoscopicGamepadCamera extends GamepadCamera {
  122915. /**
  122916. * Creates a new StereoscopicGamepadCamera
  122917. * @param name defines camera name
  122918. * @param position defines initial position
  122919. * @param interaxialDistance defines distance between each color axis
  122920. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122921. * @param scene defines the hosting scene
  122922. */
  122923. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122924. /**
  122925. * Gets camera class name
  122926. * @returns StereoscopicGamepadCamera
  122927. */
  122928. getClassName(): string;
  122929. }
  122930. }
  122931. declare module BABYLON {
  122932. /**
  122933. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  122934. * @see http://doc.babylonjs.com/features/cameras
  122935. */
  122936. export class StereoscopicUniversalCamera extends UniversalCamera {
  122937. /**
  122938. * Creates a new StereoscopicUniversalCamera
  122939. * @param name defines camera name
  122940. * @param position defines initial position
  122941. * @param interaxialDistance defines distance between each color axis
  122942. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122943. * @param scene defines the hosting scene
  122944. */
  122945. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122946. /**
  122947. * Gets camera class name
  122948. * @returns StereoscopicUniversalCamera
  122949. */
  122950. getClassName(): string;
  122951. }
  122952. }
  122953. declare module BABYLON {
  122954. /**
  122955. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  122956. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122957. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122958. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122959. */
  122960. export class VirtualJoysticksCamera extends FreeCamera {
  122961. /**
  122962. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  122963. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122964. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122965. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122966. * @param name Define the name of the camera in the scene
  122967. * @param position Define the start position of the camera in the scene
  122968. * @param scene Define the scene the camera belongs to
  122969. */
  122970. constructor(name: string, position: Vector3, scene: Scene);
  122971. /**
  122972. * Gets the current object class name.
  122973. * @return the class name
  122974. */
  122975. getClassName(): string;
  122976. }
  122977. }
  122978. declare module BABYLON {
  122979. /**
  122980. * This represents all the required metrics to create a VR camera.
  122981. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  122982. */
  122983. export class VRCameraMetrics {
  122984. /**
  122985. * Define the horizontal resolution off the screen.
  122986. */
  122987. hResolution: number;
  122988. /**
  122989. * Define the vertical resolution off the screen.
  122990. */
  122991. vResolution: number;
  122992. /**
  122993. * Define the horizontal screen size.
  122994. */
  122995. hScreenSize: number;
  122996. /**
  122997. * Define the vertical screen size.
  122998. */
  122999. vScreenSize: number;
  123000. /**
  123001. * Define the vertical screen center position.
  123002. */
  123003. vScreenCenter: number;
  123004. /**
  123005. * Define the distance of the eyes to the screen.
  123006. */
  123007. eyeToScreenDistance: number;
  123008. /**
  123009. * Define the distance between both lenses
  123010. */
  123011. lensSeparationDistance: number;
  123012. /**
  123013. * Define the distance between both viewer's eyes.
  123014. */
  123015. interpupillaryDistance: number;
  123016. /**
  123017. * Define the distortion factor of the VR postprocess.
  123018. * Please, touch with care.
  123019. */
  123020. distortionK: number[];
  123021. /**
  123022. * Define the chromatic aberration correction factors for the VR post process.
  123023. */
  123024. chromaAbCorrection: number[];
  123025. /**
  123026. * Define the scale factor of the post process.
  123027. * The smaller the better but the slower.
  123028. */
  123029. postProcessScaleFactor: number;
  123030. /**
  123031. * Define an offset for the lens center.
  123032. */
  123033. lensCenterOffset: number;
  123034. /**
  123035. * Define if the current vr camera should compensate the distortion of the lense or not.
  123036. */
  123037. compensateDistortion: boolean;
  123038. /**
  123039. * Defines if multiview should be enabled when rendering (Default: false)
  123040. */
  123041. multiviewEnabled: boolean;
  123042. /**
  123043. * Gets the rendering aspect ratio based on the provided resolutions.
  123044. */
  123045. get aspectRatio(): number;
  123046. /**
  123047. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  123048. */
  123049. get aspectRatioFov(): number;
  123050. /**
  123051. * @hidden
  123052. */
  123053. get leftHMatrix(): Matrix;
  123054. /**
  123055. * @hidden
  123056. */
  123057. get rightHMatrix(): Matrix;
  123058. /**
  123059. * @hidden
  123060. */
  123061. get leftPreViewMatrix(): Matrix;
  123062. /**
  123063. * @hidden
  123064. */
  123065. get rightPreViewMatrix(): Matrix;
  123066. /**
  123067. * Get the default VRMetrics based on the most generic setup.
  123068. * @returns the default vr metrics
  123069. */
  123070. static GetDefault(): VRCameraMetrics;
  123071. }
  123072. }
  123073. declare module BABYLON {
  123074. /** @hidden */
  123075. export var vrDistortionCorrectionPixelShader: {
  123076. name: string;
  123077. shader: string;
  123078. };
  123079. }
  123080. declare module BABYLON {
  123081. /**
  123082. * VRDistortionCorrectionPostProcess used for mobile VR
  123083. */
  123084. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123085. private _isRightEye;
  123086. private _distortionFactors;
  123087. private _postProcessScaleFactor;
  123088. private _lensCenterOffset;
  123089. private _scaleIn;
  123090. private _scaleFactor;
  123091. private _lensCenter;
  123092. /**
  123093. * Initializes the VRDistortionCorrectionPostProcess
  123094. * @param name The name of the effect.
  123095. * @param camera The camera to apply the render pass to.
  123096. * @param isRightEye If this is for the right eye distortion
  123097. * @param vrMetrics All the required metrics for the VR camera
  123098. */
  123099. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  123100. }
  123101. }
  123102. declare module BABYLON {
  123103. /**
  123104. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  123105. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123106. */
  123107. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  123108. /**
  123109. * Creates a new VRDeviceOrientationArcRotateCamera
  123110. * @param name defines camera name
  123111. * @param alpha defines the camera rotation along the logitudinal axis
  123112. * @param beta defines the camera rotation along the latitudinal axis
  123113. * @param radius defines the camera distance from its target
  123114. * @param target defines the camera target
  123115. * @param scene defines the scene the camera belongs to
  123116. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123117. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123118. */
  123119. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123120. /**
  123121. * Gets camera class name
  123122. * @returns VRDeviceOrientationArcRotateCamera
  123123. */
  123124. getClassName(): string;
  123125. }
  123126. }
  123127. declare module BABYLON {
  123128. /**
  123129. * Camera used to simulate VR rendering (based on FreeCamera)
  123130. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123131. */
  123132. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  123133. /**
  123134. * Creates a new VRDeviceOrientationFreeCamera
  123135. * @param name defines camera name
  123136. * @param position defines the start position of the camera
  123137. * @param scene defines the scene the camera belongs to
  123138. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123139. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123140. */
  123141. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123142. /**
  123143. * Gets camera class name
  123144. * @returns VRDeviceOrientationFreeCamera
  123145. */
  123146. getClassName(): string;
  123147. }
  123148. }
  123149. declare module BABYLON {
  123150. /**
  123151. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  123152. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123153. */
  123154. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  123155. /**
  123156. * Creates a new VRDeviceOrientationGamepadCamera
  123157. * @param name defines camera name
  123158. * @param position defines the start position of the camera
  123159. * @param scene defines the scene the camera belongs to
  123160. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123161. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123162. */
  123163. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123164. /**
  123165. * Gets camera class name
  123166. * @returns VRDeviceOrientationGamepadCamera
  123167. */
  123168. getClassName(): string;
  123169. }
  123170. }
  123171. declare module BABYLON {
  123172. /** @hidden */
  123173. export var imageProcessingPixelShader: {
  123174. name: string;
  123175. shader: string;
  123176. };
  123177. }
  123178. declare module BABYLON {
  123179. /**
  123180. * ImageProcessingPostProcess
  123181. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123182. */
  123183. export class ImageProcessingPostProcess extends PostProcess {
  123184. /**
  123185. * Default configuration related to image processing available in the PBR Material.
  123186. */
  123187. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123188. /**
  123189. * Gets the image processing configuration used either in this material.
  123190. */
  123191. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123192. /**
  123193. * Sets the Default image processing configuration used either in the this material.
  123194. *
  123195. * If sets to null, the scene one is in use.
  123196. */
  123197. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  123198. /**
  123199. * Keep track of the image processing observer to allow dispose and replace.
  123200. */
  123201. private _imageProcessingObserver;
  123202. /**
  123203. * Attaches a new image processing configuration to the PBR Material.
  123204. * @param configuration
  123205. */
  123206. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  123207. /**
  123208. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123209. */
  123210. get colorCurves(): Nullable<ColorCurves>;
  123211. /**
  123212. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123213. */
  123214. set colorCurves(value: Nullable<ColorCurves>);
  123215. /**
  123216. * Gets wether the color curves effect is enabled.
  123217. */
  123218. get colorCurvesEnabled(): boolean;
  123219. /**
  123220. * Sets wether the color curves effect is enabled.
  123221. */
  123222. set colorCurvesEnabled(value: boolean);
  123223. /**
  123224. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123225. */
  123226. get colorGradingTexture(): Nullable<BaseTexture>;
  123227. /**
  123228. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123229. */
  123230. set colorGradingTexture(value: Nullable<BaseTexture>);
  123231. /**
  123232. * Gets wether the color grading effect is enabled.
  123233. */
  123234. get colorGradingEnabled(): boolean;
  123235. /**
  123236. * Gets wether the color grading effect is enabled.
  123237. */
  123238. set colorGradingEnabled(value: boolean);
  123239. /**
  123240. * Gets exposure used in the effect.
  123241. */
  123242. get exposure(): number;
  123243. /**
  123244. * Sets exposure used in the effect.
  123245. */
  123246. set exposure(value: number);
  123247. /**
  123248. * Gets wether tonemapping is enabled or not.
  123249. */
  123250. get toneMappingEnabled(): boolean;
  123251. /**
  123252. * Sets wether tonemapping is enabled or not
  123253. */
  123254. set toneMappingEnabled(value: boolean);
  123255. /**
  123256. * Gets the type of tone mapping effect.
  123257. */
  123258. get toneMappingType(): number;
  123259. /**
  123260. * Sets the type of tone mapping effect.
  123261. */
  123262. set toneMappingType(value: number);
  123263. /**
  123264. * Gets contrast used in the effect.
  123265. */
  123266. get contrast(): number;
  123267. /**
  123268. * Sets contrast used in the effect.
  123269. */
  123270. set contrast(value: number);
  123271. /**
  123272. * Gets Vignette stretch size.
  123273. */
  123274. get vignetteStretch(): number;
  123275. /**
  123276. * Sets Vignette stretch size.
  123277. */
  123278. set vignetteStretch(value: number);
  123279. /**
  123280. * Gets Vignette centre X Offset.
  123281. */
  123282. get vignetteCentreX(): number;
  123283. /**
  123284. * Sets Vignette centre X Offset.
  123285. */
  123286. set vignetteCentreX(value: number);
  123287. /**
  123288. * Gets Vignette centre Y Offset.
  123289. */
  123290. get vignetteCentreY(): number;
  123291. /**
  123292. * Sets Vignette centre Y Offset.
  123293. */
  123294. set vignetteCentreY(value: number);
  123295. /**
  123296. * Gets Vignette weight or intensity of the vignette effect.
  123297. */
  123298. get vignetteWeight(): number;
  123299. /**
  123300. * Sets Vignette weight or intensity of the vignette effect.
  123301. */
  123302. set vignetteWeight(value: number);
  123303. /**
  123304. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123305. * if vignetteEnabled is set to true.
  123306. */
  123307. get vignetteColor(): Color4;
  123308. /**
  123309. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123310. * if vignetteEnabled is set to true.
  123311. */
  123312. set vignetteColor(value: Color4);
  123313. /**
  123314. * Gets Camera field of view used by the Vignette effect.
  123315. */
  123316. get vignetteCameraFov(): number;
  123317. /**
  123318. * Sets Camera field of view used by the Vignette effect.
  123319. */
  123320. set vignetteCameraFov(value: number);
  123321. /**
  123322. * Gets the vignette blend mode allowing different kind of effect.
  123323. */
  123324. get vignetteBlendMode(): number;
  123325. /**
  123326. * Sets the vignette blend mode allowing different kind of effect.
  123327. */
  123328. set vignetteBlendMode(value: number);
  123329. /**
  123330. * Gets wether the vignette effect is enabled.
  123331. */
  123332. get vignetteEnabled(): boolean;
  123333. /**
  123334. * Sets wether the vignette effect is enabled.
  123335. */
  123336. set vignetteEnabled(value: boolean);
  123337. private _fromLinearSpace;
  123338. /**
  123339. * Gets wether the input of the processing is in Gamma or Linear Space.
  123340. */
  123341. get fromLinearSpace(): boolean;
  123342. /**
  123343. * Sets wether the input of the processing is in Gamma or Linear Space.
  123344. */
  123345. set fromLinearSpace(value: boolean);
  123346. /**
  123347. * Defines cache preventing GC.
  123348. */
  123349. private _defines;
  123350. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  123351. /**
  123352. * "ImageProcessingPostProcess"
  123353. * @returns "ImageProcessingPostProcess"
  123354. */
  123355. getClassName(): string;
  123356. protected _updateParameters(): void;
  123357. dispose(camera?: Camera): void;
  123358. }
  123359. }
  123360. declare module BABYLON {
  123361. /**
  123362. * Class containing static functions to help procedurally build meshes
  123363. */
  123364. export class GroundBuilder {
  123365. /**
  123366. * Creates a ground mesh
  123367. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123368. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123370. * @param name defines the name of the mesh
  123371. * @param options defines the options used to create the mesh
  123372. * @param scene defines the hosting scene
  123373. * @returns the ground mesh
  123374. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123375. */
  123376. static CreateGround(name: string, options: {
  123377. width?: number;
  123378. height?: number;
  123379. subdivisions?: number;
  123380. subdivisionsX?: number;
  123381. subdivisionsY?: number;
  123382. updatable?: boolean;
  123383. }, scene: any): Mesh;
  123384. /**
  123385. * Creates a tiled ground mesh
  123386. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123387. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123388. * * 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
  123389. * * 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
  123390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123391. * @param name defines the name of the mesh
  123392. * @param options defines the options used to create the mesh
  123393. * @param scene defines the hosting scene
  123394. * @returns the tiled ground mesh
  123395. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123396. */
  123397. static CreateTiledGround(name: string, options: {
  123398. xmin: number;
  123399. zmin: number;
  123400. xmax: number;
  123401. zmax: number;
  123402. subdivisions?: {
  123403. w: number;
  123404. h: number;
  123405. };
  123406. precision?: {
  123407. w: number;
  123408. h: number;
  123409. };
  123410. updatable?: boolean;
  123411. }, scene?: Nullable<Scene>): Mesh;
  123412. /**
  123413. * Creates a ground mesh from a height map
  123414. * * The parameter `url` sets the URL of the height map image resource.
  123415. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123416. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123417. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123418. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123419. * * 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.
  123420. * * 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).
  123421. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123423. * @param name defines the name of the mesh
  123424. * @param url defines the url to the height map
  123425. * @param options defines the options used to create the mesh
  123426. * @param scene defines the hosting scene
  123427. * @returns the ground mesh
  123428. * @see https://doc.babylonjs.com/babylon101/height_map
  123429. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123430. */
  123431. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123432. width?: number;
  123433. height?: number;
  123434. subdivisions?: number;
  123435. minHeight?: number;
  123436. maxHeight?: number;
  123437. colorFilter?: Color3;
  123438. alphaFilter?: number;
  123439. updatable?: boolean;
  123440. onReady?: (mesh: GroundMesh) => void;
  123441. }, scene?: Nullable<Scene>): GroundMesh;
  123442. }
  123443. }
  123444. declare module BABYLON {
  123445. /**
  123446. * Class containing static functions to help procedurally build meshes
  123447. */
  123448. export class TorusBuilder {
  123449. /**
  123450. * Creates a torus mesh
  123451. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123452. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123453. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123457. * @param name defines the name of the mesh
  123458. * @param options defines the options used to create the mesh
  123459. * @param scene defines the hosting scene
  123460. * @returns the torus mesh
  123461. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123462. */
  123463. static CreateTorus(name: string, options: {
  123464. diameter?: number;
  123465. thickness?: number;
  123466. tessellation?: number;
  123467. updatable?: boolean;
  123468. sideOrientation?: number;
  123469. frontUVs?: Vector4;
  123470. backUVs?: Vector4;
  123471. }, scene: any): Mesh;
  123472. }
  123473. }
  123474. declare module BABYLON {
  123475. /**
  123476. * Class containing static functions to help procedurally build meshes
  123477. */
  123478. export class CylinderBuilder {
  123479. /**
  123480. * Creates a cylinder or a cone mesh
  123481. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123482. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123483. * * 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.
  123484. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123485. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123486. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123487. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123488. * * 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).
  123489. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123490. * * 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).
  123491. * * 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
  123492. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123493. * * 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
  123494. * * 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.
  123495. * * If `enclose` is false, a ring surface is one element.
  123496. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123497. * * 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
  123498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123501. * @param name defines the name of the mesh
  123502. * @param options defines the options used to create the mesh
  123503. * @param scene defines the hosting scene
  123504. * @returns the cylinder mesh
  123505. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123506. */
  123507. static CreateCylinder(name: string, options: {
  123508. height?: number;
  123509. diameterTop?: number;
  123510. diameterBottom?: number;
  123511. diameter?: number;
  123512. tessellation?: number;
  123513. subdivisions?: number;
  123514. arc?: number;
  123515. faceColors?: Color4[];
  123516. faceUV?: Vector4[];
  123517. updatable?: boolean;
  123518. hasRings?: boolean;
  123519. enclose?: boolean;
  123520. cap?: number;
  123521. sideOrientation?: number;
  123522. frontUVs?: Vector4;
  123523. backUVs?: Vector4;
  123524. }, scene: any): Mesh;
  123525. }
  123526. }
  123527. declare module BABYLON {
  123528. /**
  123529. * States of the webXR experience
  123530. */
  123531. export enum WebXRState {
  123532. /**
  123533. * Transitioning to being in XR mode
  123534. */
  123535. ENTERING_XR = 0,
  123536. /**
  123537. * Transitioning to non XR mode
  123538. */
  123539. EXITING_XR = 1,
  123540. /**
  123541. * In XR mode and presenting
  123542. */
  123543. IN_XR = 2,
  123544. /**
  123545. * Not entered XR mode
  123546. */
  123547. NOT_IN_XR = 3
  123548. }
  123549. /**
  123550. * Abstraction of the XR render target
  123551. */
  123552. export interface WebXRRenderTarget extends IDisposable {
  123553. /**
  123554. * xrpresent context of the canvas which can be used to display/mirror xr content
  123555. */
  123556. canvasContext: WebGLRenderingContext;
  123557. /**
  123558. * xr layer for the canvas
  123559. */
  123560. xrLayer: Nullable<XRWebGLLayer>;
  123561. /**
  123562. * Initializes the xr layer for the session
  123563. * @param xrSession xr session
  123564. * @returns a promise that will resolve once the XR Layer has been created
  123565. */
  123566. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123567. }
  123568. }
  123569. declare module BABYLON {
  123570. /**
  123571. * COnfiguration object for WebXR output canvas
  123572. */
  123573. export class WebXRManagedOutputCanvasOptions {
  123574. /**
  123575. * An optional canvas in case you wish to create it yourself and provide it here.
  123576. * If not provided, a new canvas will be created
  123577. */
  123578. canvasElement?: HTMLCanvasElement;
  123579. /**
  123580. * Options for this XR Layer output
  123581. */
  123582. canvasOptions?: XRWebGLLayerOptions;
  123583. /**
  123584. * CSS styling for a newly created canvas (if not provided)
  123585. */
  123586. newCanvasCssStyle?: string;
  123587. /**
  123588. * Get the default values of the configuration object
  123589. * @returns default values of this configuration object
  123590. */
  123591. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  123592. }
  123593. /**
  123594. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  123595. */
  123596. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  123597. private _options;
  123598. private _canvas;
  123599. private _engine;
  123600. /**
  123601. * Rendering context of the canvas which can be used to display/mirror xr content
  123602. */
  123603. canvasContext: WebGLRenderingContext;
  123604. /**
  123605. * xr layer for the canvas
  123606. */
  123607. xrLayer: Nullable<XRWebGLLayer>;
  123608. /**
  123609. * Initializes the canvas to be added/removed upon entering/exiting xr
  123610. * @param _xrSessionManager The XR Session manager
  123611. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  123612. */
  123613. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  123614. /**
  123615. * Disposes of the object
  123616. */
  123617. dispose(): void;
  123618. /**
  123619. * Initializes the xr layer for the session
  123620. * @param xrSession xr session
  123621. * @returns a promise that will resolve once the XR Layer has been created
  123622. */
  123623. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123624. private _addCanvas;
  123625. private _removeCanvas;
  123626. private _setManagedOutputCanvas;
  123627. }
  123628. }
  123629. declare module BABYLON {
  123630. /**
  123631. * Manages an XRSession to work with Babylon's engine
  123632. * @see https://doc.babylonjs.com/how_to/webxr
  123633. */
  123634. export class WebXRSessionManager implements IDisposable {
  123635. /** The scene which the session should be created for */
  123636. scene: Scene;
  123637. private _referenceSpace;
  123638. private _rttProvider;
  123639. private _sessionEnded;
  123640. private _xrNavigator;
  123641. private baseLayer;
  123642. /**
  123643. * The base reference space from which the session started. good if you want to reset your
  123644. * reference space
  123645. */
  123646. baseReferenceSpace: XRReferenceSpace;
  123647. /**
  123648. * Current XR frame
  123649. */
  123650. currentFrame: Nullable<XRFrame>;
  123651. /** WebXR timestamp updated every frame */
  123652. currentTimestamp: number;
  123653. /**
  123654. * Used just in case of a failure to initialize an immersive session.
  123655. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  123656. */
  123657. defaultHeightCompensation: number;
  123658. /**
  123659. * Fires every time a new xrFrame arrives which can be used to update the camera
  123660. */
  123661. onXRFrameObservable: Observable<XRFrame>;
  123662. /**
  123663. * Fires when the reference space changed
  123664. */
  123665. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  123666. /**
  123667. * Fires when the xr session is ended either by the device or manually done
  123668. */
  123669. onXRSessionEnded: Observable<any>;
  123670. /**
  123671. * Fires when the xr session is ended either by the device or manually done
  123672. */
  123673. onXRSessionInit: Observable<XRSession>;
  123674. /**
  123675. * Underlying xr session
  123676. */
  123677. session: XRSession;
  123678. /**
  123679. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  123680. * or get the offset the player is currently at.
  123681. */
  123682. viewerReferenceSpace: XRReferenceSpace;
  123683. /**
  123684. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  123685. * @param scene The scene which the session should be created for
  123686. */
  123687. constructor(
  123688. /** The scene which the session should be created for */
  123689. scene: Scene);
  123690. /**
  123691. * The current reference space used in this session. This reference space can constantly change!
  123692. * It is mainly used to offset the camera's position.
  123693. */
  123694. get referenceSpace(): XRReferenceSpace;
  123695. /**
  123696. * Set a new reference space and triggers the observable
  123697. */
  123698. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  123699. /**
  123700. * Disposes of the session manager
  123701. */
  123702. dispose(): void;
  123703. /**
  123704. * Stops the xrSession and restores the render loop
  123705. * @returns Promise which resolves after it exits XR
  123706. */
  123707. exitXRAsync(): Promise<void>;
  123708. /**
  123709. * Gets the correct render target texture to be rendered this frame for this eye
  123710. * @param eye the eye for which to get the render target
  123711. * @returns the render target for the specified eye
  123712. */
  123713. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  123714. /**
  123715. * Creates a WebXRRenderTarget object for the XR session
  123716. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  123717. * @param options optional options to provide when creating a new render target
  123718. * @returns a WebXR render target to which the session can render
  123719. */
  123720. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  123721. /**
  123722. * Initializes the manager
  123723. * After initialization enterXR can be called to start an XR session
  123724. * @returns Promise which resolves after it is initialized
  123725. */
  123726. initializeAsync(): Promise<void>;
  123727. /**
  123728. * Initializes an xr session
  123729. * @param xrSessionMode mode to initialize
  123730. * @param xrSessionInit defines optional and required values to pass to the session builder
  123731. * @returns a promise which will resolve once the session has been initialized
  123732. */
  123733. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  123734. /**
  123735. * Checks if a session would be supported for the creation options specified
  123736. * @param sessionMode session mode to check if supported eg. immersive-vr
  123737. * @returns A Promise that resolves to true if supported and false if not
  123738. */
  123739. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123740. /**
  123741. * Resets the reference space to the one started the session
  123742. */
  123743. resetReferenceSpace(): void;
  123744. /**
  123745. * Starts rendering to the xr layer
  123746. */
  123747. runXRRenderLoop(): void;
  123748. /**
  123749. * Sets the reference space on the xr session
  123750. * @param referenceSpaceType space to set
  123751. * @returns a promise that will resolve once the reference space has been set
  123752. */
  123753. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  123754. /**
  123755. * Updates the render state of the session
  123756. * @param state state to set
  123757. * @returns a promise that resolves once the render state has been updated
  123758. */
  123759. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  123760. /**
  123761. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  123762. * @param sessionMode defines the session to test
  123763. * @returns a promise with boolean as final value
  123764. */
  123765. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123766. private _createRenderTargetTexture;
  123767. }
  123768. }
  123769. declare module BABYLON {
  123770. /**
  123771. * WebXR Camera which holds the views for the xrSession
  123772. * @see https://doc.babylonjs.com/how_to/webxr_camera
  123773. */
  123774. export class WebXRCamera extends FreeCamera {
  123775. private _xrSessionManager;
  123776. private _firstFrame;
  123777. private _referenceQuaternion;
  123778. private _referencedPosition;
  123779. private _xrInvPositionCache;
  123780. private _xrInvQuaternionCache;
  123781. /**
  123782. * Should position compensation execute on first frame.
  123783. * This is used when copying the position from a native (non XR) camera
  123784. */
  123785. compensateOnFirstFrame: boolean;
  123786. /**
  123787. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  123788. * @param name the name of the camera
  123789. * @param scene the scene to add the camera to
  123790. * @param _xrSessionManager a constructed xr session manager
  123791. */
  123792. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  123793. /**
  123794. * Return the user's height, unrelated to the current ground.
  123795. * This will be the y position of this camera, when ground level is 0.
  123796. */
  123797. get realWorldHeight(): number;
  123798. /** @hidden */
  123799. _updateForDualEyeDebugging(): void;
  123800. /**
  123801. * Sets this camera's transformation based on a non-vr camera
  123802. * @param otherCamera the non-vr camera to copy the transformation from
  123803. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  123804. */
  123805. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  123806. /**
  123807. * Gets the current instance class name ("WebXRCamera").
  123808. * @returns the class name
  123809. */
  123810. getClassName(): string;
  123811. /**
  123812. * Overriding the _getViewMatrix function, as it is computed by WebXR
  123813. */
  123814. _getViewMatrix(): Matrix;
  123815. private _updateFromXRSession;
  123816. private _updateNumberOfRigCameras;
  123817. private _updateReferenceSpace;
  123818. private _updateReferenceSpaceOffset;
  123819. }
  123820. }
  123821. declare module BABYLON {
  123822. /**
  123823. * Defining the interface required for a (webxr) feature
  123824. */
  123825. export interface IWebXRFeature extends IDisposable {
  123826. /**
  123827. * Is this feature attached
  123828. */
  123829. attached: boolean;
  123830. /**
  123831. * Should auto-attach be disabled?
  123832. */
  123833. disableAutoAttach: boolean;
  123834. /**
  123835. * Attach the feature to the session
  123836. * Will usually be called by the features manager
  123837. *
  123838. * @param force should attachment be forced (even when already attached)
  123839. * @returns true if successful.
  123840. */
  123841. attach(force?: boolean): boolean;
  123842. /**
  123843. * Detach the feature from the session
  123844. * Will usually be called by the features manager
  123845. *
  123846. * @returns true if successful.
  123847. */
  123848. detach(): boolean;
  123849. }
  123850. /**
  123851. * A list of the currently available features without referencing them
  123852. */
  123853. export class WebXRFeatureName {
  123854. /**
  123855. * The name of the anchor system feature
  123856. */
  123857. static ANCHOR_SYSTEM: string;
  123858. /**
  123859. * The name of the background remover feature
  123860. */
  123861. static BACKGROUND_REMOVER: string;
  123862. /**
  123863. * The name of the hit test feature
  123864. */
  123865. static HIT_TEST: string;
  123866. /**
  123867. * physics impostors for xr controllers feature
  123868. */
  123869. static PHYSICS_CONTROLLERS: string;
  123870. /**
  123871. * The name of the plane detection feature
  123872. */
  123873. static PLANE_DETECTION: string;
  123874. /**
  123875. * The name of the pointer selection feature
  123876. */
  123877. static POINTER_SELECTION: string;
  123878. /**
  123879. * The name of the teleportation feature
  123880. */
  123881. static TELEPORTATION: string;
  123882. }
  123883. /**
  123884. * Defining the constructor of a feature. Used to register the modules.
  123885. */
  123886. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  123887. /**
  123888. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  123889. * It is mainly used in AR sessions.
  123890. *
  123891. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  123892. */
  123893. export class WebXRFeaturesManager implements IDisposable {
  123894. private _xrSessionManager;
  123895. private static readonly _AvailableFeatures;
  123896. private _features;
  123897. /**
  123898. * constructs a new features manages.
  123899. *
  123900. * @param _xrSessionManager an instance of WebXRSessionManager
  123901. */
  123902. constructor(_xrSessionManager: WebXRSessionManager);
  123903. /**
  123904. * Used to register a module. After calling this function a developer can use this feature in the scene.
  123905. * Mainly used internally.
  123906. *
  123907. * @param featureName the name of the feature to register
  123908. * @param constructorFunction the function used to construct the module
  123909. * @param version the (babylon) version of the module
  123910. * @param stable is that a stable version of this module
  123911. */
  123912. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  123913. /**
  123914. * Returns a constructor of a specific feature.
  123915. *
  123916. * @param featureName the name of the feature to construct
  123917. * @param version the version of the feature to load
  123918. * @param xrSessionManager the xrSessionManager. Used to construct the module
  123919. * @param options optional options provided to the module.
  123920. * @returns a function that, when called, will return a new instance of this feature
  123921. */
  123922. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  123923. /**
  123924. * Can be used to return the list of features currently registered
  123925. *
  123926. * @returns an Array of available features
  123927. */
  123928. static GetAvailableFeatures(): string[];
  123929. /**
  123930. * Gets the versions available for a specific feature
  123931. * @param featureName the name of the feature
  123932. * @returns an array with the available versions
  123933. */
  123934. static GetAvailableVersions(featureName: string): string[];
  123935. /**
  123936. * Return the latest unstable version of this feature
  123937. * @param featureName the name of the feature to search
  123938. * @returns the version number. if not found will return -1
  123939. */
  123940. static GetLatestVersionOfFeature(featureName: string): number;
  123941. /**
  123942. * Return the latest stable version of this feature
  123943. * @param featureName the name of the feature to search
  123944. * @returns the version number. if not found will return -1
  123945. */
  123946. static GetStableVersionOfFeature(featureName: string): number;
  123947. /**
  123948. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  123949. * Can be used during a session to start a feature
  123950. * @param featureName the name of feature to attach
  123951. */
  123952. attachFeature(featureName: string): void;
  123953. /**
  123954. * Can be used inside a session or when the session ends to detach a specific feature
  123955. * @param featureName the name of the feature to detach
  123956. */
  123957. detachFeature(featureName: string): void;
  123958. /**
  123959. * Used to disable an already-enabled feature
  123960. * The feature will be disposed and will be recreated once enabled.
  123961. * @param featureName the feature to disable
  123962. * @returns true if disable was successful
  123963. */
  123964. disableFeature(featureName: string | {
  123965. Name: string;
  123966. }): boolean;
  123967. /**
  123968. * dispose this features manager
  123969. */
  123970. dispose(): void;
  123971. /**
  123972. * 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.
  123973. * 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.
  123974. *
  123975. * @param featureName the name of the feature to load or the class of the feature
  123976. * @param version optional version to load. if not provided the latest version will be enabled
  123977. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  123978. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  123979. * @returns a new constructed feature or throws an error if feature not found.
  123980. */
  123981. enableFeature(featureName: string | {
  123982. Name: string;
  123983. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  123984. /**
  123985. * get the implementation of an enabled feature.
  123986. * @param featureName the name of the feature to load
  123987. * @returns the feature class, if found
  123988. */
  123989. getEnabledFeature(featureName: string): IWebXRFeature;
  123990. /**
  123991. * Get the list of enabled features
  123992. * @returns an array of enabled features
  123993. */
  123994. getEnabledFeatures(): string[];
  123995. }
  123996. }
  123997. declare module BABYLON {
  123998. /**
  123999. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  124000. * @see https://doc.babylonjs.com/how_to/webxr
  124001. */
  124002. export class WebXRExperienceHelper implements IDisposable {
  124003. private scene;
  124004. private _nonVRCamera;
  124005. private _originalSceneAutoClear;
  124006. private _supported;
  124007. /**
  124008. * Camera used to render xr content
  124009. */
  124010. camera: WebXRCamera;
  124011. /** A features manager for this xr session */
  124012. featuresManager: WebXRFeaturesManager;
  124013. /**
  124014. * Observers registered here will be triggered after the camera's initial transformation is set
  124015. * This can be used to set a different ground level or an extra rotation.
  124016. *
  124017. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  124018. * to the position set after this observable is done executing.
  124019. */
  124020. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  124021. /**
  124022. * Fires when the state of the experience helper has changed
  124023. */
  124024. onStateChangedObservable: Observable<WebXRState>;
  124025. /** Session manager used to keep track of xr session */
  124026. sessionManager: WebXRSessionManager;
  124027. /**
  124028. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  124029. */
  124030. state: WebXRState;
  124031. /**
  124032. * Creates a WebXRExperienceHelper
  124033. * @param scene The scene the helper should be created in
  124034. */
  124035. private constructor();
  124036. /**
  124037. * Creates the experience helper
  124038. * @param scene the scene to attach the experience helper to
  124039. * @returns a promise for the experience helper
  124040. */
  124041. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  124042. /**
  124043. * Disposes of the experience helper
  124044. */
  124045. dispose(): void;
  124046. /**
  124047. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  124048. * @param sessionMode options for the XR session
  124049. * @param referenceSpaceType frame of reference of the XR session
  124050. * @param renderTarget the output canvas that will be used to enter XR mode
  124051. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  124052. * @returns promise that resolves after xr mode has entered
  124053. */
  124054. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  124055. /**
  124056. * Exits XR mode and returns the scene to its original state
  124057. * @returns promise that resolves after xr mode has exited
  124058. */
  124059. exitXRAsync(): Promise<void>;
  124060. private _nonXRToXRCamera;
  124061. private _setState;
  124062. }
  124063. }
  124064. declare module BABYLON {
  124065. /**
  124066. * X-Y values for axes in WebXR
  124067. */
  124068. export interface IWebXRMotionControllerAxesValue {
  124069. /**
  124070. * The value of the x axis
  124071. */
  124072. x: number;
  124073. /**
  124074. * The value of the y-axis
  124075. */
  124076. y: number;
  124077. }
  124078. /**
  124079. * changed / previous values for the values of this component
  124080. */
  124081. export interface IWebXRMotionControllerComponentChangesValues<T> {
  124082. /**
  124083. * current (this frame) value
  124084. */
  124085. current: T;
  124086. /**
  124087. * previous (last change) value
  124088. */
  124089. previous: T;
  124090. }
  124091. /**
  124092. * Represents changes in the component between current frame and last values recorded
  124093. */
  124094. export interface IWebXRMotionControllerComponentChanges {
  124095. /**
  124096. * will be populated with previous and current values if axes changed
  124097. */
  124098. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  124099. /**
  124100. * will be populated with previous and current values if pressed changed
  124101. */
  124102. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124103. /**
  124104. * will be populated with previous and current values if touched changed
  124105. */
  124106. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124107. /**
  124108. * will be populated with previous and current values if value changed
  124109. */
  124110. value?: IWebXRMotionControllerComponentChangesValues<number>;
  124111. }
  124112. /**
  124113. * This class represents a single component (for example button or thumbstick) of a motion controller
  124114. */
  124115. export class WebXRControllerComponent implements IDisposable {
  124116. /**
  124117. * the id of this component
  124118. */
  124119. id: string;
  124120. /**
  124121. * the type of the component
  124122. */
  124123. type: MotionControllerComponentType;
  124124. private _buttonIndex;
  124125. private _axesIndices;
  124126. private _axes;
  124127. private _changes;
  124128. private _currentValue;
  124129. private _hasChanges;
  124130. private _pressed;
  124131. private _touched;
  124132. /**
  124133. * button component type
  124134. */
  124135. static BUTTON_TYPE: MotionControllerComponentType;
  124136. /**
  124137. * squeeze component type
  124138. */
  124139. static SQUEEZE_TYPE: MotionControllerComponentType;
  124140. /**
  124141. * Thumbstick component type
  124142. */
  124143. static THUMBSTICK_TYPE: MotionControllerComponentType;
  124144. /**
  124145. * Touchpad component type
  124146. */
  124147. static TOUCHPAD_TYPE: MotionControllerComponentType;
  124148. /**
  124149. * trigger component type
  124150. */
  124151. static TRIGGER_TYPE: MotionControllerComponentType;
  124152. /**
  124153. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  124154. * the axes data changes
  124155. */
  124156. onAxisValueChangedObservable: Observable<{
  124157. x: number;
  124158. y: number;
  124159. }>;
  124160. /**
  124161. * Observers registered here will be triggered when the state of a button changes
  124162. * State change is either pressed / touched / value
  124163. */
  124164. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  124165. /**
  124166. * Creates a new component for a motion controller.
  124167. * It is created by the motion controller itself
  124168. *
  124169. * @param id the id of this component
  124170. * @param type the type of the component
  124171. * @param _buttonIndex index in the buttons array of the gamepad
  124172. * @param _axesIndices indices of the values in the axes array of the gamepad
  124173. */
  124174. constructor(
  124175. /**
  124176. * the id of this component
  124177. */
  124178. id: string,
  124179. /**
  124180. * the type of the component
  124181. */
  124182. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  124183. /**
  124184. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  124185. */
  124186. get axes(): IWebXRMotionControllerAxesValue;
  124187. /**
  124188. * Get the changes. Elements will be populated only if they changed with their previous and current value
  124189. */
  124190. get changes(): IWebXRMotionControllerComponentChanges;
  124191. /**
  124192. * Return whether or not the component changed the last frame
  124193. */
  124194. get hasChanges(): boolean;
  124195. /**
  124196. * is the button currently pressed
  124197. */
  124198. get pressed(): boolean;
  124199. /**
  124200. * is the button currently touched
  124201. */
  124202. get touched(): boolean;
  124203. /**
  124204. * Get the current value of this component
  124205. */
  124206. get value(): number;
  124207. /**
  124208. * Dispose this component
  124209. */
  124210. dispose(): void;
  124211. /**
  124212. * Are there axes correlating to this component
  124213. * @return true is axes data is available
  124214. */
  124215. isAxes(): boolean;
  124216. /**
  124217. * Is this component a button (hence - pressable)
  124218. * @returns true if can be pressed
  124219. */
  124220. isButton(): boolean;
  124221. /**
  124222. * update this component using the gamepad object it is in. Called on every frame
  124223. * @param nativeController the native gamepad controller object
  124224. */
  124225. update(nativeController: IMinimalMotionControllerObject): void;
  124226. }
  124227. }
  124228. declare module BABYLON {
  124229. /**
  124230. * Class used to represent data loading progression
  124231. */
  124232. export class SceneLoaderProgressEvent {
  124233. /** defines if data length to load can be evaluated */
  124234. readonly lengthComputable: boolean;
  124235. /** defines the loaded data length */
  124236. readonly loaded: number;
  124237. /** defines the data length to load */
  124238. readonly total: number;
  124239. /**
  124240. * Create a new progress event
  124241. * @param lengthComputable defines if data length to load can be evaluated
  124242. * @param loaded defines the loaded data length
  124243. * @param total defines the data length to load
  124244. */
  124245. constructor(
  124246. /** defines if data length to load can be evaluated */
  124247. lengthComputable: boolean,
  124248. /** defines the loaded data length */
  124249. loaded: number,
  124250. /** defines the data length to load */
  124251. total: number);
  124252. /**
  124253. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  124254. * @param event defines the source event
  124255. * @returns a new SceneLoaderProgressEvent
  124256. */
  124257. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  124258. }
  124259. /**
  124260. * Interface used by SceneLoader plugins to define supported file extensions
  124261. */
  124262. export interface ISceneLoaderPluginExtensions {
  124263. /**
  124264. * Defines the list of supported extensions
  124265. */
  124266. [extension: string]: {
  124267. isBinary: boolean;
  124268. };
  124269. }
  124270. /**
  124271. * Interface used by SceneLoader plugin factory
  124272. */
  124273. export interface ISceneLoaderPluginFactory {
  124274. /**
  124275. * Defines the name of the factory
  124276. */
  124277. name: string;
  124278. /**
  124279. * Function called to create a new plugin
  124280. * @return the new plugin
  124281. */
  124282. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  124283. /**
  124284. * The callback that returns true if the data can be directly loaded.
  124285. * @param data string containing the file data
  124286. * @returns if the data can be loaded directly
  124287. */
  124288. canDirectLoad?(data: string): boolean;
  124289. }
  124290. /**
  124291. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  124292. */
  124293. export interface ISceneLoaderPluginBase {
  124294. /**
  124295. * The friendly name of this plugin.
  124296. */
  124297. name: string;
  124298. /**
  124299. * The file extensions supported by this plugin.
  124300. */
  124301. extensions: string | ISceneLoaderPluginExtensions;
  124302. /**
  124303. * The callback called when loading from a url.
  124304. * @param scene scene loading this url
  124305. * @param url url to load
  124306. * @param onSuccess callback called when the file successfully loads
  124307. * @param onProgress callback called while file is loading (if the server supports this mode)
  124308. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  124309. * @param onError callback called when the file fails to load
  124310. * @returns a file request object
  124311. */
  124312. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124313. /**
  124314. * The callback called when loading from a file object.
  124315. * @param scene scene loading this file
  124316. * @param file defines the file to load
  124317. * @param onSuccess defines the callback to call when data is loaded
  124318. * @param onProgress defines the callback to call during loading process
  124319. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  124320. * @param onError defines the callback to call when an error occurs
  124321. * @returns a file request object
  124322. */
  124323. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124324. /**
  124325. * The callback that returns true if the data can be directly loaded.
  124326. * @param data string containing the file data
  124327. * @returns if the data can be loaded directly
  124328. */
  124329. canDirectLoad?(data: string): boolean;
  124330. /**
  124331. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  124332. * @param scene scene loading this data
  124333. * @param data string containing the data
  124334. * @returns data to pass to the plugin
  124335. */
  124336. directLoad?(scene: Scene, data: string): any;
  124337. /**
  124338. * The callback that allows custom handling of the root url based on the response url.
  124339. * @param rootUrl the original root url
  124340. * @param responseURL the response url if available
  124341. * @returns the new root url
  124342. */
  124343. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  124344. }
  124345. /**
  124346. * Interface used to define a SceneLoader plugin
  124347. */
  124348. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  124349. /**
  124350. * Import meshes into a scene.
  124351. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124352. * @param scene The scene to import into
  124353. * @param data The data to import
  124354. * @param rootUrl The root url for scene and resources
  124355. * @param meshes The meshes array to import into
  124356. * @param particleSystems The particle systems array to import into
  124357. * @param skeletons The skeletons array to import into
  124358. * @param onError The callback when import fails
  124359. * @returns True if successful or false otherwise
  124360. */
  124361. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  124362. /**
  124363. * Load into a scene.
  124364. * @param scene The scene to load into
  124365. * @param data The data to import
  124366. * @param rootUrl The root url for scene and resources
  124367. * @param onError The callback when import fails
  124368. * @returns True if successful or false otherwise
  124369. */
  124370. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  124371. /**
  124372. * Load into an asset container.
  124373. * @param scene The scene to load into
  124374. * @param data The data to import
  124375. * @param rootUrl The root url for scene and resources
  124376. * @param onError The callback when import fails
  124377. * @returns The loaded asset container
  124378. */
  124379. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  124380. }
  124381. /**
  124382. * Interface used to define an async SceneLoader plugin
  124383. */
  124384. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  124385. /**
  124386. * Import meshes into a scene.
  124387. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124388. * @param scene The scene to import into
  124389. * @param data The data to import
  124390. * @param rootUrl The root url for scene and resources
  124391. * @param onProgress The callback when the load progresses
  124392. * @param fileName Defines the name of the file to load
  124393. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  124394. */
  124395. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  124396. meshes: AbstractMesh[];
  124397. particleSystems: IParticleSystem[];
  124398. skeletons: Skeleton[];
  124399. animationGroups: AnimationGroup[];
  124400. }>;
  124401. /**
  124402. * Load into a scene.
  124403. * @param scene The scene to load into
  124404. * @param data The data to import
  124405. * @param rootUrl The root url for scene and resources
  124406. * @param onProgress The callback when the load progresses
  124407. * @param fileName Defines the name of the file to load
  124408. * @returns Nothing
  124409. */
  124410. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  124411. /**
  124412. * Load into an asset container.
  124413. * @param scene The scene to load into
  124414. * @param data The data to import
  124415. * @param rootUrl The root url for scene and resources
  124416. * @param onProgress The callback when the load progresses
  124417. * @param fileName Defines the name of the file to load
  124418. * @returns The loaded asset container
  124419. */
  124420. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  124421. }
  124422. /**
  124423. * Mode that determines how to handle old animation groups before loading new ones.
  124424. */
  124425. export enum SceneLoaderAnimationGroupLoadingMode {
  124426. /**
  124427. * Reset all old animations to initial state then dispose them.
  124428. */
  124429. Clean = 0,
  124430. /**
  124431. * Stop all old animations.
  124432. */
  124433. Stop = 1,
  124434. /**
  124435. * Restart old animations from first frame.
  124436. */
  124437. Sync = 2,
  124438. /**
  124439. * Old animations remains untouched.
  124440. */
  124441. NoSync = 3
  124442. }
  124443. /**
  124444. * Class used to load scene from various file formats using registered plugins
  124445. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  124446. */
  124447. export class SceneLoader {
  124448. /**
  124449. * No logging while loading
  124450. */
  124451. static readonly NO_LOGGING: number;
  124452. /**
  124453. * Minimal logging while loading
  124454. */
  124455. static readonly MINIMAL_LOGGING: number;
  124456. /**
  124457. * Summary logging while loading
  124458. */
  124459. static readonly SUMMARY_LOGGING: number;
  124460. /**
  124461. * Detailled logging while loading
  124462. */
  124463. static readonly DETAILED_LOGGING: number;
  124464. /**
  124465. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  124466. */
  124467. static get ForceFullSceneLoadingForIncremental(): boolean;
  124468. static set ForceFullSceneLoadingForIncremental(value: boolean);
  124469. /**
  124470. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  124471. */
  124472. static get ShowLoadingScreen(): boolean;
  124473. static set ShowLoadingScreen(value: boolean);
  124474. /**
  124475. * Defines the current logging level (while loading the scene)
  124476. * @ignorenaming
  124477. */
  124478. static get loggingLevel(): number;
  124479. static set loggingLevel(value: number);
  124480. /**
  124481. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  124482. */
  124483. static get CleanBoneMatrixWeights(): boolean;
  124484. static set CleanBoneMatrixWeights(value: boolean);
  124485. /**
  124486. * Event raised when a plugin is used to load a scene
  124487. */
  124488. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124489. private static _registeredPlugins;
  124490. private static _getDefaultPlugin;
  124491. private static _getPluginForExtension;
  124492. private static _getPluginForDirectLoad;
  124493. private static _getPluginForFilename;
  124494. private static _getDirectLoad;
  124495. private static _loadData;
  124496. private static _getFileInfo;
  124497. /**
  124498. * Gets a plugin that can load the given extension
  124499. * @param extension defines the extension to load
  124500. * @returns a plugin or null if none works
  124501. */
  124502. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  124503. /**
  124504. * Gets a boolean indicating that the given extension can be loaded
  124505. * @param extension defines the extension to load
  124506. * @returns true if the extension is supported
  124507. */
  124508. static IsPluginForExtensionAvailable(extension: string): boolean;
  124509. /**
  124510. * Adds a new plugin to the list of registered plugins
  124511. * @param plugin defines the plugin to add
  124512. */
  124513. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  124514. /**
  124515. * Import meshes into a scene
  124516. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124517. * @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)
  124518. * @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)
  124519. * @param scene the instance of BABYLON.Scene to append to
  124520. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  124521. * @param onProgress a callback with a progress event for each file being loaded
  124522. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124523. * @param pluginExtension the extension used to determine the plugin
  124524. * @returns The loaded plugin
  124525. */
  124526. 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>;
  124527. /**
  124528. * Import meshes into a scene
  124529. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124530. * @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)
  124531. * @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)
  124532. * @param scene the instance of BABYLON.Scene to append to
  124533. * @param onProgress a callback with a progress event for each file being loaded
  124534. * @param pluginExtension the extension used to determine the plugin
  124535. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  124536. */
  124537. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  124538. meshes: AbstractMesh[];
  124539. particleSystems: IParticleSystem[];
  124540. skeletons: Skeleton[];
  124541. animationGroups: AnimationGroup[];
  124542. }>;
  124543. /**
  124544. * Load a scene
  124545. * @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)
  124546. * @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)
  124547. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124548. * @param onSuccess a callback with the scene when import succeeds
  124549. * @param onProgress a callback with a progress event for each file being loaded
  124550. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124551. * @param pluginExtension the extension used to determine the plugin
  124552. * @returns The loaded plugin
  124553. */
  124554. 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>;
  124555. /**
  124556. * Load a scene
  124557. * @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)
  124558. * @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)
  124559. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124560. * @param onProgress a callback with a progress event for each file being loaded
  124561. * @param pluginExtension the extension used to determine the plugin
  124562. * @returns The loaded scene
  124563. */
  124564. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124565. /**
  124566. * Append a scene
  124567. * @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)
  124568. * @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)
  124569. * @param scene is the instance of BABYLON.Scene to append to
  124570. * @param onSuccess a callback with the scene when import succeeds
  124571. * @param onProgress a callback with a progress event for each file being loaded
  124572. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124573. * @param pluginExtension the extension used to determine the plugin
  124574. * @returns The loaded plugin
  124575. */
  124576. 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>;
  124577. /**
  124578. * Append a scene
  124579. * @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)
  124580. * @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)
  124581. * @param scene is the instance of BABYLON.Scene to append to
  124582. * @param onProgress a callback with a progress event for each file being loaded
  124583. * @param pluginExtension the extension used to determine the plugin
  124584. * @returns The given scene
  124585. */
  124586. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124587. /**
  124588. * Load a scene into an asset container
  124589. * @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)
  124590. * @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)
  124591. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124592. * @param onSuccess a callback with the scene when import succeeds
  124593. * @param onProgress a callback with a progress event for each file being loaded
  124594. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124595. * @param pluginExtension the extension used to determine the plugin
  124596. * @returns The loaded plugin
  124597. */
  124598. 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>;
  124599. /**
  124600. * Load a scene into an asset container
  124601. * @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)
  124602. * @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)
  124603. * @param scene is the instance of Scene to append to
  124604. * @param onProgress a callback with a progress event for each file being loaded
  124605. * @param pluginExtension the extension used to determine the plugin
  124606. * @returns The loaded asset container
  124607. */
  124608. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  124609. /**
  124610. * Import animations from a file into a scene
  124611. * @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)
  124612. * @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)
  124613. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124614. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124615. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124616. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124617. * @param onSuccess a callback with the scene when import succeeds
  124618. * @param onProgress a callback with a progress event for each file being loaded
  124619. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124620. */
  124621. 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;
  124622. /**
  124623. * Import animations from a file into a scene
  124624. * @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)
  124625. * @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)
  124626. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124627. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124628. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124629. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124630. * @param onSuccess a callback with the scene when import succeeds
  124631. * @param onProgress a callback with a progress event for each file being loaded
  124632. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124633. * @returns the updated scene with imported animations
  124634. */
  124635. 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>;
  124636. }
  124637. }
  124638. declare module BABYLON {
  124639. /**
  124640. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  124641. */
  124642. export type MotionControllerHandedness = "none" | "left" | "right";
  124643. /**
  124644. * The type of components available in motion controllers.
  124645. * This is not the name of the component.
  124646. */
  124647. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  124648. /**
  124649. * The state of a controller component
  124650. */
  124651. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  124652. /**
  124653. * The schema of motion controller layout.
  124654. * No object will be initialized using this interface
  124655. * This is used just to define the profile.
  124656. */
  124657. export interface IMotionControllerLayout {
  124658. /**
  124659. * Path to load the assets. Usually relative to the base path
  124660. */
  124661. assetPath: string;
  124662. /**
  124663. * Available components (unsorted)
  124664. */
  124665. components: {
  124666. /**
  124667. * A map of component Ids
  124668. */
  124669. [componentId: string]: {
  124670. /**
  124671. * The type of input the component outputs
  124672. */
  124673. type: MotionControllerComponentType;
  124674. /**
  124675. * The indices of this component in the gamepad object
  124676. */
  124677. gamepadIndices: {
  124678. /**
  124679. * Index of button
  124680. */
  124681. button?: number;
  124682. /**
  124683. * If available, index of x-axis
  124684. */
  124685. xAxis?: number;
  124686. /**
  124687. * If available, index of y-axis
  124688. */
  124689. yAxis?: number;
  124690. };
  124691. /**
  124692. * The mesh's root node name
  124693. */
  124694. rootNodeName: string;
  124695. /**
  124696. * Animation definitions for this model
  124697. */
  124698. visualResponses: {
  124699. [stateKey: string]: {
  124700. /**
  124701. * What property will be animated
  124702. */
  124703. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  124704. /**
  124705. * What states influence this visual response
  124706. */
  124707. states: MotionControllerComponentStateType[];
  124708. /**
  124709. * Type of animation - movement or visibility
  124710. */
  124711. valueNodeProperty: "transform" | "visibility";
  124712. /**
  124713. * Base node name to move. Its position will be calculated according to the min and max nodes
  124714. */
  124715. valueNodeName?: string;
  124716. /**
  124717. * Minimum movement node
  124718. */
  124719. minNodeName?: string;
  124720. /**
  124721. * Max movement node
  124722. */
  124723. maxNodeName?: string;
  124724. };
  124725. };
  124726. /**
  124727. * If touch enabled, what is the name of node to display user feedback
  124728. */
  124729. touchPointNodeName?: string;
  124730. };
  124731. };
  124732. /**
  124733. * Is it xr standard mapping or not
  124734. */
  124735. gamepadMapping: "" | "xr-standard";
  124736. /**
  124737. * Base root node of this entire model
  124738. */
  124739. rootNodeName: string;
  124740. /**
  124741. * Defines the main button component id
  124742. */
  124743. selectComponentId: string;
  124744. }
  124745. /**
  124746. * A definition for the layout map in the input profile
  124747. */
  124748. export interface IMotionControllerLayoutMap {
  124749. /**
  124750. * Layouts with handedness type as a key
  124751. */
  124752. [handedness: string]: IMotionControllerLayout;
  124753. }
  124754. /**
  124755. * The XR Input profile schema
  124756. * Profiles can be found here:
  124757. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  124758. */
  124759. export interface IMotionControllerProfile {
  124760. /**
  124761. * fallback profiles for this profileId
  124762. */
  124763. fallbackProfileIds: string[];
  124764. /**
  124765. * The layout map, with handedness as key
  124766. */
  124767. layouts: IMotionControllerLayoutMap;
  124768. /**
  124769. * The id of this profile
  124770. * correlates to the profile(s) in the xrInput.profiles array
  124771. */
  124772. profileId: string;
  124773. }
  124774. /**
  124775. * A helper-interface for the 3 meshes needed for controller button animation
  124776. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  124777. */
  124778. export interface IMotionControllerButtonMeshMap {
  124779. /**
  124780. * the mesh that defines the pressed value mesh position.
  124781. * This is used to find the max-position of this button
  124782. */
  124783. pressedMesh: AbstractMesh;
  124784. /**
  124785. * the mesh that defines the unpressed value mesh position.
  124786. * This is used to find the min (or initial) position of this button
  124787. */
  124788. unpressedMesh: AbstractMesh;
  124789. /**
  124790. * The mesh that will be changed when value changes
  124791. */
  124792. valueMesh: AbstractMesh;
  124793. }
  124794. /**
  124795. * A helper-interface for the 3 meshes needed for controller axis animation.
  124796. * This will be expanded when touchpad animations are fully supported
  124797. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  124798. */
  124799. export interface IMotionControllerMeshMap {
  124800. /**
  124801. * the mesh that defines the maximum value mesh position.
  124802. */
  124803. maxMesh?: AbstractMesh;
  124804. /**
  124805. * the mesh that defines the minimum value mesh position.
  124806. */
  124807. minMesh?: AbstractMesh;
  124808. /**
  124809. * The mesh that will be changed when axis value changes
  124810. */
  124811. valueMesh: AbstractMesh;
  124812. }
  124813. /**
  124814. * The elements needed for change-detection of the gamepad objects in motion controllers
  124815. */
  124816. export interface IMinimalMotionControllerObject {
  124817. /**
  124818. * Available axes of this controller
  124819. */
  124820. axes: number[];
  124821. /**
  124822. * An array of available buttons
  124823. */
  124824. buttons: Array<{
  124825. /**
  124826. * Value of the button/trigger
  124827. */
  124828. value: number;
  124829. /**
  124830. * If the button/trigger is currently touched
  124831. */
  124832. touched: boolean;
  124833. /**
  124834. * If the button/trigger is currently pressed
  124835. */
  124836. pressed: boolean;
  124837. }>;
  124838. /**
  124839. * EXPERIMENTAL haptic support.
  124840. */
  124841. hapticActuators?: Array<{
  124842. pulse: (value: number, duration: number) => Promise<boolean>;
  124843. }>;
  124844. }
  124845. /**
  124846. * An Abstract Motion controller
  124847. * This class receives an xrInput and a profile layout and uses those to initialize the components
  124848. * Each component has an observable to check for changes in value and state
  124849. */
  124850. export abstract class WebXRAbstractMotionController implements IDisposable {
  124851. protected scene: Scene;
  124852. protected layout: IMotionControllerLayout;
  124853. /**
  124854. * The gamepad object correlating to this controller
  124855. */
  124856. gamepadObject: IMinimalMotionControllerObject;
  124857. /**
  124858. * handedness (left/right/none) of this controller
  124859. */
  124860. handedness: MotionControllerHandedness;
  124861. private _initComponent;
  124862. private _modelReady;
  124863. /**
  124864. * A map of components (WebXRControllerComponent) in this motion controller
  124865. * Components have a ComponentType and can also have both button and axis definitions
  124866. */
  124867. readonly components: {
  124868. [id: string]: WebXRControllerComponent;
  124869. };
  124870. /**
  124871. * Disable the model's animation. Can be set at any time.
  124872. */
  124873. disableAnimation: boolean;
  124874. /**
  124875. * Observers registered here will be triggered when the model of this controller is done loading
  124876. */
  124877. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  124878. /**
  124879. * The profile id of this motion controller
  124880. */
  124881. abstract profileId: string;
  124882. /**
  124883. * The root mesh of the model. It is null if the model was not yet initialized
  124884. */
  124885. rootMesh: Nullable<AbstractMesh>;
  124886. /**
  124887. * constructs a new abstract motion controller
  124888. * @param scene the scene to which the model of the controller will be added
  124889. * @param layout The profile layout to load
  124890. * @param gamepadObject The gamepad object correlating to this controller
  124891. * @param handedness handedness (left/right/none) of this controller
  124892. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  124893. */
  124894. constructor(scene: Scene, layout: IMotionControllerLayout,
  124895. /**
  124896. * The gamepad object correlating to this controller
  124897. */
  124898. gamepadObject: IMinimalMotionControllerObject,
  124899. /**
  124900. * handedness (left/right/none) of this controller
  124901. */
  124902. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  124903. /**
  124904. * Dispose this controller, the model mesh and all its components
  124905. */
  124906. dispose(): void;
  124907. /**
  124908. * Returns all components of specific type
  124909. * @param type the type to search for
  124910. * @return an array of components with this type
  124911. */
  124912. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  124913. /**
  124914. * get a component based an its component id as defined in layout.components
  124915. * @param id the id of the component
  124916. * @returns the component correlates to the id or undefined if not found
  124917. */
  124918. getComponent(id: string): WebXRControllerComponent;
  124919. /**
  124920. * Get the list of components available in this motion controller
  124921. * @returns an array of strings correlating to available components
  124922. */
  124923. getComponentIds(): string[];
  124924. /**
  124925. * Get the first component of specific type
  124926. * @param type type of component to find
  124927. * @return a controller component or null if not found
  124928. */
  124929. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  124930. /**
  124931. * Get the main (Select) component of this controller as defined in the layout
  124932. * @returns the main component of this controller
  124933. */
  124934. getMainComponent(): WebXRControllerComponent;
  124935. /**
  124936. * Loads the model correlating to this controller
  124937. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  124938. * @returns A promise fulfilled with the result of the model loading
  124939. */
  124940. loadModel(): Promise<boolean>;
  124941. /**
  124942. * Update this model using the current XRFrame
  124943. * @param xrFrame the current xr frame to use and update the model
  124944. */
  124945. updateFromXRFrame(xrFrame: XRFrame): void;
  124946. /**
  124947. * Backwards compatibility due to a deeply-integrated typo
  124948. */
  124949. get handness(): XREye;
  124950. /**
  124951. * Pulse (vibrate) this controller
  124952. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  124953. * Consecutive calls to this function will cancel the last pulse call
  124954. *
  124955. * @param value the strength of the pulse in 0.0...1.0 range
  124956. * @param duration Duration of the pulse in milliseconds
  124957. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  124958. * @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
  124959. */
  124960. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  124961. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124962. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124963. /**
  124964. * Moves the axis on the controller mesh based on its current state
  124965. * @param axis the index of the axis
  124966. * @param axisValue the value of the axis which determines the meshes new position
  124967. * @hidden
  124968. */
  124969. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  124970. /**
  124971. * Update the model itself with the current frame data
  124972. * @param xrFrame the frame to use for updating the model mesh
  124973. */
  124974. protected updateModel(xrFrame: XRFrame): void;
  124975. /**
  124976. * Get the filename and path for this controller's model
  124977. * @returns a map of filename and path
  124978. */
  124979. protected abstract _getFilenameAndPath(): {
  124980. filename: string;
  124981. path: string;
  124982. };
  124983. /**
  124984. * This function is called before the mesh is loaded. It checks for loading constraints.
  124985. * For example, this function can check if the GLB loader is available
  124986. * If this function returns false, the generic controller will be loaded instead
  124987. * @returns Is the client ready to load the mesh
  124988. */
  124989. protected abstract _getModelLoadingConstraints(): boolean;
  124990. /**
  124991. * This function will be called after the model was successfully loaded and can be used
  124992. * for mesh transformations before it is available for the user
  124993. * @param meshes the loaded meshes
  124994. */
  124995. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  124996. /**
  124997. * Set the root mesh for this controller. Important for the WebXR controller class
  124998. * @param meshes the loaded meshes
  124999. */
  125000. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  125001. /**
  125002. * A function executed each frame that updates the mesh (if needed)
  125003. * @param xrFrame the current xrFrame
  125004. */
  125005. protected abstract _updateModel(xrFrame: XRFrame): void;
  125006. private _getGenericFilenameAndPath;
  125007. private _getGenericParentMesh;
  125008. }
  125009. }
  125010. declare module BABYLON {
  125011. /**
  125012. * A generic trigger-only motion controller for WebXR
  125013. */
  125014. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  125015. /**
  125016. * Static version of the profile id of this controller
  125017. */
  125018. static ProfileId: string;
  125019. profileId: string;
  125020. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  125021. protected _getFilenameAndPath(): {
  125022. filename: string;
  125023. path: string;
  125024. };
  125025. protected _getModelLoadingConstraints(): boolean;
  125026. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  125027. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125028. protected _updateModel(): void;
  125029. }
  125030. }
  125031. declare module BABYLON {
  125032. /**
  125033. * Class containing static functions to help procedurally build meshes
  125034. */
  125035. export class SphereBuilder {
  125036. /**
  125037. * Creates a sphere mesh
  125038. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125039. * * 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`)
  125040. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125041. * * 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
  125042. * * 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)
  125043. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125044. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125046. * @param name defines the name of the mesh
  125047. * @param options defines the options used to create the mesh
  125048. * @param scene defines the hosting scene
  125049. * @returns the sphere mesh
  125050. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125051. */
  125052. static CreateSphere(name: string, options: {
  125053. segments?: number;
  125054. diameter?: number;
  125055. diameterX?: number;
  125056. diameterY?: number;
  125057. diameterZ?: number;
  125058. arc?: number;
  125059. slice?: number;
  125060. sideOrientation?: number;
  125061. frontUVs?: Vector4;
  125062. backUVs?: Vector4;
  125063. updatable?: boolean;
  125064. }, scene?: Nullable<Scene>): Mesh;
  125065. }
  125066. }
  125067. declare module BABYLON {
  125068. /**
  125069. * A profiled motion controller has its profile loaded from an online repository.
  125070. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  125071. */
  125072. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  125073. private _repositoryUrl;
  125074. private _buttonMeshMapping;
  125075. private _touchDots;
  125076. /**
  125077. * The profile ID of this controller. Will be populated when the controller initializes.
  125078. */
  125079. profileId: string;
  125080. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  125081. dispose(): void;
  125082. protected _getFilenameAndPath(): {
  125083. filename: string;
  125084. path: string;
  125085. };
  125086. protected _getModelLoadingConstraints(): boolean;
  125087. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  125088. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125089. protected _updateModel(_xrFrame: XRFrame): void;
  125090. }
  125091. }
  125092. declare module BABYLON {
  125093. /**
  125094. * A construction function type to create a new controller based on an xrInput object
  125095. */
  125096. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  125097. /**
  125098. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  125099. *
  125100. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  125101. * it should be replaced with auto-loaded controllers.
  125102. *
  125103. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  125104. */
  125105. export class WebXRMotionControllerManager {
  125106. private static _AvailableControllers;
  125107. private static _Fallbacks;
  125108. private static _ProfileLoadingPromises;
  125109. private static _ProfilesList;
  125110. /**
  125111. * The base URL of the online controller repository. Can be changed at any time.
  125112. */
  125113. static BaseRepositoryUrl: string;
  125114. /**
  125115. * Which repository gets priority - local or online
  125116. */
  125117. static PrioritizeOnlineRepository: boolean;
  125118. /**
  125119. * Use the online repository, or use only locally-defined controllers
  125120. */
  125121. static UseOnlineRepository: boolean;
  125122. /**
  125123. * Clear the cache used for profile loading and reload when requested again
  125124. */
  125125. static ClearProfilesCache(): void;
  125126. /**
  125127. * Register the default fallbacks.
  125128. * This function is called automatically when this file is imported.
  125129. */
  125130. static DefaultFallbacks(): void;
  125131. /**
  125132. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  125133. * @param profileId the profile to which a fallback needs to be found
  125134. * @return an array with corresponding fallback profiles
  125135. */
  125136. static FindFallbackWithProfileId(profileId: string): string[];
  125137. /**
  125138. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  125139. * The order of search:
  125140. *
  125141. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  125142. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  125143. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  125144. * 4) return the generic trigger controller if none were found
  125145. *
  125146. * @param xrInput the xrInput to which a new controller is initialized
  125147. * @param scene the scene to which the model will be added
  125148. * @param forceProfile force a certain profile for this controller
  125149. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  125150. */
  125151. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  125152. /**
  125153. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  125154. *
  125155. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  125156. *
  125157. * @param type the profile type to register
  125158. * @param constructFunction the function to be called when loading this profile
  125159. */
  125160. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  125161. /**
  125162. * Register a fallback to a specific profile.
  125163. * @param profileId the profileId that will receive the fallbacks
  125164. * @param fallbacks A list of fallback profiles
  125165. */
  125166. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  125167. /**
  125168. * Will update the list of profiles available in the repository
  125169. * @return a promise that resolves to a map of profiles available online
  125170. */
  125171. static UpdateProfilesList(): Promise<{
  125172. [profile: string]: string;
  125173. }>;
  125174. private static _LoadProfileFromRepository;
  125175. private static _LoadProfilesFromAvailableControllers;
  125176. }
  125177. }
  125178. declare module BABYLON {
  125179. /**
  125180. * Configuration options for the WebXR controller creation
  125181. */
  125182. export interface IWebXRControllerOptions {
  125183. /**
  125184. * Should the controller mesh be animated when a user interacts with it
  125185. * The pressed buttons / thumbstick and touchpad animations will be disabled
  125186. */
  125187. disableMotionControllerAnimation?: boolean;
  125188. /**
  125189. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  125190. */
  125191. doNotLoadControllerMesh?: boolean;
  125192. /**
  125193. * Force a specific controller type for this controller.
  125194. * This can be used when creating your own profile or when testing different controllers
  125195. */
  125196. forceControllerProfile?: string;
  125197. /**
  125198. * Defines a rendering group ID for meshes that will be loaded.
  125199. * This is for the default controllers only.
  125200. */
  125201. renderingGroupId?: number;
  125202. }
  125203. /**
  125204. * Represents an XR controller
  125205. */
  125206. export class WebXRInputSource {
  125207. private _scene;
  125208. /** The underlying input source for the controller */
  125209. inputSource: XRInputSource;
  125210. private _options;
  125211. private _tmpVector;
  125212. private _uniqueId;
  125213. /**
  125214. * 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
  125215. */
  125216. grip?: AbstractMesh;
  125217. /**
  125218. * If available, this is the gamepad object related to this controller.
  125219. * Using this object it is possible to get click events and trackpad changes of the
  125220. * webxr controller that is currently being used.
  125221. */
  125222. motionController?: WebXRAbstractMotionController;
  125223. /**
  125224. * Event that fires when the controller is removed/disposed.
  125225. * The object provided as event data is this controller, after associated assets were disposed.
  125226. * uniqueId is still available.
  125227. */
  125228. onDisposeObservable: Observable<WebXRInputSource>;
  125229. /**
  125230. * Will be triggered when the mesh associated with the motion controller is done loading.
  125231. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  125232. * A shortened version of controller -> motion controller -> on mesh loaded.
  125233. */
  125234. onMeshLoadedObservable: Observable<AbstractMesh>;
  125235. /**
  125236. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  125237. */
  125238. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  125239. /**
  125240. * Pointer which can be used to select objects or attach a visible laser to
  125241. */
  125242. pointer: AbstractMesh;
  125243. /**
  125244. * Creates the controller
  125245. * @see https://doc.babylonjs.com/how_to/webxr
  125246. * @param _scene the scene which the controller should be associated to
  125247. * @param inputSource the underlying input source for the controller
  125248. * @param _options options for this controller creation
  125249. */
  125250. constructor(_scene: Scene,
  125251. /** The underlying input source for the controller */
  125252. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  125253. /**
  125254. * Get this controllers unique id
  125255. */
  125256. get uniqueId(): string;
  125257. /**
  125258. * Disposes of the object
  125259. */
  125260. dispose(): void;
  125261. /**
  125262. * Gets a world space ray coming from the pointer or grip
  125263. * @param result the resulting ray
  125264. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  125265. */
  125266. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  125267. /**
  125268. * Updates the controller pose based on the given XRFrame
  125269. * @param xrFrame xr frame to update the pose with
  125270. * @param referenceSpace reference space to use
  125271. */
  125272. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  125273. }
  125274. }
  125275. declare module BABYLON {
  125276. /**
  125277. * The schema for initialization options of the XR Input class
  125278. */
  125279. export interface IWebXRInputOptions {
  125280. /**
  125281. * If set to true no model will be automatically loaded
  125282. */
  125283. doNotLoadControllerMeshes?: boolean;
  125284. /**
  125285. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  125286. * If not found, the xr input profile data will be used.
  125287. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  125288. */
  125289. forceInputProfile?: string;
  125290. /**
  125291. * Do not send a request to the controller repository to load the profile.
  125292. *
  125293. * Instead, use the controllers available in babylon itself.
  125294. */
  125295. disableOnlineControllerRepository?: boolean;
  125296. /**
  125297. * A custom URL for the controllers repository
  125298. */
  125299. customControllersRepositoryURL?: string;
  125300. /**
  125301. * Should the controller model's components not move according to the user input
  125302. */
  125303. disableControllerAnimation?: boolean;
  125304. /**
  125305. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  125306. */
  125307. controllerOptions?: IWebXRControllerOptions;
  125308. }
  125309. /**
  125310. * XR input used to track XR inputs such as controllers/rays
  125311. */
  125312. export class WebXRInput implements IDisposable {
  125313. /**
  125314. * the xr session manager for this session
  125315. */
  125316. xrSessionManager: WebXRSessionManager;
  125317. /**
  125318. * the WebXR camera for this session. Mainly used for teleportation
  125319. */
  125320. xrCamera: WebXRCamera;
  125321. private readonly options;
  125322. /**
  125323. * XR controllers being tracked
  125324. */
  125325. controllers: Array<WebXRInputSource>;
  125326. private _frameObserver;
  125327. private _sessionEndedObserver;
  125328. private _sessionInitObserver;
  125329. /**
  125330. * Event when a controller has been connected/added
  125331. */
  125332. onControllerAddedObservable: Observable<WebXRInputSource>;
  125333. /**
  125334. * Event when a controller has been removed/disconnected
  125335. */
  125336. onControllerRemovedObservable: Observable<WebXRInputSource>;
  125337. /**
  125338. * Initializes the WebXRInput
  125339. * @param xrSessionManager the xr session manager for this session
  125340. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  125341. * @param options = initialization options for this xr input
  125342. */
  125343. constructor(
  125344. /**
  125345. * the xr session manager for this session
  125346. */
  125347. xrSessionManager: WebXRSessionManager,
  125348. /**
  125349. * the WebXR camera for this session. Mainly used for teleportation
  125350. */
  125351. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  125352. private _onInputSourcesChange;
  125353. private _addAndRemoveControllers;
  125354. /**
  125355. * Disposes of the object
  125356. */
  125357. dispose(): void;
  125358. }
  125359. }
  125360. declare module BABYLON {
  125361. /**
  125362. * This is the base class for all WebXR features.
  125363. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  125364. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  125365. */
  125366. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  125367. protected _xrSessionManager: WebXRSessionManager;
  125368. private _attached;
  125369. private _removeOnDetach;
  125370. /**
  125371. * Should auto-attach be disabled?
  125372. */
  125373. disableAutoAttach: boolean;
  125374. /**
  125375. * Construct a new (abstract) WebXR feature
  125376. * @param _xrSessionManager the xr session manager for this feature
  125377. */
  125378. constructor(_xrSessionManager: WebXRSessionManager);
  125379. /**
  125380. * Is this feature attached
  125381. */
  125382. get attached(): boolean;
  125383. /**
  125384. * attach this feature
  125385. *
  125386. * @param force should attachment be forced (even when already attached)
  125387. * @returns true if successful, false is failed or already attached
  125388. */
  125389. attach(force?: boolean): boolean;
  125390. /**
  125391. * detach this feature.
  125392. *
  125393. * @returns true if successful, false if failed or already detached
  125394. */
  125395. detach(): boolean;
  125396. /**
  125397. * Dispose this feature and all of the resources attached
  125398. */
  125399. dispose(): void;
  125400. /**
  125401. * This is used to register callbacks that will automatically be removed when detach is called.
  125402. * @param observable the observable to which the observer will be attached
  125403. * @param callback the callback to register
  125404. */
  125405. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  125406. /**
  125407. * Code in this function will be executed on each xrFrame received from the browser.
  125408. * This function will not execute after the feature is detached.
  125409. * @param _xrFrame the current frame
  125410. */
  125411. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  125412. }
  125413. }
  125414. declare module BABYLON {
  125415. /**
  125416. * Renders a layer on top of an existing scene
  125417. */
  125418. export class UtilityLayerRenderer implements IDisposable {
  125419. /** the original scene that will be rendered on top of */
  125420. originalScene: Scene;
  125421. private _pointerCaptures;
  125422. private _lastPointerEvents;
  125423. private static _DefaultUtilityLayer;
  125424. private static _DefaultKeepDepthUtilityLayer;
  125425. private _sharedGizmoLight;
  125426. private _renderCamera;
  125427. /**
  125428. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  125429. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  125430. * @returns the camera that is used when rendering the utility layer
  125431. */
  125432. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  125433. /**
  125434. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  125435. * @param cam the camera that should be used when rendering the utility layer
  125436. */
  125437. setRenderCamera(cam: Nullable<Camera>): void;
  125438. /**
  125439. * @hidden
  125440. * Light which used by gizmos to get light shading
  125441. */
  125442. _getSharedGizmoLight(): HemisphericLight;
  125443. /**
  125444. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  125445. */
  125446. pickUtilitySceneFirst: boolean;
  125447. /**
  125448. * 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)
  125449. */
  125450. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  125451. /**
  125452. * 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)
  125453. */
  125454. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  125455. /**
  125456. * The scene that is rendered on top of the original scene
  125457. */
  125458. utilityLayerScene: Scene;
  125459. /**
  125460. * If the utility layer should automatically be rendered on top of existing scene
  125461. */
  125462. shouldRender: boolean;
  125463. /**
  125464. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  125465. */
  125466. onlyCheckPointerDownEvents: boolean;
  125467. /**
  125468. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  125469. */
  125470. processAllEvents: boolean;
  125471. /**
  125472. * Observable raised when the pointer move from the utility layer scene to the main scene
  125473. */
  125474. onPointerOutObservable: Observable<number>;
  125475. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  125476. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  125477. private _afterRenderObserver;
  125478. private _sceneDisposeObserver;
  125479. private _originalPointerObserver;
  125480. /**
  125481. * Instantiates a UtilityLayerRenderer
  125482. * @param originalScene the original scene that will be rendered on top of
  125483. * @param handleEvents boolean indicating if the utility layer should handle events
  125484. */
  125485. constructor(
  125486. /** the original scene that will be rendered on top of */
  125487. originalScene: Scene, handleEvents?: boolean);
  125488. private _notifyObservers;
  125489. /**
  125490. * Renders the utility layers scene on top of the original scene
  125491. */
  125492. render(): void;
  125493. /**
  125494. * Disposes of the renderer
  125495. */
  125496. dispose(): void;
  125497. private _updateCamera;
  125498. }
  125499. }
  125500. declare module BABYLON {
  125501. /**
  125502. * Options interface for the pointer selection module
  125503. */
  125504. export interface IWebXRControllerPointerSelectionOptions {
  125505. /**
  125506. * if provided, this scene will be used to render meshes.
  125507. */
  125508. customUtilityLayerScene?: Scene;
  125509. /**
  125510. * 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)
  125511. * If not disabled, the last picked point will be used to execute a pointer up event
  125512. * If disabled, pointer up event will be triggered right after the pointer down event.
  125513. * Used in screen and gaze target ray mode only
  125514. */
  125515. disablePointerUpOnTouchOut: boolean;
  125516. /**
  125517. * For gaze mode (time to select instead of press)
  125518. */
  125519. forceGazeMode: boolean;
  125520. /**
  125521. * 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
  125522. * to start a new countdown to the pointer down event.
  125523. * Defaults to 1.
  125524. */
  125525. gazeModePointerMovedFactor?: number;
  125526. /**
  125527. * Different button type to use instead of the main component
  125528. */
  125529. overrideButtonId?: string;
  125530. /**
  125531. * use this rendering group id for the meshes (optional)
  125532. */
  125533. renderingGroupId?: number;
  125534. /**
  125535. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  125536. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  125537. * 3000 means 3 seconds between pointing at something and selecting it
  125538. */
  125539. timeToSelect?: number;
  125540. /**
  125541. * Should meshes created here be added to a utility layer or the main scene
  125542. */
  125543. useUtilityLayer?: boolean;
  125544. /**
  125545. * the xr input to use with this pointer selection
  125546. */
  125547. xrInput: WebXRInput;
  125548. }
  125549. /**
  125550. * A module that will enable pointer selection for motion controllers of XR Input Sources
  125551. */
  125552. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  125553. private readonly _options;
  125554. private static _idCounter;
  125555. private _attachController;
  125556. private _controllers;
  125557. private _scene;
  125558. private _tmpVectorForPickCompare;
  125559. /**
  125560. * The module's name
  125561. */
  125562. static readonly Name: string;
  125563. /**
  125564. * The (Babylon) version of this module.
  125565. * This is an integer representing the implementation version.
  125566. * This number does not correspond to the WebXR specs version
  125567. */
  125568. static readonly Version: number;
  125569. /**
  125570. * Disable lighting on the laser pointer (so it will always be visible)
  125571. */
  125572. disablePointerLighting: boolean;
  125573. /**
  125574. * Disable lighting on the selection mesh (so it will always be visible)
  125575. */
  125576. disableSelectionMeshLighting: boolean;
  125577. /**
  125578. * Should the laser pointer be displayed
  125579. */
  125580. displayLaserPointer: boolean;
  125581. /**
  125582. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  125583. */
  125584. displaySelectionMesh: boolean;
  125585. /**
  125586. * This color will be set to the laser pointer when selection is triggered
  125587. */
  125588. laserPointerPickedColor: Color3;
  125589. /**
  125590. * Default color of the laser pointer
  125591. */
  125592. laserPointerDefaultColor: Color3;
  125593. /**
  125594. * default color of the selection ring
  125595. */
  125596. selectionMeshDefaultColor: Color3;
  125597. /**
  125598. * This color will be applied to the selection ring when selection is triggered
  125599. */
  125600. selectionMeshPickedColor: Color3;
  125601. /**
  125602. * Optional filter to be used for ray selection. This predicate shares behavior with
  125603. * scene.pointerMovePredicate which takes priority if it is also assigned.
  125604. */
  125605. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125606. /**
  125607. * constructs a new background remover module
  125608. * @param _xrSessionManager the session manager for this module
  125609. * @param _options read-only options to be used in this module
  125610. */
  125611. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  125612. /**
  125613. * attach this feature
  125614. * Will usually be called by the features manager
  125615. *
  125616. * @returns true if successful.
  125617. */
  125618. attach(): boolean;
  125619. /**
  125620. * detach this feature.
  125621. * Will usually be called by the features manager
  125622. *
  125623. * @returns true if successful.
  125624. */
  125625. detach(): boolean;
  125626. /**
  125627. * Will get the mesh under a specific pointer.
  125628. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  125629. * @param controllerId the controllerId to check
  125630. * @returns The mesh under pointer or null if no mesh is under the pointer
  125631. */
  125632. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  125633. /**
  125634. * Get the xr controller that correlates to the pointer id in the pointer event
  125635. *
  125636. * @param id the pointer id to search for
  125637. * @returns the controller that correlates to this id or null if not found
  125638. */
  125639. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  125640. protected _onXRFrame(_xrFrame: XRFrame): void;
  125641. private _attachGazeMode;
  125642. private _attachScreenRayMode;
  125643. private _attachTrackedPointerRayMode;
  125644. private _convertNormalToDirectionOfRay;
  125645. private _detachController;
  125646. private _generateNewMeshPair;
  125647. private _pickingMoved;
  125648. private _updatePointerDistance;
  125649. /** @hidden */
  125650. get lasterPointerDefaultColor(): Color3;
  125651. }
  125652. }
  125653. declare module BABYLON {
  125654. /**
  125655. * Button which can be used to enter a different mode of XR
  125656. */
  125657. export class WebXREnterExitUIButton {
  125658. /** button element */
  125659. element: HTMLElement;
  125660. /** XR initialization options for the button */
  125661. sessionMode: XRSessionMode;
  125662. /** Reference space type */
  125663. referenceSpaceType: XRReferenceSpaceType;
  125664. /**
  125665. * Creates a WebXREnterExitUIButton
  125666. * @param element button element
  125667. * @param sessionMode XR initialization session mode
  125668. * @param referenceSpaceType the type of reference space to be used
  125669. */
  125670. constructor(
  125671. /** button element */
  125672. element: HTMLElement,
  125673. /** XR initialization options for the button */
  125674. sessionMode: XRSessionMode,
  125675. /** Reference space type */
  125676. referenceSpaceType: XRReferenceSpaceType);
  125677. /**
  125678. * Extendable function which can be used to update the button's visuals when the state changes
  125679. * @param activeButton the current active button in the UI
  125680. */
  125681. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  125682. }
  125683. /**
  125684. * Options to create the webXR UI
  125685. */
  125686. export class WebXREnterExitUIOptions {
  125687. /**
  125688. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  125689. */
  125690. customButtons?: Array<WebXREnterExitUIButton>;
  125691. /**
  125692. * A reference space type to use when creating the default button.
  125693. * Default is local-floor
  125694. */
  125695. referenceSpaceType?: XRReferenceSpaceType;
  125696. /**
  125697. * Context to enter xr with
  125698. */
  125699. renderTarget?: Nullable<WebXRRenderTarget>;
  125700. /**
  125701. * A session mode to use when creating the default button.
  125702. * Default is immersive-vr
  125703. */
  125704. sessionMode?: XRSessionMode;
  125705. /**
  125706. * A list of optional features to init the session with
  125707. */
  125708. optionalFeatures?: string[];
  125709. }
  125710. /**
  125711. * UI to allow the user to enter/exit XR mode
  125712. */
  125713. export class WebXREnterExitUI implements IDisposable {
  125714. private scene;
  125715. /** version of the options passed to this UI */
  125716. options: WebXREnterExitUIOptions;
  125717. private _activeButton;
  125718. private _buttons;
  125719. private _overlay;
  125720. /**
  125721. * Fired every time the active button is changed.
  125722. *
  125723. * When xr is entered via a button that launches xr that button will be the callback parameter
  125724. *
  125725. * When exiting xr the callback parameter will be null)
  125726. */
  125727. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  125728. /**
  125729. *
  125730. * @param scene babylon scene object to use
  125731. * @param options (read-only) version of the options passed to this UI
  125732. */
  125733. private constructor();
  125734. /**
  125735. * Creates UI to allow the user to enter/exit XR mode
  125736. * @param scene the scene to add the ui to
  125737. * @param helper the xr experience helper to enter/exit xr with
  125738. * @param options options to configure the UI
  125739. * @returns the created ui
  125740. */
  125741. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  125742. /**
  125743. * Disposes of the XR UI component
  125744. */
  125745. dispose(): void;
  125746. private _updateButtons;
  125747. }
  125748. }
  125749. declare module BABYLON {
  125750. /**
  125751. * Class containing static functions to help procedurally build meshes
  125752. */
  125753. export class LinesBuilder {
  125754. /**
  125755. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125756. * * 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
  125757. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125758. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125759. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125760. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125761. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125762. * * 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
  125763. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125766. * @param name defines the name of the new line system
  125767. * @param options defines the options used to create the line system
  125768. * @param scene defines the hosting scene
  125769. * @returns a new line system mesh
  125770. */
  125771. static CreateLineSystem(name: string, options: {
  125772. lines: Vector3[][];
  125773. updatable?: boolean;
  125774. instance?: Nullable<LinesMesh>;
  125775. colors?: Nullable<Color4[][]>;
  125776. useVertexAlpha?: boolean;
  125777. }, scene: Nullable<Scene>): LinesMesh;
  125778. /**
  125779. * Creates a line mesh
  125780. * 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
  125781. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125782. * * The parameter `points` is an array successive Vector3
  125783. * * 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
  125784. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125785. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125786. * * When updating an instance, remember that only point positions can change, not the number of points
  125787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125789. * @param name defines the name of the new line system
  125790. * @param options defines the options used to create the line system
  125791. * @param scene defines the hosting scene
  125792. * @returns a new line mesh
  125793. */
  125794. static CreateLines(name: string, options: {
  125795. points: Vector3[];
  125796. updatable?: boolean;
  125797. instance?: Nullable<LinesMesh>;
  125798. colors?: Color4[];
  125799. useVertexAlpha?: boolean;
  125800. }, scene?: Nullable<Scene>): LinesMesh;
  125801. /**
  125802. * Creates a dashed line mesh
  125803. * * 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
  125804. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125805. * * The parameter `points` is an array successive Vector3
  125806. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125807. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125808. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125809. * * 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
  125810. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125811. * * When updating an instance, remember that only point positions can change, not the number of points
  125812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125813. * @param name defines the name of the mesh
  125814. * @param options defines the options used to create the mesh
  125815. * @param scene defines the hosting scene
  125816. * @returns the dashed line mesh
  125817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125818. */
  125819. static CreateDashedLines(name: string, options: {
  125820. points: Vector3[];
  125821. dashSize?: number;
  125822. gapSize?: number;
  125823. dashNb?: number;
  125824. updatable?: boolean;
  125825. instance?: LinesMesh;
  125826. useVertexAlpha?: boolean;
  125827. }, scene?: Nullable<Scene>): LinesMesh;
  125828. }
  125829. }
  125830. declare module BABYLON {
  125831. /**
  125832. * Construction options for a timer
  125833. */
  125834. export interface ITimerOptions<T> {
  125835. /**
  125836. * Time-to-end
  125837. */
  125838. timeout: number;
  125839. /**
  125840. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  125841. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  125842. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  125843. */
  125844. contextObservable: Observable<T>;
  125845. /**
  125846. * Optional parameters when adding an observer to the observable
  125847. */
  125848. observableParameters?: {
  125849. mask?: number;
  125850. insertFirst?: boolean;
  125851. scope?: any;
  125852. };
  125853. /**
  125854. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  125855. */
  125856. breakCondition?: (data?: ITimerData<T>) => boolean;
  125857. /**
  125858. * Will be triggered when the time condition has met
  125859. */
  125860. onEnded?: (data: ITimerData<any>) => void;
  125861. /**
  125862. * Will be triggered when the break condition has met (prematurely ended)
  125863. */
  125864. onAborted?: (data: ITimerData<any>) => void;
  125865. /**
  125866. * Optional function to execute on each tick (or count)
  125867. */
  125868. onTick?: (data: ITimerData<any>) => void;
  125869. }
  125870. /**
  125871. * An interface defining the data sent by the timer
  125872. */
  125873. export interface ITimerData<T> {
  125874. /**
  125875. * When did it start
  125876. */
  125877. startTime: number;
  125878. /**
  125879. * Time now
  125880. */
  125881. currentTime: number;
  125882. /**
  125883. * Time passed since started
  125884. */
  125885. deltaTime: number;
  125886. /**
  125887. * How much is completed, in [0.0...1.0].
  125888. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  125889. */
  125890. completeRate: number;
  125891. /**
  125892. * What the registered observable sent in the last count
  125893. */
  125894. payload: T;
  125895. }
  125896. /**
  125897. * The current state of the timer
  125898. */
  125899. export enum TimerState {
  125900. /**
  125901. * Timer initialized, not yet started
  125902. */
  125903. INIT = 0,
  125904. /**
  125905. * Timer started and counting
  125906. */
  125907. STARTED = 1,
  125908. /**
  125909. * Timer ended (whether aborted or time reached)
  125910. */
  125911. ENDED = 2
  125912. }
  125913. /**
  125914. * A simple version of the timer. Will take options and start the timer immediately after calling it
  125915. *
  125916. * @param options options with which to initialize this timer
  125917. */
  125918. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  125919. /**
  125920. * An advanced implementation of a timer class
  125921. */
  125922. export class AdvancedTimer<T = any> implements IDisposable {
  125923. /**
  125924. * Will notify each time the timer calculates the remaining time
  125925. */
  125926. onEachCountObservable: Observable<ITimerData<T>>;
  125927. /**
  125928. * Will trigger when the timer was aborted due to the break condition
  125929. */
  125930. onTimerAbortedObservable: Observable<ITimerData<T>>;
  125931. /**
  125932. * Will trigger when the timer ended successfully
  125933. */
  125934. onTimerEndedObservable: Observable<ITimerData<T>>;
  125935. /**
  125936. * Will trigger when the timer state has changed
  125937. */
  125938. onStateChangedObservable: Observable<TimerState>;
  125939. private _observer;
  125940. private _contextObservable;
  125941. private _observableParameters;
  125942. private _startTime;
  125943. private _timer;
  125944. private _state;
  125945. private _breakCondition;
  125946. private _timeToEnd;
  125947. private _breakOnNextTick;
  125948. /**
  125949. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  125950. * @param options construction options for this advanced timer
  125951. */
  125952. constructor(options: ITimerOptions<T>);
  125953. /**
  125954. * set a breaking condition for this timer. Default is to never break during count
  125955. * @param predicate the new break condition. Returns true to break, false otherwise
  125956. */
  125957. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  125958. /**
  125959. * Reset ALL associated observables in this advanced timer
  125960. */
  125961. clearObservables(): void;
  125962. /**
  125963. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  125964. *
  125965. * @param timeToEnd how much time to measure until timer ended
  125966. */
  125967. start(timeToEnd?: number): void;
  125968. /**
  125969. * Will force a stop on the next tick.
  125970. */
  125971. stop(): void;
  125972. /**
  125973. * Dispose this timer, clearing all resources
  125974. */
  125975. dispose(): void;
  125976. private _setState;
  125977. private _tick;
  125978. private _stop;
  125979. }
  125980. }
  125981. declare module BABYLON {
  125982. /**
  125983. * The options container for the teleportation module
  125984. */
  125985. export interface IWebXRTeleportationOptions {
  125986. /**
  125987. * if provided, this scene will be used to render meshes.
  125988. */
  125989. customUtilityLayerScene?: Scene;
  125990. /**
  125991. * Values to configure the default target mesh
  125992. */
  125993. defaultTargetMeshOptions?: {
  125994. /**
  125995. * Fill color of the teleportation area
  125996. */
  125997. teleportationFillColor?: string;
  125998. /**
  125999. * Border color for the teleportation area
  126000. */
  126001. teleportationBorderColor?: string;
  126002. /**
  126003. * Disable the mesh's animation sequence
  126004. */
  126005. disableAnimation?: boolean;
  126006. /**
  126007. * Disable lighting on the material or the ring and arrow
  126008. */
  126009. disableLighting?: boolean;
  126010. /**
  126011. * Override the default material of the torus and arrow
  126012. */
  126013. torusArrowMaterial?: Material;
  126014. };
  126015. /**
  126016. * A list of meshes to use as floor meshes.
  126017. * Meshes can be added and removed after initializing the feature using the
  126018. * addFloorMesh and removeFloorMesh functions
  126019. * If empty, rotation will still work
  126020. */
  126021. floorMeshes?: AbstractMesh[];
  126022. /**
  126023. * use this rendering group id for the meshes (optional)
  126024. */
  126025. renderingGroupId?: number;
  126026. /**
  126027. * Should teleportation move only to snap points
  126028. */
  126029. snapPointsOnly?: boolean;
  126030. /**
  126031. * An array of points to which the teleportation will snap to.
  126032. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  126033. */
  126034. snapPositions?: Vector3[];
  126035. /**
  126036. * How close should the teleportation ray be in order to snap to position.
  126037. * Default to 0.8 units (meters)
  126038. */
  126039. snapToPositionRadius?: number;
  126040. /**
  126041. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  126042. * If you want to support rotation, make sure your mesh has a direction indicator.
  126043. *
  126044. * When left untouched, the default mesh will be initialized.
  126045. */
  126046. teleportationTargetMesh?: AbstractMesh;
  126047. /**
  126048. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  126049. */
  126050. timeToTeleport?: number;
  126051. /**
  126052. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  126053. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  126054. */
  126055. useMainComponentOnly?: boolean;
  126056. /**
  126057. * Should meshes created here be added to a utility layer or the main scene
  126058. */
  126059. useUtilityLayer?: boolean;
  126060. /**
  126061. * Babylon XR Input class for controller
  126062. */
  126063. xrInput: WebXRInput;
  126064. }
  126065. /**
  126066. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  126067. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  126068. * the input of the attached controllers.
  126069. */
  126070. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  126071. private _options;
  126072. private _controllers;
  126073. private _currentTeleportationControllerId;
  126074. private _floorMeshes;
  126075. private _quadraticBezierCurve;
  126076. private _selectionFeature;
  126077. private _snapToPositions;
  126078. private _snappedToPoint;
  126079. private _teleportationRingMaterial?;
  126080. private _tmpRay;
  126081. private _tmpVector;
  126082. /**
  126083. * The module's name
  126084. */
  126085. static readonly Name: string;
  126086. /**
  126087. * The (Babylon) version of this module.
  126088. * This is an integer representing the implementation version.
  126089. * This number does not correspond to the webxr specs version
  126090. */
  126091. static readonly Version: number;
  126092. /**
  126093. * Is movement backwards enabled
  126094. */
  126095. backwardsMovementEnabled: boolean;
  126096. /**
  126097. * Distance to travel when moving backwards
  126098. */
  126099. backwardsTeleportationDistance: number;
  126100. /**
  126101. * The distance from the user to the inspection point in the direction of the controller
  126102. * A higher number will allow the user to move further
  126103. * defaults to 5 (meters, in xr units)
  126104. */
  126105. parabolicCheckRadius: number;
  126106. /**
  126107. * Should the module support parabolic ray on top of direct ray
  126108. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  126109. * Very helpful when moving between floors / different heights
  126110. */
  126111. parabolicRayEnabled: boolean;
  126112. /**
  126113. * How much rotation should be applied when rotating right and left
  126114. */
  126115. rotationAngle: number;
  126116. /**
  126117. * Is rotation enabled when moving forward?
  126118. * Disabling this feature will prevent the user from deciding the direction when teleporting
  126119. */
  126120. rotationEnabled: boolean;
  126121. /**
  126122. * constructs a new anchor system
  126123. * @param _xrSessionManager an instance of WebXRSessionManager
  126124. * @param _options configuration object for this feature
  126125. */
  126126. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  126127. /**
  126128. * Get the snapPointsOnly flag
  126129. */
  126130. get snapPointsOnly(): boolean;
  126131. /**
  126132. * Sets the snapPointsOnly flag
  126133. * @param snapToPoints should teleportation be exclusively to snap points
  126134. */
  126135. set snapPointsOnly(snapToPoints: boolean);
  126136. /**
  126137. * Add a new mesh to the floor meshes array
  126138. * @param mesh the mesh to use as floor mesh
  126139. */
  126140. addFloorMesh(mesh: AbstractMesh): void;
  126141. /**
  126142. * Add a new snap-to point to fix teleportation to this position
  126143. * @param newSnapPoint The new Snap-To point
  126144. */
  126145. addSnapPoint(newSnapPoint: Vector3): void;
  126146. attach(): boolean;
  126147. detach(): boolean;
  126148. dispose(): void;
  126149. /**
  126150. * Remove a mesh from the floor meshes array
  126151. * @param mesh the mesh to remove
  126152. */
  126153. removeFloorMesh(mesh: AbstractMesh): void;
  126154. /**
  126155. * Remove a mesh from the floor meshes array using its name
  126156. * @param name the mesh name to remove
  126157. */
  126158. removeFloorMeshByName(name: string): void;
  126159. /**
  126160. * 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
  126161. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  126162. * @returns was the point found and removed or not
  126163. */
  126164. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  126165. /**
  126166. * This function sets a selection feature that will be disabled when
  126167. * the forward ray is shown and will be reattached when hidden.
  126168. * This is used to remove the selection rays when moving.
  126169. * @param selectionFeature the feature to disable when forward movement is enabled
  126170. */
  126171. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  126172. protected _onXRFrame(_xrFrame: XRFrame): void;
  126173. private _attachController;
  126174. private _createDefaultTargetMesh;
  126175. private _detachController;
  126176. private _findClosestSnapPointWithRadius;
  126177. private _setTargetMeshPosition;
  126178. private _setTargetMeshVisibility;
  126179. private _showParabolicPath;
  126180. private _teleportForward;
  126181. }
  126182. }
  126183. declare module BABYLON {
  126184. /**
  126185. * Options for the default xr helper
  126186. */
  126187. export class WebXRDefaultExperienceOptions {
  126188. /**
  126189. * Enable or disable default UI to enter XR
  126190. */
  126191. disableDefaultUI?: boolean;
  126192. /**
  126193. * Should teleportation not initialize. defaults to false.
  126194. */
  126195. disableTeleportation?: boolean;
  126196. /**
  126197. * Floor meshes that will be used for teleport
  126198. */
  126199. floorMeshes?: Array<AbstractMesh>;
  126200. /**
  126201. * If set to true, the first frame will not be used to reset position
  126202. * The first frame is mainly used when copying transformation from the old camera
  126203. * Mainly used in AR
  126204. */
  126205. ignoreNativeCameraTransformation?: boolean;
  126206. /**
  126207. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  126208. */
  126209. inputOptions?: IWebXRInputOptions;
  126210. /**
  126211. * optional configuration for the output canvas
  126212. */
  126213. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  126214. /**
  126215. * optional UI options. This can be used among other to change session mode and reference space type
  126216. */
  126217. uiOptions?: WebXREnterExitUIOptions;
  126218. /**
  126219. * When loading teleportation and pointer select, use stable versions instead of latest.
  126220. */
  126221. useStablePlugins?: boolean;
  126222. /**
  126223. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  126224. */
  126225. renderingGroupId?: number;
  126226. /**
  126227. * A list of optional features to init the session with
  126228. * If set to true, all features we support will be added
  126229. */
  126230. optionalFeatures?: boolean | string[];
  126231. }
  126232. /**
  126233. * Default experience which provides a similar setup to the previous webVRExperience
  126234. */
  126235. export class WebXRDefaultExperience {
  126236. /**
  126237. * Base experience
  126238. */
  126239. baseExperience: WebXRExperienceHelper;
  126240. /**
  126241. * Enables ui for entering/exiting xr
  126242. */
  126243. enterExitUI: WebXREnterExitUI;
  126244. /**
  126245. * Input experience extension
  126246. */
  126247. input: WebXRInput;
  126248. /**
  126249. * Enables laser pointer and selection
  126250. */
  126251. pointerSelection: WebXRControllerPointerSelection;
  126252. /**
  126253. * Default target xr should render to
  126254. */
  126255. renderTarget: WebXRRenderTarget;
  126256. /**
  126257. * Enables teleportation
  126258. */
  126259. teleportation: WebXRMotionControllerTeleportation;
  126260. private constructor();
  126261. /**
  126262. * Creates the default xr experience
  126263. * @param scene scene
  126264. * @param options options for basic configuration
  126265. * @returns resulting WebXRDefaultExperience
  126266. */
  126267. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126268. /**
  126269. * DIsposes of the experience helper
  126270. */
  126271. dispose(): void;
  126272. }
  126273. }
  126274. declare module BABYLON {
  126275. /**
  126276. * Options to modify the vr teleportation behavior.
  126277. */
  126278. export interface VRTeleportationOptions {
  126279. /**
  126280. * The name of the mesh which should be used as the teleportation floor. (default: null)
  126281. */
  126282. floorMeshName?: string;
  126283. /**
  126284. * A list of meshes to be used as the teleportation floor. (default: empty)
  126285. */
  126286. floorMeshes?: Mesh[];
  126287. /**
  126288. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  126289. */
  126290. teleportationMode?: number;
  126291. /**
  126292. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  126293. */
  126294. teleportationTime?: number;
  126295. /**
  126296. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  126297. */
  126298. teleportationSpeed?: number;
  126299. /**
  126300. * The easing function used in the animation or null for Linear. (default CircleEase)
  126301. */
  126302. easingFunction?: EasingFunction;
  126303. }
  126304. /**
  126305. * Options to modify the vr experience helper's behavior.
  126306. */
  126307. export interface VRExperienceHelperOptions extends WebVROptions {
  126308. /**
  126309. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  126310. */
  126311. createDeviceOrientationCamera?: boolean;
  126312. /**
  126313. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  126314. */
  126315. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  126316. /**
  126317. * Uses the main button on the controller to toggle the laser casted. (default: true)
  126318. */
  126319. laserToggle?: boolean;
  126320. /**
  126321. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  126322. */
  126323. floorMeshes?: Mesh[];
  126324. /**
  126325. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  126326. */
  126327. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  126328. /**
  126329. * Defines if WebXR should be used instead of WebVR (if available)
  126330. */
  126331. useXR?: boolean;
  126332. }
  126333. /**
  126334. * Event containing information after VR has been entered
  126335. */
  126336. export class OnAfterEnteringVRObservableEvent {
  126337. /**
  126338. * If entering vr was successful
  126339. */
  126340. success: boolean;
  126341. }
  126342. /**
  126343. * Helps to quickly add VR support to an existing scene.
  126344. * See http://doc.babylonjs.com/how_to/webvr_helper
  126345. */
  126346. export class VRExperienceHelper {
  126347. /** Options to modify the vr experience helper's behavior. */
  126348. webVROptions: VRExperienceHelperOptions;
  126349. private _scene;
  126350. private _position;
  126351. private _btnVR;
  126352. private _btnVRDisplayed;
  126353. private _webVRsupported;
  126354. private _webVRready;
  126355. private _webVRrequesting;
  126356. private _webVRpresenting;
  126357. private _hasEnteredVR;
  126358. private _fullscreenVRpresenting;
  126359. private _inputElement;
  126360. private _webVRCamera;
  126361. private _vrDeviceOrientationCamera;
  126362. private _deviceOrientationCamera;
  126363. private _existingCamera;
  126364. private _onKeyDown;
  126365. private _onVrDisplayPresentChange;
  126366. private _onVRDisplayChanged;
  126367. private _onVRRequestPresentStart;
  126368. private _onVRRequestPresentComplete;
  126369. /**
  126370. * 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)
  126371. */
  126372. enableGazeEvenWhenNoPointerLock: boolean;
  126373. /**
  126374. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  126375. */
  126376. exitVROnDoubleTap: boolean;
  126377. /**
  126378. * Observable raised right before entering VR.
  126379. */
  126380. onEnteringVRObservable: Observable<VRExperienceHelper>;
  126381. /**
  126382. * Observable raised when entering VR has completed.
  126383. */
  126384. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  126385. /**
  126386. * Observable raised when exiting VR.
  126387. */
  126388. onExitingVRObservable: Observable<VRExperienceHelper>;
  126389. /**
  126390. * Observable raised when controller mesh is loaded.
  126391. */
  126392. onControllerMeshLoadedObservable: Observable<WebVRController>;
  126393. /** Return this.onEnteringVRObservable
  126394. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  126395. */
  126396. get onEnteringVR(): Observable<VRExperienceHelper>;
  126397. /** Return this.onExitingVRObservable
  126398. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  126399. */
  126400. get onExitingVR(): Observable<VRExperienceHelper>;
  126401. /** Return this.onControllerMeshLoadedObservable
  126402. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  126403. */
  126404. get onControllerMeshLoaded(): Observable<WebVRController>;
  126405. private _rayLength;
  126406. private _useCustomVRButton;
  126407. private _teleportationRequested;
  126408. private _teleportActive;
  126409. private _floorMeshName;
  126410. private _floorMeshesCollection;
  126411. private _teleportationMode;
  126412. private _teleportationTime;
  126413. private _teleportationSpeed;
  126414. private _teleportationEasing;
  126415. private _rotationAllowed;
  126416. private _teleportBackwardsVector;
  126417. private _teleportationTarget;
  126418. private _isDefaultTeleportationTarget;
  126419. private _postProcessMove;
  126420. private _teleportationFillColor;
  126421. private _teleportationBorderColor;
  126422. private _rotationAngle;
  126423. private _haloCenter;
  126424. private _cameraGazer;
  126425. private _padSensibilityUp;
  126426. private _padSensibilityDown;
  126427. private _leftController;
  126428. private _rightController;
  126429. private _gazeColor;
  126430. private _laserColor;
  126431. private _pickedLaserColor;
  126432. private _pickedGazeColor;
  126433. /**
  126434. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  126435. */
  126436. onNewMeshSelected: Observable<AbstractMesh>;
  126437. /**
  126438. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  126439. * This observable will provide the mesh and the controller used to select the mesh
  126440. */
  126441. onMeshSelectedWithController: Observable<{
  126442. mesh: AbstractMesh;
  126443. controller: WebVRController;
  126444. }>;
  126445. /**
  126446. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  126447. */
  126448. onNewMeshPicked: Observable<PickingInfo>;
  126449. private _circleEase;
  126450. /**
  126451. * Observable raised before camera teleportation
  126452. */
  126453. onBeforeCameraTeleport: Observable<Vector3>;
  126454. /**
  126455. * Observable raised after camera teleportation
  126456. */
  126457. onAfterCameraTeleport: Observable<Vector3>;
  126458. /**
  126459. * Observable raised when current selected mesh gets unselected
  126460. */
  126461. onSelectedMeshUnselected: Observable<AbstractMesh>;
  126462. private _raySelectionPredicate;
  126463. /**
  126464. * To be optionaly changed by user to define custom ray selection
  126465. */
  126466. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126467. /**
  126468. * To be optionaly changed by user to define custom selection logic (after ray selection)
  126469. */
  126470. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126471. /**
  126472. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  126473. */
  126474. teleportationEnabled: boolean;
  126475. private _defaultHeight;
  126476. private _teleportationInitialized;
  126477. private _interactionsEnabled;
  126478. private _interactionsRequested;
  126479. private _displayGaze;
  126480. private _displayLaserPointer;
  126481. /**
  126482. * The mesh used to display where the user is going to teleport.
  126483. */
  126484. get teleportationTarget(): Mesh;
  126485. /**
  126486. * Sets the mesh to be used to display where the user is going to teleport.
  126487. */
  126488. set teleportationTarget(value: Mesh);
  126489. /**
  126490. * 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
  126491. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  126492. * See http://doc.babylonjs.com/resources/baking_transformations
  126493. */
  126494. get gazeTrackerMesh(): Mesh;
  126495. set gazeTrackerMesh(value: Mesh);
  126496. /**
  126497. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  126498. */
  126499. updateGazeTrackerScale: boolean;
  126500. /**
  126501. * If the gaze trackers color should be updated when selecting meshes
  126502. */
  126503. updateGazeTrackerColor: boolean;
  126504. /**
  126505. * If the controller laser color should be updated when selecting meshes
  126506. */
  126507. updateControllerLaserColor: boolean;
  126508. /**
  126509. * The gaze tracking mesh corresponding to the left controller
  126510. */
  126511. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  126512. /**
  126513. * The gaze tracking mesh corresponding to the right controller
  126514. */
  126515. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  126516. /**
  126517. * If the ray of the gaze should be displayed.
  126518. */
  126519. get displayGaze(): boolean;
  126520. /**
  126521. * Sets if the ray of the gaze should be displayed.
  126522. */
  126523. set displayGaze(value: boolean);
  126524. /**
  126525. * If the ray of the LaserPointer should be displayed.
  126526. */
  126527. get displayLaserPointer(): boolean;
  126528. /**
  126529. * Sets if the ray of the LaserPointer should be displayed.
  126530. */
  126531. set displayLaserPointer(value: boolean);
  126532. /**
  126533. * The deviceOrientationCamera used as the camera when not in VR.
  126534. */
  126535. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  126536. /**
  126537. * Based on the current WebVR support, returns the current VR camera used.
  126538. */
  126539. get currentVRCamera(): Nullable<Camera>;
  126540. /**
  126541. * The webVRCamera which is used when in VR.
  126542. */
  126543. get webVRCamera(): WebVRFreeCamera;
  126544. /**
  126545. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  126546. */
  126547. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  126548. /**
  126549. * The html button that is used to trigger entering into VR.
  126550. */
  126551. get vrButton(): Nullable<HTMLButtonElement>;
  126552. private get _teleportationRequestInitiated();
  126553. /**
  126554. * Defines whether or not Pointer lock should be requested when switching to
  126555. * full screen.
  126556. */
  126557. requestPointerLockOnFullScreen: boolean;
  126558. /**
  126559. * If asking to force XR, this will be populated with the default xr experience
  126560. */
  126561. xr: WebXRDefaultExperience;
  126562. /**
  126563. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  126564. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  126565. */
  126566. xrTestDone: boolean;
  126567. /**
  126568. * Instantiates a VRExperienceHelper.
  126569. * Helps to quickly add VR support to an existing scene.
  126570. * @param scene The scene the VRExperienceHelper belongs to.
  126571. * @param webVROptions Options to modify the vr experience helper's behavior.
  126572. */
  126573. constructor(scene: Scene,
  126574. /** Options to modify the vr experience helper's behavior. */
  126575. webVROptions?: VRExperienceHelperOptions);
  126576. private completeVRInit;
  126577. private _onDefaultMeshLoaded;
  126578. private _onResize;
  126579. private _onFullscreenChange;
  126580. /**
  126581. * Gets a value indicating if we are currently in VR mode.
  126582. */
  126583. get isInVRMode(): boolean;
  126584. private onVrDisplayPresentChange;
  126585. private onVRDisplayChanged;
  126586. private moveButtonToBottomRight;
  126587. private displayVRButton;
  126588. private updateButtonVisibility;
  126589. private _cachedAngularSensibility;
  126590. /**
  126591. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  126592. * Otherwise, will use the fullscreen API.
  126593. */
  126594. enterVR(): void;
  126595. /**
  126596. * Attempt to exit VR, or fullscreen.
  126597. */
  126598. exitVR(): void;
  126599. /**
  126600. * The position of the vr experience helper.
  126601. */
  126602. get position(): Vector3;
  126603. /**
  126604. * Sets the position of the vr experience helper.
  126605. */
  126606. set position(value: Vector3);
  126607. /**
  126608. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  126609. */
  126610. enableInteractions(): void;
  126611. private get _noControllerIsActive();
  126612. private beforeRender;
  126613. private _isTeleportationFloor;
  126614. /**
  126615. * Adds a floor mesh to be used for teleportation.
  126616. * @param floorMesh the mesh to be used for teleportation.
  126617. */
  126618. addFloorMesh(floorMesh: Mesh): void;
  126619. /**
  126620. * Removes a floor mesh from being used for teleportation.
  126621. * @param floorMesh the mesh to be removed.
  126622. */
  126623. removeFloorMesh(floorMesh: Mesh): void;
  126624. /**
  126625. * Enables interactions and teleportation using the VR controllers and gaze.
  126626. * @param vrTeleportationOptions options to modify teleportation behavior.
  126627. */
  126628. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  126629. private _onNewGamepadConnected;
  126630. private _tryEnableInteractionOnController;
  126631. private _onNewGamepadDisconnected;
  126632. private _enableInteractionOnController;
  126633. private _checkTeleportWithRay;
  126634. private _checkRotate;
  126635. private _checkTeleportBackwards;
  126636. private _enableTeleportationOnController;
  126637. private _createTeleportationCircles;
  126638. private _displayTeleportationTarget;
  126639. private _hideTeleportationTarget;
  126640. private _rotateCamera;
  126641. private _moveTeleportationSelectorTo;
  126642. private _workingVector;
  126643. private _workingQuaternion;
  126644. private _workingMatrix;
  126645. /**
  126646. * Time Constant Teleportation Mode
  126647. */
  126648. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  126649. /**
  126650. * Speed Constant Teleportation Mode
  126651. */
  126652. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  126653. /**
  126654. * Teleports the users feet to the desired location
  126655. * @param location The location where the user's feet should be placed
  126656. */
  126657. teleportCamera(location: Vector3): void;
  126658. private _convertNormalToDirectionOfRay;
  126659. private _castRayAndSelectObject;
  126660. private _notifySelectedMeshUnselected;
  126661. /**
  126662. * Permanently set new colors for the laser pointer
  126663. * @param color the new laser color
  126664. * @param pickedColor the new laser color when picked mesh detected
  126665. */
  126666. setLaserColor(color: Color3, pickedColor?: Color3): void;
  126667. /**
  126668. * Set lighting enabled / disabled on the laser pointer of both controllers
  126669. * @param enabled should the lighting be enabled on the laser pointer
  126670. */
  126671. setLaserLightingState(enabled?: boolean): void;
  126672. /**
  126673. * Permanently set new colors for the gaze pointer
  126674. * @param color the new gaze color
  126675. * @param pickedColor the new gaze color when picked mesh detected
  126676. */
  126677. setGazeColor(color: Color3, pickedColor?: Color3): void;
  126678. /**
  126679. * Sets the color of the laser ray from the vr controllers.
  126680. * @param color new color for the ray.
  126681. */
  126682. changeLaserColor(color: Color3): void;
  126683. /**
  126684. * Sets the color of the ray from the vr headsets gaze.
  126685. * @param color new color for the ray.
  126686. */
  126687. changeGazeColor(color: Color3): void;
  126688. /**
  126689. * Exits VR and disposes of the vr experience helper
  126690. */
  126691. dispose(): void;
  126692. /**
  126693. * Gets the name of the VRExperienceHelper class
  126694. * @returns "VRExperienceHelper"
  126695. */
  126696. getClassName(): string;
  126697. }
  126698. }
  126699. declare module BABYLON {
  126700. /**
  126701. * Contains an array of blocks representing the octree
  126702. */
  126703. export interface IOctreeContainer<T> {
  126704. /**
  126705. * Blocks within the octree
  126706. */
  126707. blocks: Array<OctreeBlock<T>>;
  126708. }
  126709. /**
  126710. * Class used to store a cell in an octree
  126711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126712. */
  126713. export class OctreeBlock<T> {
  126714. /**
  126715. * Gets the content of the current block
  126716. */
  126717. entries: T[];
  126718. /**
  126719. * Gets the list of block children
  126720. */
  126721. blocks: Array<OctreeBlock<T>>;
  126722. private _depth;
  126723. private _maxDepth;
  126724. private _capacity;
  126725. private _minPoint;
  126726. private _maxPoint;
  126727. private _boundingVectors;
  126728. private _creationFunc;
  126729. /**
  126730. * Creates a new block
  126731. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  126732. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  126733. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126734. * @param depth defines the current depth of this block in the octree
  126735. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  126736. * @param creationFunc defines a callback to call when an element is added to the block
  126737. */
  126738. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  126739. /**
  126740. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126741. */
  126742. get capacity(): number;
  126743. /**
  126744. * Gets the minimum vector (in world space) of the block's bounding box
  126745. */
  126746. get minPoint(): Vector3;
  126747. /**
  126748. * Gets the maximum vector (in world space) of the block's bounding box
  126749. */
  126750. get maxPoint(): Vector3;
  126751. /**
  126752. * Add a new element to this block
  126753. * @param entry defines the element to add
  126754. */
  126755. addEntry(entry: T): void;
  126756. /**
  126757. * Remove an element from this block
  126758. * @param entry defines the element to remove
  126759. */
  126760. removeEntry(entry: T): void;
  126761. /**
  126762. * Add an array of elements to this block
  126763. * @param entries defines the array of elements to add
  126764. */
  126765. addEntries(entries: T[]): void;
  126766. /**
  126767. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  126768. * @param frustumPlanes defines the frustum planes to test
  126769. * @param selection defines the array to store current content if selection is positive
  126770. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126771. */
  126772. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  126773. /**
  126774. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  126775. * @param sphereCenter defines the bounding sphere center
  126776. * @param sphereRadius defines the bounding sphere radius
  126777. * @param selection defines the array to store current content if selection is positive
  126778. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126779. */
  126780. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  126781. /**
  126782. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  126783. * @param ray defines the ray to test with
  126784. * @param selection defines the array to store current content if selection is positive
  126785. */
  126786. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  126787. /**
  126788. * Subdivide the content into child blocks (this block will then be empty)
  126789. */
  126790. createInnerBlocks(): void;
  126791. /**
  126792. * @hidden
  126793. */
  126794. 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;
  126795. }
  126796. }
  126797. declare module BABYLON {
  126798. /**
  126799. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  126800. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126801. */
  126802. export class Octree<T> {
  126803. /** 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.) */
  126804. maxDepth: number;
  126805. /**
  126806. * Blocks within the octree containing objects
  126807. */
  126808. blocks: Array<OctreeBlock<T>>;
  126809. /**
  126810. * Content stored in the octree
  126811. */
  126812. dynamicContent: T[];
  126813. private _maxBlockCapacity;
  126814. private _selectionContent;
  126815. private _creationFunc;
  126816. /**
  126817. * Creates a octree
  126818. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126819. * @param creationFunc function to be used to instatiate the octree
  126820. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  126821. * @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.)
  126822. */
  126823. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  126824. /** 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.) */
  126825. maxDepth?: number);
  126826. /**
  126827. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  126828. * @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);
  126829. * @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);
  126830. * @param entries meshes to be added to the octree blocks
  126831. */
  126832. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  126833. /**
  126834. * Adds a mesh to the octree
  126835. * @param entry Mesh to add to the octree
  126836. */
  126837. addMesh(entry: T): void;
  126838. /**
  126839. * Remove an element from the octree
  126840. * @param entry defines the element to remove
  126841. */
  126842. removeMesh(entry: T): void;
  126843. /**
  126844. * Selects an array of meshes within the frustum
  126845. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  126846. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  126847. * @returns array of meshes within the frustum
  126848. */
  126849. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  126850. /**
  126851. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  126852. * @param sphereCenter defines the bounding sphere center
  126853. * @param sphereRadius defines the bounding sphere radius
  126854. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126855. * @returns an array of objects that intersect the sphere
  126856. */
  126857. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  126858. /**
  126859. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  126860. * @param ray defines the ray to test with
  126861. * @returns array of intersected objects
  126862. */
  126863. intersectsRay(ray: Ray): SmartArray<T>;
  126864. /**
  126865. * Adds a mesh into the octree block if it intersects the block
  126866. */
  126867. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  126868. /**
  126869. * Adds a submesh into the octree block if it intersects the block
  126870. */
  126871. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  126872. }
  126873. }
  126874. declare module BABYLON {
  126875. interface Scene {
  126876. /**
  126877. * @hidden
  126878. * Backing Filed
  126879. */
  126880. _selectionOctree: Octree<AbstractMesh>;
  126881. /**
  126882. * Gets the octree used to boost mesh selection (picking)
  126883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126884. */
  126885. selectionOctree: Octree<AbstractMesh>;
  126886. /**
  126887. * Creates or updates the octree used to boost selection (picking)
  126888. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126889. * @param maxCapacity defines the maximum capacity per leaf
  126890. * @param maxDepth defines the maximum depth of the octree
  126891. * @returns an octree of AbstractMesh
  126892. */
  126893. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  126894. }
  126895. interface AbstractMesh {
  126896. /**
  126897. * @hidden
  126898. * Backing Field
  126899. */
  126900. _submeshesOctree: Octree<SubMesh>;
  126901. /**
  126902. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  126903. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  126904. * @param maxCapacity defines the maximum size of each block (64 by default)
  126905. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  126906. * @returns the new octree
  126907. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  126908. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126909. */
  126910. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  126911. }
  126912. /**
  126913. * Defines the octree scene component responsible to manage any octrees
  126914. * in a given scene.
  126915. */
  126916. export class OctreeSceneComponent {
  126917. /**
  126918. * The component name help to identify the component in the list of scene components.
  126919. */
  126920. readonly name: string;
  126921. /**
  126922. * The scene the component belongs to.
  126923. */
  126924. scene: Scene;
  126925. /**
  126926. * Indicates if the meshes have been checked to make sure they are isEnabled()
  126927. */
  126928. readonly checksIsEnabled: boolean;
  126929. /**
  126930. * Creates a new instance of the component for the given scene
  126931. * @param scene Defines the scene to register the component in
  126932. */
  126933. constructor(scene: Scene);
  126934. /**
  126935. * Registers the component in a given scene
  126936. */
  126937. register(): void;
  126938. /**
  126939. * Return the list of active meshes
  126940. * @returns the list of active meshes
  126941. */
  126942. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  126943. /**
  126944. * Return the list of active sub meshes
  126945. * @param mesh The mesh to get the candidates sub meshes from
  126946. * @returns the list of active sub meshes
  126947. */
  126948. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  126949. private _tempRay;
  126950. /**
  126951. * Return the list of sub meshes intersecting with a given local ray
  126952. * @param mesh defines the mesh to find the submesh for
  126953. * @param localRay defines the ray in local space
  126954. * @returns the list of intersecting sub meshes
  126955. */
  126956. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  126957. /**
  126958. * Return the list of sub meshes colliding with a collider
  126959. * @param mesh defines the mesh to find the submesh for
  126960. * @param collider defines the collider to evaluate the collision against
  126961. * @returns the list of colliding sub meshes
  126962. */
  126963. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  126964. /**
  126965. * Rebuilds the elements related to this component in case of
  126966. * context lost for instance.
  126967. */
  126968. rebuild(): void;
  126969. /**
  126970. * Disposes the component and the associated ressources.
  126971. */
  126972. dispose(): void;
  126973. }
  126974. }
  126975. declare module BABYLON {
  126976. /**
  126977. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  126978. */
  126979. export class Gizmo implements IDisposable {
  126980. /** The utility layer the gizmo will be added to */
  126981. gizmoLayer: UtilityLayerRenderer;
  126982. /**
  126983. * The root mesh of the gizmo
  126984. */
  126985. _rootMesh: Mesh;
  126986. private _attachedMesh;
  126987. /**
  126988. * Ratio for the scale of the gizmo (Default: 1)
  126989. */
  126990. scaleRatio: number;
  126991. /**
  126992. * If a custom mesh has been set (Default: false)
  126993. */
  126994. protected _customMeshSet: boolean;
  126995. /**
  126996. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  126997. * * When set, interactions will be enabled
  126998. */
  126999. get attachedMesh(): Nullable<AbstractMesh>;
  127000. set attachedMesh(value: Nullable<AbstractMesh>);
  127001. /**
  127002. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  127003. * @param mesh The mesh to replace the default mesh of the gizmo
  127004. */
  127005. setCustomMesh(mesh: Mesh): void;
  127006. /**
  127007. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  127008. */
  127009. updateGizmoRotationToMatchAttachedMesh: boolean;
  127010. /**
  127011. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  127012. */
  127013. updateGizmoPositionToMatchAttachedMesh: boolean;
  127014. /**
  127015. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  127016. */
  127017. updateScale: boolean;
  127018. protected _interactionsEnabled: boolean;
  127019. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127020. private _beforeRenderObserver;
  127021. private _tempVector;
  127022. /**
  127023. * Creates a gizmo
  127024. * @param gizmoLayer The utility layer the gizmo will be added to
  127025. */
  127026. constructor(
  127027. /** The utility layer the gizmo will be added to */
  127028. gizmoLayer?: UtilityLayerRenderer);
  127029. /**
  127030. * Updates the gizmo to match the attached mesh's position/rotation
  127031. */
  127032. protected _update(): void;
  127033. /**
  127034. * Disposes of the gizmo
  127035. */
  127036. dispose(): void;
  127037. }
  127038. }
  127039. declare module BABYLON {
  127040. /**
  127041. * Single plane drag gizmo
  127042. */
  127043. export class PlaneDragGizmo extends Gizmo {
  127044. /**
  127045. * Drag behavior responsible for the gizmos dragging interactions
  127046. */
  127047. dragBehavior: PointerDragBehavior;
  127048. private _pointerObserver;
  127049. /**
  127050. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127051. */
  127052. snapDistance: number;
  127053. /**
  127054. * Event that fires each time the gizmo snaps to a new location.
  127055. * * snapDistance is the the change in distance
  127056. */
  127057. onSnapObservable: Observable<{
  127058. snapDistance: number;
  127059. }>;
  127060. private _plane;
  127061. private _coloredMaterial;
  127062. private _hoverMaterial;
  127063. private _isEnabled;
  127064. private _parent;
  127065. /** @hidden */
  127066. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  127067. /** @hidden */
  127068. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127069. /**
  127070. * Creates a PlaneDragGizmo
  127071. * @param gizmoLayer The utility layer the gizmo will be added to
  127072. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  127073. * @param color The color of the gizmo
  127074. */
  127075. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127076. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127077. /**
  127078. * If the gizmo is enabled
  127079. */
  127080. set isEnabled(value: boolean);
  127081. get isEnabled(): boolean;
  127082. /**
  127083. * Disposes of the gizmo
  127084. */
  127085. dispose(): void;
  127086. }
  127087. }
  127088. declare module BABYLON {
  127089. /**
  127090. * Gizmo that enables dragging a mesh along 3 axis
  127091. */
  127092. export class PositionGizmo extends Gizmo {
  127093. /**
  127094. * Internal gizmo used for interactions on the x axis
  127095. */
  127096. xGizmo: AxisDragGizmo;
  127097. /**
  127098. * Internal gizmo used for interactions on the y axis
  127099. */
  127100. yGizmo: AxisDragGizmo;
  127101. /**
  127102. * Internal gizmo used for interactions on the z axis
  127103. */
  127104. zGizmo: AxisDragGizmo;
  127105. /**
  127106. * Internal gizmo used for interactions on the yz plane
  127107. */
  127108. xPlaneGizmo: PlaneDragGizmo;
  127109. /**
  127110. * Internal gizmo used for interactions on the xz plane
  127111. */
  127112. yPlaneGizmo: PlaneDragGizmo;
  127113. /**
  127114. * Internal gizmo used for interactions on the xy plane
  127115. */
  127116. zPlaneGizmo: PlaneDragGizmo;
  127117. /**
  127118. * private variables
  127119. */
  127120. private _meshAttached;
  127121. private _updateGizmoRotationToMatchAttachedMesh;
  127122. private _snapDistance;
  127123. private _scaleRatio;
  127124. /** Fires an event when any of it's sub gizmos are dragged */
  127125. onDragStartObservable: Observable<unknown>;
  127126. /** Fires an event when any of it's sub gizmos are released from dragging */
  127127. onDragEndObservable: Observable<unknown>;
  127128. /**
  127129. * If set to true, planar drag is enabled
  127130. */
  127131. private _planarGizmoEnabled;
  127132. get attachedMesh(): Nullable<AbstractMesh>;
  127133. set attachedMesh(mesh: Nullable<AbstractMesh>);
  127134. /**
  127135. * Creates a PositionGizmo
  127136. * @param gizmoLayer The utility layer the gizmo will be added to
  127137. */
  127138. constructor(gizmoLayer?: UtilityLayerRenderer);
  127139. /**
  127140. * If the planar drag gizmo is enabled
  127141. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  127142. */
  127143. set planarGizmoEnabled(value: boolean);
  127144. get planarGizmoEnabled(): boolean;
  127145. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  127146. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  127147. /**
  127148. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127149. */
  127150. set snapDistance(value: number);
  127151. get snapDistance(): number;
  127152. /**
  127153. * Ratio for the scale of the gizmo (Default: 1)
  127154. */
  127155. set scaleRatio(value: number);
  127156. get scaleRatio(): number;
  127157. /**
  127158. * Disposes of the gizmo
  127159. */
  127160. dispose(): void;
  127161. /**
  127162. * CustomMeshes are not supported by this gizmo
  127163. * @param mesh The mesh to replace the default mesh of the gizmo
  127164. */
  127165. setCustomMesh(mesh: Mesh): void;
  127166. }
  127167. }
  127168. declare module BABYLON {
  127169. /**
  127170. * Single axis drag gizmo
  127171. */
  127172. export class AxisDragGizmo extends Gizmo {
  127173. /**
  127174. * Drag behavior responsible for the gizmos dragging interactions
  127175. */
  127176. dragBehavior: PointerDragBehavior;
  127177. private _pointerObserver;
  127178. /**
  127179. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127180. */
  127181. snapDistance: number;
  127182. /**
  127183. * Event that fires each time the gizmo snaps to a new location.
  127184. * * snapDistance is the the change in distance
  127185. */
  127186. onSnapObservable: Observable<{
  127187. snapDistance: number;
  127188. }>;
  127189. private _isEnabled;
  127190. private _parent;
  127191. private _arrow;
  127192. private _coloredMaterial;
  127193. private _hoverMaterial;
  127194. /** @hidden */
  127195. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  127196. /** @hidden */
  127197. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127198. /**
  127199. * Creates an AxisDragGizmo
  127200. * @param gizmoLayer The utility layer the gizmo will be added to
  127201. * @param dragAxis The axis which the gizmo will be able to drag on
  127202. * @param color The color of the gizmo
  127203. */
  127204. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127205. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127206. /**
  127207. * If the gizmo is enabled
  127208. */
  127209. set isEnabled(value: boolean);
  127210. get isEnabled(): boolean;
  127211. /**
  127212. * Disposes of the gizmo
  127213. */
  127214. dispose(): void;
  127215. }
  127216. }
  127217. declare module BABYLON.Debug {
  127218. /**
  127219. * The Axes viewer will show 3 axes in a specific point in space
  127220. */
  127221. export class AxesViewer {
  127222. private _xAxis;
  127223. private _yAxis;
  127224. private _zAxis;
  127225. private _scaleLinesFactor;
  127226. private _instanced;
  127227. /**
  127228. * Gets the hosting scene
  127229. */
  127230. scene: Scene;
  127231. /**
  127232. * Gets or sets a number used to scale line length
  127233. */
  127234. scaleLines: number;
  127235. /** Gets the node hierarchy used to render x-axis */
  127236. get xAxis(): TransformNode;
  127237. /** Gets the node hierarchy used to render y-axis */
  127238. get yAxis(): TransformNode;
  127239. /** Gets the node hierarchy used to render z-axis */
  127240. get zAxis(): TransformNode;
  127241. /**
  127242. * Creates a new AxesViewer
  127243. * @param scene defines the hosting scene
  127244. * @param scaleLines defines a number used to scale line length (1 by default)
  127245. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  127246. * @param xAxis defines the node hierarchy used to render the x-axis
  127247. * @param yAxis defines the node hierarchy used to render the y-axis
  127248. * @param zAxis defines the node hierarchy used to render the z-axis
  127249. */
  127250. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  127251. /**
  127252. * Force the viewer to update
  127253. * @param position defines the position of the viewer
  127254. * @param xaxis defines the x axis of the viewer
  127255. * @param yaxis defines the y axis of the viewer
  127256. * @param zaxis defines the z axis of the viewer
  127257. */
  127258. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  127259. /**
  127260. * Creates an instance of this axes viewer.
  127261. * @returns a new axes viewer with instanced meshes
  127262. */
  127263. createInstance(): AxesViewer;
  127264. /** Releases resources */
  127265. dispose(): void;
  127266. private static _SetRenderingGroupId;
  127267. }
  127268. }
  127269. declare module BABYLON.Debug {
  127270. /**
  127271. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  127272. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  127273. */
  127274. export class BoneAxesViewer extends AxesViewer {
  127275. /**
  127276. * Gets or sets the target mesh where to display the axes viewer
  127277. */
  127278. mesh: Nullable<Mesh>;
  127279. /**
  127280. * Gets or sets the target bone where to display the axes viewer
  127281. */
  127282. bone: Nullable<Bone>;
  127283. /** Gets current position */
  127284. pos: Vector3;
  127285. /** Gets direction of X axis */
  127286. xaxis: Vector3;
  127287. /** Gets direction of Y axis */
  127288. yaxis: Vector3;
  127289. /** Gets direction of Z axis */
  127290. zaxis: Vector3;
  127291. /**
  127292. * Creates a new BoneAxesViewer
  127293. * @param scene defines the hosting scene
  127294. * @param bone defines the target bone
  127295. * @param mesh defines the target mesh
  127296. * @param scaleLines defines a scaling factor for line length (1 by default)
  127297. */
  127298. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  127299. /**
  127300. * Force the viewer to update
  127301. */
  127302. update(): void;
  127303. /** Releases resources */
  127304. dispose(): void;
  127305. }
  127306. }
  127307. declare module BABYLON {
  127308. /**
  127309. * Interface used to define scene explorer extensibility option
  127310. */
  127311. export interface IExplorerExtensibilityOption {
  127312. /**
  127313. * Define the option label
  127314. */
  127315. label: string;
  127316. /**
  127317. * Defines the action to execute on click
  127318. */
  127319. action: (entity: any) => void;
  127320. }
  127321. /**
  127322. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  127323. */
  127324. export interface IExplorerExtensibilityGroup {
  127325. /**
  127326. * Defines a predicate to test if a given type mut be extended
  127327. */
  127328. predicate: (entity: any) => boolean;
  127329. /**
  127330. * Gets the list of options added to a type
  127331. */
  127332. entries: IExplorerExtensibilityOption[];
  127333. }
  127334. /**
  127335. * Interface used to define the options to use to create the Inspector
  127336. */
  127337. export interface IInspectorOptions {
  127338. /**
  127339. * Display in overlay mode (default: false)
  127340. */
  127341. overlay?: boolean;
  127342. /**
  127343. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  127344. */
  127345. globalRoot?: HTMLElement;
  127346. /**
  127347. * Display the Scene explorer
  127348. */
  127349. showExplorer?: boolean;
  127350. /**
  127351. * Display the property inspector
  127352. */
  127353. showInspector?: boolean;
  127354. /**
  127355. * Display in embed mode (both panes on the right)
  127356. */
  127357. embedMode?: boolean;
  127358. /**
  127359. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  127360. */
  127361. handleResize?: boolean;
  127362. /**
  127363. * Allow the panes to popup (default: true)
  127364. */
  127365. enablePopup?: boolean;
  127366. /**
  127367. * Allow the panes to be closed by users (default: true)
  127368. */
  127369. enableClose?: boolean;
  127370. /**
  127371. * Optional list of extensibility entries
  127372. */
  127373. explorerExtensibility?: IExplorerExtensibilityGroup[];
  127374. /**
  127375. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  127376. */
  127377. inspectorURL?: string;
  127378. /**
  127379. * Optional initial tab (default to DebugLayerTab.Properties)
  127380. */
  127381. initialTab?: DebugLayerTab;
  127382. }
  127383. interface Scene {
  127384. /**
  127385. * @hidden
  127386. * Backing field
  127387. */
  127388. _debugLayer: DebugLayer;
  127389. /**
  127390. * Gets the debug layer (aka Inspector) associated with the scene
  127391. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127392. */
  127393. debugLayer: DebugLayer;
  127394. }
  127395. /**
  127396. * Enum of inspector action tab
  127397. */
  127398. export enum DebugLayerTab {
  127399. /**
  127400. * Properties tag (default)
  127401. */
  127402. Properties = 0,
  127403. /**
  127404. * Debug tab
  127405. */
  127406. Debug = 1,
  127407. /**
  127408. * Statistics tab
  127409. */
  127410. Statistics = 2,
  127411. /**
  127412. * Tools tab
  127413. */
  127414. Tools = 3,
  127415. /**
  127416. * Settings tab
  127417. */
  127418. Settings = 4
  127419. }
  127420. /**
  127421. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127422. * what is happening in your scene
  127423. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127424. */
  127425. export class DebugLayer {
  127426. /**
  127427. * Define the url to get the inspector script from.
  127428. * By default it uses the babylonjs CDN.
  127429. * @ignoreNaming
  127430. */
  127431. static InspectorURL: string;
  127432. private _scene;
  127433. private BJSINSPECTOR;
  127434. private _onPropertyChangedObservable?;
  127435. /**
  127436. * Observable triggered when a property is changed through the inspector.
  127437. */
  127438. get onPropertyChangedObservable(): any;
  127439. /**
  127440. * Instantiates a new debug layer.
  127441. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127442. * what is happening in your scene
  127443. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127444. * @param scene Defines the scene to inspect
  127445. */
  127446. constructor(scene: Scene);
  127447. /** Creates the inspector window. */
  127448. private _createInspector;
  127449. /**
  127450. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  127451. * @param entity defines the entity to select
  127452. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  127453. */
  127454. select(entity: any, lineContainerTitles?: string | string[]): void;
  127455. /** Get the inspector from bundle or global */
  127456. private _getGlobalInspector;
  127457. /**
  127458. * Get if the inspector is visible or not.
  127459. * @returns true if visible otherwise, false
  127460. */
  127461. isVisible(): boolean;
  127462. /**
  127463. * Hide the inspector and close its window.
  127464. */
  127465. hide(): void;
  127466. /**
  127467. * Update the scene in the inspector
  127468. */
  127469. setAsActiveScene(): void;
  127470. /**
  127471. * Launch the debugLayer.
  127472. * @param config Define the configuration of the inspector
  127473. * @return a promise fulfilled when the debug layer is visible
  127474. */
  127475. show(config?: IInspectorOptions): Promise<DebugLayer>;
  127476. }
  127477. }
  127478. declare module BABYLON {
  127479. /**
  127480. * Class containing static functions to help procedurally build meshes
  127481. */
  127482. export class BoxBuilder {
  127483. /**
  127484. * Creates a box mesh
  127485. * * The parameter `size` sets the size (float) of each box side (default 1)
  127486. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  127487. * * 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)
  127488. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127492. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127493. * @param name defines the name of the mesh
  127494. * @param options defines the options used to create the mesh
  127495. * @param scene defines the hosting scene
  127496. * @returns the box mesh
  127497. */
  127498. static CreateBox(name: string, options: {
  127499. size?: number;
  127500. width?: number;
  127501. height?: number;
  127502. depth?: number;
  127503. faceUV?: Vector4[];
  127504. faceColors?: Color4[];
  127505. sideOrientation?: number;
  127506. frontUVs?: Vector4;
  127507. backUVs?: Vector4;
  127508. wrap?: boolean;
  127509. topBaseAt?: number;
  127510. bottomBaseAt?: number;
  127511. updatable?: boolean;
  127512. }, scene?: Nullable<Scene>): Mesh;
  127513. }
  127514. }
  127515. declare module BABYLON.Debug {
  127516. /**
  127517. * Used to show the physics impostor around the specific mesh
  127518. */
  127519. export class PhysicsViewer {
  127520. /** @hidden */
  127521. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  127522. /** @hidden */
  127523. protected _meshes: Array<Nullable<AbstractMesh>>;
  127524. /** @hidden */
  127525. protected _scene: Nullable<Scene>;
  127526. /** @hidden */
  127527. protected _numMeshes: number;
  127528. /** @hidden */
  127529. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  127530. private _renderFunction;
  127531. private _utilityLayer;
  127532. private _debugBoxMesh;
  127533. private _debugSphereMesh;
  127534. private _debugCylinderMesh;
  127535. private _debugMaterial;
  127536. private _debugMeshMeshes;
  127537. /**
  127538. * Creates a new PhysicsViewer
  127539. * @param scene defines the hosting scene
  127540. */
  127541. constructor(scene: Scene);
  127542. /** @hidden */
  127543. protected _updateDebugMeshes(): void;
  127544. /**
  127545. * Renders a specified physic impostor
  127546. * @param impostor defines the impostor to render
  127547. * @param targetMesh defines the mesh represented by the impostor
  127548. * @returns the new debug mesh used to render the impostor
  127549. */
  127550. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  127551. /**
  127552. * Hides a specified physic impostor
  127553. * @param impostor defines the impostor to hide
  127554. */
  127555. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  127556. private _getDebugMaterial;
  127557. private _getDebugBoxMesh;
  127558. private _getDebugSphereMesh;
  127559. private _getDebugCylinderMesh;
  127560. private _getDebugMeshMesh;
  127561. private _getDebugMesh;
  127562. /** Releases all resources */
  127563. dispose(): void;
  127564. }
  127565. }
  127566. declare module BABYLON {
  127567. /**
  127568. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127569. * in order to better appreciate the issue one might have.
  127570. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127571. */
  127572. export class RayHelper {
  127573. /**
  127574. * Defines the ray we are currently tryin to visualize.
  127575. */
  127576. ray: Nullable<Ray>;
  127577. private _renderPoints;
  127578. private _renderLine;
  127579. private _renderFunction;
  127580. private _scene;
  127581. private _updateToMeshFunction;
  127582. private _attachedToMesh;
  127583. private _meshSpaceDirection;
  127584. private _meshSpaceOrigin;
  127585. /**
  127586. * Helper function to create a colored helper in a scene in one line.
  127587. * @param ray Defines the ray we are currently tryin to visualize
  127588. * @param scene Defines the scene the ray is used in
  127589. * @param color Defines the color we want to see the ray in
  127590. * @returns The newly created ray helper.
  127591. */
  127592. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  127593. /**
  127594. * Instantiate a new ray helper.
  127595. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127596. * in order to better appreciate the issue one might have.
  127597. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127598. * @param ray Defines the ray we are currently tryin to visualize
  127599. */
  127600. constructor(ray: Ray);
  127601. /**
  127602. * Shows the ray we are willing to debug.
  127603. * @param scene Defines the scene the ray needs to be rendered in
  127604. * @param color Defines the color the ray needs to be rendered in
  127605. */
  127606. show(scene: Scene, color?: Color3): void;
  127607. /**
  127608. * Hides the ray we are debugging.
  127609. */
  127610. hide(): void;
  127611. private _render;
  127612. /**
  127613. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  127614. * @param mesh Defines the mesh we want the helper attached to
  127615. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  127616. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  127617. * @param length Defines the length of the ray
  127618. */
  127619. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  127620. /**
  127621. * Detach the ray helper from the mesh it has previously been attached to.
  127622. */
  127623. detachFromMesh(): void;
  127624. private _updateToMesh;
  127625. /**
  127626. * Dispose the helper and release its associated resources.
  127627. */
  127628. dispose(): void;
  127629. }
  127630. }
  127631. declare module BABYLON.Debug {
  127632. /**
  127633. * Class used to render a debug view of a given skeleton
  127634. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  127635. */
  127636. export class SkeletonViewer {
  127637. /** defines the skeleton to render */
  127638. skeleton: Skeleton;
  127639. /** defines the mesh attached to the skeleton */
  127640. mesh: AbstractMesh;
  127641. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127642. autoUpdateBonesMatrices: boolean;
  127643. /** defines the rendering group id to use with the viewer */
  127644. renderingGroupId: number;
  127645. /** Gets or sets the color used to render the skeleton */
  127646. color: Color3;
  127647. private _scene;
  127648. private _debugLines;
  127649. private _debugMesh;
  127650. private _isEnabled;
  127651. private _renderFunction;
  127652. private _utilityLayer;
  127653. /**
  127654. * Returns the mesh used to render the bones
  127655. */
  127656. get debugMesh(): Nullable<LinesMesh>;
  127657. /**
  127658. * Creates a new SkeletonViewer
  127659. * @param skeleton defines the skeleton to render
  127660. * @param mesh defines the mesh attached to the skeleton
  127661. * @param scene defines the hosting scene
  127662. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  127663. * @param renderingGroupId defines the rendering group id to use with the viewer
  127664. */
  127665. constructor(
  127666. /** defines the skeleton to render */
  127667. skeleton: Skeleton,
  127668. /** defines the mesh attached to the skeleton */
  127669. mesh: AbstractMesh, scene: Scene,
  127670. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127671. autoUpdateBonesMatrices?: boolean,
  127672. /** defines the rendering group id to use with the viewer */
  127673. renderingGroupId?: number);
  127674. /** Gets or sets a boolean indicating if the viewer is enabled */
  127675. set isEnabled(value: boolean);
  127676. get isEnabled(): boolean;
  127677. private _getBonePosition;
  127678. private _getLinesForBonesWithLength;
  127679. private _getLinesForBonesNoLength;
  127680. /** Update the viewer to sync with current skeleton state */
  127681. update(): void;
  127682. /** Release associated resources */
  127683. dispose(): void;
  127684. }
  127685. }
  127686. declare module BABYLON {
  127687. /**
  127688. * Enum for Device Types
  127689. */
  127690. export enum DeviceType {
  127691. /** Generic */
  127692. Generic = 0,
  127693. /** Keyboard */
  127694. Keyboard = 1,
  127695. /** Mouse */
  127696. Mouse = 2,
  127697. /** Touch Pointers */
  127698. Touch = 3,
  127699. /** PS4 Dual Shock */
  127700. DualShock = 4,
  127701. /** Xbox */
  127702. Xbox = 5,
  127703. /** Switch Controller */
  127704. Switch = 6
  127705. }
  127706. /**
  127707. * Enum for All Pointers (Touch/Mouse)
  127708. */
  127709. export enum PointerInput {
  127710. /** Horizontal Axis */
  127711. Horizontal = 0,
  127712. /** Vertical Axis */
  127713. Vertical = 1,
  127714. /** Left Click or Touch */
  127715. LeftClick = 2,
  127716. /** Middle Click */
  127717. MiddleClick = 3,
  127718. /** Right Click */
  127719. RightClick = 4,
  127720. /** Browser Back */
  127721. BrowserBack = 5,
  127722. /** Browser Forward */
  127723. BrowserForward = 6
  127724. }
  127725. /**
  127726. * Enum for Dual Shock Gamepad
  127727. */
  127728. export enum DualShockInput {
  127729. /** Cross */
  127730. Cross = 0,
  127731. /** Circle */
  127732. Circle = 1,
  127733. /** Square */
  127734. Square = 2,
  127735. /** Triangle */
  127736. Triangle = 3,
  127737. /** L1 */
  127738. L1 = 4,
  127739. /** R1 */
  127740. R1 = 5,
  127741. /** L2 */
  127742. L2 = 6,
  127743. /** R2 */
  127744. R2 = 7,
  127745. /** Share */
  127746. Share = 8,
  127747. /** Options */
  127748. Options = 9,
  127749. /** L3 */
  127750. L3 = 10,
  127751. /** R3 */
  127752. R3 = 11,
  127753. /** DPadUp */
  127754. DPadUp = 12,
  127755. /** DPadDown */
  127756. DPadDown = 13,
  127757. /** DPadLeft */
  127758. DPadLeft = 14,
  127759. /** DRight */
  127760. DPadRight = 15,
  127761. /** Home */
  127762. Home = 16,
  127763. /** TouchPad */
  127764. TouchPad = 17,
  127765. /** LStickXAxis */
  127766. LStickXAxis = 18,
  127767. /** LStickYAxis */
  127768. LStickYAxis = 19,
  127769. /** RStickXAxis */
  127770. RStickXAxis = 20,
  127771. /** RStickYAxis */
  127772. RStickYAxis = 21
  127773. }
  127774. /**
  127775. * Enum for Xbox Gamepad
  127776. */
  127777. export enum XboxInput {
  127778. /** A */
  127779. A = 0,
  127780. /** B */
  127781. B = 1,
  127782. /** X */
  127783. X = 2,
  127784. /** Y */
  127785. Y = 3,
  127786. /** LB */
  127787. LB = 4,
  127788. /** RB */
  127789. RB = 5,
  127790. /** LT */
  127791. LT = 6,
  127792. /** RT */
  127793. RT = 7,
  127794. /** Back */
  127795. Back = 8,
  127796. /** Start */
  127797. Start = 9,
  127798. /** LS */
  127799. LS = 10,
  127800. /** RS */
  127801. RS = 11,
  127802. /** DPadUp */
  127803. DPadUp = 12,
  127804. /** DPadDown */
  127805. DPadDown = 13,
  127806. /** DPadLeft */
  127807. DPadLeft = 14,
  127808. /** DRight */
  127809. DPadRight = 15,
  127810. /** Home */
  127811. Home = 16,
  127812. /** LStickXAxis */
  127813. LStickXAxis = 17,
  127814. /** LStickYAxis */
  127815. LStickYAxis = 18,
  127816. /** RStickXAxis */
  127817. RStickXAxis = 19,
  127818. /** RStickYAxis */
  127819. RStickYAxis = 20
  127820. }
  127821. /**
  127822. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  127823. */
  127824. export enum SwitchInput {
  127825. /** B */
  127826. B = 0,
  127827. /** A */
  127828. A = 1,
  127829. /** Y */
  127830. Y = 2,
  127831. /** X */
  127832. X = 3,
  127833. /** L */
  127834. L = 4,
  127835. /** R */
  127836. R = 5,
  127837. /** ZL */
  127838. ZL = 6,
  127839. /** ZR */
  127840. ZR = 7,
  127841. /** Minus */
  127842. Minus = 8,
  127843. /** Plus */
  127844. Plus = 9,
  127845. /** LS */
  127846. LS = 10,
  127847. /** RS */
  127848. RS = 11,
  127849. /** DPadUp */
  127850. DPadUp = 12,
  127851. /** DPadDown */
  127852. DPadDown = 13,
  127853. /** DPadLeft */
  127854. DPadLeft = 14,
  127855. /** DRight */
  127856. DPadRight = 15,
  127857. /** Home */
  127858. Home = 16,
  127859. /** Capture */
  127860. Capture = 17,
  127861. /** LStickXAxis */
  127862. LStickXAxis = 18,
  127863. /** LStickYAxis */
  127864. LStickYAxis = 19,
  127865. /** RStickXAxis */
  127866. RStickXAxis = 20,
  127867. /** RStickYAxis */
  127868. RStickYAxis = 21
  127869. }
  127870. }
  127871. declare module BABYLON {
  127872. /**
  127873. * This class will take all inputs from Keyboard, Pointer, and
  127874. * any Gamepads and provide a polling system that all devices
  127875. * will use. This class assumes that there will only be one
  127876. * pointer device and one keyboard.
  127877. */
  127878. export class DeviceInputSystem implements IDisposable {
  127879. /**
  127880. * Callback to be triggered when a device is connected
  127881. */
  127882. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127883. /**
  127884. * Callback to be triggered when a device is disconnected
  127885. */
  127886. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127887. /**
  127888. * Callback to be triggered when event driven input is updated
  127889. */
  127890. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  127891. private _inputs;
  127892. private _gamepads;
  127893. private _keyboardActive;
  127894. private _pointerActive;
  127895. private _elementToAttachTo;
  127896. private _keyboardDownEvent;
  127897. private _keyboardUpEvent;
  127898. private _pointerMoveEvent;
  127899. private _pointerDownEvent;
  127900. private _pointerUpEvent;
  127901. private _gamepadConnectedEvent;
  127902. private _gamepadDisconnectedEvent;
  127903. private static _MAX_KEYCODES;
  127904. private static _MAX_POINTER_INPUTS;
  127905. private constructor();
  127906. /**
  127907. * Creates a new DeviceInputSystem instance
  127908. * @param engine Engine to pull input element from
  127909. * @returns The new instance
  127910. */
  127911. static Create(engine: Engine): DeviceInputSystem;
  127912. /**
  127913. * Checks for current device input value, given an id and input index
  127914. * @param deviceName Id of connected device
  127915. * @param inputIndex Index of device input
  127916. * @returns Current value of input
  127917. */
  127918. /**
  127919. * Checks for current device input value, given an id and input index
  127920. * @param deviceType Enum specifiying device type
  127921. * @param deviceSlot "Slot" or index that device is referenced in
  127922. * @param inputIndex Id of input to be checked
  127923. * @returns Current value of input
  127924. */
  127925. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  127926. /**
  127927. * Dispose of all the eventlisteners
  127928. */
  127929. dispose(): void;
  127930. /**
  127931. * Add device and inputs to device array
  127932. * @param deviceType Enum specifiying device type
  127933. * @param deviceSlot "Slot" or index that device is referenced in
  127934. * @param numberOfInputs Number of input entries to create for given device
  127935. */
  127936. private _registerDevice;
  127937. /**
  127938. * Given a specific device name, remove that device from the device map
  127939. * @param deviceType Enum specifiying device type
  127940. * @param deviceSlot "Slot" or index that device is referenced in
  127941. */
  127942. private _unregisterDevice;
  127943. /**
  127944. * Handle all actions that come from keyboard interaction
  127945. */
  127946. private _handleKeyActions;
  127947. /**
  127948. * Handle all actions that come from pointer interaction
  127949. */
  127950. private _handlePointerActions;
  127951. /**
  127952. * Handle all actions that come from gamepad interaction
  127953. */
  127954. private _handleGamepadActions;
  127955. /**
  127956. * Update all non-event based devices with each frame
  127957. * @param deviceType Enum specifiying device type
  127958. * @param deviceSlot "Slot" or index that device is referenced in
  127959. * @param inputIndex Id of input to be checked
  127960. */
  127961. private _updateDevice;
  127962. /**
  127963. * Gets DeviceType from the device name
  127964. * @param deviceName Name of Device from DeviceInputSystem
  127965. * @returns DeviceType enum value
  127966. */
  127967. private _getGamepadDeviceType;
  127968. }
  127969. }
  127970. declare module BABYLON {
  127971. /**
  127972. * Type to handle enforcement of inputs
  127973. */
  127974. 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;
  127975. }
  127976. declare module BABYLON {
  127977. /**
  127978. * Class that handles all input for a specific device
  127979. */
  127980. export class DeviceSource<T extends DeviceType> {
  127981. /** Type of device */
  127982. readonly deviceType: DeviceType;
  127983. /** "Slot" or index that device is referenced in */
  127984. readonly deviceSlot: number;
  127985. /**
  127986. * Observable to handle device input changes per device
  127987. */
  127988. readonly onInputChangedObservable: Observable<{
  127989. inputIndex: DeviceInput<T>;
  127990. previousState: Nullable<number>;
  127991. currentState: Nullable<number>;
  127992. }>;
  127993. private readonly _deviceInputSystem;
  127994. /**
  127995. * Default Constructor
  127996. * @param deviceInputSystem Reference to DeviceInputSystem
  127997. * @param deviceType Type of device
  127998. * @param deviceSlot "Slot" or index that device is referenced in
  127999. */
  128000. constructor(deviceInputSystem: DeviceInputSystem,
  128001. /** Type of device */
  128002. deviceType: DeviceType,
  128003. /** "Slot" or index that device is referenced in */
  128004. deviceSlot?: number);
  128005. /**
  128006. * Get input for specific input
  128007. * @param inputIndex index of specific input on device
  128008. * @returns Input value from DeviceInputSystem
  128009. */
  128010. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  128011. }
  128012. /**
  128013. * Class to keep track of devices
  128014. */
  128015. export class DeviceSourceManager implements IDisposable {
  128016. /**
  128017. * Observable to be triggered when before a device is connected
  128018. */
  128019. readonly onBeforeDeviceConnectedObservable: Observable<{
  128020. deviceType: DeviceType;
  128021. deviceSlot: number;
  128022. }>;
  128023. /**
  128024. * Observable to be triggered when before a device is disconnected
  128025. */
  128026. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  128027. deviceType: DeviceType;
  128028. deviceSlot: number;
  128029. }>;
  128030. /**
  128031. * Observable to be triggered when after a device is connected
  128032. */
  128033. readonly onAfterDeviceConnectedObservable: Observable<{
  128034. deviceType: DeviceType;
  128035. deviceSlot: number;
  128036. }>;
  128037. /**
  128038. * Observable to be triggered when after a device is disconnected
  128039. */
  128040. readonly onAfterDeviceDisconnectedObservable: Observable<{
  128041. deviceType: DeviceType;
  128042. deviceSlot: number;
  128043. }>;
  128044. private readonly _devices;
  128045. private readonly _firstDevice;
  128046. private readonly _deviceInputSystem;
  128047. /**
  128048. * Default Constructor
  128049. * @param engine engine to pull input element from
  128050. */
  128051. constructor(engine: Engine);
  128052. /**
  128053. * Gets a DeviceSource, given a type and slot
  128054. * @param deviceType Enum specifying device type
  128055. * @param deviceSlot "Slot" or index that device is referenced in
  128056. * @returns DeviceSource object
  128057. */
  128058. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  128059. /**
  128060. * Gets an array of DeviceSource objects for a given device type
  128061. * @param deviceType Enum specifying device type
  128062. * @returns Array of DeviceSource objects
  128063. */
  128064. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  128065. /**
  128066. * Dispose of DeviceInputSystem and other parts
  128067. */
  128068. dispose(): void;
  128069. /**
  128070. * Function to add device name to device list
  128071. * @param deviceType Enum specifying device type
  128072. * @param deviceSlot "Slot" or index that device is referenced in
  128073. */
  128074. private _addDevice;
  128075. /**
  128076. * Function to remove device name to device list
  128077. * @param deviceType Enum specifying device type
  128078. * @param deviceSlot "Slot" or index that device is referenced in
  128079. */
  128080. private _removeDevice;
  128081. /**
  128082. * Updates array storing first connected device of each type
  128083. * @param type Type of Device
  128084. */
  128085. private _updateFirstDevices;
  128086. }
  128087. }
  128088. declare module BABYLON {
  128089. /**
  128090. * Options to create the null engine
  128091. */
  128092. export class NullEngineOptions {
  128093. /**
  128094. * Render width (Default: 512)
  128095. */
  128096. renderWidth: number;
  128097. /**
  128098. * Render height (Default: 256)
  128099. */
  128100. renderHeight: number;
  128101. /**
  128102. * Texture size (Default: 512)
  128103. */
  128104. textureSize: number;
  128105. /**
  128106. * If delta time between frames should be constant
  128107. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128108. */
  128109. deterministicLockstep: boolean;
  128110. /**
  128111. * Maximum about of steps between frames (Default: 4)
  128112. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128113. */
  128114. lockstepMaxSteps: number;
  128115. }
  128116. /**
  128117. * The null engine class provides support for headless version of babylon.js.
  128118. * This can be used in server side scenario or for testing purposes
  128119. */
  128120. export class NullEngine extends Engine {
  128121. private _options;
  128122. /**
  128123. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  128124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128125. * @returns true if engine is in deterministic lock step mode
  128126. */
  128127. isDeterministicLockStep(): boolean;
  128128. /**
  128129. * Gets the max steps when engine is running in deterministic lock step
  128130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128131. * @returns the max steps
  128132. */
  128133. getLockstepMaxSteps(): number;
  128134. /**
  128135. * Gets the current hardware scaling level.
  128136. * By default the hardware scaling level is computed from the window device ratio.
  128137. * 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.
  128138. * @returns a number indicating the current hardware scaling level
  128139. */
  128140. getHardwareScalingLevel(): number;
  128141. constructor(options?: NullEngineOptions);
  128142. /**
  128143. * Creates a vertex buffer
  128144. * @param vertices the data for the vertex buffer
  128145. * @returns the new WebGL static buffer
  128146. */
  128147. createVertexBuffer(vertices: FloatArray): DataBuffer;
  128148. /**
  128149. * Creates a new index buffer
  128150. * @param indices defines the content of the index buffer
  128151. * @param updatable defines if the index buffer must be updatable
  128152. * @returns a new webGL buffer
  128153. */
  128154. createIndexBuffer(indices: IndicesArray): DataBuffer;
  128155. /**
  128156. * Clear the current render buffer or the current render target (if any is set up)
  128157. * @param color defines the color to use
  128158. * @param backBuffer defines if the back buffer must be cleared
  128159. * @param depth defines if the depth buffer must be cleared
  128160. * @param stencil defines if the stencil buffer must be cleared
  128161. */
  128162. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128163. /**
  128164. * Gets the current render width
  128165. * @param useScreen defines if screen size must be used (or the current render target if any)
  128166. * @returns a number defining the current render width
  128167. */
  128168. getRenderWidth(useScreen?: boolean): number;
  128169. /**
  128170. * Gets the current render height
  128171. * @param useScreen defines if screen size must be used (or the current render target if any)
  128172. * @returns a number defining the current render height
  128173. */
  128174. getRenderHeight(useScreen?: boolean): number;
  128175. /**
  128176. * Set the WebGL's viewport
  128177. * @param viewport defines the viewport element to be used
  128178. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  128179. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  128180. */
  128181. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  128182. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  128183. /**
  128184. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  128185. * @param pipelineContext defines the pipeline context to use
  128186. * @param uniformsNames defines the list of uniform names
  128187. * @returns an array of webGL uniform locations
  128188. */
  128189. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  128190. /**
  128191. * Gets the lsit of active attributes for a given webGL program
  128192. * @param pipelineContext defines the pipeline context to use
  128193. * @param attributesNames defines the list of attribute names to get
  128194. * @returns an array of indices indicating the offset of each attribute
  128195. */
  128196. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128197. /**
  128198. * Binds an effect to the webGL context
  128199. * @param effect defines the effect to bind
  128200. */
  128201. bindSamplers(effect: Effect): void;
  128202. /**
  128203. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  128204. * @param effect defines the effect to activate
  128205. */
  128206. enableEffect(effect: Effect): void;
  128207. /**
  128208. * Set various states to the webGL context
  128209. * @param culling defines backface culling state
  128210. * @param zOffset defines the value to apply to zOffset (0 by default)
  128211. * @param force defines if states must be applied even if cache is up to date
  128212. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  128213. */
  128214. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128215. /**
  128216. * Set the value of an uniform to an array of int32
  128217. * @param uniform defines the webGL uniform location where to store the value
  128218. * @param array defines the array of int32 to store
  128219. */
  128220. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128221. /**
  128222. * Set the value of an uniform to an array of int32 (stored as vec2)
  128223. * @param uniform defines the webGL uniform location where to store the value
  128224. * @param array defines the array of int32 to store
  128225. */
  128226. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128227. /**
  128228. * Set the value of an uniform to an array of int32 (stored as vec3)
  128229. * @param uniform defines the webGL uniform location where to store the value
  128230. * @param array defines the array of int32 to store
  128231. */
  128232. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128233. /**
  128234. * Set the value of an uniform to an array of int32 (stored as vec4)
  128235. * @param uniform defines the webGL uniform location where to store the value
  128236. * @param array defines the array of int32 to store
  128237. */
  128238. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128239. /**
  128240. * Set the value of an uniform to an array of float32
  128241. * @param uniform defines the webGL uniform location where to store the value
  128242. * @param array defines the array of float32 to store
  128243. */
  128244. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128245. /**
  128246. * Set the value of an uniform to an array of float32 (stored as vec2)
  128247. * @param uniform defines the webGL uniform location where to store the value
  128248. * @param array defines the array of float32 to store
  128249. */
  128250. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128251. /**
  128252. * Set the value of an uniform to an array of float32 (stored as vec3)
  128253. * @param uniform defines the webGL uniform location where to store the value
  128254. * @param array defines the array of float32 to store
  128255. */
  128256. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128257. /**
  128258. * Set the value of an uniform to an array of float32 (stored as vec4)
  128259. * @param uniform defines the webGL uniform location where to store the value
  128260. * @param array defines the array of float32 to store
  128261. */
  128262. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128263. /**
  128264. * Set the value of an uniform to an array of number
  128265. * @param uniform defines the webGL uniform location where to store the value
  128266. * @param array defines the array of number to store
  128267. */
  128268. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128269. /**
  128270. * Set the value of an uniform to an array of number (stored as vec2)
  128271. * @param uniform defines the webGL uniform location where to store the value
  128272. * @param array defines the array of number to store
  128273. */
  128274. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128275. /**
  128276. * Set the value of an uniform to an array of number (stored as vec3)
  128277. * @param uniform defines the webGL uniform location where to store the value
  128278. * @param array defines the array of number to store
  128279. */
  128280. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128281. /**
  128282. * Set the value of an uniform to an array of number (stored as vec4)
  128283. * @param uniform defines the webGL uniform location where to store the value
  128284. * @param array defines the array of number to store
  128285. */
  128286. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128287. /**
  128288. * Set the value of an uniform to an array of float32 (stored as matrices)
  128289. * @param uniform defines the webGL uniform location where to store the value
  128290. * @param matrices defines the array of float32 to store
  128291. */
  128292. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128293. /**
  128294. * Set the value of an uniform to a matrix (3x3)
  128295. * @param uniform defines the webGL uniform location where to store the value
  128296. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  128297. */
  128298. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128299. /**
  128300. * Set the value of an uniform to a matrix (2x2)
  128301. * @param uniform defines the webGL uniform location where to store the value
  128302. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  128303. */
  128304. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128305. /**
  128306. * Set the value of an uniform to a number (float)
  128307. * @param uniform defines the webGL uniform location where to store the value
  128308. * @param value defines the float number to store
  128309. */
  128310. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128311. /**
  128312. * Set the value of an uniform to a vec2
  128313. * @param uniform defines the webGL uniform location where to store the value
  128314. * @param x defines the 1st component of the value
  128315. * @param y defines the 2nd component of the value
  128316. */
  128317. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128318. /**
  128319. * Set the value of an uniform to a vec3
  128320. * @param uniform defines the webGL uniform location where to store the value
  128321. * @param x defines the 1st component of the value
  128322. * @param y defines the 2nd component of the value
  128323. * @param z defines the 3rd component of the value
  128324. */
  128325. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128326. /**
  128327. * Set the value of an uniform to a boolean
  128328. * @param uniform defines the webGL uniform location where to store the value
  128329. * @param bool defines the boolean to store
  128330. */
  128331. setBool(uniform: WebGLUniformLocation, bool: number): void;
  128332. /**
  128333. * Set the value of an uniform to a vec4
  128334. * @param uniform defines the webGL uniform location where to store the value
  128335. * @param x defines the 1st component of the value
  128336. * @param y defines the 2nd component of the value
  128337. * @param z defines the 3rd component of the value
  128338. * @param w defines the 4th component of the value
  128339. */
  128340. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128341. /**
  128342. * Sets the current alpha mode
  128343. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  128344. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128345. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128346. */
  128347. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128348. /**
  128349. * Bind webGl buffers directly to the webGL context
  128350. * @param vertexBuffers defines the vertex buffer to bind
  128351. * @param indexBuffer defines the index buffer to bind
  128352. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  128353. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  128354. * @param effect defines the effect associated with the vertex buffer
  128355. */
  128356. bindBuffers(vertexBuffers: {
  128357. [key: string]: VertexBuffer;
  128358. }, indexBuffer: DataBuffer, effect: Effect): void;
  128359. /**
  128360. * Force the entire cache to be cleared
  128361. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  128362. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  128363. */
  128364. wipeCaches(bruteForce?: boolean): void;
  128365. /**
  128366. * Send a draw order
  128367. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  128368. * @param indexStart defines the starting index
  128369. * @param indexCount defines the number of index to draw
  128370. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128371. */
  128372. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  128373. /**
  128374. * Draw a list of indexed primitives
  128375. * @param fillMode defines the primitive to use
  128376. * @param indexStart defines the starting index
  128377. * @param indexCount defines the number of index to draw
  128378. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128379. */
  128380. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128381. /**
  128382. * Draw a list of unindexed primitives
  128383. * @param fillMode defines the primitive to use
  128384. * @param verticesStart defines the index of first vertex to draw
  128385. * @param verticesCount defines the count of vertices to draw
  128386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128387. */
  128388. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128389. /** @hidden */
  128390. _createTexture(): WebGLTexture;
  128391. /** @hidden */
  128392. _releaseTexture(texture: InternalTexture): void;
  128393. /**
  128394. * Usually called from Texture.ts.
  128395. * Passed information to create a WebGLTexture
  128396. * @param urlArg defines a value which contains one of the following:
  128397. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128398. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128399. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128400. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128401. * @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)
  128402. * @param scene needed for loading to the correct scene
  128403. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128404. * @param onLoad optional callback to be called upon successful completion
  128405. * @param onError optional callback to be called upon failure
  128406. * @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
  128407. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128408. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128409. * @param forcedExtension defines the extension to use to pick the right loader
  128410. * @param mimeType defines an optional mime type
  128411. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128412. */
  128413. 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;
  128414. /**
  128415. * Creates a new render target texture
  128416. * @param size defines the size of the texture
  128417. * @param options defines the options used to create the texture
  128418. * @returns a new render target texture stored in an InternalTexture
  128419. */
  128420. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  128421. /**
  128422. * Update the sampling mode of a given texture
  128423. * @param samplingMode defines the required sampling mode
  128424. * @param texture defines the texture to update
  128425. */
  128426. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128427. /**
  128428. * Binds the frame buffer to the specified texture.
  128429. * @param texture The texture to render to or null for the default canvas
  128430. * @param faceIndex The face of the texture to render to in case of cube texture
  128431. * @param requiredWidth The width of the target to render to
  128432. * @param requiredHeight The height of the target to render to
  128433. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  128434. * @param lodLevel defines le lod level to bind to the frame buffer
  128435. */
  128436. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128437. /**
  128438. * Unbind the current render target texture from the webGL context
  128439. * @param texture defines the render target texture to unbind
  128440. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128441. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128442. */
  128443. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128444. /**
  128445. * Creates a dynamic vertex buffer
  128446. * @param vertices the data for the dynamic vertex buffer
  128447. * @returns the new WebGL dynamic buffer
  128448. */
  128449. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  128450. /**
  128451. * Update the content of a dynamic texture
  128452. * @param texture defines the texture to update
  128453. * @param canvas defines the canvas containing the source
  128454. * @param invertY defines if data must be stored with Y axis inverted
  128455. * @param premulAlpha defines if alpha is stored as premultiplied
  128456. * @param format defines the format of the data
  128457. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  128458. */
  128459. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  128460. /**
  128461. * Gets a boolean indicating if all created effects are ready
  128462. * @returns true if all effects are ready
  128463. */
  128464. areAllEffectsReady(): boolean;
  128465. /**
  128466. * @hidden
  128467. * Get the current error code of the webGL context
  128468. * @returns the error code
  128469. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  128470. */
  128471. getError(): number;
  128472. /** @hidden */
  128473. _getUnpackAlignement(): number;
  128474. /** @hidden */
  128475. _unpackFlipY(value: boolean): void;
  128476. /**
  128477. * Update a dynamic index buffer
  128478. * @param indexBuffer defines the target index buffer
  128479. * @param indices defines the data to update
  128480. * @param offset defines the offset in the target index buffer where update should start
  128481. */
  128482. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  128483. /**
  128484. * Updates a dynamic vertex buffer.
  128485. * @param vertexBuffer the vertex buffer to update
  128486. * @param vertices the data used to update the vertex buffer
  128487. * @param byteOffset the byte offset of the data (optional)
  128488. * @param byteLength the byte length of the data (optional)
  128489. */
  128490. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  128491. /** @hidden */
  128492. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  128493. /** @hidden */
  128494. _bindTexture(channel: number, texture: InternalTexture): void;
  128495. protected _deleteBuffer(buffer: WebGLBuffer): void;
  128496. /**
  128497. * 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
  128498. */
  128499. releaseEffects(): void;
  128500. displayLoadingUI(): void;
  128501. hideLoadingUI(): void;
  128502. /** @hidden */
  128503. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128504. /** @hidden */
  128505. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128506. /** @hidden */
  128507. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128508. /** @hidden */
  128509. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128510. }
  128511. }
  128512. declare module BABYLON {
  128513. /**
  128514. * @hidden
  128515. **/
  128516. export class _TimeToken {
  128517. _startTimeQuery: Nullable<WebGLQuery>;
  128518. _endTimeQuery: Nullable<WebGLQuery>;
  128519. _timeElapsedQuery: Nullable<WebGLQuery>;
  128520. _timeElapsedQueryEnded: boolean;
  128521. }
  128522. }
  128523. declare module BABYLON {
  128524. /** @hidden */
  128525. export class _OcclusionDataStorage {
  128526. /** @hidden */
  128527. occlusionInternalRetryCounter: number;
  128528. /** @hidden */
  128529. isOcclusionQueryInProgress: boolean;
  128530. /** @hidden */
  128531. isOccluded: boolean;
  128532. /** @hidden */
  128533. occlusionRetryCount: number;
  128534. /** @hidden */
  128535. occlusionType: number;
  128536. /** @hidden */
  128537. occlusionQueryAlgorithmType: number;
  128538. }
  128539. interface Engine {
  128540. /**
  128541. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  128542. * @return the new query
  128543. */
  128544. createQuery(): WebGLQuery;
  128545. /**
  128546. * Delete and release a webGL query
  128547. * @param query defines the query to delete
  128548. * @return the current engine
  128549. */
  128550. deleteQuery(query: WebGLQuery): Engine;
  128551. /**
  128552. * Check if a given query has resolved and got its value
  128553. * @param query defines the query to check
  128554. * @returns true if the query got its value
  128555. */
  128556. isQueryResultAvailable(query: WebGLQuery): boolean;
  128557. /**
  128558. * Gets the value of a given query
  128559. * @param query defines the query to check
  128560. * @returns the value of the query
  128561. */
  128562. getQueryResult(query: WebGLQuery): number;
  128563. /**
  128564. * Initiates an occlusion query
  128565. * @param algorithmType defines the algorithm to use
  128566. * @param query defines the query to use
  128567. * @returns the current engine
  128568. * @see http://doc.babylonjs.com/features/occlusionquery
  128569. */
  128570. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  128571. /**
  128572. * Ends an occlusion query
  128573. * @see http://doc.babylonjs.com/features/occlusionquery
  128574. * @param algorithmType defines the algorithm to use
  128575. * @returns the current engine
  128576. */
  128577. endOcclusionQuery(algorithmType: number): Engine;
  128578. /**
  128579. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  128580. * Please note that only one query can be issued at a time
  128581. * @returns a time token used to track the time span
  128582. */
  128583. startTimeQuery(): Nullable<_TimeToken>;
  128584. /**
  128585. * Ends a time query
  128586. * @param token defines the token used to measure the time span
  128587. * @returns the time spent (in ns)
  128588. */
  128589. endTimeQuery(token: _TimeToken): int;
  128590. /** @hidden */
  128591. _currentNonTimestampToken: Nullable<_TimeToken>;
  128592. /** @hidden */
  128593. _createTimeQuery(): WebGLQuery;
  128594. /** @hidden */
  128595. _deleteTimeQuery(query: WebGLQuery): void;
  128596. /** @hidden */
  128597. _getGlAlgorithmType(algorithmType: number): number;
  128598. /** @hidden */
  128599. _getTimeQueryResult(query: WebGLQuery): any;
  128600. /** @hidden */
  128601. _getTimeQueryAvailability(query: WebGLQuery): any;
  128602. }
  128603. interface AbstractMesh {
  128604. /**
  128605. * Backing filed
  128606. * @hidden
  128607. */
  128608. __occlusionDataStorage: _OcclusionDataStorage;
  128609. /**
  128610. * Access property
  128611. * @hidden
  128612. */
  128613. _occlusionDataStorage: _OcclusionDataStorage;
  128614. /**
  128615. * 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.
  128616. * The default value is -1 which means don't break the query and wait till the result
  128617. * @see http://doc.babylonjs.com/features/occlusionquery
  128618. */
  128619. occlusionRetryCount: number;
  128620. /**
  128621. * 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:
  128622. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  128623. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  128624. * * 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.
  128625. * @see http://doc.babylonjs.com/features/occlusionquery
  128626. */
  128627. occlusionType: number;
  128628. /**
  128629. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  128630. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  128631. * * 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.
  128632. * @see http://doc.babylonjs.com/features/occlusionquery
  128633. */
  128634. occlusionQueryAlgorithmType: number;
  128635. /**
  128636. * 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
  128637. * @see http://doc.babylonjs.com/features/occlusionquery
  128638. */
  128639. isOccluded: boolean;
  128640. /**
  128641. * Flag to check the progress status of the query
  128642. * @see http://doc.babylonjs.com/features/occlusionquery
  128643. */
  128644. isOcclusionQueryInProgress: boolean;
  128645. }
  128646. }
  128647. declare module BABYLON {
  128648. /** @hidden */
  128649. export var _forceTransformFeedbackToBundle: boolean;
  128650. interface Engine {
  128651. /**
  128652. * Creates a webGL transform feedback object
  128653. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  128654. * @returns the webGL transform feedback object
  128655. */
  128656. createTransformFeedback(): WebGLTransformFeedback;
  128657. /**
  128658. * Delete a webGL transform feedback object
  128659. * @param value defines the webGL transform feedback object to delete
  128660. */
  128661. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  128662. /**
  128663. * Bind a webGL transform feedback object to the webgl context
  128664. * @param value defines the webGL transform feedback object to bind
  128665. */
  128666. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  128667. /**
  128668. * Begins a transform feedback operation
  128669. * @param usePoints defines if points or triangles must be used
  128670. */
  128671. beginTransformFeedback(usePoints: boolean): void;
  128672. /**
  128673. * Ends a transform feedback operation
  128674. */
  128675. endTransformFeedback(): void;
  128676. /**
  128677. * Specify the varyings to use with transform feedback
  128678. * @param program defines the associated webGL program
  128679. * @param value defines the list of strings representing the varying names
  128680. */
  128681. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  128682. /**
  128683. * Bind a webGL buffer for a transform feedback operation
  128684. * @param value defines the webGL buffer to bind
  128685. */
  128686. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  128687. }
  128688. }
  128689. declare module BABYLON {
  128690. /**
  128691. * Creation options of the multi render target texture.
  128692. */
  128693. export interface IMultiRenderTargetOptions {
  128694. /**
  128695. * Define if the texture needs to create mip maps after render.
  128696. */
  128697. generateMipMaps?: boolean;
  128698. /**
  128699. * Define the types of all the draw buffers we want to create
  128700. */
  128701. types?: number[];
  128702. /**
  128703. * Define the sampling modes of all the draw buffers we want to create
  128704. */
  128705. samplingModes?: number[];
  128706. /**
  128707. * Define if a depth buffer is required
  128708. */
  128709. generateDepthBuffer?: boolean;
  128710. /**
  128711. * Define if a stencil buffer is required
  128712. */
  128713. generateStencilBuffer?: boolean;
  128714. /**
  128715. * Define if a depth texture is required instead of a depth buffer
  128716. */
  128717. generateDepthTexture?: boolean;
  128718. /**
  128719. * Define the number of desired draw buffers
  128720. */
  128721. textureCount?: number;
  128722. /**
  128723. * Define if aspect ratio should be adapted to the texture or stay the scene one
  128724. */
  128725. doNotChangeAspectRatio?: boolean;
  128726. /**
  128727. * Define the default type of the buffers we are creating
  128728. */
  128729. defaultType?: number;
  128730. }
  128731. /**
  128732. * A multi render target, like a render target provides the ability to render to a texture.
  128733. * Unlike the render target, it can render to several draw buffers in one draw.
  128734. * This is specially interesting in deferred rendering or for any effects requiring more than
  128735. * just one color from a single pass.
  128736. */
  128737. export class MultiRenderTarget extends RenderTargetTexture {
  128738. private _internalTextures;
  128739. private _textures;
  128740. private _multiRenderTargetOptions;
  128741. /**
  128742. * Get if draw buffers are currently supported by the used hardware and browser.
  128743. */
  128744. get isSupported(): boolean;
  128745. /**
  128746. * Get the list of textures generated by the multi render target.
  128747. */
  128748. get textures(): Texture[];
  128749. /**
  128750. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  128751. */
  128752. get depthTexture(): Texture;
  128753. /**
  128754. * Set the wrapping mode on U of all the textures we are rendering to.
  128755. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  128756. */
  128757. set wrapU(wrap: number);
  128758. /**
  128759. * Set the wrapping mode on V of all the textures we are rendering to.
  128760. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  128761. */
  128762. set wrapV(wrap: number);
  128763. /**
  128764. * Instantiate a new multi render target texture.
  128765. * A multi render target, like a render target provides the ability to render to a texture.
  128766. * Unlike the render target, it can render to several draw buffers in one draw.
  128767. * This is specially interesting in deferred rendering or for any effects requiring more than
  128768. * just one color from a single pass.
  128769. * @param name Define the name of the texture
  128770. * @param size Define the size of the buffers to render to
  128771. * @param count Define the number of target we are rendering into
  128772. * @param scene Define the scene the texture belongs to
  128773. * @param options Define the options used to create the multi render target
  128774. */
  128775. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  128776. /** @hidden */
  128777. _rebuild(): void;
  128778. private _createInternalTextures;
  128779. private _createTextures;
  128780. /**
  128781. * Define the number of samples used if MSAA is enabled.
  128782. */
  128783. get samples(): number;
  128784. set samples(value: number);
  128785. /**
  128786. * Resize all the textures in the multi render target.
  128787. * Be carrefull as it will recreate all the data in the new texture.
  128788. * @param size Define the new size
  128789. */
  128790. resize(size: any): void;
  128791. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  128792. /**
  128793. * Dispose the render targets and their associated resources
  128794. */
  128795. dispose(): void;
  128796. /**
  128797. * Release all the underlying texture used as draw buffers.
  128798. */
  128799. releaseInternalTextures(): void;
  128800. }
  128801. }
  128802. declare module BABYLON {
  128803. interface ThinEngine {
  128804. /**
  128805. * Unbind a list of render target textures from the webGL context
  128806. * This is used only when drawBuffer extension or webGL2 are active
  128807. * @param textures defines the render target textures to unbind
  128808. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128809. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128810. */
  128811. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  128812. /**
  128813. * Create a multi render target texture
  128814. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  128815. * @param size defines the size of the texture
  128816. * @param options defines the creation options
  128817. * @returns the cube texture as an InternalTexture
  128818. */
  128819. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  128820. /**
  128821. * Update the sample count for a given multiple render target texture
  128822. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  128823. * @param textures defines the textures to update
  128824. * @param samples defines the sample count to set
  128825. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  128826. */
  128827. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  128828. }
  128829. }
  128830. declare module BABYLON {
  128831. /**
  128832. * Class used to define an additional view for the engine
  128833. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128834. */
  128835. export class EngineView {
  128836. /** Defines the canvas where to render the view */
  128837. target: HTMLCanvasElement;
  128838. /** Defines an optional camera used to render the view (will use active camera else) */
  128839. camera?: Camera;
  128840. }
  128841. interface Engine {
  128842. /**
  128843. * Gets or sets the HTML element to use for attaching events
  128844. */
  128845. inputElement: Nullable<HTMLElement>;
  128846. /**
  128847. * Gets the current engine view
  128848. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128849. */
  128850. activeView: Nullable<EngineView>;
  128851. /** Gets or sets the list of views */
  128852. views: EngineView[];
  128853. /**
  128854. * Register a new child canvas
  128855. * @param canvas defines the canvas to register
  128856. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  128857. * @returns the associated view
  128858. */
  128859. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  128860. /**
  128861. * Remove a registered child canvas
  128862. * @param canvas defines the canvas to remove
  128863. * @returns the current engine
  128864. */
  128865. unRegisterView(canvas: HTMLCanvasElement): Engine;
  128866. }
  128867. }
  128868. declare module BABYLON {
  128869. interface Engine {
  128870. /** @hidden */
  128871. _excludedCompressedTextures: string[];
  128872. /** @hidden */
  128873. _textureFormatInUse: string;
  128874. /**
  128875. * Gets the list of texture formats supported
  128876. */
  128877. readonly texturesSupported: Array<string>;
  128878. /**
  128879. * Gets the texture format in use
  128880. */
  128881. readonly textureFormatInUse: Nullable<string>;
  128882. /**
  128883. * Set the compressed texture extensions or file names to skip.
  128884. *
  128885. * @param skippedFiles defines the list of those texture files you want to skip
  128886. * Example: [".dds", ".env", "myfile.png"]
  128887. */
  128888. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  128889. /**
  128890. * Set the compressed texture format to use, based on the formats you have, and the formats
  128891. * supported by the hardware / browser.
  128892. *
  128893. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  128894. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  128895. * to API arguments needed to compressed textures. This puts the burden on the container
  128896. * generator to house the arcane code for determining these for current & future formats.
  128897. *
  128898. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  128899. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  128900. *
  128901. * Note: The result of this call is not taken into account when a texture is base64.
  128902. *
  128903. * @param formatsAvailable defines the list of those format families you have created
  128904. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  128905. *
  128906. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  128907. * @returns The extension selected.
  128908. */
  128909. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  128910. }
  128911. }
  128912. declare module BABYLON {
  128913. /**
  128914. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  128915. */
  128916. export interface CubeMapInfo {
  128917. /**
  128918. * The pixel array for the front face.
  128919. * This is stored in format, left to right, up to down format.
  128920. */
  128921. front: Nullable<ArrayBufferView>;
  128922. /**
  128923. * The pixel array for the back face.
  128924. * This is stored in format, left to right, up to down format.
  128925. */
  128926. back: Nullable<ArrayBufferView>;
  128927. /**
  128928. * The pixel array for the left face.
  128929. * This is stored in format, left to right, up to down format.
  128930. */
  128931. left: Nullable<ArrayBufferView>;
  128932. /**
  128933. * The pixel array for the right face.
  128934. * This is stored in format, left to right, up to down format.
  128935. */
  128936. right: Nullable<ArrayBufferView>;
  128937. /**
  128938. * The pixel array for the up face.
  128939. * This is stored in format, left to right, up to down format.
  128940. */
  128941. up: Nullable<ArrayBufferView>;
  128942. /**
  128943. * The pixel array for the down face.
  128944. * This is stored in format, left to right, up to down format.
  128945. */
  128946. down: Nullable<ArrayBufferView>;
  128947. /**
  128948. * The size of the cubemap stored.
  128949. *
  128950. * Each faces will be size * size pixels.
  128951. */
  128952. size: number;
  128953. /**
  128954. * The format of the texture.
  128955. *
  128956. * RGBA, RGB.
  128957. */
  128958. format: number;
  128959. /**
  128960. * The type of the texture data.
  128961. *
  128962. * UNSIGNED_INT, FLOAT.
  128963. */
  128964. type: number;
  128965. /**
  128966. * Specifies whether the texture is in gamma space.
  128967. */
  128968. gammaSpace: boolean;
  128969. }
  128970. /**
  128971. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  128972. */
  128973. export class PanoramaToCubeMapTools {
  128974. private static FACE_LEFT;
  128975. private static FACE_RIGHT;
  128976. private static FACE_FRONT;
  128977. private static FACE_BACK;
  128978. private static FACE_DOWN;
  128979. private static FACE_UP;
  128980. /**
  128981. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  128982. *
  128983. * @param float32Array The source data.
  128984. * @param inputWidth The width of the input panorama.
  128985. * @param inputHeight The height of the input panorama.
  128986. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  128987. * @return The cubemap data
  128988. */
  128989. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  128990. private static CreateCubemapTexture;
  128991. private static CalcProjectionSpherical;
  128992. }
  128993. }
  128994. declare module BABYLON {
  128995. /**
  128996. * Helper class dealing with the extraction of spherical polynomial dataArray
  128997. * from a cube map.
  128998. */
  128999. export class CubeMapToSphericalPolynomialTools {
  129000. private static FileFaces;
  129001. /**
  129002. * Converts a texture to the according Spherical Polynomial data.
  129003. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129004. *
  129005. * @param texture The texture to extract the information from.
  129006. * @return The Spherical Polynomial data.
  129007. */
  129008. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  129009. /**
  129010. * Converts a cubemap to the according Spherical Polynomial data.
  129011. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129012. *
  129013. * @param cubeInfo The Cube map to extract the information from.
  129014. * @return The Spherical Polynomial data.
  129015. */
  129016. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  129017. }
  129018. }
  129019. declare module BABYLON {
  129020. interface BaseTexture {
  129021. /**
  129022. * Get the polynomial representation of the texture data.
  129023. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  129024. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  129025. */
  129026. sphericalPolynomial: Nullable<SphericalPolynomial>;
  129027. }
  129028. }
  129029. declare module BABYLON {
  129030. /** @hidden */
  129031. export var rgbdEncodePixelShader: {
  129032. name: string;
  129033. shader: string;
  129034. };
  129035. }
  129036. declare module BABYLON {
  129037. /** @hidden */
  129038. export var rgbdDecodePixelShader: {
  129039. name: string;
  129040. shader: string;
  129041. };
  129042. }
  129043. declare module BABYLON {
  129044. /**
  129045. * Raw texture data and descriptor sufficient for WebGL texture upload
  129046. */
  129047. export interface EnvironmentTextureInfo {
  129048. /**
  129049. * Version of the environment map
  129050. */
  129051. version: number;
  129052. /**
  129053. * Width of image
  129054. */
  129055. width: number;
  129056. /**
  129057. * Irradiance information stored in the file.
  129058. */
  129059. irradiance: any;
  129060. /**
  129061. * Specular information stored in the file.
  129062. */
  129063. specular: any;
  129064. }
  129065. /**
  129066. * Defines One Image in the file. It requires only the position in the file
  129067. * as well as the length.
  129068. */
  129069. interface BufferImageData {
  129070. /**
  129071. * Length of the image data.
  129072. */
  129073. length: number;
  129074. /**
  129075. * Position of the data from the null terminator delimiting the end of the JSON.
  129076. */
  129077. position: number;
  129078. }
  129079. /**
  129080. * Defines the specular data enclosed in the file.
  129081. * This corresponds to the version 1 of the data.
  129082. */
  129083. export interface EnvironmentTextureSpecularInfoV1 {
  129084. /**
  129085. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  129086. */
  129087. specularDataPosition?: number;
  129088. /**
  129089. * This contains all the images data needed to reconstruct the cubemap.
  129090. */
  129091. mipmaps: Array<BufferImageData>;
  129092. /**
  129093. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  129094. */
  129095. lodGenerationScale: number;
  129096. }
  129097. /**
  129098. * Sets of helpers addressing the serialization and deserialization of environment texture
  129099. * stored in a BabylonJS env file.
  129100. * Those files are usually stored as .env files.
  129101. */
  129102. export class EnvironmentTextureTools {
  129103. /**
  129104. * Magic number identifying the env file.
  129105. */
  129106. private static _MagicBytes;
  129107. /**
  129108. * Gets the environment info from an env file.
  129109. * @param data The array buffer containing the .env bytes.
  129110. * @returns the environment file info (the json header) if successfully parsed.
  129111. */
  129112. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  129113. /**
  129114. * Creates an environment texture from a loaded cube texture.
  129115. * @param texture defines the cube texture to convert in env file
  129116. * @return a promise containing the environment data if succesfull.
  129117. */
  129118. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  129119. /**
  129120. * Creates a JSON representation of the spherical data.
  129121. * @param texture defines the texture containing the polynomials
  129122. * @return the JSON representation of the spherical info
  129123. */
  129124. private static _CreateEnvTextureIrradiance;
  129125. /**
  129126. * Creates the ArrayBufferViews used for initializing environment texture image data.
  129127. * @param data the image data
  129128. * @param info parameters that determine what views will be created for accessing the underlying buffer
  129129. * @return the views described by info providing access to the underlying buffer
  129130. */
  129131. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  129132. /**
  129133. * Uploads the texture info contained in the env file to the GPU.
  129134. * @param texture defines the internal texture to upload to
  129135. * @param data defines the data to load
  129136. * @param info defines the texture info retrieved through the GetEnvInfo method
  129137. * @returns a promise
  129138. */
  129139. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  129140. private static _OnImageReadyAsync;
  129141. /**
  129142. * Uploads the levels of image data to the GPU.
  129143. * @param texture defines the internal texture to upload to
  129144. * @param imageData defines the array buffer views of image data [mipmap][face]
  129145. * @returns a promise
  129146. */
  129147. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  129148. /**
  129149. * Uploads spherical polynomials information to the texture.
  129150. * @param texture defines the texture we are trying to upload the information to
  129151. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  129152. */
  129153. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  129154. /** @hidden */
  129155. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129156. }
  129157. }
  129158. declare module BABYLON {
  129159. /**
  129160. * Class used to inline functions in shader code
  129161. */
  129162. export class ShaderCodeInliner {
  129163. private static readonly _RegexpFindFunctionNameAndType;
  129164. private _sourceCode;
  129165. private _functionDescr;
  129166. private _numMaxIterations;
  129167. /** Gets or sets the token used to mark the functions to inline */
  129168. inlineToken: string;
  129169. /** Gets or sets the debug mode */
  129170. debug: boolean;
  129171. /** Gets the code after the inlining process */
  129172. get code(): string;
  129173. /**
  129174. * Initializes the inliner
  129175. * @param sourceCode shader code source to inline
  129176. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129177. */
  129178. constructor(sourceCode: string, numMaxIterations?: number);
  129179. /**
  129180. * Start the processing of the shader code
  129181. */
  129182. processCode(): void;
  129183. private _collectFunctions;
  129184. private _processInlining;
  129185. private _extractBetweenMarkers;
  129186. private _skipWhitespaces;
  129187. private _removeComments;
  129188. private _replaceFunctionCallsByCode;
  129189. private _findBackward;
  129190. private _escapeRegExp;
  129191. private _replaceNames;
  129192. }
  129193. }
  129194. declare module BABYLON {
  129195. /**
  129196. * Container for accessors for natively-stored mesh data buffers.
  129197. */
  129198. class NativeDataBuffer extends DataBuffer {
  129199. /**
  129200. * Accessor value used to identify/retrieve a natively-stored index buffer.
  129201. */
  129202. nativeIndexBuffer?: any;
  129203. /**
  129204. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  129205. */
  129206. nativeVertexBuffer?: any;
  129207. }
  129208. /** @hidden */
  129209. class NativeTexture extends InternalTexture {
  129210. getInternalTexture(): InternalTexture;
  129211. getViewCount(): number;
  129212. }
  129213. /** @hidden */
  129214. export class NativeEngine extends Engine {
  129215. private readonly _native;
  129216. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  129217. private readonly INVALID_HANDLE;
  129218. getHardwareScalingLevel(): number;
  129219. constructor();
  129220. dispose(): void;
  129221. /**
  129222. * Can be used to override the current requestAnimationFrame requester.
  129223. * @hidden
  129224. */
  129225. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  129226. /**
  129227. * Override default engine behavior.
  129228. * @param color
  129229. * @param backBuffer
  129230. * @param depth
  129231. * @param stencil
  129232. */
  129233. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  129234. /**
  129235. * Gets host document
  129236. * @returns the host document object
  129237. */
  129238. getHostDocument(): Nullable<Document>;
  129239. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129240. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  129241. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  129242. recordVertexArrayObject(vertexBuffers: {
  129243. [key: string]: VertexBuffer;
  129244. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  129245. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129246. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129247. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129248. /**
  129249. * Draw a list of indexed primitives
  129250. * @param fillMode defines the primitive to use
  129251. * @param indexStart defines the starting index
  129252. * @param indexCount defines the number of index to draw
  129253. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129254. */
  129255. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129256. /**
  129257. * Draw a list of unindexed primitives
  129258. * @param fillMode defines the primitive to use
  129259. * @param verticesStart defines the index of first vertex to draw
  129260. * @param verticesCount defines the count of vertices to draw
  129261. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129262. */
  129263. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129264. createPipelineContext(): IPipelineContext;
  129265. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  129266. /** @hidden */
  129267. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  129268. /** @hidden */
  129269. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  129270. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129271. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129272. protected _setProgram(program: WebGLProgram): void;
  129273. _releaseEffect(effect: Effect): void;
  129274. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129275. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  129276. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  129277. bindSamplers(effect: Effect): void;
  129278. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  129279. getRenderWidth(useScreen?: boolean): number;
  129280. getRenderHeight(useScreen?: boolean): number;
  129281. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  129282. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129283. /**
  129284. * Set the z offset to apply to current rendering
  129285. * @param value defines the offset to apply
  129286. */
  129287. setZOffset(value: number): void;
  129288. /**
  129289. * Gets the current value of the zOffset
  129290. * @returns the current zOffset state
  129291. */
  129292. getZOffset(): number;
  129293. /**
  129294. * Enable or disable depth buffering
  129295. * @param enable defines the state to set
  129296. */
  129297. setDepthBuffer(enable: boolean): void;
  129298. /**
  129299. * Gets a boolean indicating if depth writing is enabled
  129300. * @returns the current depth writing state
  129301. */
  129302. getDepthWrite(): boolean;
  129303. /**
  129304. * Enable or disable depth writing
  129305. * @param enable defines the state to set
  129306. */
  129307. setDepthWrite(enable: boolean): void;
  129308. /**
  129309. * Enable or disable color writing
  129310. * @param enable defines the state to set
  129311. */
  129312. setColorWrite(enable: boolean): void;
  129313. /**
  129314. * Gets a boolean indicating if color writing is enabled
  129315. * @returns the current color writing state
  129316. */
  129317. getColorWrite(): boolean;
  129318. /**
  129319. * Sets alpha constants used by some alpha blending modes
  129320. * @param r defines the red component
  129321. * @param g defines the green component
  129322. * @param b defines the blue component
  129323. * @param a defines the alpha component
  129324. */
  129325. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  129326. /**
  129327. * Sets the current alpha mode
  129328. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  129329. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129330. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129331. */
  129332. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129333. /**
  129334. * Gets the current alpha mode
  129335. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129336. * @returns the current alpha mode
  129337. */
  129338. getAlphaMode(): number;
  129339. setInt(uniform: WebGLUniformLocation, int: number): void;
  129340. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  129341. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  129342. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  129343. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  129344. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  129345. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  129346. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  129347. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  129348. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  129349. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  129350. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  129351. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  129352. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  129353. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129354. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129355. setFloat(uniform: WebGLUniformLocation, value: number): void;
  129356. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  129357. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129358. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129359. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  129360. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  129361. wipeCaches(bruteForce?: boolean): void;
  129362. _createTexture(): WebGLTexture;
  129363. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  129364. /**
  129365. * Usually called from Texture.ts.
  129366. * Passed information to create a WebGLTexture
  129367. * @param url defines a value which contains one of the following:
  129368. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129369. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129370. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129371. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129372. * @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)
  129373. * @param scene needed for loading to the correct scene
  129374. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129375. * @param onLoad optional callback to be called upon successful completion
  129376. * @param onError optional callback to be called upon failure
  129377. * @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
  129378. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129379. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129380. * @param forcedExtension defines the extension to use to pick the right loader
  129381. * @param mimeType defines an optional mime type
  129382. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129383. */
  129384. 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;
  129385. /**
  129386. * Creates a cube texture
  129387. * @param rootUrl defines the url where the files to load is located
  129388. * @param scene defines the current scene
  129389. * @param files defines the list of files to load (1 per face)
  129390. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  129391. * @param onLoad defines an optional callback raised when the texture is loaded
  129392. * @param onError defines an optional callback raised if there is an issue to load the texture
  129393. * @param format defines the format of the data
  129394. * @param forcedExtension defines the extension to use to pick the right loader
  129395. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  129396. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129397. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129398. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  129399. * @returns the cube texture as an InternalTexture
  129400. */
  129401. 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;
  129402. private _getSamplingFilter;
  129403. private static _GetNativeTextureFormat;
  129404. createRenderTargetTexture(size: number | {
  129405. width: number;
  129406. height: number;
  129407. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  129408. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129409. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129410. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129411. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  129412. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  129413. /**
  129414. * Updates a dynamic vertex buffer.
  129415. * @param vertexBuffer the vertex buffer to update
  129416. * @param data the data used to update the vertex buffer
  129417. * @param byteOffset the byte offset of the data (optional)
  129418. * @param byteLength the byte length of the data (optional)
  129419. */
  129420. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  129421. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  129422. private _updateAnisotropicLevel;
  129423. private _getAddressMode;
  129424. /** @hidden */
  129425. _bindTexture(channel: number, texture: InternalTexture): void;
  129426. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  129427. releaseEffects(): void;
  129428. /** @hidden */
  129429. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129430. /** @hidden */
  129431. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129432. /** @hidden */
  129433. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129434. /** @hidden */
  129435. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129436. }
  129437. }
  129438. declare module BABYLON {
  129439. /**
  129440. * Gather the list of clipboard event types as constants.
  129441. */
  129442. export class ClipboardEventTypes {
  129443. /**
  129444. * The clipboard event is fired when a copy command is active (pressed).
  129445. */
  129446. static readonly COPY: number;
  129447. /**
  129448. * The clipboard event is fired when a cut command is active (pressed).
  129449. */
  129450. static readonly CUT: number;
  129451. /**
  129452. * The clipboard event is fired when a paste command is active (pressed).
  129453. */
  129454. static readonly PASTE: number;
  129455. }
  129456. /**
  129457. * This class is used to store clipboard related info for the onClipboardObservable event.
  129458. */
  129459. export class ClipboardInfo {
  129460. /**
  129461. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129462. */
  129463. type: number;
  129464. /**
  129465. * Defines the related dom event
  129466. */
  129467. event: ClipboardEvent;
  129468. /**
  129469. *Creates an instance of ClipboardInfo.
  129470. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  129471. * @param event Defines the related dom event
  129472. */
  129473. constructor(
  129474. /**
  129475. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129476. */
  129477. type: number,
  129478. /**
  129479. * Defines the related dom event
  129480. */
  129481. event: ClipboardEvent);
  129482. /**
  129483. * Get the clipboard event's type from the keycode.
  129484. * @param keyCode Defines the keyCode for the current keyboard event.
  129485. * @return {number}
  129486. */
  129487. static GetTypeFromCharacter(keyCode: number): number;
  129488. }
  129489. }
  129490. declare module BABYLON {
  129491. /**
  129492. * Google Daydream controller
  129493. */
  129494. export class DaydreamController extends WebVRController {
  129495. /**
  129496. * Base Url for the controller model.
  129497. */
  129498. static MODEL_BASE_URL: string;
  129499. /**
  129500. * File name for the controller model.
  129501. */
  129502. static MODEL_FILENAME: string;
  129503. /**
  129504. * Gamepad Id prefix used to identify Daydream Controller.
  129505. */
  129506. static readonly GAMEPAD_ID_PREFIX: string;
  129507. /**
  129508. * Creates a new DaydreamController from a gamepad
  129509. * @param vrGamepad the gamepad that the controller should be created from
  129510. */
  129511. constructor(vrGamepad: any);
  129512. /**
  129513. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129514. * @param scene scene in which to add meshes
  129515. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129516. */
  129517. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129518. /**
  129519. * Called once for each button that changed state since the last frame
  129520. * @param buttonIdx Which button index changed
  129521. * @param state New state of the button
  129522. * @param changes Which properties on the state changed since last frame
  129523. */
  129524. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129525. }
  129526. }
  129527. declare module BABYLON {
  129528. /**
  129529. * Gear VR Controller
  129530. */
  129531. export class GearVRController extends WebVRController {
  129532. /**
  129533. * Base Url for the controller model.
  129534. */
  129535. static MODEL_BASE_URL: string;
  129536. /**
  129537. * File name for the controller model.
  129538. */
  129539. static MODEL_FILENAME: string;
  129540. /**
  129541. * Gamepad Id prefix used to identify this controller.
  129542. */
  129543. static readonly GAMEPAD_ID_PREFIX: string;
  129544. private readonly _buttonIndexToObservableNameMap;
  129545. /**
  129546. * Creates a new GearVRController from a gamepad
  129547. * @param vrGamepad the gamepad that the controller should be created from
  129548. */
  129549. constructor(vrGamepad: any);
  129550. /**
  129551. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129552. * @param scene scene in which to add meshes
  129553. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129554. */
  129555. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129556. /**
  129557. * Called once for each button that changed state since the last frame
  129558. * @param buttonIdx Which button index changed
  129559. * @param state New state of the button
  129560. * @param changes Which properties on the state changed since last frame
  129561. */
  129562. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129563. }
  129564. }
  129565. declare module BABYLON {
  129566. /**
  129567. * Generic Controller
  129568. */
  129569. export class GenericController extends WebVRController {
  129570. /**
  129571. * Base Url for the controller model.
  129572. */
  129573. static readonly MODEL_BASE_URL: string;
  129574. /**
  129575. * File name for the controller model.
  129576. */
  129577. static readonly MODEL_FILENAME: string;
  129578. /**
  129579. * Creates a new GenericController from a gamepad
  129580. * @param vrGamepad the gamepad that the controller should be created from
  129581. */
  129582. constructor(vrGamepad: any);
  129583. /**
  129584. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129585. * @param scene scene in which to add meshes
  129586. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129587. */
  129588. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129589. /**
  129590. * Called once for each button that changed state since the last frame
  129591. * @param buttonIdx Which button index changed
  129592. * @param state New state of the button
  129593. * @param changes Which properties on the state changed since last frame
  129594. */
  129595. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129596. }
  129597. }
  129598. declare module BABYLON {
  129599. /**
  129600. * Oculus Touch Controller
  129601. */
  129602. export class OculusTouchController extends WebVRController {
  129603. /**
  129604. * Base Url for the controller model.
  129605. */
  129606. static MODEL_BASE_URL: string;
  129607. /**
  129608. * File name for the left controller model.
  129609. */
  129610. static MODEL_LEFT_FILENAME: string;
  129611. /**
  129612. * File name for the right controller model.
  129613. */
  129614. static MODEL_RIGHT_FILENAME: string;
  129615. /**
  129616. * Base Url for the Quest controller model.
  129617. */
  129618. static QUEST_MODEL_BASE_URL: string;
  129619. /**
  129620. * @hidden
  129621. * If the controllers are running on a device that needs the updated Quest controller models
  129622. */
  129623. static _IsQuest: boolean;
  129624. /**
  129625. * Fired when the secondary trigger on this controller is modified
  129626. */
  129627. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  129628. /**
  129629. * Fired when the thumb rest on this controller is modified
  129630. */
  129631. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  129632. /**
  129633. * Creates a new OculusTouchController from a gamepad
  129634. * @param vrGamepad the gamepad that the controller should be created from
  129635. */
  129636. constructor(vrGamepad: any);
  129637. /**
  129638. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129639. * @param scene scene in which to add meshes
  129640. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129641. */
  129642. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129643. /**
  129644. * Fired when the A button on this controller is modified
  129645. */
  129646. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129647. /**
  129648. * Fired when the B button on this controller is modified
  129649. */
  129650. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129651. /**
  129652. * Fired when the X button on this controller is modified
  129653. */
  129654. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129655. /**
  129656. * Fired when the Y button on this controller is modified
  129657. */
  129658. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129659. /**
  129660. * Called once for each button that changed state since the last frame
  129661. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  129662. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  129663. * 2) secondary trigger (same)
  129664. * 3) A (right) X (left), touch, pressed = value
  129665. * 4) B / Y
  129666. * 5) thumb rest
  129667. * @param buttonIdx Which button index changed
  129668. * @param state New state of the button
  129669. * @param changes Which properties on the state changed since last frame
  129670. */
  129671. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129672. }
  129673. }
  129674. declare module BABYLON {
  129675. /**
  129676. * Vive Controller
  129677. */
  129678. export class ViveController extends WebVRController {
  129679. /**
  129680. * Base Url for the controller model.
  129681. */
  129682. static MODEL_BASE_URL: string;
  129683. /**
  129684. * File name for the controller model.
  129685. */
  129686. static MODEL_FILENAME: string;
  129687. /**
  129688. * Creates a new ViveController from a gamepad
  129689. * @param vrGamepad the gamepad that the controller should be created from
  129690. */
  129691. constructor(vrGamepad: any);
  129692. /**
  129693. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129694. * @param scene scene in which to add meshes
  129695. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129696. */
  129697. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129698. /**
  129699. * Fired when the left button on this controller is modified
  129700. */
  129701. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129702. /**
  129703. * Fired when the right button on this controller is modified
  129704. */
  129705. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129706. /**
  129707. * Fired when the menu button on this controller is modified
  129708. */
  129709. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129710. /**
  129711. * Called once for each button that changed state since the last frame
  129712. * Vive mapping:
  129713. * 0: touchpad
  129714. * 1: trigger
  129715. * 2: left AND right buttons
  129716. * 3: menu button
  129717. * @param buttonIdx Which button index changed
  129718. * @param state New state of the button
  129719. * @param changes Which properties on the state changed since last frame
  129720. */
  129721. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129722. }
  129723. }
  129724. declare module BABYLON {
  129725. /**
  129726. * Defines the WindowsMotionController object that the state of the windows motion controller
  129727. */
  129728. export class WindowsMotionController extends WebVRController {
  129729. /**
  129730. * The base url used to load the left and right controller models
  129731. */
  129732. static MODEL_BASE_URL: string;
  129733. /**
  129734. * The name of the left controller model file
  129735. */
  129736. static MODEL_LEFT_FILENAME: string;
  129737. /**
  129738. * The name of the right controller model file
  129739. */
  129740. static MODEL_RIGHT_FILENAME: string;
  129741. /**
  129742. * The controller name prefix for this controller type
  129743. */
  129744. static readonly GAMEPAD_ID_PREFIX: string;
  129745. /**
  129746. * The controller id pattern for this controller type
  129747. */
  129748. private static readonly GAMEPAD_ID_PATTERN;
  129749. private _loadedMeshInfo;
  129750. protected readonly _mapping: {
  129751. buttons: string[];
  129752. buttonMeshNames: {
  129753. trigger: string;
  129754. menu: string;
  129755. grip: string;
  129756. thumbstick: string;
  129757. trackpad: string;
  129758. };
  129759. buttonObservableNames: {
  129760. trigger: string;
  129761. menu: string;
  129762. grip: string;
  129763. thumbstick: string;
  129764. trackpad: string;
  129765. };
  129766. axisMeshNames: string[];
  129767. pointingPoseMeshName: string;
  129768. };
  129769. /**
  129770. * Fired when the trackpad on this controller is clicked
  129771. */
  129772. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129773. /**
  129774. * Fired when the trackpad on this controller is modified
  129775. */
  129776. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129777. /**
  129778. * The current x and y values of this controller's trackpad
  129779. */
  129780. trackpad: StickValues;
  129781. /**
  129782. * Creates a new WindowsMotionController from a gamepad
  129783. * @param vrGamepad the gamepad that the controller should be created from
  129784. */
  129785. constructor(vrGamepad: any);
  129786. /**
  129787. * Fired when the trigger on this controller is modified
  129788. */
  129789. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129790. /**
  129791. * Fired when the menu button on this controller is modified
  129792. */
  129793. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129794. /**
  129795. * Fired when the grip button on this controller is modified
  129796. */
  129797. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129798. /**
  129799. * Fired when the thumbstick button on this controller is modified
  129800. */
  129801. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129802. /**
  129803. * Fired when the touchpad button on this controller is modified
  129804. */
  129805. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129806. /**
  129807. * Fired when the touchpad values on this controller are modified
  129808. */
  129809. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  129810. protected _updateTrackpad(): void;
  129811. /**
  129812. * Called once per frame by the engine.
  129813. */
  129814. update(): void;
  129815. /**
  129816. * Called once for each button that changed state since the last frame
  129817. * @param buttonIdx Which button index changed
  129818. * @param state New state of the button
  129819. * @param changes Which properties on the state changed since last frame
  129820. */
  129821. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129822. /**
  129823. * Moves the buttons on the controller mesh based on their current state
  129824. * @param buttonName the name of the button to move
  129825. * @param buttonValue the value of the button which determines the buttons new position
  129826. */
  129827. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  129828. /**
  129829. * Moves the axis on the controller mesh based on its current state
  129830. * @param axis the index of the axis
  129831. * @param axisValue the value of the axis which determines the meshes new position
  129832. * @hidden
  129833. */
  129834. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  129835. /**
  129836. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129837. * @param scene scene in which to add meshes
  129838. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129839. */
  129840. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  129841. /**
  129842. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  129843. * can be transformed by button presses and axes values, based on this._mapping.
  129844. *
  129845. * @param scene scene in which the meshes exist
  129846. * @param meshes list of meshes that make up the controller model to process
  129847. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  129848. */
  129849. private processModel;
  129850. private createMeshInfo;
  129851. /**
  129852. * Gets the ray of the controller in the direction the controller is pointing
  129853. * @param length the length the resulting ray should be
  129854. * @returns a ray in the direction the controller is pointing
  129855. */
  129856. getForwardRay(length?: number): Ray;
  129857. /**
  129858. * Disposes of the controller
  129859. */
  129860. dispose(): void;
  129861. }
  129862. /**
  129863. * This class represents a new windows motion controller in XR.
  129864. */
  129865. export class XRWindowsMotionController extends WindowsMotionController {
  129866. /**
  129867. * Changing the original WIndowsMotionController mapping to fir the new mapping
  129868. */
  129869. protected readonly _mapping: {
  129870. buttons: string[];
  129871. buttonMeshNames: {
  129872. trigger: string;
  129873. menu: string;
  129874. grip: string;
  129875. thumbstick: string;
  129876. trackpad: string;
  129877. };
  129878. buttonObservableNames: {
  129879. trigger: string;
  129880. menu: string;
  129881. grip: string;
  129882. thumbstick: string;
  129883. trackpad: string;
  129884. };
  129885. axisMeshNames: string[];
  129886. pointingPoseMeshName: string;
  129887. };
  129888. /**
  129889. * Construct a new XR-Based windows motion controller
  129890. *
  129891. * @param gamepadInfo the gamepad object from the browser
  129892. */
  129893. constructor(gamepadInfo: any);
  129894. /**
  129895. * holds the thumbstick values (X,Y)
  129896. */
  129897. thumbstickValues: StickValues;
  129898. /**
  129899. * Fired when the thumbstick on this controller is clicked
  129900. */
  129901. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  129902. /**
  129903. * Fired when the thumbstick on this controller is modified
  129904. */
  129905. onThumbstickValuesChangedObservable: Observable<StickValues>;
  129906. /**
  129907. * Fired when the touchpad button on this controller is modified
  129908. */
  129909. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129910. /**
  129911. * Fired when the touchpad values on this controller are modified
  129912. */
  129913. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129914. /**
  129915. * Fired when the thumbstick button on this controller is modified
  129916. * here to prevent breaking changes
  129917. */
  129918. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129919. /**
  129920. * updating the thumbstick(!) and not the trackpad.
  129921. * This is named this way due to the difference between WebVR and XR and to avoid
  129922. * changing the parent class.
  129923. */
  129924. protected _updateTrackpad(): void;
  129925. /**
  129926. * Disposes the class with joy
  129927. */
  129928. dispose(): void;
  129929. }
  129930. }
  129931. declare module BABYLON {
  129932. /**
  129933. * Class containing static functions to help procedurally build meshes
  129934. */
  129935. export class PolyhedronBuilder {
  129936. /**
  129937. * Creates a polyhedron mesh
  129938. * * 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
  129939. * * The parameter `size` (positive float, default 1) sets the polygon size
  129940. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  129941. * * 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`
  129942. * * 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
  129943. * * 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)`)
  129944. * * 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
  129945. * * 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
  129946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129949. * @param name defines the name of the mesh
  129950. * @param options defines the options used to create the mesh
  129951. * @param scene defines the hosting scene
  129952. * @returns the polyhedron mesh
  129953. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  129954. */
  129955. static CreatePolyhedron(name: string, options: {
  129956. type?: number;
  129957. size?: number;
  129958. sizeX?: number;
  129959. sizeY?: number;
  129960. sizeZ?: number;
  129961. custom?: any;
  129962. faceUV?: Vector4[];
  129963. faceColors?: Color4[];
  129964. flat?: boolean;
  129965. updatable?: boolean;
  129966. sideOrientation?: number;
  129967. frontUVs?: Vector4;
  129968. backUVs?: Vector4;
  129969. }, scene?: Nullable<Scene>): Mesh;
  129970. }
  129971. }
  129972. declare module BABYLON {
  129973. /**
  129974. * Gizmo that enables scaling a mesh along 3 axis
  129975. */
  129976. export class ScaleGizmo extends Gizmo {
  129977. /**
  129978. * Internal gizmo used for interactions on the x axis
  129979. */
  129980. xGizmo: AxisScaleGizmo;
  129981. /**
  129982. * Internal gizmo used for interactions on the y axis
  129983. */
  129984. yGizmo: AxisScaleGizmo;
  129985. /**
  129986. * Internal gizmo used for interactions on the z axis
  129987. */
  129988. zGizmo: AxisScaleGizmo;
  129989. /**
  129990. * Internal gizmo used to scale all axis equally
  129991. */
  129992. uniformScaleGizmo: AxisScaleGizmo;
  129993. private _meshAttached;
  129994. private _updateGizmoRotationToMatchAttachedMesh;
  129995. private _snapDistance;
  129996. private _scaleRatio;
  129997. private _uniformScalingMesh;
  129998. private _octahedron;
  129999. private _sensitivity;
  130000. /** Fires an event when any of it's sub gizmos are dragged */
  130001. onDragStartObservable: Observable<unknown>;
  130002. /** Fires an event when any of it's sub gizmos are released from dragging */
  130003. onDragEndObservable: Observable<unknown>;
  130004. get attachedMesh(): Nullable<AbstractMesh>;
  130005. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130006. /**
  130007. * Creates a ScaleGizmo
  130008. * @param gizmoLayer The utility layer the gizmo will be added to
  130009. */
  130010. constructor(gizmoLayer?: UtilityLayerRenderer);
  130011. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130012. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130013. /**
  130014. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130015. */
  130016. set snapDistance(value: number);
  130017. get snapDistance(): number;
  130018. /**
  130019. * Ratio for the scale of the gizmo (Default: 1)
  130020. */
  130021. set scaleRatio(value: number);
  130022. get scaleRatio(): number;
  130023. /**
  130024. * Sensitivity factor for dragging (Default: 1)
  130025. */
  130026. set sensitivity(value: number);
  130027. get sensitivity(): number;
  130028. /**
  130029. * Disposes of the gizmo
  130030. */
  130031. dispose(): void;
  130032. }
  130033. }
  130034. declare module BABYLON {
  130035. /**
  130036. * Single axis scale gizmo
  130037. */
  130038. export class AxisScaleGizmo extends Gizmo {
  130039. /**
  130040. * Drag behavior responsible for the gizmos dragging interactions
  130041. */
  130042. dragBehavior: PointerDragBehavior;
  130043. private _pointerObserver;
  130044. /**
  130045. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130046. */
  130047. snapDistance: number;
  130048. /**
  130049. * Event that fires each time the gizmo snaps to a new location.
  130050. * * snapDistance is the the change in distance
  130051. */
  130052. onSnapObservable: Observable<{
  130053. snapDistance: number;
  130054. }>;
  130055. /**
  130056. * If the scaling operation should be done on all axis (default: false)
  130057. */
  130058. uniformScaling: boolean;
  130059. /**
  130060. * Custom sensitivity value for the drag strength
  130061. */
  130062. sensitivity: number;
  130063. private _isEnabled;
  130064. private _parent;
  130065. private _arrow;
  130066. private _coloredMaterial;
  130067. private _hoverMaterial;
  130068. /**
  130069. * Creates an AxisScaleGizmo
  130070. * @param gizmoLayer The utility layer the gizmo will be added to
  130071. * @param dragAxis The axis which the gizmo will be able to scale on
  130072. * @param color The color of the gizmo
  130073. */
  130074. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  130075. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130076. /**
  130077. * If the gizmo is enabled
  130078. */
  130079. set isEnabled(value: boolean);
  130080. get isEnabled(): boolean;
  130081. /**
  130082. * Disposes of the gizmo
  130083. */
  130084. dispose(): void;
  130085. /**
  130086. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130087. * @param mesh The mesh to replace the default mesh of the gizmo
  130088. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  130089. */
  130090. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  130091. }
  130092. }
  130093. declare module BABYLON {
  130094. /**
  130095. * Bounding box gizmo
  130096. */
  130097. export class BoundingBoxGizmo extends Gizmo {
  130098. private _lineBoundingBox;
  130099. private _rotateSpheresParent;
  130100. private _scaleBoxesParent;
  130101. private _boundingDimensions;
  130102. private _renderObserver;
  130103. private _pointerObserver;
  130104. private _scaleDragSpeed;
  130105. private _tmpQuaternion;
  130106. private _tmpVector;
  130107. private _tmpRotationMatrix;
  130108. /**
  130109. * 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)
  130110. */
  130111. ignoreChildren: boolean;
  130112. /**
  130113. * 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)
  130114. */
  130115. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  130116. /**
  130117. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  130118. */
  130119. rotationSphereSize: number;
  130120. /**
  130121. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  130122. */
  130123. scaleBoxSize: number;
  130124. /**
  130125. * 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)
  130126. */
  130127. fixedDragMeshScreenSize: boolean;
  130128. /**
  130129. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  130130. */
  130131. fixedDragMeshScreenSizeDistanceFactor: number;
  130132. /**
  130133. * Fired when a rotation sphere or scale box is dragged
  130134. */
  130135. onDragStartObservable: Observable<{}>;
  130136. /**
  130137. * Fired when a scale box is dragged
  130138. */
  130139. onScaleBoxDragObservable: Observable<{}>;
  130140. /**
  130141. * Fired when a scale box drag is ended
  130142. */
  130143. onScaleBoxDragEndObservable: Observable<{}>;
  130144. /**
  130145. * Fired when a rotation sphere is dragged
  130146. */
  130147. onRotationSphereDragObservable: Observable<{}>;
  130148. /**
  130149. * Fired when a rotation sphere drag is ended
  130150. */
  130151. onRotationSphereDragEndObservable: Observable<{}>;
  130152. /**
  130153. * 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)
  130154. */
  130155. scalePivot: Nullable<Vector3>;
  130156. /**
  130157. * Mesh used as a pivot to rotate the attached mesh
  130158. */
  130159. private _anchorMesh;
  130160. private _existingMeshScale;
  130161. private _dragMesh;
  130162. private pointerDragBehavior;
  130163. private coloredMaterial;
  130164. private hoverColoredMaterial;
  130165. /**
  130166. * Sets the color of the bounding box gizmo
  130167. * @param color the color to set
  130168. */
  130169. setColor(color: Color3): void;
  130170. /**
  130171. * Creates an BoundingBoxGizmo
  130172. * @param gizmoLayer The utility layer the gizmo will be added to
  130173. * @param color The color of the gizmo
  130174. */
  130175. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  130176. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130177. private _selectNode;
  130178. /**
  130179. * Updates the bounding box information for the Gizmo
  130180. */
  130181. updateBoundingBox(): void;
  130182. private _updateRotationSpheres;
  130183. private _updateScaleBoxes;
  130184. /**
  130185. * Enables rotation on the specified axis and disables rotation on the others
  130186. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  130187. */
  130188. setEnabledRotationAxis(axis: string): void;
  130189. /**
  130190. * Enables/disables scaling
  130191. * @param enable if scaling should be enabled
  130192. * @param homogeneousScaling defines if scaling should only be homogeneous
  130193. */
  130194. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  130195. private _updateDummy;
  130196. /**
  130197. * Enables a pointer drag behavior on the bounding box of the gizmo
  130198. */
  130199. enableDragBehavior(): void;
  130200. /**
  130201. * Disposes of the gizmo
  130202. */
  130203. dispose(): void;
  130204. /**
  130205. * 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)
  130206. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  130207. * @returns the bounding box mesh with the passed in mesh as a child
  130208. */
  130209. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  130210. /**
  130211. * CustomMeshes are not supported by this gizmo
  130212. * @param mesh The mesh to replace the default mesh of the gizmo
  130213. */
  130214. setCustomMesh(mesh: Mesh): void;
  130215. }
  130216. }
  130217. declare module BABYLON {
  130218. /**
  130219. * Single plane rotation gizmo
  130220. */
  130221. export class PlaneRotationGizmo extends Gizmo {
  130222. /**
  130223. * Drag behavior responsible for the gizmos dragging interactions
  130224. */
  130225. dragBehavior: PointerDragBehavior;
  130226. private _pointerObserver;
  130227. /**
  130228. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  130229. */
  130230. snapDistance: number;
  130231. /**
  130232. * Event that fires each time the gizmo snaps to a new location.
  130233. * * snapDistance is the the change in distance
  130234. */
  130235. onSnapObservable: Observable<{
  130236. snapDistance: number;
  130237. }>;
  130238. private _isEnabled;
  130239. private _parent;
  130240. /**
  130241. * Creates a PlaneRotationGizmo
  130242. * @param gizmoLayer The utility layer the gizmo will be added to
  130243. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  130244. * @param color The color of the gizmo
  130245. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130246. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130247. */
  130248. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  130249. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130250. /**
  130251. * If the gizmo is enabled
  130252. */
  130253. set isEnabled(value: boolean);
  130254. get isEnabled(): boolean;
  130255. /**
  130256. * Disposes of the gizmo
  130257. */
  130258. dispose(): void;
  130259. }
  130260. }
  130261. declare module BABYLON {
  130262. /**
  130263. * Gizmo that enables rotating a mesh along 3 axis
  130264. */
  130265. export class RotationGizmo extends Gizmo {
  130266. /**
  130267. * Internal gizmo used for interactions on the x axis
  130268. */
  130269. xGizmo: PlaneRotationGizmo;
  130270. /**
  130271. * Internal gizmo used for interactions on the y axis
  130272. */
  130273. yGizmo: PlaneRotationGizmo;
  130274. /**
  130275. * Internal gizmo used for interactions on the z axis
  130276. */
  130277. zGizmo: PlaneRotationGizmo;
  130278. /** Fires an event when any of it's sub gizmos are dragged */
  130279. onDragStartObservable: Observable<unknown>;
  130280. /** Fires an event when any of it's sub gizmos are released from dragging */
  130281. onDragEndObservable: Observable<unknown>;
  130282. private _meshAttached;
  130283. get attachedMesh(): Nullable<AbstractMesh>;
  130284. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130285. /**
  130286. * Creates a RotationGizmo
  130287. * @param gizmoLayer The utility layer the gizmo will be added to
  130288. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130289. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130290. */
  130291. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  130292. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130293. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130294. /**
  130295. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130296. */
  130297. set snapDistance(value: number);
  130298. get snapDistance(): number;
  130299. /**
  130300. * Ratio for the scale of the gizmo (Default: 1)
  130301. */
  130302. set scaleRatio(value: number);
  130303. get scaleRatio(): number;
  130304. /**
  130305. * Disposes of the gizmo
  130306. */
  130307. dispose(): void;
  130308. /**
  130309. * CustomMeshes are not supported by this gizmo
  130310. * @param mesh The mesh to replace the default mesh of the gizmo
  130311. */
  130312. setCustomMesh(mesh: Mesh): void;
  130313. }
  130314. }
  130315. declare module BABYLON {
  130316. /**
  130317. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  130318. */
  130319. export class GizmoManager implements IDisposable {
  130320. private scene;
  130321. /**
  130322. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  130323. */
  130324. gizmos: {
  130325. positionGizmo: Nullable<PositionGizmo>;
  130326. rotationGizmo: Nullable<RotationGizmo>;
  130327. scaleGizmo: Nullable<ScaleGizmo>;
  130328. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  130329. };
  130330. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  130331. clearGizmoOnEmptyPointerEvent: boolean;
  130332. /** Fires an event when the manager is attached to a mesh */
  130333. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  130334. private _gizmosEnabled;
  130335. private _pointerObserver;
  130336. private _attachedMesh;
  130337. private _boundingBoxColor;
  130338. private _defaultUtilityLayer;
  130339. private _defaultKeepDepthUtilityLayer;
  130340. /**
  130341. * When bounding box gizmo is enabled, this can be used to track drag/end events
  130342. */
  130343. boundingBoxDragBehavior: SixDofDragBehavior;
  130344. /**
  130345. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  130346. */
  130347. attachableMeshes: Nullable<Array<AbstractMesh>>;
  130348. /**
  130349. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  130350. */
  130351. usePointerToAttachGizmos: boolean;
  130352. /**
  130353. * Utility layer that the bounding box gizmo belongs to
  130354. */
  130355. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  130356. /**
  130357. * Utility layer that all gizmos besides bounding box belong to
  130358. */
  130359. get utilityLayer(): UtilityLayerRenderer;
  130360. /**
  130361. * Instatiates a gizmo manager
  130362. * @param scene the scene to overlay the gizmos on top of
  130363. */
  130364. constructor(scene: Scene);
  130365. /**
  130366. * Attaches a set of gizmos to the specified mesh
  130367. * @param mesh The mesh the gizmo's should be attached to
  130368. */
  130369. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130370. /**
  130371. * If the position gizmo is enabled
  130372. */
  130373. set positionGizmoEnabled(value: boolean);
  130374. get positionGizmoEnabled(): boolean;
  130375. /**
  130376. * If the rotation gizmo is enabled
  130377. */
  130378. set rotationGizmoEnabled(value: boolean);
  130379. get rotationGizmoEnabled(): boolean;
  130380. /**
  130381. * If the scale gizmo is enabled
  130382. */
  130383. set scaleGizmoEnabled(value: boolean);
  130384. get scaleGizmoEnabled(): boolean;
  130385. /**
  130386. * If the boundingBox gizmo is enabled
  130387. */
  130388. set boundingBoxGizmoEnabled(value: boolean);
  130389. get boundingBoxGizmoEnabled(): boolean;
  130390. /**
  130391. * Disposes of the gizmo manager
  130392. */
  130393. dispose(): void;
  130394. }
  130395. }
  130396. declare module BABYLON {
  130397. /**
  130398. * A directional light is defined by a direction (what a surprise!).
  130399. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  130400. * 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.
  130401. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130402. */
  130403. export class DirectionalLight extends ShadowLight {
  130404. private _shadowFrustumSize;
  130405. /**
  130406. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  130407. */
  130408. get shadowFrustumSize(): number;
  130409. /**
  130410. * Specifies a fix frustum size for the shadow generation.
  130411. */
  130412. set shadowFrustumSize(value: number);
  130413. private _shadowOrthoScale;
  130414. /**
  130415. * Gets the shadow projection scale against the optimal computed one.
  130416. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130417. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130418. */
  130419. get shadowOrthoScale(): number;
  130420. /**
  130421. * Sets the shadow projection scale against the optimal computed one.
  130422. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130423. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130424. */
  130425. set shadowOrthoScale(value: number);
  130426. /**
  130427. * Automatically compute the projection matrix to best fit (including all the casters)
  130428. * on each frame.
  130429. */
  130430. autoUpdateExtends: boolean;
  130431. /**
  130432. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  130433. * on each frame. autoUpdateExtends must be set to true for this to work
  130434. */
  130435. autoCalcShadowZBounds: boolean;
  130436. private _orthoLeft;
  130437. private _orthoRight;
  130438. private _orthoTop;
  130439. private _orthoBottom;
  130440. /**
  130441. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  130442. * The directional light is emitted from everywhere in the given direction.
  130443. * It can cast shadows.
  130444. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130445. * @param name The friendly name of the light
  130446. * @param direction The direction of the light
  130447. * @param scene The scene the light belongs to
  130448. */
  130449. constructor(name: string, direction: Vector3, scene: Scene);
  130450. /**
  130451. * Returns the string "DirectionalLight".
  130452. * @return The class name
  130453. */
  130454. getClassName(): string;
  130455. /**
  130456. * Returns the integer 1.
  130457. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130458. */
  130459. getTypeID(): number;
  130460. /**
  130461. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  130462. * Returns the DirectionalLight Shadow projection matrix.
  130463. */
  130464. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130465. /**
  130466. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  130467. * Returns the DirectionalLight Shadow projection matrix.
  130468. */
  130469. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  130470. /**
  130471. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  130472. * Returns the DirectionalLight Shadow projection matrix.
  130473. */
  130474. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130475. protected _buildUniformLayout(): void;
  130476. /**
  130477. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  130478. * @param effect The effect to update
  130479. * @param lightIndex The index of the light in the effect to update
  130480. * @returns The directional light
  130481. */
  130482. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  130483. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  130484. /**
  130485. * Gets the minZ used for shadow according to both the scene and the light.
  130486. *
  130487. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130488. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130489. * @param activeCamera The camera we are returning the min for
  130490. * @returns the depth min z
  130491. */
  130492. getDepthMinZ(activeCamera: Camera): number;
  130493. /**
  130494. * Gets the maxZ used for shadow according to both the scene and the light.
  130495. *
  130496. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130497. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130498. * @param activeCamera The camera we are returning the max for
  130499. * @returns the depth max z
  130500. */
  130501. getDepthMaxZ(activeCamera: Camera): number;
  130502. /**
  130503. * Prepares the list of defines specific to the light type.
  130504. * @param defines the list of defines
  130505. * @param lightIndex defines the index of the light for the effect
  130506. */
  130507. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130508. }
  130509. }
  130510. declare module BABYLON {
  130511. /**
  130512. * Class containing static functions to help procedurally build meshes
  130513. */
  130514. export class HemisphereBuilder {
  130515. /**
  130516. * Creates a hemisphere mesh
  130517. * @param name defines the name of the mesh
  130518. * @param options defines the options used to create the mesh
  130519. * @param scene defines the hosting scene
  130520. * @returns the hemisphere mesh
  130521. */
  130522. static CreateHemisphere(name: string, options: {
  130523. segments?: number;
  130524. diameter?: number;
  130525. sideOrientation?: number;
  130526. }, scene: any): Mesh;
  130527. }
  130528. }
  130529. declare module BABYLON {
  130530. /**
  130531. * A spot light is defined by a position, a direction, an angle, and an exponent.
  130532. * These values define a cone of light starting from the position, emitting toward the direction.
  130533. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  130534. * and the exponent defines the speed of the decay of the light with distance (reach).
  130535. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130536. */
  130537. export class SpotLight extends ShadowLight {
  130538. private _angle;
  130539. private _innerAngle;
  130540. private _cosHalfAngle;
  130541. private _lightAngleScale;
  130542. private _lightAngleOffset;
  130543. /**
  130544. * Gets the cone angle of the spot light in Radians.
  130545. */
  130546. get angle(): number;
  130547. /**
  130548. * Sets the cone angle of the spot light in Radians.
  130549. */
  130550. set angle(value: number);
  130551. /**
  130552. * Only used in gltf falloff mode, this defines the angle where
  130553. * the directional falloff will start before cutting at angle which could be seen
  130554. * as outer angle.
  130555. */
  130556. get innerAngle(): number;
  130557. /**
  130558. * Only used in gltf falloff mode, this defines the angle where
  130559. * the directional falloff will start before cutting at angle which could be seen
  130560. * as outer angle.
  130561. */
  130562. set innerAngle(value: number);
  130563. private _shadowAngleScale;
  130564. /**
  130565. * Allows scaling the angle of the light for shadow generation only.
  130566. */
  130567. get shadowAngleScale(): number;
  130568. /**
  130569. * Allows scaling the angle of the light for shadow generation only.
  130570. */
  130571. set shadowAngleScale(value: number);
  130572. /**
  130573. * The light decay speed with the distance from the emission spot.
  130574. */
  130575. exponent: number;
  130576. private _projectionTextureMatrix;
  130577. /**
  130578. * Allows reading the projecton texture
  130579. */
  130580. get projectionTextureMatrix(): Matrix;
  130581. protected _projectionTextureLightNear: number;
  130582. /**
  130583. * Gets the near clip of the Spotlight for texture projection.
  130584. */
  130585. get projectionTextureLightNear(): number;
  130586. /**
  130587. * Sets the near clip of the Spotlight for texture projection.
  130588. */
  130589. set projectionTextureLightNear(value: number);
  130590. protected _projectionTextureLightFar: number;
  130591. /**
  130592. * Gets the far clip of the Spotlight for texture projection.
  130593. */
  130594. get projectionTextureLightFar(): number;
  130595. /**
  130596. * Sets the far clip of the Spotlight for texture projection.
  130597. */
  130598. set projectionTextureLightFar(value: number);
  130599. protected _projectionTextureUpDirection: Vector3;
  130600. /**
  130601. * Gets the Up vector of the Spotlight for texture projection.
  130602. */
  130603. get projectionTextureUpDirection(): Vector3;
  130604. /**
  130605. * Sets the Up vector of the Spotlight for texture projection.
  130606. */
  130607. set projectionTextureUpDirection(value: Vector3);
  130608. private _projectionTexture;
  130609. /**
  130610. * Gets the projection texture of the light.
  130611. */
  130612. get projectionTexture(): Nullable<BaseTexture>;
  130613. /**
  130614. * Sets the projection texture of the light.
  130615. */
  130616. set projectionTexture(value: Nullable<BaseTexture>);
  130617. private _projectionTextureViewLightDirty;
  130618. private _projectionTextureProjectionLightDirty;
  130619. private _projectionTextureDirty;
  130620. private _projectionTextureViewTargetVector;
  130621. private _projectionTextureViewLightMatrix;
  130622. private _projectionTextureProjectionLightMatrix;
  130623. private _projectionTextureScalingMatrix;
  130624. /**
  130625. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  130626. * It can cast shadows.
  130627. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130628. * @param name The light friendly name
  130629. * @param position The position of the spot light in the scene
  130630. * @param direction The direction of the light in the scene
  130631. * @param angle The cone angle of the light in Radians
  130632. * @param exponent The light decay speed with the distance from the emission spot
  130633. * @param scene The scene the lights belongs to
  130634. */
  130635. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  130636. /**
  130637. * Returns the string "SpotLight".
  130638. * @returns the class name
  130639. */
  130640. getClassName(): string;
  130641. /**
  130642. * Returns the integer 2.
  130643. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130644. */
  130645. getTypeID(): number;
  130646. /**
  130647. * Overrides the direction setter to recompute the projection texture view light Matrix.
  130648. */
  130649. protected _setDirection(value: Vector3): void;
  130650. /**
  130651. * Overrides the position setter to recompute the projection texture view light Matrix.
  130652. */
  130653. protected _setPosition(value: Vector3): void;
  130654. /**
  130655. * 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.
  130656. * Returns the SpotLight.
  130657. */
  130658. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130659. protected _computeProjectionTextureViewLightMatrix(): void;
  130660. protected _computeProjectionTextureProjectionLightMatrix(): void;
  130661. /**
  130662. * Main function for light texture projection matrix computing.
  130663. */
  130664. protected _computeProjectionTextureMatrix(): void;
  130665. protected _buildUniformLayout(): void;
  130666. private _computeAngleValues;
  130667. /**
  130668. * Sets the passed Effect "effect" with the Light textures.
  130669. * @param effect The effect to update
  130670. * @param lightIndex The index of the light in the effect to update
  130671. * @returns The light
  130672. */
  130673. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  130674. /**
  130675. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  130676. * @param effect The effect to update
  130677. * @param lightIndex The index of the light in the effect to update
  130678. * @returns The spot light
  130679. */
  130680. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  130681. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  130682. /**
  130683. * Disposes the light and the associated resources.
  130684. */
  130685. dispose(): void;
  130686. /**
  130687. * Prepares the list of defines specific to the light type.
  130688. * @param defines the list of defines
  130689. * @param lightIndex defines the index of the light for the effect
  130690. */
  130691. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130692. }
  130693. }
  130694. declare module BABYLON {
  130695. /**
  130696. * Gizmo that enables viewing a light
  130697. */
  130698. export class LightGizmo extends Gizmo {
  130699. private _lightMesh;
  130700. private _material;
  130701. private _cachedPosition;
  130702. private _cachedForward;
  130703. private _attachedMeshParent;
  130704. /**
  130705. * Creates a LightGizmo
  130706. * @param gizmoLayer The utility layer the gizmo will be added to
  130707. */
  130708. constructor(gizmoLayer?: UtilityLayerRenderer);
  130709. private _light;
  130710. /**
  130711. * The light that the gizmo is attached to
  130712. */
  130713. set light(light: Nullable<Light>);
  130714. get light(): Nullable<Light>;
  130715. /**
  130716. * Gets the material used to render the light gizmo
  130717. */
  130718. get material(): StandardMaterial;
  130719. /**
  130720. * @hidden
  130721. * Updates the gizmo to match the attached mesh's position/rotation
  130722. */
  130723. protected _update(): void;
  130724. private static _Scale;
  130725. /**
  130726. * Creates the lines for a light mesh
  130727. */
  130728. private static _CreateLightLines;
  130729. /**
  130730. * Disposes of the light gizmo
  130731. */
  130732. dispose(): void;
  130733. private static _CreateHemisphericLightMesh;
  130734. private static _CreatePointLightMesh;
  130735. private static _CreateSpotLightMesh;
  130736. private static _CreateDirectionalLightMesh;
  130737. }
  130738. }
  130739. declare module BABYLON {
  130740. /** @hidden */
  130741. export var backgroundFragmentDeclaration: {
  130742. name: string;
  130743. shader: string;
  130744. };
  130745. }
  130746. declare module BABYLON {
  130747. /** @hidden */
  130748. export var backgroundUboDeclaration: {
  130749. name: string;
  130750. shader: string;
  130751. };
  130752. }
  130753. declare module BABYLON {
  130754. /** @hidden */
  130755. export var backgroundPixelShader: {
  130756. name: string;
  130757. shader: string;
  130758. };
  130759. }
  130760. declare module BABYLON {
  130761. /** @hidden */
  130762. export var backgroundVertexDeclaration: {
  130763. name: string;
  130764. shader: string;
  130765. };
  130766. }
  130767. declare module BABYLON {
  130768. /** @hidden */
  130769. export var backgroundVertexShader: {
  130770. name: string;
  130771. shader: string;
  130772. };
  130773. }
  130774. declare module BABYLON {
  130775. /**
  130776. * Background material used to create an efficient environement around your scene.
  130777. */
  130778. export class BackgroundMaterial extends PushMaterial {
  130779. /**
  130780. * Standard reflectance value at parallel view angle.
  130781. */
  130782. static StandardReflectance0: number;
  130783. /**
  130784. * Standard reflectance value at grazing angle.
  130785. */
  130786. static StandardReflectance90: number;
  130787. protected _primaryColor: Color3;
  130788. /**
  130789. * Key light Color (multiply against the environement texture)
  130790. */
  130791. primaryColor: Color3;
  130792. protected __perceptualColor: Nullable<Color3>;
  130793. /**
  130794. * Experimental Internal Use Only.
  130795. *
  130796. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  130797. * This acts as a helper to set the primary color to a more "human friendly" value.
  130798. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  130799. * output color as close as possible from the chosen value.
  130800. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  130801. * part of lighting setup.)
  130802. */
  130803. get _perceptualColor(): Nullable<Color3>;
  130804. set _perceptualColor(value: Nullable<Color3>);
  130805. protected _primaryColorShadowLevel: float;
  130806. /**
  130807. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  130808. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  130809. */
  130810. get primaryColorShadowLevel(): float;
  130811. set primaryColorShadowLevel(value: float);
  130812. protected _primaryColorHighlightLevel: float;
  130813. /**
  130814. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  130815. * The primary color is used at the level chosen to define what the white area would look.
  130816. */
  130817. get primaryColorHighlightLevel(): float;
  130818. set primaryColorHighlightLevel(value: float);
  130819. protected _reflectionTexture: Nullable<BaseTexture>;
  130820. /**
  130821. * Reflection Texture used in the material.
  130822. * Should be author in a specific way for the best result (refer to the documentation).
  130823. */
  130824. reflectionTexture: Nullable<BaseTexture>;
  130825. protected _reflectionBlur: float;
  130826. /**
  130827. * Reflection Texture level of blur.
  130828. *
  130829. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  130830. * texture twice.
  130831. */
  130832. reflectionBlur: float;
  130833. protected _diffuseTexture: Nullable<BaseTexture>;
  130834. /**
  130835. * Diffuse Texture used in the material.
  130836. * Should be author in a specific way for the best result (refer to the documentation).
  130837. */
  130838. diffuseTexture: Nullable<BaseTexture>;
  130839. protected _shadowLights: Nullable<IShadowLight[]>;
  130840. /**
  130841. * Specify the list of lights casting shadow on the material.
  130842. * All scene shadow lights will be included if null.
  130843. */
  130844. shadowLights: Nullable<IShadowLight[]>;
  130845. protected _shadowLevel: float;
  130846. /**
  130847. * Helps adjusting the shadow to a softer level if required.
  130848. * 0 means black shadows and 1 means no shadows.
  130849. */
  130850. shadowLevel: float;
  130851. protected _sceneCenter: Vector3;
  130852. /**
  130853. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  130854. * It is usually zero but might be interesting to modify according to your setup.
  130855. */
  130856. sceneCenter: Vector3;
  130857. protected _opacityFresnel: boolean;
  130858. /**
  130859. * This helps specifying that the material is falling off to the sky box at grazing angle.
  130860. * This helps ensuring a nice transition when the camera goes under the ground.
  130861. */
  130862. opacityFresnel: boolean;
  130863. protected _reflectionFresnel: boolean;
  130864. /**
  130865. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  130866. * This helps adding a mirror texture on the ground.
  130867. */
  130868. reflectionFresnel: boolean;
  130869. protected _reflectionFalloffDistance: number;
  130870. /**
  130871. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  130872. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  130873. */
  130874. reflectionFalloffDistance: number;
  130875. protected _reflectionAmount: number;
  130876. /**
  130877. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  130878. */
  130879. reflectionAmount: number;
  130880. protected _reflectionReflectance0: number;
  130881. /**
  130882. * This specifies the weight of the reflection at grazing angle.
  130883. */
  130884. reflectionReflectance0: number;
  130885. protected _reflectionReflectance90: number;
  130886. /**
  130887. * This specifies the weight of the reflection at a perpendicular point of view.
  130888. */
  130889. reflectionReflectance90: number;
  130890. /**
  130891. * Sets the reflection reflectance fresnel values according to the default standard
  130892. * empirically know to work well :-)
  130893. */
  130894. set reflectionStandardFresnelWeight(value: number);
  130895. protected _useRGBColor: boolean;
  130896. /**
  130897. * Helps to directly use the maps channels instead of their level.
  130898. */
  130899. useRGBColor: boolean;
  130900. protected _enableNoise: boolean;
  130901. /**
  130902. * This helps reducing the banding effect that could occur on the background.
  130903. */
  130904. enableNoise: boolean;
  130905. /**
  130906. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130907. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  130908. * Recommended to be keep at 1.0 except for special cases.
  130909. */
  130910. get fovMultiplier(): number;
  130911. set fovMultiplier(value: number);
  130912. private _fovMultiplier;
  130913. /**
  130914. * Enable the FOV adjustment feature controlled by fovMultiplier.
  130915. */
  130916. useEquirectangularFOV: boolean;
  130917. private _maxSimultaneousLights;
  130918. /**
  130919. * Number of Simultaneous lights allowed on the material.
  130920. */
  130921. maxSimultaneousLights: int;
  130922. /**
  130923. * Default configuration related to image processing available in the Background Material.
  130924. */
  130925. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130926. /**
  130927. * Keep track of the image processing observer to allow dispose and replace.
  130928. */
  130929. private _imageProcessingObserver;
  130930. /**
  130931. * Attaches a new image processing configuration to the PBR Material.
  130932. * @param configuration (if null the scene configuration will be use)
  130933. */
  130934. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130935. /**
  130936. * Gets the image processing configuration used either in this material.
  130937. */
  130938. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  130939. /**
  130940. * Sets the Default image processing configuration used either in the this material.
  130941. *
  130942. * If sets to null, the scene one is in use.
  130943. */
  130944. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  130945. /**
  130946. * Gets wether the color curves effect is enabled.
  130947. */
  130948. get cameraColorCurvesEnabled(): boolean;
  130949. /**
  130950. * Sets wether the color curves effect is enabled.
  130951. */
  130952. set cameraColorCurvesEnabled(value: boolean);
  130953. /**
  130954. * Gets wether the color grading effect is enabled.
  130955. */
  130956. get cameraColorGradingEnabled(): boolean;
  130957. /**
  130958. * Gets wether the color grading effect is enabled.
  130959. */
  130960. set cameraColorGradingEnabled(value: boolean);
  130961. /**
  130962. * Gets wether tonemapping is enabled or not.
  130963. */
  130964. get cameraToneMappingEnabled(): boolean;
  130965. /**
  130966. * Sets wether tonemapping is enabled or not
  130967. */
  130968. set cameraToneMappingEnabled(value: boolean);
  130969. /**
  130970. * The camera exposure used on this material.
  130971. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130972. * This corresponds to a photographic exposure.
  130973. */
  130974. get cameraExposure(): float;
  130975. /**
  130976. * The camera exposure used on this material.
  130977. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130978. * This corresponds to a photographic exposure.
  130979. */
  130980. set cameraExposure(value: float);
  130981. /**
  130982. * Gets The camera contrast used on this material.
  130983. */
  130984. get cameraContrast(): float;
  130985. /**
  130986. * Sets The camera contrast used on this material.
  130987. */
  130988. set cameraContrast(value: float);
  130989. /**
  130990. * Gets the Color Grading 2D Lookup Texture.
  130991. */
  130992. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  130993. /**
  130994. * Sets the Color Grading 2D Lookup Texture.
  130995. */
  130996. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  130997. /**
  130998. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  130999. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131000. * 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;
  131001. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131002. */
  131003. get cameraColorCurves(): Nullable<ColorCurves>;
  131004. /**
  131005. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131006. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131007. * 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;
  131008. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131009. */
  131010. set cameraColorCurves(value: Nullable<ColorCurves>);
  131011. /**
  131012. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  131013. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  131014. */
  131015. switchToBGR: boolean;
  131016. private _renderTargets;
  131017. private _reflectionControls;
  131018. private _white;
  131019. private _primaryShadowColor;
  131020. private _primaryHighlightColor;
  131021. /**
  131022. * Instantiates a Background Material in the given scene
  131023. * @param name The friendly name of the material
  131024. * @param scene The scene to add the material to
  131025. */
  131026. constructor(name: string, scene: Scene);
  131027. /**
  131028. * Gets a boolean indicating that current material needs to register RTT
  131029. */
  131030. get hasRenderTargetTextures(): boolean;
  131031. /**
  131032. * The entire material has been created in order to prevent overdraw.
  131033. * @returns false
  131034. */
  131035. needAlphaTesting(): boolean;
  131036. /**
  131037. * The entire material has been created in order to prevent overdraw.
  131038. * @returns true if blending is enable
  131039. */
  131040. needAlphaBlending(): boolean;
  131041. /**
  131042. * Checks wether the material is ready to be rendered for a given mesh.
  131043. * @param mesh The mesh to render
  131044. * @param subMesh The submesh to check against
  131045. * @param useInstances Specify wether or not the material is used with instances
  131046. * @returns true if all the dependencies are ready (Textures, Effects...)
  131047. */
  131048. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131049. /**
  131050. * Compute the primary color according to the chosen perceptual color.
  131051. */
  131052. private _computePrimaryColorFromPerceptualColor;
  131053. /**
  131054. * Compute the highlights and shadow colors according to their chosen levels.
  131055. */
  131056. private _computePrimaryColors;
  131057. /**
  131058. * Build the uniform buffer used in the material.
  131059. */
  131060. buildUniformLayout(): void;
  131061. /**
  131062. * Unbind the material.
  131063. */
  131064. unbind(): void;
  131065. /**
  131066. * Bind only the world matrix to the material.
  131067. * @param world The world matrix to bind.
  131068. */
  131069. bindOnlyWorldMatrix(world: Matrix): void;
  131070. /**
  131071. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  131072. * @param world The world matrix to bind.
  131073. * @param subMesh The submesh to bind for.
  131074. */
  131075. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131076. /**
  131077. * Checks to see if a texture is used in the material.
  131078. * @param texture - Base texture to use.
  131079. * @returns - Boolean specifying if a texture is used in the material.
  131080. */
  131081. hasTexture(texture: BaseTexture): boolean;
  131082. /**
  131083. * Dispose the material.
  131084. * @param forceDisposeEffect Force disposal of the associated effect.
  131085. * @param forceDisposeTextures Force disposal of the associated textures.
  131086. */
  131087. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131088. /**
  131089. * Clones the material.
  131090. * @param name The cloned name.
  131091. * @returns The cloned material.
  131092. */
  131093. clone(name: string): BackgroundMaterial;
  131094. /**
  131095. * Serializes the current material to its JSON representation.
  131096. * @returns The JSON representation.
  131097. */
  131098. serialize(): any;
  131099. /**
  131100. * Gets the class name of the material
  131101. * @returns "BackgroundMaterial"
  131102. */
  131103. getClassName(): string;
  131104. /**
  131105. * Parse a JSON input to create back a background material.
  131106. * @param source The JSON data to parse
  131107. * @param scene The scene to create the parsed material in
  131108. * @param rootUrl The root url of the assets the material depends upon
  131109. * @returns the instantiated BackgroundMaterial.
  131110. */
  131111. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  131112. }
  131113. }
  131114. declare module BABYLON {
  131115. /**
  131116. * Represents the different options available during the creation of
  131117. * a Environment helper.
  131118. *
  131119. * This can control the default ground, skybox and image processing setup of your scene.
  131120. */
  131121. export interface IEnvironmentHelperOptions {
  131122. /**
  131123. * Specifies whether or not to create a ground.
  131124. * True by default.
  131125. */
  131126. createGround: boolean;
  131127. /**
  131128. * Specifies the ground size.
  131129. * 15 by default.
  131130. */
  131131. groundSize: number;
  131132. /**
  131133. * The texture used on the ground for the main color.
  131134. * Comes from the BabylonJS CDN by default.
  131135. *
  131136. * Remarks: Can be either a texture or a url.
  131137. */
  131138. groundTexture: string | BaseTexture;
  131139. /**
  131140. * The color mixed in the ground texture by default.
  131141. * BabylonJS clearColor by default.
  131142. */
  131143. groundColor: Color3;
  131144. /**
  131145. * Specifies the ground opacity.
  131146. * 1 by default.
  131147. */
  131148. groundOpacity: number;
  131149. /**
  131150. * Enables the ground to receive shadows.
  131151. * True by default.
  131152. */
  131153. enableGroundShadow: boolean;
  131154. /**
  131155. * Helps preventing the shadow to be fully black on the ground.
  131156. * 0.5 by default.
  131157. */
  131158. groundShadowLevel: number;
  131159. /**
  131160. * Creates a mirror texture attach to the ground.
  131161. * false by default.
  131162. */
  131163. enableGroundMirror: boolean;
  131164. /**
  131165. * Specifies the ground mirror size ratio.
  131166. * 0.3 by default as the default kernel is 64.
  131167. */
  131168. groundMirrorSizeRatio: number;
  131169. /**
  131170. * Specifies the ground mirror blur kernel size.
  131171. * 64 by default.
  131172. */
  131173. groundMirrorBlurKernel: number;
  131174. /**
  131175. * Specifies the ground mirror visibility amount.
  131176. * 1 by default
  131177. */
  131178. groundMirrorAmount: number;
  131179. /**
  131180. * Specifies the ground mirror reflectance weight.
  131181. * This uses the standard weight of the background material to setup the fresnel effect
  131182. * of the mirror.
  131183. * 1 by default.
  131184. */
  131185. groundMirrorFresnelWeight: number;
  131186. /**
  131187. * Specifies the ground mirror Falloff distance.
  131188. * This can helps reducing the size of the reflection.
  131189. * 0 by Default.
  131190. */
  131191. groundMirrorFallOffDistance: number;
  131192. /**
  131193. * Specifies the ground mirror texture type.
  131194. * Unsigned Int by Default.
  131195. */
  131196. groundMirrorTextureType: number;
  131197. /**
  131198. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  131199. * the shown objects.
  131200. */
  131201. groundYBias: number;
  131202. /**
  131203. * Specifies whether or not to create a skybox.
  131204. * True by default.
  131205. */
  131206. createSkybox: boolean;
  131207. /**
  131208. * Specifies the skybox size.
  131209. * 20 by default.
  131210. */
  131211. skyboxSize: number;
  131212. /**
  131213. * The texture used on the skybox for the main color.
  131214. * Comes from the BabylonJS CDN by default.
  131215. *
  131216. * Remarks: Can be either a texture or a url.
  131217. */
  131218. skyboxTexture: string | BaseTexture;
  131219. /**
  131220. * The color mixed in the skybox texture by default.
  131221. * BabylonJS clearColor by default.
  131222. */
  131223. skyboxColor: Color3;
  131224. /**
  131225. * The background rotation around the Y axis of the scene.
  131226. * This helps aligning the key lights of your scene with the background.
  131227. * 0 by default.
  131228. */
  131229. backgroundYRotation: number;
  131230. /**
  131231. * Compute automatically the size of the elements to best fit with the scene.
  131232. */
  131233. sizeAuto: boolean;
  131234. /**
  131235. * Default position of the rootMesh if autoSize is not true.
  131236. */
  131237. rootPosition: Vector3;
  131238. /**
  131239. * Sets up the image processing in the scene.
  131240. * true by default.
  131241. */
  131242. setupImageProcessing: boolean;
  131243. /**
  131244. * The texture used as your environment texture in the scene.
  131245. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  131246. *
  131247. * Remarks: Can be either a texture or a url.
  131248. */
  131249. environmentTexture: string | BaseTexture;
  131250. /**
  131251. * The value of the exposure to apply to the scene.
  131252. * 0.6 by default if setupImageProcessing is true.
  131253. */
  131254. cameraExposure: number;
  131255. /**
  131256. * The value of the contrast to apply to the scene.
  131257. * 1.6 by default if setupImageProcessing is true.
  131258. */
  131259. cameraContrast: number;
  131260. /**
  131261. * Specifies whether or not tonemapping should be enabled in the scene.
  131262. * true by default if setupImageProcessing is true.
  131263. */
  131264. toneMappingEnabled: boolean;
  131265. }
  131266. /**
  131267. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  131268. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  131269. * It also helps with the default setup of your imageProcessing configuration.
  131270. */
  131271. export class EnvironmentHelper {
  131272. /**
  131273. * Default ground texture URL.
  131274. */
  131275. private static _groundTextureCDNUrl;
  131276. /**
  131277. * Default skybox texture URL.
  131278. */
  131279. private static _skyboxTextureCDNUrl;
  131280. /**
  131281. * Default environment texture URL.
  131282. */
  131283. private static _environmentTextureCDNUrl;
  131284. /**
  131285. * Creates the default options for the helper.
  131286. */
  131287. private static _getDefaultOptions;
  131288. private _rootMesh;
  131289. /**
  131290. * Gets the root mesh created by the helper.
  131291. */
  131292. get rootMesh(): Mesh;
  131293. private _skybox;
  131294. /**
  131295. * Gets the skybox created by the helper.
  131296. */
  131297. get skybox(): Nullable<Mesh>;
  131298. private _skyboxTexture;
  131299. /**
  131300. * Gets the skybox texture created by the helper.
  131301. */
  131302. get skyboxTexture(): Nullable<BaseTexture>;
  131303. private _skyboxMaterial;
  131304. /**
  131305. * Gets the skybox material created by the helper.
  131306. */
  131307. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  131308. private _ground;
  131309. /**
  131310. * Gets the ground mesh created by the helper.
  131311. */
  131312. get ground(): Nullable<Mesh>;
  131313. private _groundTexture;
  131314. /**
  131315. * Gets the ground texture created by the helper.
  131316. */
  131317. get groundTexture(): Nullable<BaseTexture>;
  131318. private _groundMirror;
  131319. /**
  131320. * Gets the ground mirror created by the helper.
  131321. */
  131322. get groundMirror(): Nullable<MirrorTexture>;
  131323. /**
  131324. * Gets the ground mirror render list to helps pushing the meshes
  131325. * you wish in the ground reflection.
  131326. */
  131327. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  131328. private _groundMaterial;
  131329. /**
  131330. * Gets the ground material created by the helper.
  131331. */
  131332. get groundMaterial(): Nullable<BackgroundMaterial>;
  131333. /**
  131334. * Stores the creation options.
  131335. */
  131336. private readonly _scene;
  131337. private _options;
  131338. /**
  131339. * This observable will be notified with any error during the creation of the environment,
  131340. * mainly texture creation errors.
  131341. */
  131342. onErrorObservable: Observable<{
  131343. message?: string;
  131344. exception?: any;
  131345. }>;
  131346. /**
  131347. * constructor
  131348. * @param options Defines the options we want to customize the helper
  131349. * @param scene The scene to add the material to
  131350. */
  131351. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  131352. /**
  131353. * Updates the background according to the new options
  131354. * @param options
  131355. */
  131356. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  131357. /**
  131358. * Sets the primary color of all the available elements.
  131359. * @param color the main color to affect to the ground and the background
  131360. */
  131361. setMainColor(color: Color3): void;
  131362. /**
  131363. * Setup the image processing according to the specified options.
  131364. */
  131365. private _setupImageProcessing;
  131366. /**
  131367. * Setup the environment texture according to the specified options.
  131368. */
  131369. private _setupEnvironmentTexture;
  131370. /**
  131371. * Setup the background according to the specified options.
  131372. */
  131373. private _setupBackground;
  131374. /**
  131375. * Get the scene sizes according to the setup.
  131376. */
  131377. private _getSceneSize;
  131378. /**
  131379. * Setup the ground according to the specified options.
  131380. */
  131381. private _setupGround;
  131382. /**
  131383. * Setup the ground material according to the specified options.
  131384. */
  131385. private _setupGroundMaterial;
  131386. /**
  131387. * Setup the ground diffuse texture according to the specified options.
  131388. */
  131389. private _setupGroundDiffuseTexture;
  131390. /**
  131391. * Setup the ground mirror texture according to the specified options.
  131392. */
  131393. private _setupGroundMirrorTexture;
  131394. /**
  131395. * Setup the ground to receive the mirror texture.
  131396. */
  131397. private _setupMirrorInGroundMaterial;
  131398. /**
  131399. * Setup the skybox according to the specified options.
  131400. */
  131401. private _setupSkybox;
  131402. /**
  131403. * Setup the skybox material according to the specified options.
  131404. */
  131405. private _setupSkyboxMaterial;
  131406. /**
  131407. * Setup the skybox reflection texture according to the specified options.
  131408. */
  131409. private _setupSkyboxReflectionTexture;
  131410. private _errorHandler;
  131411. /**
  131412. * Dispose all the elements created by the Helper.
  131413. */
  131414. dispose(): void;
  131415. }
  131416. }
  131417. declare module BABYLON {
  131418. /**
  131419. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  131420. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  131421. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  131422. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  131423. */
  131424. export class PhotoDome extends TransformNode {
  131425. /**
  131426. * Define the image as a Monoscopic panoramic 360 image.
  131427. */
  131428. static readonly MODE_MONOSCOPIC: number;
  131429. /**
  131430. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131431. */
  131432. static readonly MODE_TOPBOTTOM: number;
  131433. /**
  131434. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131435. */
  131436. static readonly MODE_SIDEBYSIDE: number;
  131437. private _useDirectMapping;
  131438. /**
  131439. * The texture being displayed on the sphere
  131440. */
  131441. protected _photoTexture: Texture;
  131442. /**
  131443. * Gets or sets the texture being displayed on the sphere
  131444. */
  131445. get photoTexture(): Texture;
  131446. set photoTexture(value: Texture);
  131447. /**
  131448. * Observable raised when an error occured while loading the 360 image
  131449. */
  131450. onLoadErrorObservable: Observable<string>;
  131451. /**
  131452. * The skybox material
  131453. */
  131454. protected _material: BackgroundMaterial;
  131455. /**
  131456. * The surface used for the skybox
  131457. */
  131458. protected _mesh: Mesh;
  131459. /**
  131460. * Gets the mesh used for the skybox.
  131461. */
  131462. get mesh(): Mesh;
  131463. /**
  131464. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131465. * Also see the options.resolution property.
  131466. */
  131467. get fovMultiplier(): number;
  131468. set fovMultiplier(value: number);
  131469. private _imageMode;
  131470. /**
  131471. * Gets or set the current video mode for the video. It can be:
  131472. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  131473. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131474. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131475. */
  131476. get imageMode(): number;
  131477. set imageMode(value: number);
  131478. /**
  131479. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  131480. * @param name Element's name, child elements will append suffixes for their own names.
  131481. * @param urlsOfPhoto defines the url of the photo to display
  131482. * @param options defines an object containing optional or exposed sub element properties
  131483. * @param onError defines a callback called when an error occured while loading the texture
  131484. */
  131485. constructor(name: string, urlOfPhoto: string, options: {
  131486. resolution?: number;
  131487. size?: number;
  131488. useDirectMapping?: boolean;
  131489. faceForward?: boolean;
  131490. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  131491. private _onBeforeCameraRenderObserver;
  131492. private _changeImageMode;
  131493. /**
  131494. * Releases resources associated with this node.
  131495. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  131496. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  131497. */
  131498. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  131499. }
  131500. }
  131501. declare module BABYLON {
  131502. /**
  131503. * Class used to host RGBD texture specific utilities
  131504. */
  131505. export class RGBDTextureTools {
  131506. /**
  131507. * Expand the RGBD Texture from RGBD to Half Float if possible.
  131508. * @param texture the texture to expand.
  131509. */
  131510. static ExpandRGBDTexture(texture: Texture): void;
  131511. }
  131512. }
  131513. declare module BABYLON {
  131514. /**
  131515. * Class used to host texture specific utilities
  131516. */
  131517. export class BRDFTextureTools {
  131518. /**
  131519. * Prevents texture cache collision
  131520. */
  131521. private static _instanceNumber;
  131522. /**
  131523. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  131524. * @param scene defines the hosting scene
  131525. * @returns the environment BRDF texture
  131526. */
  131527. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  131528. private static _environmentBRDFBase64Texture;
  131529. }
  131530. }
  131531. declare module BABYLON {
  131532. /**
  131533. * @hidden
  131534. */
  131535. export interface IMaterialClearCoatDefines {
  131536. CLEARCOAT: boolean;
  131537. CLEARCOAT_DEFAULTIOR: boolean;
  131538. CLEARCOAT_TEXTURE: boolean;
  131539. CLEARCOAT_TEXTUREDIRECTUV: number;
  131540. CLEARCOAT_BUMP: boolean;
  131541. CLEARCOAT_BUMPDIRECTUV: number;
  131542. CLEARCOAT_TINT: boolean;
  131543. CLEARCOAT_TINT_TEXTURE: boolean;
  131544. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131545. /** @hidden */
  131546. _areTexturesDirty: boolean;
  131547. }
  131548. /**
  131549. * Define the code related to the clear coat parameters of the pbr material.
  131550. */
  131551. export class PBRClearCoatConfiguration {
  131552. /**
  131553. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131554. * The default fits with a polyurethane material.
  131555. */
  131556. private static readonly _DefaultIndexOfRefraction;
  131557. private _isEnabled;
  131558. /**
  131559. * Defines if the clear coat is enabled in the material.
  131560. */
  131561. isEnabled: boolean;
  131562. /**
  131563. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  131564. */
  131565. intensity: number;
  131566. /**
  131567. * Defines the clear coat layer roughness.
  131568. */
  131569. roughness: number;
  131570. private _indexOfRefraction;
  131571. /**
  131572. * Defines the index of refraction of the clear coat.
  131573. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131574. * The default fits with a polyurethane material.
  131575. * Changing the default value is more performance intensive.
  131576. */
  131577. indexOfRefraction: number;
  131578. private _texture;
  131579. /**
  131580. * Stores the clear coat values in a texture.
  131581. */
  131582. texture: Nullable<BaseTexture>;
  131583. private _bumpTexture;
  131584. /**
  131585. * Define the clear coat specific bump texture.
  131586. */
  131587. bumpTexture: Nullable<BaseTexture>;
  131588. private _isTintEnabled;
  131589. /**
  131590. * Defines if the clear coat tint is enabled in the material.
  131591. */
  131592. isTintEnabled: boolean;
  131593. /**
  131594. * Defines the clear coat tint of the material.
  131595. * This is only use if tint is enabled
  131596. */
  131597. tintColor: Color3;
  131598. /**
  131599. * Defines the distance at which the tint color should be found in the
  131600. * clear coat media.
  131601. * This is only use if tint is enabled
  131602. */
  131603. tintColorAtDistance: number;
  131604. /**
  131605. * Defines the clear coat layer thickness.
  131606. * This is only use if tint is enabled
  131607. */
  131608. tintThickness: number;
  131609. private _tintTexture;
  131610. /**
  131611. * Stores the clear tint values in a texture.
  131612. * rgb is tint
  131613. * a is a thickness factor
  131614. */
  131615. tintTexture: Nullable<BaseTexture>;
  131616. /** @hidden */
  131617. private _internalMarkAllSubMeshesAsTexturesDirty;
  131618. /** @hidden */
  131619. _markAllSubMeshesAsTexturesDirty(): void;
  131620. /**
  131621. * Instantiate a new istance of clear coat configuration.
  131622. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131623. */
  131624. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131625. /**
  131626. * Gets wehter the submesh is ready to be used or not.
  131627. * @param defines the list of "defines" to update.
  131628. * @param scene defines the scene the material belongs to.
  131629. * @param engine defines the engine the material belongs to.
  131630. * @param disableBumpMap defines wether the material disables bump or not.
  131631. * @returns - boolean indicating that the submesh is ready or not.
  131632. */
  131633. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  131634. /**
  131635. * Checks to see if a texture is used in the material.
  131636. * @param defines the list of "defines" to update.
  131637. * @param scene defines the scene to the material belongs to.
  131638. */
  131639. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  131640. /**
  131641. * Binds the material data.
  131642. * @param uniformBuffer defines the Uniform buffer to fill in.
  131643. * @param scene defines the scene the material belongs to.
  131644. * @param engine defines the engine the material belongs to.
  131645. * @param disableBumpMap defines wether the material disables bump or not.
  131646. * @param isFrozen defines wether the material is frozen or not.
  131647. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  131648. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  131649. */
  131650. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  131651. /**
  131652. * Checks to see if a texture is used in the material.
  131653. * @param texture - Base texture to use.
  131654. * @returns - Boolean specifying if a texture is used in the material.
  131655. */
  131656. hasTexture(texture: BaseTexture): boolean;
  131657. /**
  131658. * Returns an array of the actively used textures.
  131659. * @param activeTextures Array of BaseTextures
  131660. */
  131661. getActiveTextures(activeTextures: BaseTexture[]): void;
  131662. /**
  131663. * Returns the animatable textures.
  131664. * @param animatables Array of animatable textures.
  131665. */
  131666. getAnimatables(animatables: IAnimatable[]): void;
  131667. /**
  131668. * Disposes the resources of the material.
  131669. * @param forceDisposeTextures - Forces the disposal of all textures.
  131670. */
  131671. dispose(forceDisposeTextures?: boolean): void;
  131672. /**
  131673. * Get the current class name of the texture useful for serialization or dynamic coding.
  131674. * @returns "PBRClearCoatConfiguration"
  131675. */
  131676. getClassName(): string;
  131677. /**
  131678. * Add fallbacks to the effect fallbacks list.
  131679. * @param defines defines the Base texture to use.
  131680. * @param fallbacks defines the current fallback list.
  131681. * @param currentRank defines the current fallback rank.
  131682. * @returns the new fallback rank.
  131683. */
  131684. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131685. /**
  131686. * Add the required uniforms to the current list.
  131687. * @param uniforms defines the current uniform list.
  131688. */
  131689. static AddUniforms(uniforms: string[]): void;
  131690. /**
  131691. * Add the required samplers to the current list.
  131692. * @param samplers defines the current sampler list.
  131693. */
  131694. static AddSamplers(samplers: string[]): void;
  131695. /**
  131696. * Add the required uniforms to the current buffer.
  131697. * @param uniformBuffer defines the current uniform buffer.
  131698. */
  131699. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131700. /**
  131701. * Makes a duplicate of the current configuration into another one.
  131702. * @param clearCoatConfiguration define the config where to copy the info
  131703. */
  131704. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  131705. /**
  131706. * Serializes this clear coat configuration.
  131707. * @returns - An object with the serialized config.
  131708. */
  131709. serialize(): any;
  131710. /**
  131711. * Parses a anisotropy Configuration from a serialized object.
  131712. * @param source - Serialized object.
  131713. * @param scene Defines the scene we are parsing for
  131714. * @param rootUrl Defines the rootUrl to load from
  131715. */
  131716. parse(source: any, scene: Scene, rootUrl: string): void;
  131717. }
  131718. }
  131719. declare module BABYLON {
  131720. /**
  131721. * @hidden
  131722. */
  131723. export interface IMaterialAnisotropicDefines {
  131724. ANISOTROPIC: boolean;
  131725. ANISOTROPIC_TEXTURE: boolean;
  131726. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131727. MAINUV1: boolean;
  131728. _areTexturesDirty: boolean;
  131729. _needUVs: boolean;
  131730. }
  131731. /**
  131732. * Define the code related to the anisotropic parameters of the pbr material.
  131733. */
  131734. export class PBRAnisotropicConfiguration {
  131735. private _isEnabled;
  131736. /**
  131737. * Defines if the anisotropy is enabled in the material.
  131738. */
  131739. isEnabled: boolean;
  131740. /**
  131741. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  131742. */
  131743. intensity: number;
  131744. /**
  131745. * Defines if the effect is along the tangents, bitangents or in between.
  131746. * By default, the effect is "strectching" the highlights along the tangents.
  131747. */
  131748. direction: Vector2;
  131749. private _texture;
  131750. /**
  131751. * Stores the anisotropy values in a texture.
  131752. * rg is direction (like normal from -1 to 1)
  131753. * b is a intensity
  131754. */
  131755. texture: Nullable<BaseTexture>;
  131756. /** @hidden */
  131757. private _internalMarkAllSubMeshesAsTexturesDirty;
  131758. /** @hidden */
  131759. _markAllSubMeshesAsTexturesDirty(): void;
  131760. /**
  131761. * Instantiate a new istance of anisotropy configuration.
  131762. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131763. */
  131764. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131765. /**
  131766. * Specifies that the submesh is ready to be used.
  131767. * @param defines the list of "defines" to update.
  131768. * @param scene defines the scene the material belongs to.
  131769. * @returns - boolean indicating that the submesh is ready or not.
  131770. */
  131771. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  131772. /**
  131773. * Checks to see if a texture is used in the material.
  131774. * @param defines the list of "defines" to update.
  131775. * @param mesh the mesh we are preparing the defines for.
  131776. * @param scene defines the scene the material belongs to.
  131777. */
  131778. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  131779. /**
  131780. * Binds the material data.
  131781. * @param uniformBuffer defines the Uniform buffer to fill in.
  131782. * @param scene defines the scene the material belongs to.
  131783. * @param isFrozen defines wether the material is frozen or not.
  131784. */
  131785. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  131786. /**
  131787. * Checks to see if a texture is used in the material.
  131788. * @param texture - Base texture to use.
  131789. * @returns - Boolean specifying if a texture is used in the material.
  131790. */
  131791. hasTexture(texture: BaseTexture): boolean;
  131792. /**
  131793. * Returns an array of the actively used textures.
  131794. * @param activeTextures Array of BaseTextures
  131795. */
  131796. getActiveTextures(activeTextures: BaseTexture[]): void;
  131797. /**
  131798. * Returns the animatable textures.
  131799. * @param animatables Array of animatable textures.
  131800. */
  131801. getAnimatables(animatables: IAnimatable[]): void;
  131802. /**
  131803. * Disposes the resources of the material.
  131804. * @param forceDisposeTextures - Forces the disposal of all textures.
  131805. */
  131806. dispose(forceDisposeTextures?: boolean): void;
  131807. /**
  131808. * Get the current class name of the texture useful for serialization or dynamic coding.
  131809. * @returns "PBRAnisotropicConfiguration"
  131810. */
  131811. getClassName(): string;
  131812. /**
  131813. * Add fallbacks to the effect fallbacks list.
  131814. * @param defines defines the Base texture to use.
  131815. * @param fallbacks defines the current fallback list.
  131816. * @param currentRank defines the current fallback rank.
  131817. * @returns the new fallback rank.
  131818. */
  131819. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131820. /**
  131821. * Add the required uniforms to the current list.
  131822. * @param uniforms defines the current uniform list.
  131823. */
  131824. static AddUniforms(uniforms: string[]): void;
  131825. /**
  131826. * Add the required uniforms to the current buffer.
  131827. * @param uniformBuffer defines the current uniform buffer.
  131828. */
  131829. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131830. /**
  131831. * Add the required samplers to the current list.
  131832. * @param samplers defines the current sampler list.
  131833. */
  131834. static AddSamplers(samplers: string[]): void;
  131835. /**
  131836. * Makes a duplicate of the current configuration into another one.
  131837. * @param anisotropicConfiguration define the config where to copy the info
  131838. */
  131839. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  131840. /**
  131841. * Serializes this anisotropy configuration.
  131842. * @returns - An object with the serialized config.
  131843. */
  131844. serialize(): any;
  131845. /**
  131846. * Parses a anisotropy Configuration from a serialized object.
  131847. * @param source - Serialized object.
  131848. * @param scene Defines the scene we are parsing for
  131849. * @param rootUrl Defines the rootUrl to load from
  131850. */
  131851. parse(source: any, scene: Scene, rootUrl: string): void;
  131852. }
  131853. }
  131854. declare module BABYLON {
  131855. /**
  131856. * @hidden
  131857. */
  131858. export interface IMaterialBRDFDefines {
  131859. BRDF_V_HEIGHT_CORRELATED: boolean;
  131860. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131861. SPHERICAL_HARMONICS: boolean;
  131862. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131863. /** @hidden */
  131864. _areMiscDirty: boolean;
  131865. }
  131866. /**
  131867. * Define the code related to the BRDF parameters of the pbr material.
  131868. */
  131869. export class PBRBRDFConfiguration {
  131870. /**
  131871. * Default value used for the energy conservation.
  131872. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131873. */
  131874. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  131875. /**
  131876. * Default value used for the Smith Visibility Height Correlated mode.
  131877. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131878. */
  131879. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  131880. /**
  131881. * Default value used for the IBL diffuse part.
  131882. * This can help switching back to the polynomials mode globally which is a tiny bit
  131883. * less GPU intensive at the drawback of a lower quality.
  131884. */
  131885. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  131886. /**
  131887. * Default value used for activating energy conservation for the specular workflow.
  131888. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131889. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131890. */
  131891. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  131892. private _useEnergyConservation;
  131893. /**
  131894. * Defines if the material uses energy conservation.
  131895. */
  131896. useEnergyConservation: boolean;
  131897. private _useSmithVisibilityHeightCorrelated;
  131898. /**
  131899. * LEGACY Mode set to false
  131900. * Defines if the material uses height smith correlated visibility term.
  131901. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  131902. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  131903. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  131904. * Not relying on height correlated will also disable energy conservation.
  131905. */
  131906. useSmithVisibilityHeightCorrelated: boolean;
  131907. private _useSphericalHarmonics;
  131908. /**
  131909. * LEGACY Mode set to false
  131910. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  131911. * diffuse part of the IBL.
  131912. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  131913. * to the ground truth.
  131914. */
  131915. useSphericalHarmonics: boolean;
  131916. private _useSpecularGlossinessInputEnergyConservation;
  131917. /**
  131918. * Defines if the material uses energy conservation, when the specular workflow is active.
  131919. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131920. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131921. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  131922. */
  131923. useSpecularGlossinessInputEnergyConservation: boolean;
  131924. /** @hidden */
  131925. private _internalMarkAllSubMeshesAsMiscDirty;
  131926. /** @hidden */
  131927. _markAllSubMeshesAsMiscDirty(): void;
  131928. /**
  131929. * Instantiate a new istance of clear coat configuration.
  131930. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  131931. */
  131932. constructor(markAllSubMeshesAsMiscDirty: () => void);
  131933. /**
  131934. * Checks to see if a texture is used in the material.
  131935. * @param defines the list of "defines" to update.
  131936. */
  131937. prepareDefines(defines: IMaterialBRDFDefines): void;
  131938. /**
  131939. * Get the current class name of the texture useful for serialization or dynamic coding.
  131940. * @returns "PBRClearCoatConfiguration"
  131941. */
  131942. getClassName(): string;
  131943. /**
  131944. * Makes a duplicate of the current configuration into another one.
  131945. * @param brdfConfiguration define the config where to copy the info
  131946. */
  131947. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  131948. /**
  131949. * Serializes this BRDF configuration.
  131950. * @returns - An object with the serialized config.
  131951. */
  131952. serialize(): any;
  131953. /**
  131954. * Parses a anisotropy Configuration from a serialized object.
  131955. * @param source - Serialized object.
  131956. * @param scene Defines the scene we are parsing for
  131957. * @param rootUrl Defines the rootUrl to load from
  131958. */
  131959. parse(source: any, scene: Scene, rootUrl: string): void;
  131960. }
  131961. }
  131962. declare module BABYLON {
  131963. /**
  131964. * @hidden
  131965. */
  131966. export interface IMaterialSheenDefines {
  131967. SHEEN: boolean;
  131968. SHEEN_TEXTURE: boolean;
  131969. SHEEN_TEXTUREDIRECTUV: number;
  131970. SHEEN_LINKWITHALBEDO: boolean;
  131971. SHEEN_ROUGHNESS: boolean;
  131972. SHEEN_ALBEDOSCALING: boolean;
  131973. /** @hidden */
  131974. _areTexturesDirty: boolean;
  131975. }
  131976. /**
  131977. * Define the code related to the Sheen parameters of the pbr material.
  131978. */
  131979. export class PBRSheenConfiguration {
  131980. private _isEnabled;
  131981. /**
  131982. * Defines if the material uses sheen.
  131983. */
  131984. isEnabled: boolean;
  131985. private _linkSheenWithAlbedo;
  131986. /**
  131987. * Defines if the sheen is linked to the sheen color.
  131988. */
  131989. linkSheenWithAlbedo: boolean;
  131990. /**
  131991. * Defines the sheen intensity.
  131992. */
  131993. intensity: number;
  131994. /**
  131995. * Defines the sheen color.
  131996. */
  131997. color: Color3;
  131998. private _texture;
  131999. /**
  132000. * Stores the sheen tint values in a texture.
  132001. * rgb is tint
  132002. * a is a intensity
  132003. */
  132004. texture: Nullable<BaseTexture>;
  132005. private _roughness;
  132006. /**
  132007. * Defines the sheen roughness.
  132008. * It is not taken into account if linkSheenWithAlbedo is true.
  132009. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  132010. */
  132011. roughness: Nullable<number>;
  132012. private _albedoScaling;
  132013. /**
  132014. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  132015. * It allows the strength of the sheen effect to not depend on the base color of the material,
  132016. * making it easier to setup and tweak the effect
  132017. */
  132018. albedoScaling: boolean;
  132019. /** @hidden */
  132020. private _internalMarkAllSubMeshesAsTexturesDirty;
  132021. /** @hidden */
  132022. _markAllSubMeshesAsTexturesDirty(): void;
  132023. /**
  132024. * Instantiate a new istance of clear coat configuration.
  132025. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132026. */
  132027. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132028. /**
  132029. * Specifies that the submesh is ready to be used.
  132030. * @param defines the list of "defines" to update.
  132031. * @param scene defines the scene the material belongs to.
  132032. * @returns - boolean indicating that the submesh is ready or not.
  132033. */
  132034. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  132035. /**
  132036. * Checks to see if a texture is used in the material.
  132037. * @param defines the list of "defines" to update.
  132038. * @param scene defines the scene the material belongs to.
  132039. */
  132040. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  132041. /**
  132042. * Binds the material data.
  132043. * @param uniformBuffer defines the Uniform buffer to fill in.
  132044. * @param scene defines the scene the material belongs to.
  132045. * @param isFrozen defines wether the material is frozen or not.
  132046. */
  132047. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132048. /**
  132049. * Checks to see if a texture is used in the material.
  132050. * @param texture - Base texture to use.
  132051. * @returns - Boolean specifying if a texture is used in the material.
  132052. */
  132053. hasTexture(texture: BaseTexture): boolean;
  132054. /**
  132055. * Returns an array of the actively used textures.
  132056. * @param activeTextures Array of BaseTextures
  132057. */
  132058. getActiveTextures(activeTextures: BaseTexture[]): void;
  132059. /**
  132060. * Returns the animatable textures.
  132061. * @param animatables Array of animatable textures.
  132062. */
  132063. getAnimatables(animatables: IAnimatable[]): void;
  132064. /**
  132065. * Disposes the resources of the material.
  132066. * @param forceDisposeTextures - Forces the disposal of all textures.
  132067. */
  132068. dispose(forceDisposeTextures?: boolean): void;
  132069. /**
  132070. * Get the current class name of the texture useful for serialization or dynamic coding.
  132071. * @returns "PBRSheenConfiguration"
  132072. */
  132073. getClassName(): string;
  132074. /**
  132075. * Add fallbacks to the effect fallbacks list.
  132076. * @param defines defines the Base texture to use.
  132077. * @param fallbacks defines the current fallback list.
  132078. * @param currentRank defines the current fallback rank.
  132079. * @returns the new fallback rank.
  132080. */
  132081. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132082. /**
  132083. * Add the required uniforms to the current list.
  132084. * @param uniforms defines the current uniform list.
  132085. */
  132086. static AddUniforms(uniforms: string[]): void;
  132087. /**
  132088. * Add the required uniforms to the current buffer.
  132089. * @param uniformBuffer defines the current uniform buffer.
  132090. */
  132091. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132092. /**
  132093. * Add the required samplers to the current list.
  132094. * @param samplers defines the current sampler list.
  132095. */
  132096. static AddSamplers(samplers: string[]): void;
  132097. /**
  132098. * Makes a duplicate of the current configuration into another one.
  132099. * @param sheenConfiguration define the config where to copy the info
  132100. */
  132101. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  132102. /**
  132103. * Serializes this BRDF configuration.
  132104. * @returns - An object with the serialized config.
  132105. */
  132106. serialize(): any;
  132107. /**
  132108. * Parses a anisotropy Configuration from a serialized object.
  132109. * @param source - Serialized object.
  132110. * @param scene Defines the scene we are parsing for
  132111. * @param rootUrl Defines the rootUrl to load from
  132112. */
  132113. parse(source: any, scene: Scene, rootUrl: string): void;
  132114. }
  132115. }
  132116. declare module BABYLON {
  132117. /**
  132118. * @hidden
  132119. */
  132120. export interface IMaterialSubSurfaceDefines {
  132121. SUBSURFACE: boolean;
  132122. SS_REFRACTION: boolean;
  132123. SS_TRANSLUCENCY: boolean;
  132124. SS_SCATTERING: boolean;
  132125. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132126. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132127. SS_REFRACTIONMAP_3D: boolean;
  132128. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132129. SS_LODINREFRACTIONALPHA: boolean;
  132130. SS_GAMMAREFRACTION: boolean;
  132131. SS_RGBDREFRACTION: boolean;
  132132. SS_LINEARSPECULARREFRACTION: boolean;
  132133. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132134. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132135. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132136. /** @hidden */
  132137. _areTexturesDirty: boolean;
  132138. }
  132139. /**
  132140. * Define the code related to the sub surface parameters of the pbr material.
  132141. */
  132142. export class PBRSubSurfaceConfiguration {
  132143. private _isRefractionEnabled;
  132144. /**
  132145. * Defines if the refraction is enabled in the material.
  132146. */
  132147. isRefractionEnabled: boolean;
  132148. private _isTranslucencyEnabled;
  132149. /**
  132150. * Defines if the translucency is enabled in the material.
  132151. */
  132152. isTranslucencyEnabled: boolean;
  132153. private _isScatteringEnabled;
  132154. /**
  132155. * Defines the refraction intensity of the material.
  132156. * The refraction when enabled replaces the Diffuse part of the material.
  132157. * The intensity helps transitionning between diffuse and refraction.
  132158. */
  132159. refractionIntensity: number;
  132160. /**
  132161. * Defines the translucency intensity of the material.
  132162. * When translucency has been enabled, this defines how much of the "translucency"
  132163. * is addded to the diffuse part of the material.
  132164. */
  132165. translucencyIntensity: number;
  132166. /**
  132167. * Defines the scattering intensity of the material.
  132168. * When scattering has been enabled, this defines how much of the "scattered light"
  132169. * is addded to the diffuse part of the material.
  132170. */
  132171. scatteringIntensity: number;
  132172. /**
  132173. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  132174. */
  132175. useAlbedoToTintRefraction: boolean;
  132176. private _thicknessTexture;
  132177. /**
  132178. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  132179. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  132180. * 0 would mean minimumThickness
  132181. * 1 would mean maximumThickness
  132182. * The other channels might be use as a mask to vary the different effects intensity.
  132183. */
  132184. thicknessTexture: Nullable<BaseTexture>;
  132185. private _refractionTexture;
  132186. /**
  132187. * Defines the texture to use for refraction.
  132188. */
  132189. refractionTexture: Nullable<BaseTexture>;
  132190. private _indexOfRefraction;
  132191. /**
  132192. * Index of refraction of the material base layer.
  132193. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132194. *
  132195. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132196. *
  132197. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132198. */
  132199. indexOfRefraction: number;
  132200. private _volumeIndexOfRefraction;
  132201. /**
  132202. * Index of refraction of the material's volume.
  132203. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132204. *
  132205. * This ONLY impacts refraction. If not provided or given a non-valid value,
  132206. * the volume will use the same IOR as the surface.
  132207. */
  132208. get volumeIndexOfRefraction(): number;
  132209. set volumeIndexOfRefraction(value: number);
  132210. private _invertRefractionY;
  132211. /**
  132212. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132213. */
  132214. invertRefractionY: boolean;
  132215. private _linkRefractionWithTransparency;
  132216. /**
  132217. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132218. * Materials half opaque for instance using refraction could benefit from this control.
  132219. */
  132220. linkRefractionWithTransparency: boolean;
  132221. /**
  132222. * Defines the minimum thickness stored in the thickness map.
  132223. * If no thickness map is defined, this value will be used to simulate thickness.
  132224. */
  132225. minimumThickness: number;
  132226. /**
  132227. * Defines the maximum thickness stored in the thickness map.
  132228. */
  132229. maximumThickness: number;
  132230. /**
  132231. * Defines the volume tint of the material.
  132232. * This is used for both translucency and scattering.
  132233. */
  132234. tintColor: Color3;
  132235. /**
  132236. * Defines the distance at which the tint color should be found in the media.
  132237. * This is used for refraction only.
  132238. */
  132239. tintColorAtDistance: number;
  132240. /**
  132241. * Defines how far each channel transmit through the media.
  132242. * It is defined as a color to simplify it selection.
  132243. */
  132244. diffusionDistance: Color3;
  132245. private _useMaskFromThicknessTexture;
  132246. /**
  132247. * Stores the intensity of the different subsurface effects in the thickness texture.
  132248. * * the green channel is the translucency intensity.
  132249. * * the blue channel is the scattering intensity.
  132250. * * the alpha channel is the refraction intensity.
  132251. */
  132252. useMaskFromThicknessTexture: boolean;
  132253. /** @hidden */
  132254. private _internalMarkAllSubMeshesAsTexturesDirty;
  132255. /** @hidden */
  132256. _markAllSubMeshesAsTexturesDirty(): void;
  132257. /**
  132258. * Instantiate a new istance of sub surface configuration.
  132259. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132260. */
  132261. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132262. /**
  132263. * Gets wehter the submesh is ready to be used or not.
  132264. * @param defines the list of "defines" to update.
  132265. * @param scene defines the scene the material belongs to.
  132266. * @returns - boolean indicating that the submesh is ready or not.
  132267. */
  132268. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  132269. /**
  132270. * Checks to see if a texture is used in the material.
  132271. * @param defines the list of "defines" to update.
  132272. * @param scene defines the scene to the material belongs to.
  132273. */
  132274. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  132275. /**
  132276. * Binds the material data.
  132277. * @param uniformBuffer defines the Uniform buffer to fill in.
  132278. * @param scene defines the scene the material belongs to.
  132279. * @param engine defines the engine the material belongs to.
  132280. * @param isFrozen defines whether the material is frozen or not.
  132281. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  132282. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  132283. */
  132284. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  132285. /**
  132286. * Unbinds the material from the mesh.
  132287. * @param activeEffect defines the effect that should be unbound from.
  132288. * @returns true if unbound, otherwise false
  132289. */
  132290. unbind(activeEffect: Effect): boolean;
  132291. /**
  132292. * Returns the texture used for refraction or null if none is used.
  132293. * @param scene defines the scene the material belongs to.
  132294. * @returns - Refraction texture if present. If no refraction texture and refraction
  132295. * is linked with transparency, returns environment texture. Otherwise, returns null.
  132296. */
  132297. private _getRefractionTexture;
  132298. /**
  132299. * Returns true if alpha blending should be disabled.
  132300. */
  132301. get disableAlphaBlending(): boolean;
  132302. /**
  132303. * Fills the list of render target textures.
  132304. * @param renderTargets the list of render targets to update
  132305. */
  132306. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  132307. /**
  132308. * Checks to see if a texture is used in the material.
  132309. * @param texture - Base texture to use.
  132310. * @returns - Boolean specifying if a texture is used in the material.
  132311. */
  132312. hasTexture(texture: BaseTexture): boolean;
  132313. /**
  132314. * Gets a boolean indicating that current material needs to register RTT
  132315. * @returns true if this uses a render target otherwise false.
  132316. */
  132317. hasRenderTargetTextures(): boolean;
  132318. /**
  132319. * Returns an array of the actively used textures.
  132320. * @param activeTextures Array of BaseTextures
  132321. */
  132322. getActiveTextures(activeTextures: BaseTexture[]): void;
  132323. /**
  132324. * Returns the animatable textures.
  132325. * @param animatables Array of animatable textures.
  132326. */
  132327. getAnimatables(animatables: IAnimatable[]): void;
  132328. /**
  132329. * Disposes the resources of the material.
  132330. * @param forceDisposeTextures - Forces the disposal of all textures.
  132331. */
  132332. dispose(forceDisposeTextures?: boolean): void;
  132333. /**
  132334. * Get the current class name of the texture useful for serialization or dynamic coding.
  132335. * @returns "PBRSubSurfaceConfiguration"
  132336. */
  132337. getClassName(): string;
  132338. /**
  132339. * Add fallbacks to the effect fallbacks list.
  132340. * @param defines defines the Base texture to use.
  132341. * @param fallbacks defines the current fallback list.
  132342. * @param currentRank defines the current fallback rank.
  132343. * @returns the new fallback rank.
  132344. */
  132345. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132346. /**
  132347. * Add the required uniforms to the current list.
  132348. * @param uniforms defines the current uniform list.
  132349. */
  132350. static AddUniforms(uniforms: string[]): void;
  132351. /**
  132352. * Add the required samplers to the current list.
  132353. * @param samplers defines the current sampler list.
  132354. */
  132355. static AddSamplers(samplers: string[]): void;
  132356. /**
  132357. * Add the required uniforms to the current buffer.
  132358. * @param uniformBuffer defines the current uniform buffer.
  132359. */
  132360. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132361. /**
  132362. * Makes a duplicate of the current configuration into another one.
  132363. * @param configuration define the config where to copy the info
  132364. */
  132365. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  132366. /**
  132367. * Serializes this Sub Surface configuration.
  132368. * @returns - An object with the serialized config.
  132369. */
  132370. serialize(): any;
  132371. /**
  132372. * Parses a anisotropy Configuration from a serialized object.
  132373. * @param source - Serialized object.
  132374. * @param scene Defines the scene we are parsing for
  132375. * @param rootUrl Defines the rootUrl to load from
  132376. */
  132377. parse(source: any, scene: Scene, rootUrl: string): void;
  132378. }
  132379. }
  132380. declare module BABYLON {
  132381. /** @hidden */
  132382. export var pbrFragmentDeclaration: {
  132383. name: string;
  132384. shader: string;
  132385. };
  132386. }
  132387. declare module BABYLON {
  132388. /** @hidden */
  132389. export var pbrUboDeclaration: {
  132390. name: string;
  132391. shader: string;
  132392. };
  132393. }
  132394. declare module BABYLON {
  132395. /** @hidden */
  132396. export var pbrFragmentExtraDeclaration: {
  132397. name: string;
  132398. shader: string;
  132399. };
  132400. }
  132401. declare module BABYLON {
  132402. /** @hidden */
  132403. export var pbrFragmentSamplersDeclaration: {
  132404. name: string;
  132405. shader: string;
  132406. };
  132407. }
  132408. declare module BABYLON {
  132409. /** @hidden */
  132410. export var importanceSampling: {
  132411. name: string;
  132412. shader: string;
  132413. };
  132414. }
  132415. declare module BABYLON {
  132416. /** @hidden */
  132417. export var pbrHelperFunctions: {
  132418. name: string;
  132419. shader: string;
  132420. };
  132421. }
  132422. declare module BABYLON {
  132423. /** @hidden */
  132424. export var harmonicsFunctions: {
  132425. name: string;
  132426. shader: string;
  132427. };
  132428. }
  132429. declare module BABYLON {
  132430. /** @hidden */
  132431. export var pbrDirectLightingSetupFunctions: {
  132432. name: string;
  132433. shader: string;
  132434. };
  132435. }
  132436. declare module BABYLON {
  132437. /** @hidden */
  132438. export var pbrDirectLightingFalloffFunctions: {
  132439. name: string;
  132440. shader: string;
  132441. };
  132442. }
  132443. declare module BABYLON {
  132444. /** @hidden */
  132445. export var pbrBRDFFunctions: {
  132446. name: string;
  132447. shader: string;
  132448. };
  132449. }
  132450. declare module BABYLON {
  132451. /** @hidden */
  132452. export var hdrFilteringFunctions: {
  132453. name: string;
  132454. shader: string;
  132455. };
  132456. }
  132457. declare module BABYLON {
  132458. /** @hidden */
  132459. export var pbrDirectLightingFunctions: {
  132460. name: string;
  132461. shader: string;
  132462. };
  132463. }
  132464. declare module BABYLON {
  132465. /** @hidden */
  132466. export var pbrIBLFunctions: {
  132467. name: string;
  132468. shader: string;
  132469. };
  132470. }
  132471. declare module BABYLON {
  132472. /** @hidden */
  132473. export var pbrBlockAlbedoOpacity: {
  132474. name: string;
  132475. shader: string;
  132476. };
  132477. }
  132478. declare module BABYLON {
  132479. /** @hidden */
  132480. export var pbrBlockReflectivity: {
  132481. name: string;
  132482. shader: string;
  132483. };
  132484. }
  132485. declare module BABYLON {
  132486. /** @hidden */
  132487. export var pbrBlockAmbientOcclusion: {
  132488. name: string;
  132489. shader: string;
  132490. };
  132491. }
  132492. declare module BABYLON {
  132493. /** @hidden */
  132494. export var pbrBlockAlphaFresnel: {
  132495. name: string;
  132496. shader: string;
  132497. };
  132498. }
  132499. declare module BABYLON {
  132500. /** @hidden */
  132501. export var pbrBlockAnisotropic: {
  132502. name: string;
  132503. shader: string;
  132504. };
  132505. }
  132506. declare module BABYLON {
  132507. /** @hidden */
  132508. export var pbrBlockReflection: {
  132509. name: string;
  132510. shader: string;
  132511. };
  132512. }
  132513. declare module BABYLON {
  132514. /** @hidden */
  132515. export var pbrBlockSheen: {
  132516. name: string;
  132517. shader: string;
  132518. };
  132519. }
  132520. declare module BABYLON {
  132521. /** @hidden */
  132522. export var pbrBlockClearcoat: {
  132523. name: string;
  132524. shader: string;
  132525. };
  132526. }
  132527. declare module BABYLON {
  132528. /** @hidden */
  132529. export var pbrBlockSubSurface: {
  132530. name: string;
  132531. shader: string;
  132532. };
  132533. }
  132534. declare module BABYLON {
  132535. /** @hidden */
  132536. export var pbrBlockNormalGeometric: {
  132537. name: string;
  132538. shader: string;
  132539. };
  132540. }
  132541. declare module BABYLON {
  132542. /** @hidden */
  132543. export var pbrBlockNormalFinal: {
  132544. name: string;
  132545. shader: string;
  132546. };
  132547. }
  132548. declare module BABYLON {
  132549. /** @hidden */
  132550. export var pbrBlockGeometryInfo: {
  132551. name: string;
  132552. shader: string;
  132553. };
  132554. }
  132555. declare module BABYLON {
  132556. /** @hidden */
  132557. export var pbrBlockReflectance0: {
  132558. name: string;
  132559. shader: string;
  132560. };
  132561. }
  132562. declare module BABYLON {
  132563. /** @hidden */
  132564. export var pbrBlockReflectance: {
  132565. name: string;
  132566. shader: string;
  132567. };
  132568. }
  132569. declare module BABYLON {
  132570. /** @hidden */
  132571. export var pbrBlockDirectLighting: {
  132572. name: string;
  132573. shader: string;
  132574. };
  132575. }
  132576. declare module BABYLON {
  132577. /** @hidden */
  132578. export var pbrBlockFinalLitComponents: {
  132579. name: string;
  132580. shader: string;
  132581. };
  132582. }
  132583. declare module BABYLON {
  132584. /** @hidden */
  132585. export var pbrBlockFinalUnlitComponents: {
  132586. name: string;
  132587. shader: string;
  132588. };
  132589. }
  132590. declare module BABYLON {
  132591. /** @hidden */
  132592. export var pbrBlockFinalColorComposition: {
  132593. name: string;
  132594. shader: string;
  132595. };
  132596. }
  132597. declare module BABYLON {
  132598. /** @hidden */
  132599. export var pbrBlockImageProcessing: {
  132600. name: string;
  132601. shader: string;
  132602. };
  132603. }
  132604. declare module BABYLON {
  132605. /** @hidden */
  132606. export var pbrDebug: {
  132607. name: string;
  132608. shader: string;
  132609. };
  132610. }
  132611. declare module BABYLON {
  132612. /** @hidden */
  132613. export var pbrPixelShader: {
  132614. name: string;
  132615. shader: string;
  132616. };
  132617. }
  132618. declare module BABYLON {
  132619. /** @hidden */
  132620. export var pbrVertexDeclaration: {
  132621. name: string;
  132622. shader: string;
  132623. };
  132624. }
  132625. declare module BABYLON {
  132626. /** @hidden */
  132627. export var pbrVertexShader: {
  132628. name: string;
  132629. shader: string;
  132630. };
  132631. }
  132632. declare module BABYLON {
  132633. /**
  132634. * Manages the defines for the PBR Material.
  132635. * @hidden
  132636. */
  132637. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  132638. PBR: boolean;
  132639. NUM_SAMPLES: string;
  132640. REALTIME_FILTERING: boolean;
  132641. MAINUV1: boolean;
  132642. MAINUV2: boolean;
  132643. UV1: boolean;
  132644. UV2: boolean;
  132645. ALBEDO: boolean;
  132646. GAMMAALBEDO: boolean;
  132647. ALBEDODIRECTUV: number;
  132648. VERTEXCOLOR: boolean;
  132649. DETAIL: boolean;
  132650. DETAILDIRECTUV: number;
  132651. DETAIL_NORMALBLENDMETHOD: number;
  132652. AMBIENT: boolean;
  132653. AMBIENTDIRECTUV: number;
  132654. AMBIENTINGRAYSCALE: boolean;
  132655. OPACITY: boolean;
  132656. VERTEXALPHA: boolean;
  132657. OPACITYDIRECTUV: number;
  132658. OPACITYRGB: boolean;
  132659. ALPHATEST: boolean;
  132660. DEPTHPREPASS: boolean;
  132661. ALPHABLEND: boolean;
  132662. ALPHAFROMALBEDO: boolean;
  132663. ALPHATESTVALUE: string;
  132664. SPECULAROVERALPHA: boolean;
  132665. RADIANCEOVERALPHA: boolean;
  132666. ALPHAFRESNEL: boolean;
  132667. LINEARALPHAFRESNEL: boolean;
  132668. PREMULTIPLYALPHA: boolean;
  132669. EMISSIVE: boolean;
  132670. EMISSIVEDIRECTUV: number;
  132671. REFLECTIVITY: boolean;
  132672. REFLECTIVITYDIRECTUV: number;
  132673. SPECULARTERM: boolean;
  132674. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  132675. MICROSURFACEAUTOMATIC: boolean;
  132676. LODBASEDMICROSFURACE: boolean;
  132677. MICROSURFACEMAP: boolean;
  132678. MICROSURFACEMAPDIRECTUV: number;
  132679. METALLICWORKFLOW: boolean;
  132680. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  132681. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  132682. METALLNESSSTOREINMETALMAPBLUE: boolean;
  132683. AOSTOREINMETALMAPRED: boolean;
  132684. METALLIC_REFLECTANCE: boolean;
  132685. METALLIC_REFLECTANCEDIRECTUV: number;
  132686. ENVIRONMENTBRDF: boolean;
  132687. ENVIRONMENTBRDF_RGBD: boolean;
  132688. NORMAL: boolean;
  132689. TANGENT: boolean;
  132690. BUMP: boolean;
  132691. BUMPDIRECTUV: number;
  132692. OBJECTSPACE_NORMALMAP: boolean;
  132693. PARALLAX: boolean;
  132694. PARALLAXOCCLUSION: boolean;
  132695. NORMALXYSCALE: boolean;
  132696. LIGHTMAP: boolean;
  132697. LIGHTMAPDIRECTUV: number;
  132698. USELIGHTMAPASSHADOWMAP: boolean;
  132699. GAMMALIGHTMAP: boolean;
  132700. RGBDLIGHTMAP: boolean;
  132701. REFLECTION: boolean;
  132702. REFLECTIONMAP_3D: boolean;
  132703. REFLECTIONMAP_SPHERICAL: boolean;
  132704. REFLECTIONMAP_PLANAR: boolean;
  132705. REFLECTIONMAP_CUBIC: boolean;
  132706. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  132707. REFLECTIONMAP_PROJECTION: boolean;
  132708. REFLECTIONMAP_SKYBOX: boolean;
  132709. REFLECTIONMAP_EXPLICIT: boolean;
  132710. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  132711. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  132712. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  132713. INVERTCUBICMAP: boolean;
  132714. USESPHERICALFROMREFLECTIONMAP: boolean;
  132715. USEIRRADIANCEMAP: boolean;
  132716. SPHERICAL_HARMONICS: boolean;
  132717. USESPHERICALINVERTEX: boolean;
  132718. REFLECTIONMAP_OPPOSITEZ: boolean;
  132719. LODINREFLECTIONALPHA: boolean;
  132720. GAMMAREFLECTION: boolean;
  132721. RGBDREFLECTION: boolean;
  132722. LINEARSPECULARREFLECTION: boolean;
  132723. RADIANCEOCCLUSION: boolean;
  132724. HORIZONOCCLUSION: boolean;
  132725. INSTANCES: boolean;
  132726. THIN_INSTANCES: boolean;
  132727. NUM_BONE_INFLUENCERS: number;
  132728. BonesPerMesh: number;
  132729. BONETEXTURE: boolean;
  132730. NONUNIFORMSCALING: boolean;
  132731. MORPHTARGETS: boolean;
  132732. MORPHTARGETS_NORMAL: boolean;
  132733. MORPHTARGETS_TANGENT: boolean;
  132734. MORPHTARGETS_UV: boolean;
  132735. NUM_MORPH_INFLUENCERS: number;
  132736. IMAGEPROCESSING: boolean;
  132737. VIGNETTE: boolean;
  132738. VIGNETTEBLENDMODEMULTIPLY: boolean;
  132739. VIGNETTEBLENDMODEOPAQUE: boolean;
  132740. TONEMAPPING: boolean;
  132741. TONEMAPPING_ACES: boolean;
  132742. CONTRAST: boolean;
  132743. COLORCURVES: boolean;
  132744. COLORGRADING: boolean;
  132745. COLORGRADING3D: boolean;
  132746. SAMPLER3DGREENDEPTH: boolean;
  132747. SAMPLER3DBGRMAP: boolean;
  132748. IMAGEPROCESSINGPOSTPROCESS: boolean;
  132749. EXPOSURE: boolean;
  132750. MULTIVIEW: boolean;
  132751. USEPHYSICALLIGHTFALLOFF: boolean;
  132752. USEGLTFLIGHTFALLOFF: boolean;
  132753. TWOSIDEDLIGHTING: boolean;
  132754. SHADOWFLOAT: boolean;
  132755. CLIPPLANE: boolean;
  132756. CLIPPLANE2: boolean;
  132757. CLIPPLANE3: boolean;
  132758. CLIPPLANE4: boolean;
  132759. CLIPPLANE5: boolean;
  132760. CLIPPLANE6: boolean;
  132761. POINTSIZE: boolean;
  132762. FOG: boolean;
  132763. LOGARITHMICDEPTH: boolean;
  132764. FORCENORMALFORWARD: boolean;
  132765. SPECULARAA: boolean;
  132766. CLEARCOAT: boolean;
  132767. CLEARCOAT_DEFAULTIOR: boolean;
  132768. CLEARCOAT_TEXTURE: boolean;
  132769. CLEARCOAT_TEXTUREDIRECTUV: number;
  132770. CLEARCOAT_BUMP: boolean;
  132771. CLEARCOAT_BUMPDIRECTUV: number;
  132772. CLEARCOAT_TINT: boolean;
  132773. CLEARCOAT_TINT_TEXTURE: boolean;
  132774. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132775. ANISOTROPIC: boolean;
  132776. ANISOTROPIC_TEXTURE: boolean;
  132777. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132778. BRDF_V_HEIGHT_CORRELATED: boolean;
  132779. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132780. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132781. SHEEN: boolean;
  132782. SHEEN_TEXTURE: boolean;
  132783. SHEEN_TEXTUREDIRECTUV: number;
  132784. SHEEN_LINKWITHALBEDO: boolean;
  132785. SHEEN_ROUGHNESS: boolean;
  132786. SHEEN_ALBEDOSCALING: boolean;
  132787. SUBSURFACE: boolean;
  132788. SS_REFRACTION: boolean;
  132789. SS_TRANSLUCENCY: boolean;
  132790. SS_SCATTERING: boolean;
  132791. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132792. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132793. SS_REFRACTIONMAP_3D: boolean;
  132794. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132795. SS_LODINREFRACTIONALPHA: boolean;
  132796. SS_GAMMAREFRACTION: boolean;
  132797. SS_RGBDREFRACTION: boolean;
  132798. SS_LINEARSPECULARREFRACTION: boolean;
  132799. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132800. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132801. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132802. UNLIT: boolean;
  132803. DEBUGMODE: number;
  132804. /**
  132805. * Initializes the PBR Material defines.
  132806. */
  132807. constructor();
  132808. /**
  132809. * Resets the PBR Material defines.
  132810. */
  132811. reset(): void;
  132812. }
  132813. /**
  132814. * The Physically based material base class of BJS.
  132815. *
  132816. * This offers the main features of a standard PBR material.
  132817. * For more information, please refer to the documentation :
  132818. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132819. */
  132820. export abstract class PBRBaseMaterial extends PushMaterial {
  132821. /**
  132822. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132823. */
  132824. static readonly PBRMATERIAL_OPAQUE: number;
  132825. /**
  132826. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132827. */
  132828. static readonly PBRMATERIAL_ALPHATEST: number;
  132829. /**
  132830. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132831. */
  132832. static readonly PBRMATERIAL_ALPHABLEND: number;
  132833. /**
  132834. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132835. * They are also discarded below the alpha cutoff threshold to improve performances.
  132836. */
  132837. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132838. /**
  132839. * Defines the default value of how much AO map is occluding the analytical lights
  132840. * (point spot...).
  132841. */
  132842. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132843. /**
  132844. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  132845. */
  132846. static readonly LIGHTFALLOFF_PHYSICAL: number;
  132847. /**
  132848. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  132849. * to enhance interoperability with other engines.
  132850. */
  132851. static readonly LIGHTFALLOFF_GLTF: number;
  132852. /**
  132853. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  132854. * to enhance interoperability with other materials.
  132855. */
  132856. static readonly LIGHTFALLOFF_STANDARD: number;
  132857. /**
  132858. * Intensity of the direct lights e.g. the four lights available in your scene.
  132859. * This impacts both the direct diffuse and specular highlights.
  132860. */
  132861. protected _directIntensity: number;
  132862. /**
  132863. * Intensity of the emissive part of the material.
  132864. * This helps controlling the emissive effect without modifying the emissive color.
  132865. */
  132866. protected _emissiveIntensity: number;
  132867. /**
  132868. * Intensity of the environment e.g. how much the environment will light the object
  132869. * either through harmonics for rough material or through the refelction for shiny ones.
  132870. */
  132871. protected _environmentIntensity: number;
  132872. /**
  132873. * This is a special control allowing the reduction of the specular highlights coming from the
  132874. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132875. */
  132876. protected _specularIntensity: number;
  132877. /**
  132878. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  132879. */
  132880. private _lightingInfos;
  132881. /**
  132882. * Debug Control allowing disabling the bump map on this material.
  132883. */
  132884. protected _disableBumpMap: boolean;
  132885. /**
  132886. * AKA Diffuse Texture in standard nomenclature.
  132887. */
  132888. protected _albedoTexture: Nullable<BaseTexture>;
  132889. /**
  132890. * AKA Occlusion Texture in other nomenclature.
  132891. */
  132892. protected _ambientTexture: Nullable<BaseTexture>;
  132893. /**
  132894. * AKA Occlusion Texture Intensity in other nomenclature.
  132895. */
  132896. protected _ambientTextureStrength: number;
  132897. /**
  132898. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132899. * 1 means it completely occludes it
  132900. * 0 mean it has no impact
  132901. */
  132902. protected _ambientTextureImpactOnAnalyticalLights: number;
  132903. /**
  132904. * Stores the alpha values in a texture.
  132905. */
  132906. protected _opacityTexture: Nullable<BaseTexture>;
  132907. /**
  132908. * Stores the reflection values in a texture.
  132909. */
  132910. protected _reflectionTexture: Nullable<BaseTexture>;
  132911. /**
  132912. * Stores the emissive values in a texture.
  132913. */
  132914. protected _emissiveTexture: Nullable<BaseTexture>;
  132915. /**
  132916. * AKA Specular texture in other nomenclature.
  132917. */
  132918. protected _reflectivityTexture: Nullable<BaseTexture>;
  132919. /**
  132920. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132921. */
  132922. protected _metallicTexture: Nullable<BaseTexture>;
  132923. /**
  132924. * Specifies the metallic scalar of the metallic/roughness workflow.
  132925. * Can also be used to scale the metalness values of the metallic texture.
  132926. */
  132927. protected _metallic: Nullable<number>;
  132928. /**
  132929. * Specifies the roughness scalar of the metallic/roughness workflow.
  132930. * Can also be used to scale the roughness values of the metallic texture.
  132931. */
  132932. protected _roughness: Nullable<number>;
  132933. /**
  132934. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132935. * By default the indexOfrefraction is used to compute F0;
  132936. *
  132937. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132938. *
  132939. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132940. * F90 = metallicReflectanceColor;
  132941. */
  132942. protected _metallicF0Factor: number;
  132943. /**
  132944. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132945. * By default the F90 is always 1;
  132946. *
  132947. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132948. *
  132949. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132950. * F90 = metallicReflectanceColor;
  132951. */
  132952. protected _metallicReflectanceColor: Color3;
  132953. /**
  132954. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132955. * This is multiply against the scalar values defined in the material.
  132956. */
  132957. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  132958. /**
  132959. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132960. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132961. */
  132962. protected _microSurfaceTexture: Nullable<BaseTexture>;
  132963. /**
  132964. * Stores surface normal data used to displace a mesh in a texture.
  132965. */
  132966. protected _bumpTexture: Nullable<BaseTexture>;
  132967. /**
  132968. * Stores the pre-calculated light information of a mesh in a texture.
  132969. */
  132970. protected _lightmapTexture: Nullable<BaseTexture>;
  132971. /**
  132972. * The color of a material in ambient lighting.
  132973. */
  132974. protected _ambientColor: Color3;
  132975. /**
  132976. * AKA Diffuse Color in other nomenclature.
  132977. */
  132978. protected _albedoColor: Color3;
  132979. /**
  132980. * AKA Specular Color in other nomenclature.
  132981. */
  132982. protected _reflectivityColor: Color3;
  132983. /**
  132984. * The color applied when light is reflected from a material.
  132985. */
  132986. protected _reflectionColor: Color3;
  132987. /**
  132988. * The color applied when light is emitted from a material.
  132989. */
  132990. protected _emissiveColor: Color3;
  132991. /**
  132992. * AKA Glossiness in other nomenclature.
  132993. */
  132994. protected _microSurface: number;
  132995. /**
  132996. * Specifies that the material will use the light map as a show map.
  132997. */
  132998. protected _useLightmapAsShadowmap: boolean;
  132999. /**
  133000. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133001. * makes the reflect vector face the model (under horizon).
  133002. */
  133003. protected _useHorizonOcclusion: boolean;
  133004. /**
  133005. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133006. * too much the area relying on ambient texture to define their ambient occlusion.
  133007. */
  133008. protected _useRadianceOcclusion: boolean;
  133009. /**
  133010. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133011. */
  133012. protected _useAlphaFromAlbedoTexture: boolean;
  133013. /**
  133014. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  133015. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133016. */
  133017. protected _useSpecularOverAlpha: boolean;
  133018. /**
  133019. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133020. */
  133021. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133022. /**
  133023. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133024. */
  133025. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  133026. /**
  133027. * Specifies if the metallic texture contains the roughness information in its green channel.
  133028. */
  133029. protected _useRoughnessFromMetallicTextureGreen: boolean;
  133030. /**
  133031. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133032. */
  133033. protected _useMetallnessFromMetallicTextureBlue: boolean;
  133034. /**
  133035. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133036. */
  133037. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  133038. /**
  133039. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133040. */
  133041. protected _useAmbientInGrayScale: boolean;
  133042. /**
  133043. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133044. * The material will try to infer what glossiness each pixel should be.
  133045. */
  133046. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  133047. /**
  133048. * Defines the falloff type used in this material.
  133049. * It by default is Physical.
  133050. */
  133051. protected _lightFalloff: number;
  133052. /**
  133053. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133054. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133055. */
  133056. protected _useRadianceOverAlpha: boolean;
  133057. /**
  133058. * Allows using an object space normal map (instead of tangent space).
  133059. */
  133060. protected _useObjectSpaceNormalMap: boolean;
  133061. /**
  133062. * Allows using the bump map in parallax mode.
  133063. */
  133064. protected _useParallax: boolean;
  133065. /**
  133066. * Allows using the bump map in parallax occlusion mode.
  133067. */
  133068. protected _useParallaxOcclusion: boolean;
  133069. /**
  133070. * Controls the scale bias of the parallax mode.
  133071. */
  133072. protected _parallaxScaleBias: number;
  133073. /**
  133074. * If sets to true, disables all the lights affecting the material.
  133075. */
  133076. protected _disableLighting: boolean;
  133077. /**
  133078. * Number of Simultaneous lights allowed on the material.
  133079. */
  133080. protected _maxSimultaneousLights: number;
  133081. /**
  133082. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133083. */
  133084. protected _invertNormalMapX: boolean;
  133085. /**
  133086. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133087. */
  133088. protected _invertNormalMapY: boolean;
  133089. /**
  133090. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133091. */
  133092. protected _twoSidedLighting: boolean;
  133093. /**
  133094. * Defines the alpha limits in alpha test mode.
  133095. */
  133096. protected _alphaCutOff: number;
  133097. /**
  133098. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133099. */
  133100. protected _forceAlphaTest: boolean;
  133101. /**
  133102. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133103. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133104. */
  133105. protected _useAlphaFresnel: boolean;
  133106. /**
  133107. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133108. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133109. */
  133110. protected _useLinearAlphaFresnel: boolean;
  133111. /**
  133112. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  133113. * from cos thetav and roughness:
  133114. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  133115. */
  133116. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  133117. /**
  133118. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133119. */
  133120. protected _forceIrradianceInFragment: boolean;
  133121. private _realTimeFiltering;
  133122. /**
  133123. * Enables realtime filtering on the texture.
  133124. */
  133125. get realTimeFiltering(): boolean;
  133126. set realTimeFiltering(b: boolean);
  133127. private _realTimeFilteringQuality;
  133128. /**
  133129. * Quality switch for realtime filtering
  133130. */
  133131. get realTimeFilteringQuality(): number;
  133132. set realTimeFilteringQuality(n: number);
  133133. /**
  133134. * Force normal to face away from face.
  133135. */
  133136. protected _forceNormalForward: boolean;
  133137. /**
  133138. * Enables specular anti aliasing in the PBR shader.
  133139. * It will both interacts on the Geometry for analytical and IBL lighting.
  133140. * It also prefilter the roughness map based on the bump values.
  133141. */
  133142. protected _enableSpecularAntiAliasing: boolean;
  133143. /**
  133144. * Default configuration related to image processing available in the PBR Material.
  133145. */
  133146. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133147. /**
  133148. * Keep track of the image processing observer to allow dispose and replace.
  133149. */
  133150. private _imageProcessingObserver;
  133151. /**
  133152. * Attaches a new image processing configuration to the PBR Material.
  133153. * @param configuration
  133154. */
  133155. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133156. /**
  133157. * Stores the available render targets.
  133158. */
  133159. private _renderTargets;
  133160. /**
  133161. * Sets the global ambient color for the material used in lighting calculations.
  133162. */
  133163. private _globalAmbientColor;
  133164. /**
  133165. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  133166. */
  133167. private _useLogarithmicDepth;
  133168. /**
  133169. * If set to true, no lighting calculations will be applied.
  133170. */
  133171. private _unlit;
  133172. private _debugMode;
  133173. /**
  133174. * @hidden
  133175. * This is reserved for the inspector.
  133176. * Defines the material debug mode.
  133177. * It helps seeing only some components of the material while troubleshooting.
  133178. */
  133179. debugMode: number;
  133180. /**
  133181. * @hidden
  133182. * This is reserved for the inspector.
  133183. * Specify from where on screen the debug mode should start.
  133184. * The value goes from -1 (full screen) to 1 (not visible)
  133185. * It helps with side by side comparison against the final render
  133186. * This defaults to -1
  133187. */
  133188. private debugLimit;
  133189. /**
  133190. * @hidden
  133191. * This is reserved for the inspector.
  133192. * As the default viewing range might not be enough (if the ambient is really small for instance)
  133193. * You can use the factor to better multiply the final value.
  133194. */
  133195. private debugFactor;
  133196. /**
  133197. * Defines the clear coat layer parameters for the material.
  133198. */
  133199. readonly clearCoat: PBRClearCoatConfiguration;
  133200. /**
  133201. * Defines the anisotropic parameters for the material.
  133202. */
  133203. readonly anisotropy: PBRAnisotropicConfiguration;
  133204. /**
  133205. * Defines the BRDF parameters for the material.
  133206. */
  133207. readonly brdf: PBRBRDFConfiguration;
  133208. /**
  133209. * Defines the Sheen parameters for the material.
  133210. */
  133211. readonly sheen: PBRSheenConfiguration;
  133212. /**
  133213. * Defines the SubSurface parameters for the material.
  133214. */
  133215. readonly subSurface: PBRSubSurfaceConfiguration;
  133216. /**
  133217. * Defines the detail map parameters for the material.
  133218. */
  133219. readonly detailMap: DetailMapConfiguration;
  133220. protected _rebuildInParallel: boolean;
  133221. /**
  133222. * Instantiates a new PBRMaterial instance.
  133223. *
  133224. * @param name The material name
  133225. * @param scene The scene the material will be use in.
  133226. */
  133227. constructor(name: string, scene: Scene);
  133228. /**
  133229. * Gets a boolean indicating that current material needs to register RTT
  133230. */
  133231. get hasRenderTargetTextures(): boolean;
  133232. /**
  133233. * Gets the name of the material class.
  133234. */
  133235. getClassName(): string;
  133236. /**
  133237. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133238. */
  133239. get useLogarithmicDepth(): boolean;
  133240. /**
  133241. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133242. */
  133243. set useLogarithmicDepth(value: boolean);
  133244. /**
  133245. * Returns true if alpha blending should be disabled.
  133246. */
  133247. protected get _disableAlphaBlending(): boolean;
  133248. /**
  133249. * Specifies whether or not this material should be rendered in alpha blend mode.
  133250. */
  133251. needAlphaBlending(): boolean;
  133252. /**
  133253. * Specifies whether or not this material should be rendered in alpha test mode.
  133254. */
  133255. needAlphaTesting(): boolean;
  133256. /**
  133257. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  133258. */
  133259. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  133260. /**
  133261. * Gets the texture used for the alpha test.
  133262. */
  133263. getAlphaTestTexture(): Nullable<BaseTexture>;
  133264. /**
  133265. * Specifies that the submesh is ready to be used.
  133266. * @param mesh - BJS mesh.
  133267. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  133268. * @param useInstances - Specifies that instances should be used.
  133269. * @returns - boolean indicating that the submesh is ready or not.
  133270. */
  133271. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133272. /**
  133273. * Specifies if the material uses metallic roughness workflow.
  133274. * @returns boolean specifiying if the material uses metallic roughness workflow.
  133275. */
  133276. isMetallicWorkflow(): boolean;
  133277. private _prepareEffect;
  133278. private _prepareDefines;
  133279. /**
  133280. * Force shader compilation
  133281. */
  133282. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  133283. /**
  133284. * Initializes the uniform buffer layout for the shader.
  133285. */
  133286. buildUniformLayout(): void;
  133287. /**
  133288. * Unbinds the material from the mesh
  133289. */
  133290. unbind(): void;
  133291. /**
  133292. * Binds the submesh data.
  133293. * @param world - The world matrix.
  133294. * @param mesh - The BJS mesh.
  133295. * @param subMesh - A submesh of the BJS mesh.
  133296. */
  133297. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133298. /**
  133299. * Returns the animatable textures.
  133300. * @returns - Array of animatable textures.
  133301. */
  133302. getAnimatables(): IAnimatable[];
  133303. /**
  133304. * Returns the texture used for reflections.
  133305. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  133306. */
  133307. private _getReflectionTexture;
  133308. /**
  133309. * Returns an array of the actively used textures.
  133310. * @returns - Array of BaseTextures
  133311. */
  133312. getActiveTextures(): BaseTexture[];
  133313. /**
  133314. * Checks to see if a texture is used in the material.
  133315. * @param texture - Base texture to use.
  133316. * @returns - Boolean specifying if a texture is used in the material.
  133317. */
  133318. hasTexture(texture: BaseTexture): boolean;
  133319. /**
  133320. * Disposes the resources of the material.
  133321. * @param forceDisposeEffect - Forces the disposal of effects.
  133322. * @param forceDisposeTextures - Forces the disposal of all textures.
  133323. */
  133324. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133325. }
  133326. }
  133327. declare module BABYLON {
  133328. /**
  133329. * The Physically based material of BJS.
  133330. *
  133331. * This offers the main features of a standard PBR material.
  133332. * For more information, please refer to the documentation :
  133333. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133334. */
  133335. export class PBRMaterial extends PBRBaseMaterial {
  133336. /**
  133337. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133338. */
  133339. static readonly PBRMATERIAL_OPAQUE: number;
  133340. /**
  133341. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133342. */
  133343. static readonly PBRMATERIAL_ALPHATEST: number;
  133344. /**
  133345. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133346. */
  133347. static readonly PBRMATERIAL_ALPHABLEND: number;
  133348. /**
  133349. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133350. * They are also discarded below the alpha cutoff threshold to improve performances.
  133351. */
  133352. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133353. /**
  133354. * Defines the default value of how much AO map is occluding the analytical lights
  133355. * (point spot...).
  133356. */
  133357. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133358. /**
  133359. * Intensity of the direct lights e.g. the four lights available in your scene.
  133360. * This impacts both the direct diffuse and specular highlights.
  133361. */
  133362. directIntensity: number;
  133363. /**
  133364. * Intensity of the emissive part of the material.
  133365. * This helps controlling the emissive effect without modifying the emissive color.
  133366. */
  133367. emissiveIntensity: number;
  133368. /**
  133369. * Intensity of the environment e.g. how much the environment will light the object
  133370. * either through harmonics for rough material or through the refelction for shiny ones.
  133371. */
  133372. environmentIntensity: number;
  133373. /**
  133374. * This is a special control allowing the reduction of the specular highlights coming from the
  133375. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133376. */
  133377. specularIntensity: number;
  133378. /**
  133379. * Debug Control allowing disabling the bump map on this material.
  133380. */
  133381. disableBumpMap: boolean;
  133382. /**
  133383. * AKA Diffuse Texture in standard nomenclature.
  133384. */
  133385. albedoTexture: BaseTexture;
  133386. /**
  133387. * AKA Occlusion Texture in other nomenclature.
  133388. */
  133389. ambientTexture: BaseTexture;
  133390. /**
  133391. * AKA Occlusion Texture Intensity in other nomenclature.
  133392. */
  133393. ambientTextureStrength: number;
  133394. /**
  133395. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133396. * 1 means it completely occludes it
  133397. * 0 mean it has no impact
  133398. */
  133399. ambientTextureImpactOnAnalyticalLights: number;
  133400. /**
  133401. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  133402. */
  133403. opacityTexture: BaseTexture;
  133404. /**
  133405. * Stores the reflection values in a texture.
  133406. */
  133407. reflectionTexture: Nullable<BaseTexture>;
  133408. /**
  133409. * Stores the emissive values in a texture.
  133410. */
  133411. emissiveTexture: BaseTexture;
  133412. /**
  133413. * AKA Specular texture in other nomenclature.
  133414. */
  133415. reflectivityTexture: BaseTexture;
  133416. /**
  133417. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133418. */
  133419. metallicTexture: BaseTexture;
  133420. /**
  133421. * Specifies the metallic scalar of the metallic/roughness workflow.
  133422. * Can also be used to scale the metalness values of the metallic texture.
  133423. */
  133424. metallic: Nullable<number>;
  133425. /**
  133426. * Specifies the roughness scalar of the metallic/roughness workflow.
  133427. * Can also be used to scale the roughness values of the metallic texture.
  133428. */
  133429. roughness: Nullable<number>;
  133430. /**
  133431. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133432. * By default the indexOfrefraction is used to compute F0;
  133433. *
  133434. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133435. *
  133436. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133437. * F90 = metallicReflectanceColor;
  133438. */
  133439. metallicF0Factor: number;
  133440. /**
  133441. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133442. * By default the F90 is always 1;
  133443. *
  133444. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133445. *
  133446. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133447. * F90 = metallicReflectanceColor;
  133448. */
  133449. metallicReflectanceColor: Color3;
  133450. /**
  133451. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133452. * This is multiply against the scalar values defined in the material.
  133453. */
  133454. metallicReflectanceTexture: Nullable<BaseTexture>;
  133455. /**
  133456. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133457. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133458. */
  133459. microSurfaceTexture: BaseTexture;
  133460. /**
  133461. * Stores surface normal data used to displace a mesh in a texture.
  133462. */
  133463. bumpTexture: BaseTexture;
  133464. /**
  133465. * Stores the pre-calculated light information of a mesh in a texture.
  133466. */
  133467. lightmapTexture: BaseTexture;
  133468. /**
  133469. * Stores the refracted light information in a texture.
  133470. */
  133471. get refractionTexture(): Nullable<BaseTexture>;
  133472. set refractionTexture(value: Nullable<BaseTexture>);
  133473. /**
  133474. * The color of a material in ambient lighting.
  133475. */
  133476. ambientColor: Color3;
  133477. /**
  133478. * AKA Diffuse Color in other nomenclature.
  133479. */
  133480. albedoColor: Color3;
  133481. /**
  133482. * AKA Specular Color in other nomenclature.
  133483. */
  133484. reflectivityColor: Color3;
  133485. /**
  133486. * The color reflected from the material.
  133487. */
  133488. reflectionColor: Color3;
  133489. /**
  133490. * The color emitted from the material.
  133491. */
  133492. emissiveColor: Color3;
  133493. /**
  133494. * AKA Glossiness in other nomenclature.
  133495. */
  133496. microSurface: number;
  133497. /**
  133498. * Index of refraction of the material base layer.
  133499. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133500. *
  133501. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  133502. *
  133503. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  133504. */
  133505. get indexOfRefraction(): number;
  133506. set indexOfRefraction(value: number);
  133507. /**
  133508. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133509. */
  133510. get invertRefractionY(): boolean;
  133511. set invertRefractionY(value: boolean);
  133512. /**
  133513. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133514. * Materials half opaque for instance using refraction could benefit from this control.
  133515. */
  133516. get linkRefractionWithTransparency(): boolean;
  133517. set linkRefractionWithTransparency(value: boolean);
  133518. /**
  133519. * If true, the light map contains occlusion information instead of lighting info.
  133520. */
  133521. useLightmapAsShadowmap: boolean;
  133522. /**
  133523. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133524. */
  133525. useAlphaFromAlbedoTexture: boolean;
  133526. /**
  133527. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133528. */
  133529. forceAlphaTest: boolean;
  133530. /**
  133531. * Defines the alpha limits in alpha test mode.
  133532. */
  133533. alphaCutOff: number;
  133534. /**
  133535. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  133536. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133537. */
  133538. useSpecularOverAlpha: boolean;
  133539. /**
  133540. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133541. */
  133542. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133543. /**
  133544. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133545. */
  133546. useRoughnessFromMetallicTextureAlpha: boolean;
  133547. /**
  133548. * Specifies if the metallic texture contains the roughness information in its green channel.
  133549. */
  133550. useRoughnessFromMetallicTextureGreen: boolean;
  133551. /**
  133552. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133553. */
  133554. useMetallnessFromMetallicTextureBlue: boolean;
  133555. /**
  133556. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133557. */
  133558. useAmbientOcclusionFromMetallicTextureRed: boolean;
  133559. /**
  133560. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133561. */
  133562. useAmbientInGrayScale: boolean;
  133563. /**
  133564. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133565. * The material will try to infer what glossiness each pixel should be.
  133566. */
  133567. useAutoMicroSurfaceFromReflectivityMap: boolean;
  133568. /**
  133569. * BJS is using an harcoded light falloff based on a manually sets up range.
  133570. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133571. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133572. */
  133573. get usePhysicalLightFalloff(): boolean;
  133574. /**
  133575. * BJS is using an harcoded light falloff based on a manually sets up range.
  133576. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133577. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133578. */
  133579. set usePhysicalLightFalloff(value: boolean);
  133580. /**
  133581. * In order to support the falloff compatibility with gltf, a special mode has been added
  133582. * to reproduce the gltf light falloff.
  133583. */
  133584. get useGLTFLightFalloff(): boolean;
  133585. /**
  133586. * In order to support the falloff compatibility with gltf, a special mode has been added
  133587. * to reproduce the gltf light falloff.
  133588. */
  133589. set useGLTFLightFalloff(value: boolean);
  133590. /**
  133591. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133592. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133593. */
  133594. useRadianceOverAlpha: boolean;
  133595. /**
  133596. * Allows using an object space normal map (instead of tangent space).
  133597. */
  133598. useObjectSpaceNormalMap: boolean;
  133599. /**
  133600. * Allows using the bump map in parallax mode.
  133601. */
  133602. useParallax: boolean;
  133603. /**
  133604. * Allows using the bump map in parallax occlusion mode.
  133605. */
  133606. useParallaxOcclusion: boolean;
  133607. /**
  133608. * Controls the scale bias of the parallax mode.
  133609. */
  133610. parallaxScaleBias: number;
  133611. /**
  133612. * If sets to true, disables all the lights affecting the material.
  133613. */
  133614. disableLighting: boolean;
  133615. /**
  133616. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133617. */
  133618. forceIrradianceInFragment: boolean;
  133619. /**
  133620. * Number of Simultaneous lights allowed on the material.
  133621. */
  133622. maxSimultaneousLights: number;
  133623. /**
  133624. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  133625. */
  133626. invertNormalMapX: boolean;
  133627. /**
  133628. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  133629. */
  133630. invertNormalMapY: boolean;
  133631. /**
  133632. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133633. */
  133634. twoSidedLighting: boolean;
  133635. /**
  133636. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133637. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133638. */
  133639. useAlphaFresnel: boolean;
  133640. /**
  133641. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133642. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133643. */
  133644. useLinearAlphaFresnel: boolean;
  133645. /**
  133646. * Let user defines the brdf lookup texture used for IBL.
  133647. * A default 8bit version is embedded but you could point at :
  133648. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  133649. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  133650. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  133651. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  133652. */
  133653. environmentBRDFTexture: Nullable<BaseTexture>;
  133654. /**
  133655. * Force normal to face away from face.
  133656. */
  133657. forceNormalForward: boolean;
  133658. /**
  133659. * Enables specular anti aliasing in the PBR shader.
  133660. * It will both interacts on the Geometry for analytical and IBL lighting.
  133661. * It also prefilter the roughness map based on the bump values.
  133662. */
  133663. enableSpecularAntiAliasing: boolean;
  133664. /**
  133665. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133666. * makes the reflect vector face the model (under horizon).
  133667. */
  133668. useHorizonOcclusion: boolean;
  133669. /**
  133670. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133671. * too much the area relying on ambient texture to define their ambient occlusion.
  133672. */
  133673. useRadianceOcclusion: boolean;
  133674. /**
  133675. * If set to true, no lighting calculations will be applied.
  133676. */
  133677. unlit: boolean;
  133678. /**
  133679. * Gets the image processing configuration used either in this material.
  133680. */
  133681. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  133682. /**
  133683. * Sets the Default image processing configuration used either in the this material.
  133684. *
  133685. * If sets to null, the scene one is in use.
  133686. */
  133687. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  133688. /**
  133689. * Gets wether the color curves effect is enabled.
  133690. */
  133691. get cameraColorCurvesEnabled(): boolean;
  133692. /**
  133693. * Sets wether the color curves effect is enabled.
  133694. */
  133695. set cameraColorCurvesEnabled(value: boolean);
  133696. /**
  133697. * Gets wether the color grading effect is enabled.
  133698. */
  133699. get cameraColorGradingEnabled(): boolean;
  133700. /**
  133701. * Gets wether the color grading effect is enabled.
  133702. */
  133703. set cameraColorGradingEnabled(value: boolean);
  133704. /**
  133705. * Gets wether tonemapping is enabled or not.
  133706. */
  133707. get cameraToneMappingEnabled(): boolean;
  133708. /**
  133709. * Sets wether tonemapping is enabled or not
  133710. */
  133711. set cameraToneMappingEnabled(value: boolean);
  133712. /**
  133713. * The camera exposure used on this material.
  133714. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133715. * This corresponds to a photographic exposure.
  133716. */
  133717. get cameraExposure(): number;
  133718. /**
  133719. * The camera exposure used on this material.
  133720. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133721. * This corresponds to a photographic exposure.
  133722. */
  133723. set cameraExposure(value: number);
  133724. /**
  133725. * Gets The camera contrast used on this material.
  133726. */
  133727. get cameraContrast(): number;
  133728. /**
  133729. * Sets The camera contrast used on this material.
  133730. */
  133731. set cameraContrast(value: number);
  133732. /**
  133733. * Gets the Color Grading 2D Lookup Texture.
  133734. */
  133735. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133736. /**
  133737. * Sets the Color Grading 2D Lookup Texture.
  133738. */
  133739. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133740. /**
  133741. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133742. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133743. * 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;
  133744. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133745. */
  133746. get cameraColorCurves(): Nullable<ColorCurves>;
  133747. /**
  133748. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133749. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133750. * 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;
  133751. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133752. */
  133753. set cameraColorCurves(value: Nullable<ColorCurves>);
  133754. /**
  133755. * Instantiates a new PBRMaterial instance.
  133756. *
  133757. * @param name The material name
  133758. * @param scene The scene the material will be use in.
  133759. */
  133760. constructor(name: string, scene: Scene);
  133761. /**
  133762. * Returns the name of this material class.
  133763. */
  133764. getClassName(): string;
  133765. /**
  133766. * Makes a duplicate of the current material.
  133767. * @param name - name to use for the new material.
  133768. */
  133769. clone(name: string): PBRMaterial;
  133770. /**
  133771. * Serializes this PBR Material.
  133772. * @returns - An object with the serialized material.
  133773. */
  133774. serialize(): any;
  133775. /**
  133776. * Parses a PBR Material from a serialized object.
  133777. * @param source - Serialized object.
  133778. * @param scene - BJS scene instance.
  133779. * @param rootUrl - url for the scene object
  133780. * @returns - PBRMaterial
  133781. */
  133782. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  133783. }
  133784. }
  133785. declare module BABYLON {
  133786. /**
  133787. * Direct draw surface info
  133788. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  133789. */
  133790. export interface DDSInfo {
  133791. /**
  133792. * Width of the texture
  133793. */
  133794. width: number;
  133795. /**
  133796. * Width of the texture
  133797. */
  133798. height: number;
  133799. /**
  133800. * Number of Mipmaps for the texture
  133801. * @see https://en.wikipedia.org/wiki/Mipmap
  133802. */
  133803. mipmapCount: number;
  133804. /**
  133805. * If the textures format is a known fourCC format
  133806. * @see https://www.fourcc.org/
  133807. */
  133808. isFourCC: boolean;
  133809. /**
  133810. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  133811. */
  133812. isRGB: boolean;
  133813. /**
  133814. * If the texture is a lumincance format
  133815. */
  133816. isLuminance: boolean;
  133817. /**
  133818. * If this is a cube texture
  133819. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  133820. */
  133821. isCube: boolean;
  133822. /**
  133823. * If the texture is a compressed format eg. FOURCC_DXT1
  133824. */
  133825. isCompressed: boolean;
  133826. /**
  133827. * The dxgiFormat of the texture
  133828. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  133829. */
  133830. dxgiFormat: number;
  133831. /**
  133832. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  133833. */
  133834. textureType: number;
  133835. /**
  133836. * Sphericle polynomial created for the dds texture
  133837. */
  133838. sphericalPolynomial?: SphericalPolynomial;
  133839. }
  133840. /**
  133841. * Class used to provide DDS decompression tools
  133842. */
  133843. export class DDSTools {
  133844. /**
  133845. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  133846. */
  133847. static StoreLODInAlphaChannel: boolean;
  133848. /**
  133849. * Gets DDS information from an array buffer
  133850. * @param data defines the array buffer view to read data from
  133851. * @returns the DDS information
  133852. */
  133853. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  133854. private static _FloatView;
  133855. private static _Int32View;
  133856. private static _ToHalfFloat;
  133857. private static _FromHalfFloat;
  133858. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  133859. private static _GetHalfFloatRGBAArrayBuffer;
  133860. private static _GetFloatRGBAArrayBuffer;
  133861. private static _GetFloatAsUIntRGBAArrayBuffer;
  133862. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  133863. private static _GetRGBAArrayBuffer;
  133864. private static _ExtractLongWordOrder;
  133865. private static _GetRGBArrayBuffer;
  133866. private static _GetLuminanceArrayBuffer;
  133867. /**
  133868. * Uploads DDS Levels to a Babylon Texture
  133869. * @hidden
  133870. */
  133871. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  133872. }
  133873. interface ThinEngine {
  133874. /**
  133875. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  133876. * @param rootUrl defines the url where the file to load is located
  133877. * @param scene defines the current scene
  133878. * @param lodScale defines scale to apply to the mip map selection
  133879. * @param lodOffset defines offset to apply to the mip map selection
  133880. * @param onLoad defines an optional callback raised when the texture is loaded
  133881. * @param onError defines an optional callback raised if there is an issue to load the texture
  133882. * @param format defines the format of the data
  133883. * @param forcedExtension defines the extension to use to pick the right loader
  133884. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  133885. * @returns the cube texture as an InternalTexture
  133886. */
  133887. 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;
  133888. }
  133889. }
  133890. declare module BABYLON {
  133891. /**
  133892. * Implementation of the DDS Texture Loader.
  133893. * @hidden
  133894. */
  133895. export class _DDSTextureLoader implements IInternalTextureLoader {
  133896. /**
  133897. * Defines wether the loader supports cascade loading the different faces.
  133898. */
  133899. readonly supportCascades: boolean;
  133900. /**
  133901. * This returns if the loader support the current file information.
  133902. * @param extension defines the file extension of the file being loaded
  133903. * @returns true if the loader can load the specified file
  133904. */
  133905. canLoad(extension: string): boolean;
  133906. /**
  133907. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133908. * @param data contains the texture data
  133909. * @param texture defines the BabylonJS internal texture
  133910. * @param createPolynomials will be true if polynomials have been requested
  133911. * @param onLoad defines the callback to trigger once the texture is ready
  133912. * @param onError defines the callback to trigger in case of error
  133913. */
  133914. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133915. /**
  133916. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133917. * @param data contains the texture data
  133918. * @param texture defines the BabylonJS internal texture
  133919. * @param callback defines the method to call once ready to upload
  133920. */
  133921. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133922. }
  133923. }
  133924. declare module BABYLON {
  133925. /**
  133926. * Implementation of the ENV Texture Loader.
  133927. * @hidden
  133928. */
  133929. export class _ENVTextureLoader implements IInternalTextureLoader {
  133930. /**
  133931. * Defines wether the loader supports cascade loading the different faces.
  133932. */
  133933. readonly supportCascades: boolean;
  133934. /**
  133935. * This returns if the loader support the current file information.
  133936. * @param extension defines the file extension of the file being loaded
  133937. * @returns true if the loader can load the specified file
  133938. */
  133939. canLoad(extension: string): boolean;
  133940. /**
  133941. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133942. * @param data contains the texture data
  133943. * @param texture defines the BabylonJS internal texture
  133944. * @param createPolynomials will be true if polynomials have been requested
  133945. * @param onLoad defines the callback to trigger once the texture is ready
  133946. * @param onError defines the callback to trigger in case of error
  133947. */
  133948. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133949. /**
  133950. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133951. * @param data contains the texture data
  133952. * @param texture defines the BabylonJS internal texture
  133953. * @param callback defines the method to call once ready to upload
  133954. */
  133955. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133956. }
  133957. }
  133958. declare module BABYLON {
  133959. /**
  133960. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  133961. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  133962. */
  133963. export class KhronosTextureContainer {
  133964. /** contents of the KTX container file */
  133965. data: ArrayBufferView;
  133966. private static HEADER_LEN;
  133967. private static COMPRESSED_2D;
  133968. private static COMPRESSED_3D;
  133969. private static TEX_2D;
  133970. private static TEX_3D;
  133971. /**
  133972. * Gets the openGL type
  133973. */
  133974. glType: number;
  133975. /**
  133976. * Gets the openGL type size
  133977. */
  133978. glTypeSize: number;
  133979. /**
  133980. * Gets the openGL format
  133981. */
  133982. glFormat: number;
  133983. /**
  133984. * Gets the openGL internal format
  133985. */
  133986. glInternalFormat: number;
  133987. /**
  133988. * Gets the base internal format
  133989. */
  133990. glBaseInternalFormat: number;
  133991. /**
  133992. * Gets image width in pixel
  133993. */
  133994. pixelWidth: number;
  133995. /**
  133996. * Gets image height in pixel
  133997. */
  133998. pixelHeight: number;
  133999. /**
  134000. * Gets image depth in pixels
  134001. */
  134002. pixelDepth: number;
  134003. /**
  134004. * Gets the number of array elements
  134005. */
  134006. numberOfArrayElements: number;
  134007. /**
  134008. * Gets the number of faces
  134009. */
  134010. numberOfFaces: number;
  134011. /**
  134012. * Gets the number of mipmap levels
  134013. */
  134014. numberOfMipmapLevels: number;
  134015. /**
  134016. * Gets the bytes of key value data
  134017. */
  134018. bytesOfKeyValueData: number;
  134019. /**
  134020. * Gets the load type
  134021. */
  134022. loadType: number;
  134023. /**
  134024. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  134025. */
  134026. isInvalid: boolean;
  134027. /**
  134028. * Creates a new KhronosTextureContainer
  134029. * @param data contents of the KTX container file
  134030. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  134031. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  134032. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  134033. */
  134034. constructor(
  134035. /** contents of the KTX container file */
  134036. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  134037. /**
  134038. * Uploads KTX content to a Babylon Texture.
  134039. * It is assumed that the texture has already been created & is currently bound
  134040. * @hidden
  134041. */
  134042. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  134043. private _upload2DCompressedLevels;
  134044. /**
  134045. * Checks if the given data starts with a KTX file identifier.
  134046. * @param data the data to check
  134047. * @returns true if the data is a KTX file or false otherwise
  134048. */
  134049. static IsValid(data: ArrayBufferView): boolean;
  134050. }
  134051. }
  134052. declare module BABYLON {
  134053. /**
  134054. * Class for loading KTX2 files
  134055. * !!! Experimental Extension Subject to Changes !!!
  134056. * @hidden
  134057. */
  134058. export class KhronosTextureContainer2 {
  134059. private static _ModulePromise;
  134060. private static _TranscodeFormat;
  134061. constructor(engine: ThinEngine);
  134062. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  134063. private _determineTranscodeFormat;
  134064. /**
  134065. * Checks if the given data starts with a KTX2 file identifier.
  134066. * @param data the data to check
  134067. * @returns true if the data is a KTX2 file or false otherwise
  134068. */
  134069. static IsValid(data: ArrayBufferView): boolean;
  134070. }
  134071. }
  134072. declare module BABYLON {
  134073. /**
  134074. * Implementation of the KTX Texture Loader.
  134075. * @hidden
  134076. */
  134077. export class _KTXTextureLoader implements IInternalTextureLoader {
  134078. /**
  134079. * Defines wether the loader supports cascade loading the different faces.
  134080. */
  134081. readonly supportCascades: boolean;
  134082. /**
  134083. * This returns if the loader support the current file information.
  134084. * @param extension defines the file extension of the file being loaded
  134085. * @returns true if the loader can load the specified file
  134086. */
  134087. canLoad(extension: string): boolean;
  134088. /**
  134089. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134090. * @param data contains the texture data
  134091. * @param texture defines the BabylonJS internal texture
  134092. * @param createPolynomials will be true if polynomials have been requested
  134093. * @param onLoad defines the callback to trigger once the texture is ready
  134094. * @param onError defines the callback to trigger in case of error
  134095. */
  134096. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134097. /**
  134098. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134099. * @param data contains the texture data
  134100. * @param texture defines the BabylonJS internal texture
  134101. * @param callback defines the method to call once ready to upload
  134102. */
  134103. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  134104. }
  134105. }
  134106. declare module BABYLON {
  134107. /** @hidden */
  134108. export var _forceSceneHelpersToBundle: boolean;
  134109. interface Scene {
  134110. /**
  134111. * Creates a default light for the scene.
  134112. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  134113. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  134114. */
  134115. createDefaultLight(replace?: boolean): void;
  134116. /**
  134117. * Creates a default camera for the scene.
  134118. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  134119. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134120. * @param replace has default false, when true replaces the active camera in the scene
  134121. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  134122. */
  134123. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134124. /**
  134125. * Creates a default camera and a default light.
  134126. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  134127. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134128. * @param replace has the default false, when true replaces the active camera/light in the scene
  134129. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  134130. */
  134131. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134132. /**
  134133. * Creates a new sky box
  134134. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  134135. * @param environmentTexture defines the texture to use as environment texture
  134136. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  134137. * @param scale defines the overall scale of the skybox
  134138. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  134139. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  134140. * @returns a new mesh holding the sky box
  134141. */
  134142. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  134143. /**
  134144. * Creates a new environment
  134145. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  134146. * @param options defines the options you can use to configure the environment
  134147. * @returns the new EnvironmentHelper
  134148. */
  134149. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  134150. /**
  134151. * Creates a new VREXperienceHelper
  134152. * @see http://doc.babylonjs.com/how_to/webvr_helper
  134153. * @param webVROptions defines the options used to create the new VREXperienceHelper
  134154. * @returns a new VREXperienceHelper
  134155. */
  134156. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  134157. /**
  134158. * Creates a new WebXRDefaultExperience
  134159. * @see http://doc.babylonjs.com/how_to/webxr
  134160. * @param options experience options
  134161. * @returns a promise for a new WebXRDefaultExperience
  134162. */
  134163. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134164. }
  134165. }
  134166. declare module BABYLON {
  134167. /**
  134168. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  134169. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  134170. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  134171. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134172. */
  134173. export class VideoDome extends TransformNode {
  134174. /**
  134175. * Define the video source as a Monoscopic panoramic 360 video.
  134176. */
  134177. static readonly MODE_MONOSCOPIC: number;
  134178. /**
  134179. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134180. */
  134181. static readonly MODE_TOPBOTTOM: number;
  134182. /**
  134183. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134184. */
  134185. static readonly MODE_SIDEBYSIDE: number;
  134186. private _halfDome;
  134187. private _useDirectMapping;
  134188. /**
  134189. * The video texture being displayed on the sphere
  134190. */
  134191. protected _videoTexture: VideoTexture;
  134192. /**
  134193. * Gets the video texture being displayed on the sphere
  134194. */
  134195. get videoTexture(): VideoTexture;
  134196. /**
  134197. * The skybox material
  134198. */
  134199. protected _material: BackgroundMaterial;
  134200. /**
  134201. * The surface used for the skybox
  134202. */
  134203. protected _mesh: Mesh;
  134204. /**
  134205. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  134206. */
  134207. private _halfDomeMask;
  134208. /**
  134209. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134210. * Also see the options.resolution property.
  134211. */
  134212. get fovMultiplier(): number;
  134213. set fovMultiplier(value: number);
  134214. private _videoMode;
  134215. /**
  134216. * Gets or set the current video mode for the video. It can be:
  134217. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  134218. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134219. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134220. */
  134221. get videoMode(): number;
  134222. set videoMode(value: number);
  134223. /**
  134224. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  134225. *
  134226. */
  134227. get halfDome(): boolean;
  134228. /**
  134229. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134230. */
  134231. set halfDome(enabled: boolean);
  134232. /**
  134233. * Oberserver used in Stereoscopic VR Mode.
  134234. */
  134235. private _onBeforeCameraRenderObserver;
  134236. /**
  134237. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  134238. * @param name Element's name, child elements will append suffixes for their own names.
  134239. * @param urlsOrVideo defines the url(s) or the video element to use
  134240. * @param options An object containing optional or exposed sub element properties
  134241. */
  134242. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  134243. resolution?: number;
  134244. clickToPlay?: boolean;
  134245. autoPlay?: boolean;
  134246. loop?: boolean;
  134247. size?: number;
  134248. poster?: string;
  134249. faceForward?: boolean;
  134250. useDirectMapping?: boolean;
  134251. halfDomeMode?: boolean;
  134252. }, scene: Scene);
  134253. private _changeVideoMode;
  134254. /**
  134255. * Releases resources associated with this node.
  134256. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134257. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134258. */
  134259. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134260. }
  134261. }
  134262. declare module BABYLON {
  134263. /**
  134264. * This class can be used to get instrumentation data from a Babylon engine
  134265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134266. */
  134267. export class EngineInstrumentation implements IDisposable {
  134268. /**
  134269. * Define the instrumented engine.
  134270. */
  134271. engine: Engine;
  134272. private _captureGPUFrameTime;
  134273. private _gpuFrameTimeToken;
  134274. private _gpuFrameTime;
  134275. private _captureShaderCompilationTime;
  134276. private _shaderCompilationTime;
  134277. private _onBeginFrameObserver;
  134278. private _onEndFrameObserver;
  134279. private _onBeforeShaderCompilationObserver;
  134280. private _onAfterShaderCompilationObserver;
  134281. /**
  134282. * Gets the perf counter used for GPU frame time
  134283. */
  134284. get gpuFrameTimeCounter(): PerfCounter;
  134285. /**
  134286. * Gets the GPU frame time capture status
  134287. */
  134288. get captureGPUFrameTime(): boolean;
  134289. /**
  134290. * Enable or disable the GPU frame time capture
  134291. */
  134292. set captureGPUFrameTime(value: boolean);
  134293. /**
  134294. * Gets the perf counter used for shader compilation time
  134295. */
  134296. get shaderCompilationTimeCounter(): PerfCounter;
  134297. /**
  134298. * Gets the shader compilation time capture status
  134299. */
  134300. get captureShaderCompilationTime(): boolean;
  134301. /**
  134302. * Enable or disable the shader compilation time capture
  134303. */
  134304. set captureShaderCompilationTime(value: boolean);
  134305. /**
  134306. * Instantiates a new engine instrumentation.
  134307. * This class can be used to get instrumentation data from a Babylon engine
  134308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134309. * @param engine Defines the engine to instrument
  134310. */
  134311. constructor(
  134312. /**
  134313. * Define the instrumented engine.
  134314. */
  134315. engine: Engine);
  134316. /**
  134317. * Dispose and release associated resources.
  134318. */
  134319. dispose(): void;
  134320. }
  134321. }
  134322. declare module BABYLON {
  134323. /**
  134324. * This class can be used to get instrumentation data from a Babylon engine
  134325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  134326. */
  134327. export class SceneInstrumentation implements IDisposable {
  134328. /**
  134329. * Defines the scene to instrument
  134330. */
  134331. scene: Scene;
  134332. private _captureActiveMeshesEvaluationTime;
  134333. private _activeMeshesEvaluationTime;
  134334. private _captureRenderTargetsRenderTime;
  134335. private _renderTargetsRenderTime;
  134336. private _captureFrameTime;
  134337. private _frameTime;
  134338. private _captureRenderTime;
  134339. private _renderTime;
  134340. private _captureInterFrameTime;
  134341. private _interFrameTime;
  134342. private _captureParticlesRenderTime;
  134343. private _particlesRenderTime;
  134344. private _captureSpritesRenderTime;
  134345. private _spritesRenderTime;
  134346. private _capturePhysicsTime;
  134347. private _physicsTime;
  134348. private _captureAnimationsTime;
  134349. private _animationsTime;
  134350. private _captureCameraRenderTime;
  134351. private _cameraRenderTime;
  134352. private _onBeforeActiveMeshesEvaluationObserver;
  134353. private _onAfterActiveMeshesEvaluationObserver;
  134354. private _onBeforeRenderTargetsRenderObserver;
  134355. private _onAfterRenderTargetsRenderObserver;
  134356. private _onAfterRenderObserver;
  134357. private _onBeforeDrawPhaseObserver;
  134358. private _onAfterDrawPhaseObserver;
  134359. private _onBeforeAnimationsObserver;
  134360. private _onBeforeParticlesRenderingObserver;
  134361. private _onAfterParticlesRenderingObserver;
  134362. private _onBeforeSpritesRenderingObserver;
  134363. private _onAfterSpritesRenderingObserver;
  134364. private _onBeforePhysicsObserver;
  134365. private _onAfterPhysicsObserver;
  134366. private _onAfterAnimationsObserver;
  134367. private _onBeforeCameraRenderObserver;
  134368. private _onAfterCameraRenderObserver;
  134369. /**
  134370. * Gets the perf counter used for active meshes evaluation time
  134371. */
  134372. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  134373. /**
  134374. * Gets the active meshes evaluation time capture status
  134375. */
  134376. get captureActiveMeshesEvaluationTime(): boolean;
  134377. /**
  134378. * Enable or disable the active meshes evaluation time capture
  134379. */
  134380. set captureActiveMeshesEvaluationTime(value: boolean);
  134381. /**
  134382. * Gets the perf counter used for render targets render time
  134383. */
  134384. get renderTargetsRenderTimeCounter(): PerfCounter;
  134385. /**
  134386. * Gets the render targets render time capture status
  134387. */
  134388. get captureRenderTargetsRenderTime(): boolean;
  134389. /**
  134390. * Enable or disable the render targets render time capture
  134391. */
  134392. set captureRenderTargetsRenderTime(value: boolean);
  134393. /**
  134394. * Gets the perf counter used for particles render time
  134395. */
  134396. get particlesRenderTimeCounter(): PerfCounter;
  134397. /**
  134398. * Gets the particles render time capture status
  134399. */
  134400. get captureParticlesRenderTime(): boolean;
  134401. /**
  134402. * Enable or disable the particles render time capture
  134403. */
  134404. set captureParticlesRenderTime(value: boolean);
  134405. /**
  134406. * Gets the perf counter used for sprites render time
  134407. */
  134408. get spritesRenderTimeCounter(): PerfCounter;
  134409. /**
  134410. * Gets the sprites render time capture status
  134411. */
  134412. get captureSpritesRenderTime(): boolean;
  134413. /**
  134414. * Enable or disable the sprites render time capture
  134415. */
  134416. set captureSpritesRenderTime(value: boolean);
  134417. /**
  134418. * Gets the perf counter used for physics time
  134419. */
  134420. get physicsTimeCounter(): PerfCounter;
  134421. /**
  134422. * Gets the physics time capture status
  134423. */
  134424. get capturePhysicsTime(): boolean;
  134425. /**
  134426. * Enable or disable the physics time capture
  134427. */
  134428. set capturePhysicsTime(value: boolean);
  134429. /**
  134430. * Gets the perf counter used for animations time
  134431. */
  134432. get animationsTimeCounter(): PerfCounter;
  134433. /**
  134434. * Gets the animations time capture status
  134435. */
  134436. get captureAnimationsTime(): boolean;
  134437. /**
  134438. * Enable or disable the animations time capture
  134439. */
  134440. set captureAnimationsTime(value: boolean);
  134441. /**
  134442. * Gets the perf counter used for frame time capture
  134443. */
  134444. get frameTimeCounter(): PerfCounter;
  134445. /**
  134446. * Gets the frame time capture status
  134447. */
  134448. get captureFrameTime(): boolean;
  134449. /**
  134450. * Enable or disable the frame time capture
  134451. */
  134452. set captureFrameTime(value: boolean);
  134453. /**
  134454. * Gets the perf counter used for inter-frames time capture
  134455. */
  134456. get interFrameTimeCounter(): PerfCounter;
  134457. /**
  134458. * Gets the inter-frames time capture status
  134459. */
  134460. get captureInterFrameTime(): boolean;
  134461. /**
  134462. * Enable or disable the inter-frames time capture
  134463. */
  134464. set captureInterFrameTime(value: boolean);
  134465. /**
  134466. * Gets the perf counter used for render time capture
  134467. */
  134468. get renderTimeCounter(): PerfCounter;
  134469. /**
  134470. * Gets the render time capture status
  134471. */
  134472. get captureRenderTime(): boolean;
  134473. /**
  134474. * Enable or disable the render time capture
  134475. */
  134476. set captureRenderTime(value: boolean);
  134477. /**
  134478. * Gets the perf counter used for camera render time capture
  134479. */
  134480. get cameraRenderTimeCounter(): PerfCounter;
  134481. /**
  134482. * Gets the camera render time capture status
  134483. */
  134484. get captureCameraRenderTime(): boolean;
  134485. /**
  134486. * Enable or disable the camera render time capture
  134487. */
  134488. set captureCameraRenderTime(value: boolean);
  134489. /**
  134490. * Gets the perf counter used for draw calls
  134491. */
  134492. get drawCallsCounter(): PerfCounter;
  134493. /**
  134494. * Instantiates a new scene instrumentation.
  134495. * This class can be used to get instrumentation data from a Babylon engine
  134496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  134497. * @param scene Defines the scene to instrument
  134498. */
  134499. constructor(
  134500. /**
  134501. * Defines the scene to instrument
  134502. */
  134503. scene: Scene);
  134504. /**
  134505. * Dispose and release associated resources.
  134506. */
  134507. dispose(): void;
  134508. }
  134509. }
  134510. declare module BABYLON {
  134511. /** @hidden */
  134512. export var glowMapGenerationPixelShader: {
  134513. name: string;
  134514. shader: string;
  134515. };
  134516. }
  134517. declare module BABYLON {
  134518. /** @hidden */
  134519. export var glowMapGenerationVertexShader: {
  134520. name: string;
  134521. shader: string;
  134522. };
  134523. }
  134524. declare module BABYLON {
  134525. /**
  134526. * Effect layer options. This helps customizing the behaviour
  134527. * of the effect layer.
  134528. */
  134529. export interface IEffectLayerOptions {
  134530. /**
  134531. * Multiplication factor apply to the canvas size to compute the render target size
  134532. * used to generated the objects (the smaller the faster).
  134533. */
  134534. mainTextureRatio: number;
  134535. /**
  134536. * Enforces a fixed size texture to ensure effect stability across devices.
  134537. */
  134538. mainTextureFixedSize?: number;
  134539. /**
  134540. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  134541. */
  134542. alphaBlendingMode: number;
  134543. /**
  134544. * The camera attached to the layer.
  134545. */
  134546. camera: Nullable<Camera>;
  134547. /**
  134548. * The rendering group to draw the layer in.
  134549. */
  134550. renderingGroupId: number;
  134551. }
  134552. /**
  134553. * The effect layer Helps adding post process effect blended with the main pass.
  134554. *
  134555. * This can be for instance use to generate glow or higlight effects on the scene.
  134556. *
  134557. * The effect layer class can not be used directly and is intented to inherited from to be
  134558. * customized per effects.
  134559. */
  134560. export abstract class EffectLayer {
  134561. private _vertexBuffers;
  134562. private _indexBuffer;
  134563. private _cachedDefines;
  134564. private _effectLayerMapGenerationEffect;
  134565. private _effectLayerOptions;
  134566. private _mergeEffect;
  134567. protected _scene: Scene;
  134568. protected _engine: Engine;
  134569. protected _maxSize: number;
  134570. protected _mainTextureDesiredSize: ISize;
  134571. protected _mainTexture: RenderTargetTexture;
  134572. protected _shouldRender: boolean;
  134573. protected _postProcesses: PostProcess[];
  134574. protected _textures: BaseTexture[];
  134575. protected _emissiveTextureAndColor: {
  134576. texture: Nullable<BaseTexture>;
  134577. color: Color4;
  134578. };
  134579. /**
  134580. * The name of the layer
  134581. */
  134582. name: string;
  134583. /**
  134584. * The clear color of the texture used to generate the glow map.
  134585. */
  134586. neutralColor: Color4;
  134587. /**
  134588. * Specifies whether the highlight layer is enabled or not.
  134589. */
  134590. isEnabled: boolean;
  134591. /**
  134592. * Gets the camera attached to the layer.
  134593. */
  134594. get camera(): Nullable<Camera>;
  134595. /**
  134596. * Gets the rendering group id the layer should render in.
  134597. */
  134598. get renderingGroupId(): number;
  134599. set renderingGroupId(renderingGroupId: number);
  134600. /**
  134601. * An event triggered when the effect layer has been disposed.
  134602. */
  134603. onDisposeObservable: Observable<EffectLayer>;
  134604. /**
  134605. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  134606. */
  134607. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  134608. /**
  134609. * An event triggered when the generated texture is being merged in the scene.
  134610. */
  134611. onBeforeComposeObservable: Observable<EffectLayer>;
  134612. /**
  134613. * An event triggered when the mesh is rendered into the effect render target.
  134614. */
  134615. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  134616. /**
  134617. * An event triggered after the mesh has been rendered into the effect render target.
  134618. */
  134619. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  134620. /**
  134621. * An event triggered when the generated texture has been merged in the scene.
  134622. */
  134623. onAfterComposeObservable: Observable<EffectLayer>;
  134624. /**
  134625. * An event triggered when the efffect layer changes its size.
  134626. */
  134627. onSizeChangedObservable: Observable<EffectLayer>;
  134628. /** @hidden */
  134629. static _SceneComponentInitialization: (scene: Scene) => void;
  134630. /**
  134631. * Instantiates a new effect Layer and references it in the scene.
  134632. * @param name The name of the layer
  134633. * @param scene The scene to use the layer in
  134634. */
  134635. constructor(
  134636. /** The Friendly of the effect in the scene */
  134637. name: string, scene: Scene);
  134638. /**
  134639. * Get the effect name of the layer.
  134640. * @return The effect name
  134641. */
  134642. abstract getEffectName(): string;
  134643. /**
  134644. * Checks for the readiness of the element composing the layer.
  134645. * @param subMesh the mesh to check for
  134646. * @param useInstances specify whether or not to use instances to render the mesh
  134647. * @return true if ready otherwise, false
  134648. */
  134649. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134650. /**
  134651. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  134652. * @returns true if the effect requires stencil during the main canvas render pass.
  134653. */
  134654. abstract needStencil(): boolean;
  134655. /**
  134656. * Create the merge effect. This is the shader use to blit the information back
  134657. * to the main canvas at the end of the scene rendering.
  134658. * @returns The effect containing the shader used to merge the effect on the main canvas
  134659. */
  134660. protected abstract _createMergeEffect(): Effect;
  134661. /**
  134662. * Creates the render target textures and post processes used in the effect layer.
  134663. */
  134664. protected abstract _createTextureAndPostProcesses(): void;
  134665. /**
  134666. * Implementation specific of rendering the generating effect on the main canvas.
  134667. * @param effect The effect used to render through
  134668. */
  134669. protected abstract _internalRender(effect: Effect): void;
  134670. /**
  134671. * Sets the required values for both the emissive texture and and the main color.
  134672. */
  134673. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134674. /**
  134675. * Free any resources and references associated to a mesh.
  134676. * Internal use
  134677. * @param mesh The mesh to free.
  134678. */
  134679. abstract _disposeMesh(mesh: Mesh): void;
  134680. /**
  134681. * Serializes this layer (Glow or Highlight for example)
  134682. * @returns a serialized layer object
  134683. */
  134684. abstract serialize?(): any;
  134685. /**
  134686. * Initializes the effect layer with the required options.
  134687. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  134688. */
  134689. protected _init(options: Partial<IEffectLayerOptions>): void;
  134690. /**
  134691. * Generates the index buffer of the full screen quad blending to the main canvas.
  134692. */
  134693. private _generateIndexBuffer;
  134694. /**
  134695. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  134696. */
  134697. private _generateVertexBuffer;
  134698. /**
  134699. * Sets the main texture desired size which is the closest power of two
  134700. * of the engine canvas size.
  134701. */
  134702. private _setMainTextureSize;
  134703. /**
  134704. * Creates the main texture for the effect layer.
  134705. */
  134706. protected _createMainTexture(): void;
  134707. /**
  134708. * Adds specific effects defines.
  134709. * @param defines The defines to add specifics to.
  134710. */
  134711. protected _addCustomEffectDefines(defines: string[]): void;
  134712. /**
  134713. * Checks for the readiness of the element composing the layer.
  134714. * @param subMesh the mesh to check for
  134715. * @param useInstances specify whether or not to use instances to render the mesh
  134716. * @param emissiveTexture the associated emissive texture used to generate the glow
  134717. * @return true if ready otherwise, false
  134718. */
  134719. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  134720. /**
  134721. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  134722. */
  134723. render(): void;
  134724. /**
  134725. * Determine if a given mesh will be used in the current effect.
  134726. * @param mesh mesh to test
  134727. * @returns true if the mesh will be used
  134728. */
  134729. hasMesh(mesh: AbstractMesh): boolean;
  134730. /**
  134731. * Returns true if the layer contains information to display, otherwise false.
  134732. * @returns true if the glow layer should be rendered
  134733. */
  134734. shouldRender(): boolean;
  134735. /**
  134736. * Returns true if the mesh should render, otherwise false.
  134737. * @param mesh The mesh to render
  134738. * @returns true if it should render otherwise false
  134739. */
  134740. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  134741. /**
  134742. * Returns true if the mesh can be rendered, otherwise false.
  134743. * @param mesh The mesh to render
  134744. * @param material The material used on the mesh
  134745. * @returns true if it can be rendered otherwise false
  134746. */
  134747. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  134748. /**
  134749. * Returns true if the mesh should render, otherwise false.
  134750. * @param mesh The mesh to render
  134751. * @returns true if it should render otherwise false
  134752. */
  134753. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  134754. /**
  134755. * Renders the submesh passed in parameter to the generation map.
  134756. */
  134757. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  134758. /**
  134759. * Defines whether the current material of the mesh should be use to render the effect.
  134760. * @param mesh defines the current mesh to render
  134761. */
  134762. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  134763. /**
  134764. * Rebuild the required buffers.
  134765. * @hidden Internal use only.
  134766. */
  134767. _rebuild(): void;
  134768. /**
  134769. * Dispose only the render target textures and post process.
  134770. */
  134771. private _disposeTextureAndPostProcesses;
  134772. /**
  134773. * Dispose the highlight layer and free resources.
  134774. */
  134775. dispose(): void;
  134776. /**
  134777. * Gets the class name of the effect layer
  134778. * @returns the string with the class name of the effect layer
  134779. */
  134780. getClassName(): string;
  134781. /**
  134782. * Creates an effect layer from parsed effect layer data
  134783. * @param parsedEffectLayer defines effect layer data
  134784. * @param scene defines the current scene
  134785. * @param rootUrl defines the root URL containing the effect layer information
  134786. * @returns a parsed effect Layer
  134787. */
  134788. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  134789. }
  134790. }
  134791. declare module BABYLON {
  134792. interface AbstractScene {
  134793. /**
  134794. * The list of effect layers (highlights/glow) added to the scene
  134795. * @see http://doc.babylonjs.com/how_to/highlight_layer
  134796. * @see http://doc.babylonjs.com/how_to/glow_layer
  134797. */
  134798. effectLayers: Array<EffectLayer>;
  134799. /**
  134800. * Removes the given effect layer from this scene.
  134801. * @param toRemove defines the effect layer to remove
  134802. * @returns the index of the removed effect layer
  134803. */
  134804. removeEffectLayer(toRemove: EffectLayer): number;
  134805. /**
  134806. * Adds the given effect layer to this scene
  134807. * @param newEffectLayer defines the effect layer to add
  134808. */
  134809. addEffectLayer(newEffectLayer: EffectLayer): void;
  134810. }
  134811. /**
  134812. * Defines the layer scene component responsible to manage any effect layers
  134813. * in a given scene.
  134814. */
  134815. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  134816. /**
  134817. * The component name helpfull to identify the component in the list of scene components.
  134818. */
  134819. readonly name: string;
  134820. /**
  134821. * The scene the component belongs to.
  134822. */
  134823. scene: Scene;
  134824. private _engine;
  134825. private _renderEffects;
  134826. private _needStencil;
  134827. private _previousStencilState;
  134828. /**
  134829. * Creates a new instance of the component for the given scene
  134830. * @param scene Defines the scene to register the component in
  134831. */
  134832. constructor(scene: Scene);
  134833. /**
  134834. * Registers the component in a given scene
  134835. */
  134836. register(): void;
  134837. /**
  134838. * Rebuilds the elements related to this component in case of
  134839. * context lost for instance.
  134840. */
  134841. rebuild(): void;
  134842. /**
  134843. * Serializes the component data to the specified json object
  134844. * @param serializationObject The object to serialize to
  134845. */
  134846. serialize(serializationObject: any): void;
  134847. /**
  134848. * Adds all the elements from the container to the scene
  134849. * @param container the container holding the elements
  134850. */
  134851. addFromContainer(container: AbstractScene): void;
  134852. /**
  134853. * Removes all the elements in the container from the scene
  134854. * @param container contains the elements to remove
  134855. * @param dispose if the removed element should be disposed (default: false)
  134856. */
  134857. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134858. /**
  134859. * Disposes the component and the associated ressources.
  134860. */
  134861. dispose(): void;
  134862. private _isReadyForMesh;
  134863. private _renderMainTexture;
  134864. private _setStencil;
  134865. private _setStencilBack;
  134866. private _draw;
  134867. private _drawCamera;
  134868. private _drawRenderingGroup;
  134869. }
  134870. }
  134871. declare module BABYLON {
  134872. /** @hidden */
  134873. export var glowMapMergePixelShader: {
  134874. name: string;
  134875. shader: string;
  134876. };
  134877. }
  134878. declare module BABYLON {
  134879. /** @hidden */
  134880. export var glowMapMergeVertexShader: {
  134881. name: string;
  134882. shader: string;
  134883. };
  134884. }
  134885. declare module BABYLON {
  134886. interface AbstractScene {
  134887. /**
  134888. * Return a the first highlight layer of the scene with a given name.
  134889. * @param name The name of the highlight layer to look for.
  134890. * @return The highlight layer if found otherwise null.
  134891. */
  134892. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  134893. }
  134894. /**
  134895. * Glow layer options. This helps customizing the behaviour
  134896. * of the glow layer.
  134897. */
  134898. export interface IGlowLayerOptions {
  134899. /**
  134900. * Multiplication factor apply to the canvas size to compute the render target size
  134901. * used to generated the glowing objects (the smaller the faster).
  134902. */
  134903. mainTextureRatio: number;
  134904. /**
  134905. * Enforces a fixed size texture to ensure resize independant blur.
  134906. */
  134907. mainTextureFixedSize?: number;
  134908. /**
  134909. * How big is the kernel of the blur texture.
  134910. */
  134911. blurKernelSize: number;
  134912. /**
  134913. * The camera attached to the layer.
  134914. */
  134915. camera: Nullable<Camera>;
  134916. /**
  134917. * Enable MSAA by chosing the number of samples.
  134918. */
  134919. mainTextureSamples?: number;
  134920. /**
  134921. * The rendering group to draw the layer in.
  134922. */
  134923. renderingGroupId: number;
  134924. }
  134925. /**
  134926. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  134927. *
  134928. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  134929. *
  134930. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  134931. */
  134932. export class GlowLayer extends EffectLayer {
  134933. /**
  134934. * Effect Name of the layer.
  134935. */
  134936. static readonly EffectName: string;
  134937. /**
  134938. * The default blur kernel size used for the glow.
  134939. */
  134940. static DefaultBlurKernelSize: number;
  134941. /**
  134942. * The default texture size ratio used for the glow.
  134943. */
  134944. static DefaultTextureRatio: number;
  134945. /**
  134946. * Sets the kernel size of the blur.
  134947. */
  134948. set blurKernelSize(value: number);
  134949. /**
  134950. * Gets the kernel size of the blur.
  134951. */
  134952. get blurKernelSize(): number;
  134953. /**
  134954. * Sets the glow intensity.
  134955. */
  134956. set intensity(value: number);
  134957. /**
  134958. * Gets the glow intensity.
  134959. */
  134960. get intensity(): number;
  134961. private _options;
  134962. private _intensity;
  134963. private _horizontalBlurPostprocess1;
  134964. private _verticalBlurPostprocess1;
  134965. private _horizontalBlurPostprocess2;
  134966. private _verticalBlurPostprocess2;
  134967. private _blurTexture1;
  134968. private _blurTexture2;
  134969. private _postProcesses1;
  134970. private _postProcesses2;
  134971. private _includedOnlyMeshes;
  134972. private _excludedMeshes;
  134973. private _meshesUsingTheirOwnMaterials;
  134974. /**
  134975. * Callback used to let the user override the color selection on a per mesh basis
  134976. */
  134977. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  134978. /**
  134979. * Callback used to let the user override the texture selection on a per mesh basis
  134980. */
  134981. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  134982. /**
  134983. * Instantiates a new glow Layer and references it to the scene.
  134984. * @param name The name of the layer
  134985. * @param scene The scene to use the layer in
  134986. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  134987. */
  134988. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  134989. /**
  134990. * Get the effect name of the layer.
  134991. * @return The effect name
  134992. */
  134993. getEffectName(): string;
  134994. /**
  134995. * Create the merge effect. This is the shader use to blit the information back
  134996. * to the main canvas at the end of the scene rendering.
  134997. */
  134998. protected _createMergeEffect(): Effect;
  134999. /**
  135000. * Creates the render target textures and post processes used in the glow layer.
  135001. */
  135002. protected _createTextureAndPostProcesses(): void;
  135003. /**
  135004. * Checks for the readiness of the element composing the layer.
  135005. * @param subMesh the mesh to check for
  135006. * @param useInstances specify wether or not to use instances to render the mesh
  135007. * @param emissiveTexture the associated emissive texture used to generate the glow
  135008. * @return true if ready otherwise, false
  135009. */
  135010. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135011. /**
  135012. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135013. */
  135014. needStencil(): boolean;
  135015. /**
  135016. * Returns true if the mesh can be rendered, otherwise false.
  135017. * @param mesh The mesh to render
  135018. * @param material The material used on the mesh
  135019. * @returns true if it can be rendered otherwise false
  135020. */
  135021. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135022. /**
  135023. * Implementation specific of rendering the generating effect on the main canvas.
  135024. * @param effect The effect used to render through
  135025. */
  135026. protected _internalRender(effect: Effect): void;
  135027. /**
  135028. * Sets the required values for both the emissive texture and and the main color.
  135029. */
  135030. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135031. /**
  135032. * Returns true if the mesh should render, otherwise false.
  135033. * @param mesh The mesh to render
  135034. * @returns true if it should render otherwise false
  135035. */
  135036. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135037. /**
  135038. * Adds specific effects defines.
  135039. * @param defines The defines to add specifics to.
  135040. */
  135041. protected _addCustomEffectDefines(defines: string[]): void;
  135042. /**
  135043. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  135044. * @param mesh The mesh to exclude from the glow layer
  135045. */
  135046. addExcludedMesh(mesh: Mesh): void;
  135047. /**
  135048. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  135049. * @param mesh The mesh to remove
  135050. */
  135051. removeExcludedMesh(mesh: Mesh): void;
  135052. /**
  135053. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  135054. * @param mesh The mesh to include in the glow layer
  135055. */
  135056. addIncludedOnlyMesh(mesh: Mesh): void;
  135057. /**
  135058. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  135059. * @param mesh The mesh to remove
  135060. */
  135061. removeIncludedOnlyMesh(mesh: Mesh): void;
  135062. /**
  135063. * Determine if a given mesh will be used in the glow layer
  135064. * @param mesh The mesh to test
  135065. * @returns true if the mesh will be highlighted by the current glow layer
  135066. */
  135067. hasMesh(mesh: AbstractMesh): boolean;
  135068. /**
  135069. * Defines whether the current material of the mesh should be use to render the effect.
  135070. * @param mesh defines the current mesh to render
  135071. */
  135072. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135073. /**
  135074. * Add a mesh to be rendered through its own material and not with emissive only.
  135075. * @param mesh The mesh for which we need to use its material
  135076. */
  135077. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  135078. /**
  135079. * Remove a mesh from being rendered through its own material and not with emissive only.
  135080. * @param mesh The mesh for which we need to not use its material
  135081. */
  135082. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  135083. /**
  135084. * Free any resources and references associated to a mesh.
  135085. * Internal use
  135086. * @param mesh The mesh to free.
  135087. * @hidden
  135088. */
  135089. _disposeMesh(mesh: Mesh): void;
  135090. /**
  135091. * Gets the class name of the effect layer
  135092. * @returns the string with the class name of the effect layer
  135093. */
  135094. getClassName(): string;
  135095. /**
  135096. * Serializes this glow layer
  135097. * @returns a serialized glow layer object
  135098. */
  135099. serialize(): any;
  135100. /**
  135101. * Creates a Glow Layer from parsed glow layer data
  135102. * @param parsedGlowLayer defines glow layer data
  135103. * @param scene defines the current scene
  135104. * @param rootUrl defines the root URL containing the glow layer information
  135105. * @returns a parsed Glow Layer
  135106. */
  135107. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  135108. }
  135109. }
  135110. declare module BABYLON {
  135111. /** @hidden */
  135112. export var glowBlurPostProcessPixelShader: {
  135113. name: string;
  135114. shader: string;
  135115. };
  135116. }
  135117. declare module BABYLON {
  135118. interface AbstractScene {
  135119. /**
  135120. * Return a the first highlight layer of the scene with a given name.
  135121. * @param name The name of the highlight layer to look for.
  135122. * @return The highlight layer if found otherwise null.
  135123. */
  135124. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  135125. }
  135126. /**
  135127. * Highlight layer options. This helps customizing the behaviour
  135128. * of the highlight layer.
  135129. */
  135130. export interface IHighlightLayerOptions {
  135131. /**
  135132. * Multiplication factor apply to the canvas size to compute the render target size
  135133. * used to generated the glowing objects (the smaller the faster).
  135134. */
  135135. mainTextureRatio: number;
  135136. /**
  135137. * Enforces a fixed size texture to ensure resize independant blur.
  135138. */
  135139. mainTextureFixedSize?: number;
  135140. /**
  135141. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  135142. * of the picture to blur (the smaller the faster).
  135143. */
  135144. blurTextureSizeRatio: number;
  135145. /**
  135146. * How big in texel of the blur texture is the vertical blur.
  135147. */
  135148. blurVerticalSize: number;
  135149. /**
  135150. * How big in texel of the blur texture is the horizontal blur.
  135151. */
  135152. blurHorizontalSize: number;
  135153. /**
  135154. * Alpha blending mode used to apply the blur. Default is combine.
  135155. */
  135156. alphaBlendingMode: number;
  135157. /**
  135158. * The camera attached to the layer.
  135159. */
  135160. camera: Nullable<Camera>;
  135161. /**
  135162. * Should we display highlight as a solid stroke?
  135163. */
  135164. isStroke?: boolean;
  135165. /**
  135166. * The rendering group to draw the layer in.
  135167. */
  135168. renderingGroupId: number;
  135169. }
  135170. /**
  135171. * The highlight layer Helps adding a glow effect around a mesh.
  135172. *
  135173. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  135174. * glowy meshes to your scene.
  135175. *
  135176. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  135177. */
  135178. export class HighlightLayer extends EffectLayer {
  135179. name: string;
  135180. /**
  135181. * Effect Name of the highlight layer.
  135182. */
  135183. static readonly EffectName: string;
  135184. /**
  135185. * The neutral color used during the preparation of the glow effect.
  135186. * This is black by default as the blend operation is a blend operation.
  135187. */
  135188. static NeutralColor: Color4;
  135189. /**
  135190. * Stencil value used for glowing meshes.
  135191. */
  135192. static GlowingMeshStencilReference: number;
  135193. /**
  135194. * Stencil value used for the other meshes in the scene.
  135195. */
  135196. static NormalMeshStencilReference: number;
  135197. /**
  135198. * Specifies whether or not the inner glow is ACTIVE in the layer.
  135199. */
  135200. innerGlow: boolean;
  135201. /**
  135202. * Specifies whether or not the outer glow is ACTIVE in the layer.
  135203. */
  135204. outerGlow: boolean;
  135205. /**
  135206. * Specifies the horizontal size of the blur.
  135207. */
  135208. set blurHorizontalSize(value: number);
  135209. /**
  135210. * Specifies the vertical size of the blur.
  135211. */
  135212. set blurVerticalSize(value: number);
  135213. /**
  135214. * Gets the horizontal size of the blur.
  135215. */
  135216. get blurHorizontalSize(): number;
  135217. /**
  135218. * Gets the vertical size of the blur.
  135219. */
  135220. get blurVerticalSize(): number;
  135221. /**
  135222. * An event triggered when the highlight layer is being blurred.
  135223. */
  135224. onBeforeBlurObservable: Observable<HighlightLayer>;
  135225. /**
  135226. * An event triggered when the highlight layer has been blurred.
  135227. */
  135228. onAfterBlurObservable: Observable<HighlightLayer>;
  135229. private _instanceGlowingMeshStencilReference;
  135230. private _options;
  135231. private _downSamplePostprocess;
  135232. private _horizontalBlurPostprocess;
  135233. private _verticalBlurPostprocess;
  135234. private _blurTexture;
  135235. private _meshes;
  135236. private _excludedMeshes;
  135237. /**
  135238. * Instantiates a new highlight Layer and references it to the scene..
  135239. * @param name The name of the layer
  135240. * @param scene The scene to use the layer in
  135241. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  135242. */
  135243. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  135244. /**
  135245. * Get the effect name of the layer.
  135246. * @return The effect name
  135247. */
  135248. getEffectName(): string;
  135249. /**
  135250. * Create the merge effect. This is the shader use to blit the information back
  135251. * to the main canvas at the end of the scene rendering.
  135252. */
  135253. protected _createMergeEffect(): Effect;
  135254. /**
  135255. * Creates the render target textures and post processes used in the highlight layer.
  135256. */
  135257. protected _createTextureAndPostProcesses(): void;
  135258. /**
  135259. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  135260. */
  135261. needStencil(): boolean;
  135262. /**
  135263. * Checks for the readiness of the element composing the layer.
  135264. * @param subMesh the mesh to check for
  135265. * @param useInstances specify wether or not to use instances to render the mesh
  135266. * @param emissiveTexture the associated emissive texture used to generate the glow
  135267. * @return true if ready otherwise, false
  135268. */
  135269. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135270. /**
  135271. * Implementation specific of rendering the generating effect on the main canvas.
  135272. * @param effect The effect used to render through
  135273. */
  135274. protected _internalRender(effect: Effect): void;
  135275. /**
  135276. * Returns true if the layer contains information to display, otherwise false.
  135277. */
  135278. shouldRender(): boolean;
  135279. /**
  135280. * Returns true if the mesh should render, otherwise false.
  135281. * @param mesh The mesh to render
  135282. * @returns true if it should render otherwise false
  135283. */
  135284. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135285. /**
  135286. * Adds specific effects defines.
  135287. * @param defines The defines to add specifics to.
  135288. */
  135289. protected _addCustomEffectDefines(defines: string[]): void;
  135290. /**
  135291. * Sets the required values for both the emissive texture and and the main color.
  135292. */
  135293. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135294. /**
  135295. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  135296. * @param mesh The mesh to exclude from the highlight layer
  135297. */
  135298. addExcludedMesh(mesh: Mesh): void;
  135299. /**
  135300. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  135301. * @param mesh The mesh to highlight
  135302. */
  135303. removeExcludedMesh(mesh: Mesh): void;
  135304. /**
  135305. * Determine if a given mesh will be highlighted by the current HighlightLayer
  135306. * @param mesh mesh to test
  135307. * @returns true if the mesh will be highlighted by the current HighlightLayer
  135308. */
  135309. hasMesh(mesh: AbstractMesh): boolean;
  135310. /**
  135311. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  135312. * @param mesh The mesh to highlight
  135313. * @param color The color of the highlight
  135314. * @param glowEmissiveOnly Extract the glow from the emissive texture
  135315. */
  135316. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  135317. /**
  135318. * Remove a mesh from the highlight layer in order to make it stop glowing.
  135319. * @param mesh The mesh to highlight
  135320. */
  135321. removeMesh(mesh: Mesh): void;
  135322. /**
  135323. * Remove all the meshes currently referenced in the highlight layer
  135324. */
  135325. removeAllMeshes(): void;
  135326. /**
  135327. * Force the stencil to the normal expected value for none glowing parts
  135328. */
  135329. private _defaultStencilReference;
  135330. /**
  135331. * Free any resources and references associated to a mesh.
  135332. * Internal use
  135333. * @param mesh The mesh to free.
  135334. * @hidden
  135335. */
  135336. _disposeMesh(mesh: Mesh): void;
  135337. /**
  135338. * Dispose the highlight layer and free resources.
  135339. */
  135340. dispose(): void;
  135341. /**
  135342. * Gets the class name of the effect layer
  135343. * @returns the string with the class name of the effect layer
  135344. */
  135345. getClassName(): string;
  135346. /**
  135347. * Serializes this Highlight layer
  135348. * @returns a serialized Highlight layer object
  135349. */
  135350. serialize(): any;
  135351. /**
  135352. * Creates a Highlight layer from parsed Highlight layer data
  135353. * @param parsedHightlightLayer defines the Highlight layer data
  135354. * @param scene defines the current scene
  135355. * @param rootUrl defines the root URL containing the Highlight layer information
  135356. * @returns a parsed Highlight layer
  135357. */
  135358. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  135359. }
  135360. }
  135361. declare module BABYLON {
  135362. interface AbstractScene {
  135363. /**
  135364. * The list of layers (background and foreground) of the scene
  135365. */
  135366. layers: Array<Layer>;
  135367. }
  135368. /**
  135369. * Defines the layer scene component responsible to manage any layers
  135370. * in a given scene.
  135371. */
  135372. export class LayerSceneComponent implements ISceneComponent {
  135373. /**
  135374. * The component name helpfull to identify the component in the list of scene components.
  135375. */
  135376. readonly name: string;
  135377. /**
  135378. * The scene the component belongs to.
  135379. */
  135380. scene: Scene;
  135381. private _engine;
  135382. /**
  135383. * Creates a new instance of the component for the given scene
  135384. * @param scene Defines the scene to register the component in
  135385. */
  135386. constructor(scene: Scene);
  135387. /**
  135388. * Registers the component in a given scene
  135389. */
  135390. register(): void;
  135391. /**
  135392. * Rebuilds the elements related to this component in case of
  135393. * context lost for instance.
  135394. */
  135395. rebuild(): void;
  135396. /**
  135397. * Disposes the component and the associated ressources.
  135398. */
  135399. dispose(): void;
  135400. private _draw;
  135401. private _drawCameraPredicate;
  135402. private _drawCameraBackground;
  135403. private _drawCameraForeground;
  135404. private _drawRenderTargetPredicate;
  135405. private _drawRenderTargetBackground;
  135406. private _drawRenderTargetForeground;
  135407. /**
  135408. * Adds all the elements from the container to the scene
  135409. * @param container the container holding the elements
  135410. */
  135411. addFromContainer(container: AbstractScene): void;
  135412. /**
  135413. * Removes all the elements in the container from the scene
  135414. * @param container contains the elements to remove
  135415. * @param dispose if the removed element should be disposed (default: false)
  135416. */
  135417. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135418. }
  135419. }
  135420. declare module BABYLON {
  135421. /** @hidden */
  135422. export var layerPixelShader: {
  135423. name: string;
  135424. shader: string;
  135425. };
  135426. }
  135427. declare module BABYLON {
  135428. /** @hidden */
  135429. export var layerVertexShader: {
  135430. name: string;
  135431. shader: string;
  135432. };
  135433. }
  135434. declare module BABYLON {
  135435. /**
  135436. * This represents a full screen 2d layer.
  135437. * This can be useful to display a picture in the background of your scene for instance.
  135438. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135439. */
  135440. export class Layer {
  135441. /**
  135442. * Define the name of the layer.
  135443. */
  135444. name: string;
  135445. /**
  135446. * Define the texture the layer should display.
  135447. */
  135448. texture: Nullable<Texture>;
  135449. /**
  135450. * Is the layer in background or foreground.
  135451. */
  135452. isBackground: boolean;
  135453. /**
  135454. * Define the color of the layer (instead of texture).
  135455. */
  135456. color: Color4;
  135457. /**
  135458. * Define the scale of the layer in order to zoom in out of the texture.
  135459. */
  135460. scale: Vector2;
  135461. /**
  135462. * Define an offset for the layer in order to shift the texture.
  135463. */
  135464. offset: Vector2;
  135465. /**
  135466. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  135467. */
  135468. alphaBlendingMode: number;
  135469. /**
  135470. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  135471. * Alpha test will not mix with the background color in case of transparency.
  135472. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  135473. */
  135474. alphaTest: boolean;
  135475. /**
  135476. * Define a mask to restrict the layer to only some of the scene cameras.
  135477. */
  135478. layerMask: number;
  135479. /**
  135480. * Define the list of render target the layer is visible into.
  135481. */
  135482. renderTargetTextures: RenderTargetTexture[];
  135483. /**
  135484. * Define if the layer is only used in renderTarget or if it also
  135485. * renders in the main frame buffer of the canvas.
  135486. */
  135487. renderOnlyInRenderTargetTextures: boolean;
  135488. private _scene;
  135489. private _vertexBuffers;
  135490. private _indexBuffer;
  135491. private _effect;
  135492. private _previousDefines;
  135493. /**
  135494. * An event triggered when the layer is disposed.
  135495. */
  135496. onDisposeObservable: Observable<Layer>;
  135497. private _onDisposeObserver;
  135498. /**
  135499. * Back compatibility with callback before the onDisposeObservable existed.
  135500. * The set callback will be triggered when the layer has been disposed.
  135501. */
  135502. set onDispose(callback: () => void);
  135503. /**
  135504. * An event triggered before rendering the scene
  135505. */
  135506. onBeforeRenderObservable: Observable<Layer>;
  135507. private _onBeforeRenderObserver;
  135508. /**
  135509. * Back compatibility with callback before the onBeforeRenderObservable existed.
  135510. * The set callback will be triggered just before rendering the layer.
  135511. */
  135512. set onBeforeRender(callback: () => void);
  135513. /**
  135514. * An event triggered after rendering the scene
  135515. */
  135516. onAfterRenderObservable: Observable<Layer>;
  135517. private _onAfterRenderObserver;
  135518. /**
  135519. * Back compatibility with callback before the onAfterRenderObservable existed.
  135520. * The set callback will be triggered just after rendering the layer.
  135521. */
  135522. set onAfterRender(callback: () => void);
  135523. /**
  135524. * Instantiates a new layer.
  135525. * This represents a full screen 2d layer.
  135526. * This can be useful to display a picture in the background of your scene for instance.
  135527. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135528. * @param name Define the name of the layer in the scene
  135529. * @param imgUrl Define the url of the texture to display in the layer
  135530. * @param scene Define the scene the layer belongs to
  135531. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  135532. * @param color Defines a color for the layer
  135533. */
  135534. constructor(
  135535. /**
  135536. * Define the name of the layer.
  135537. */
  135538. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  135539. private _createIndexBuffer;
  135540. /** @hidden */
  135541. _rebuild(): void;
  135542. /**
  135543. * Renders the layer in the scene.
  135544. */
  135545. render(): void;
  135546. /**
  135547. * Disposes and releases the associated ressources.
  135548. */
  135549. dispose(): void;
  135550. }
  135551. }
  135552. declare module BABYLON {
  135553. /** @hidden */
  135554. export var lensFlarePixelShader: {
  135555. name: string;
  135556. shader: string;
  135557. };
  135558. }
  135559. declare module BABYLON {
  135560. /** @hidden */
  135561. export var lensFlareVertexShader: {
  135562. name: string;
  135563. shader: string;
  135564. };
  135565. }
  135566. declare module BABYLON {
  135567. /**
  135568. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135569. * It is usually composed of several `lensFlare`.
  135570. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135571. */
  135572. export class LensFlareSystem {
  135573. /**
  135574. * Define the name of the lens flare system
  135575. */
  135576. name: string;
  135577. /**
  135578. * List of lens flares used in this system.
  135579. */
  135580. lensFlares: LensFlare[];
  135581. /**
  135582. * Define a limit from the border the lens flare can be visible.
  135583. */
  135584. borderLimit: number;
  135585. /**
  135586. * Define a viewport border we do not want to see the lens flare in.
  135587. */
  135588. viewportBorder: number;
  135589. /**
  135590. * Define a predicate which could limit the list of meshes able to occlude the effect.
  135591. */
  135592. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  135593. /**
  135594. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  135595. */
  135596. layerMask: number;
  135597. /**
  135598. * Define the id of the lens flare system in the scene.
  135599. * (equal to name by default)
  135600. */
  135601. id: string;
  135602. private _scene;
  135603. private _emitter;
  135604. private _vertexBuffers;
  135605. private _indexBuffer;
  135606. private _effect;
  135607. private _positionX;
  135608. private _positionY;
  135609. private _isEnabled;
  135610. /** @hidden */
  135611. static _SceneComponentInitialization: (scene: Scene) => void;
  135612. /**
  135613. * Instantiates a lens flare system.
  135614. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135615. * It is usually composed of several `lensFlare`.
  135616. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135617. * @param name Define the name of the lens flare system in the scene
  135618. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  135619. * @param scene Define the scene the lens flare system belongs to
  135620. */
  135621. constructor(
  135622. /**
  135623. * Define the name of the lens flare system
  135624. */
  135625. name: string, emitter: any, scene: Scene);
  135626. /**
  135627. * Define if the lens flare system is enabled.
  135628. */
  135629. get isEnabled(): boolean;
  135630. set isEnabled(value: boolean);
  135631. /**
  135632. * Get the scene the effects belongs to.
  135633. * @returns the scene holding the lens flare system
  135634. */
  135635. getScene(): Scene;
  135636. /**
  135637. * Get the emitter of the lens flare system.
  135638. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135639. * @returns the emitter of the lens flare system
  135640. */
  135641. getEmitter(): any;
  135642. /**
  135643. * Set the emitter of the lens flare system.
  135644. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135645. * @param newEmitter Define the new emitter of the system
  135646. */
  135647. setEmitter(newEmitter: any): void;
  135648. /**
  135649. * Get the lens flare system emitter position.
  135650. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  135651. * @returns the position
  135652. */
  135653. getEmitterPosition(): Vector3;
  135654. /**
  135655. * @hidden
  135656. */
  135657. computeEffectivePosition(globalViewport: Viewport): boolean;
  135658. /** @hidden */
  135659. _isVisible(): boolean;
  135660. /**
  135661. * @hidden
  135662. */
  135663. render(): boolean;
  135664. /**
  135665. * Dispose and release the lens flare with its associated resources.
  135666. */
  135667. dispose(): void;
  135668. /**
  135669. * Parse a lens flare system from a JSON repressentation
  135670. * @param parsedLensFlareSystem Define the JSON to parse
  135671. * @param scene Define the scene the parsed system should be instantiated in
  135672. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  135673. * @returns the parsed system
  135674. */
  135675. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  135676. /**
  135677. * Serialize the current Lens Flare System into a JSON representation.
  135678. * @returns the serialized JSON
  135679. */
  135680. serialize(): any;
  135681. }
  135682. }
  135683. declare module BABYLON {
  135684. /**
  135685. * This represents one of the lens effect in a `lensFlareSystem`.
  135686. * It controls one of the indiviual texture used in the effect.
  135687. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135688. */
  135689. export class LensFlare {
  135690. /**
  135691. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  135692. */
  135693. size: number;
  135694. /**
  135695. * 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.
  135696. */
  135697. position: number;
  135698. /**
  135699. * Define the lens color.
  135700. */
  135701. color: Color3;
  135702. /**
  135703. * Define the lens texture.
  135704. */
  135705. texture: Nullable<Texture>;
  135706. /**
  135707. * Define the alpha mode to render this particular lens.
  135708. */
  135709. alphaMode: number;
  135710. private _system;
  135711. /**
  135712. * Creates a new Lens Flare.
  135713. * This represents one of the lens effect in a `lensFlareSystem`.
  135714. * It controls one of the indiviual texture used in the effect.
  135715. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135716. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  135717. * @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.
  135718. * @param color Define the lens color
  135719. * @param imgUrl Define the lens texture url
  135720. * @param system Define the `lensFlareSystem` this flare is part of
  135721. * @returns The newly created Lens Flare
  135722. */
  135723. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  135724. /**
  135725. * Instantiates a new Lens Flare.
  135726. * This represents one of the lens effect in a `lensFlareSystem`.
  135727. * It controls one of the indiviual texture used in the effect.
  135728. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135729. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  135730. * @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.
  135731. * @param color Define the lens color
  135732. * @param imgUrl Define the lens texture url
  135733. * @param system Define the `lensFlareSystem` this flare is part of
  135734. */
  135735. constructor(
  135736. /**
  135737. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  135738. */
  135739. size: number,
  135740. /**
  135741. * 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.
  135742. */
  135743. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  135744. /**
  135745. * Dispose and release the lens flare with its associated resources.
  135746. */
  135747. dispose(): void;
  135748. }
  135749. }
  135750. declare module BABYLON {
  135751. interface AbstractScene {
  135752. /**
  135753. * The list of lens flare system added to the scene
  135754. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135755. */
  135756. lensFlareSystems: Array<LensFlareSystem>;
  135757. /**
  135758. * Removes the given lens flare system from this scene.
  135759. * @param toRemove The lens flare system to remove
  135760. * @returns The index of the removed lens flare system
  135761. */
  135762. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  135763. /**
  135764. * Adds the given lens flare system to this scene
  135765. * @param newLensFlareSystem The lens flare system to add
  135766. */
  135767. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  135768. /**
  135769. * Gets a lens flare system using its name
  135770. * @param name defines the name to look for
  135771. * @returns the lens flare system or null if not found
  135772. */
  135773. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  135774. /**
  135775. * Gets a lens flare system using its id
  135776. * @param id defines the id to look for
  135777. * @returns the lens flare system or null if not found
  135778. */
  135779. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  135780. }
  135781. /**
  135782. * Defines the lens flare scene component responsible to manage any lens flares
  135783. * in a given scene.
  135784. */
  135785. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  135786. /**
  135787. * The component name helpfull to identify the component in the list of scene components.
  135788. */
  135789. readonly name: string;
  135790. /**
  135791. * The scene the component belongs to.
  135792. */
  135793. scene: Scene;
  135794. /**
  135795. * Creates a new instance of the component for the given scene
  135796. * @param scene Defines the scene to register the component in
  135797. */
  135798. constructor(scene: Scene);
  135799. /**
  135800. * Registers the component in a given scene
  135801. */
  135802. register(): void;
  135803. /**
  135804. * Rebuilds the elements related to this component in case of
  135805. * context lost for instance.
  135806. */
  135807. rebuild(): void;
  135808. /**
  135809. * Adds all the elements from the container to the scene
  135810. * @param container the container holding the elements
  135811. */
  135812. addFromContainer(container: AbstractScene): void;
  135813. /**
  135814. * Removes all the elements in the container from the scene
  135815. * @param container contains the elements to remove
  135816. * @param dispose if the removed element should be disposed (default: false)
  135817. */
  135818. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135819. /**
  135820. * Serializes the component data to the specified json object
  135821. * @param serializationObject The object to serialize to
  135822. */
  135823. serialize(serializationObject: any): void;
  135824. /**
  135825. * Disposes the component and the associated ressources.
  135826. */
  135827. dispose(): void;
  135828. private _draw;
  135829. }
  135830. }
  135831. declare module BABYLON {
  135832. /** @hidden */
  135833. export var depthPixelShader: {
  135834. name: string;
  135835. shader: string;
  135836. };
  135837. }
  135838. declare module BABYLON {
  135839. /** @hidden */
  135840. export var depthVertexShader: {
  135841. name: string;
  135842. shader: string;
  135843. };
  135844. }
  135845. declare module BABYLON {
  135846. /**
  135847. * This represents a depth renderer in Babylon.
  135848. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135849. */
  135850. export class DepthRenderer {
  135851. private _scene;
  135852. private _depthMap;
  135853. private _effect;
  135854. private readonly _storeNonLinearDepth;
  135855. private readonly _clearColor;
  135856. /** Get if the depth renderer is using packed depth or not */
  135857. readonly isPacked: boolean;
  135858. private _cachedDefines;
  135859. private _camera;
  135860. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  135861. enabled: boolean;
  135862. /**
  135863. * Specifiess that the depth renderer will only be used within
  135864. * the camera it is created for.
  135865. * This can help forcing its rendering during the camera processing.
  135866. */
  135867. useOnlyInActiveCamera: boolean;
  135868. /** @hidden */
  135869. static _SceneComponentInitialization: (scene: Scene) => void;
  135870. /**
  135871. * Instantiates a depth renderer
  135872. * @param scene The scene the renderer belongs to
  135873. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135874. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135875. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135876. */
  135877. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135878. /**
  135879. * Creates the depth rendering effect and checks if the effect is ready.
  135880. * @param subMesh The submesh to be used to render the depth map of
  135881. * @param useInstances If multiple world instances should be used
  135882. * @returns if the depth renderer is ready to render the depth map
  135883. */
  135884. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135885. /**
  135886. * Gets the texture which the depth map will be written to.
  135887. * @returns The depth map texture
  135888. */
  135889. getDepthMap(): RenderTargetTexture;
  135890. /**
  135891. * Disposes of the depth renderer.
  135892. */
  135893. dispose(): void;
  135894. }
  135895. }
  135896. declare module BABYLON {
  135897. /** @hidden */
  135898. export var minmaxReduxPixelShader: {
  135899. name: string;
  135900. shader: string;
  135901. };
  135902. }
  135903. declare module BABYLON {
  135904. /**
  135905. * This class computes a min/max reduction from a texture: it means it computes the minimum
  135906. * and maximum values from all values of the texture.
  135907. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  135908. * The source values are read from the red channel of the texture.
  135909. */
  135910. export class MinMaxReducer {
  135911. /**
  135912. * Observable triggered when the computation has been performed
  135913. */
  135914. onAfterReductionPerformed: Observable<{
  135915. min: number;
  135916. max: number;
  135917. }>;
  135918. protected _camera: Camera;
  135919. protected _sourceTexture: Nullable<RenderTargetTexture>;
  135920. protected _reductionSteps: Nullable<Array<PostProcess>>;
  135921. protected _postProcessManager: PostProcessManager;
  135922. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  135923. protected _forceFullscreenViewport: boolean;
  135924. /**
  135925. * Creates a min/max reducer
  135926. * @param camera The camera to use for the post processes
  135927. */
  135928. constructor(camera: Camera);
  135929. /**
  135930. * Gets the texture used to read the values from.
  135931. */
  135932. get sourceTexture(): Nullable<RenderTargetTexture>;
  135933. /**
  135934. * Sets the source texture to read the values from.
  135935. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  135936. * because in such textures '1' value must not be taken into account to compute the maximum
  135937. * as this value is used to clear the texture.
  135938. * Note that the computation is not activated by calling this function, you must call activate() for that!
  135939. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  135940. * @param depthRedux Indicates if the texture is a depth texture or not
  135941. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  135942. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135943. */
  135944. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135945. /**
  135946. * Defines the refresh rate of the computation.
  135947. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135948. */
  135949. get refreshRate(): number;
  135950. set refreshRate(value: number);
  135951. protected _activated: boolean;
  135952. /**
  135953. * Gets the activation status of the reducer
  135954. */
  135955. get activated(): boolean;
  135956. /**
  135957. * Activates the reduction computation.
  135958. * When activated, the observers registered in onAfterReductionPerformed are
  135959. * called after the compuation is performed
  135960. */
  135961. activate(): void;
  135962. /**
  135963. * Deactivates the reduction computation.
  135964. */
  135965. deactivate(): void;
  135966. /**
  135967. * Disposes the min/max reducer
  135968. * @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.
  135969. */
  135970. dispose(disposeAll?: boolean): void;
  135971. }
  135972. }
  135973. declare module BABYLON {
  135974. /**
  135975. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  135976. */
  135977. export class DepthReducer extends MinMaxReducer {
  135978. private _depthRenderer;
  135979. private _depthRendererId;
  135980. /**
  135981. * Gets the depth renderer used for the computation.
  135982. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  135983. */
  135984. get depthRenderer(): Nullable<DepthRenderer>;
  135985. /**
  135986. * Creates a depth reducer
  135987. * @param camera The camera used to render the depth texture
  135988. */
  135989. constructor(camera: Camera);
  135990. /**
  135991. * Sets the depth renderer to use to generate the depth map
  135992. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  135993. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  135994. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135995. */
  135996. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  135997. /** @hidden */
  135998. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135999. /**
  136000. * Activates the reduction computation.
  136001. * When activated, the observers registered in onAfterReductionPerformed are
  136002. * called after the compuation is performed
  136003. */
  136004. activate(): void;
  136005. /**
  136006. * Deactivates the reduction computation.
  136007. */
  136008. deactivate(): void;
  136009. /**
  136010. * Disposes the depth reducer
  136011. * @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.
  136012. */
  136013. dispose(disposeAll?: boolean): void;
  136014. }
  136015. }
  136016. declare module BABYLON {
  136017. /**
  136018. * A CSM implementation allowing casting shadows on large scenes.
  136019. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136020. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  136021. */
  136022. export class CascadedShadowGenerator extends ShadowGenerator {
  136023. private static readonly frustumCornersNDCSpace;
  136024. /**
  136025. * Name of the CSM class
  136026. */
  136027. static CLASSNAME: string;
  136028. /**
  136029. * Defines the default number of cascades used by the CSM.
  136030. */
  136031. static readonly DEFAULT_CASCADES_COUNT: number;
  136032. /**
  136033. * Defines the minimum number of cascades used by the CSM.
  136034. */
  136035. static readonly MIN_CASCADES_COUNT: number;
  136036. /**
  136037. * Defines the maximum number of cascades used by the CSM.
  136038. */
  136039. static readonly MAX_CASCADES_COUNT: number;
  136040. protected _validateFilter(filter: number): number;
  136041. /**
  136042. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  136043. */
  136044. penumbraDarkness: number;
  136045. private _numCascades;
  136046. /**
  136047. * Gets or set the number of cascades used by the CSM.
  136048. */
  136049. get numCascades(): number;
  136050. set numCascades(value: number);
  136051. /**
  136052. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  136053. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  136054. */
  136055. stabilizeCascades: boolean;
  136056. private _freezeShadowCastersBoundingInfo;
  136057. private _freezeShadowCastersBoundingInfoObservable;
  136058. /**
  136059. * Enables or disables the shadow casters bounding info computation.
  136060. * If your shadow casters don't move, you can disable this feature.
  136061. * If it is enabled, the bounding box computation is done every frame.
  136062. */
  136063. get freezeShadowCastersBoundingInfo(): boolean;
  136064. set freezeShadowCastersBoundingInfo(freeze: boolean);
  136065. private _scbiMin;
  136066. private _scbiMax;
  136067. protected _computeShadowCastersBoundingInfo(): void;
  136068. protected _shadowCastersBoundingInfo: BoundingInfo;
  136069. /**
  136070. * Gets or sets the shadow casters bounding info.
  136071. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  136072. * so that the system won't overwrite the bounds you provide
  136073. */
  136074. get shadowCastersBoundingInfo(): BoundingInfo;
  136075. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  136076. protected _breaksAreDirty: boolean;
  136077. protected _minDistance: number;
  136078. protected _maxDistance: number;
  136079. /**
  136080. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  136081. *
  136082. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  136083. * If you don't know these values, simply leave them to their defaults and don't call this function.
  136084. * @param min minimal distance for the breaks (default to 0.)
  136085. * @param max maximal distance for the breaks (default to 1.)
  136086. */
  136087. setMinMaxDistance(min: number, max: number): void;
  136088. /** Gets the minimal distance used in the cascade break computation */
  136089. get minDistance(): number;
  136090. /** Gets the maximal distance used in the cascade break computation */
  136091. get maxDistance(): number;
  136092. /**
  136093. * Gets the class name of that object
  136094. * @returns "CascadedShadowGenerator"
  136095. */
  136096. getClassName(): string;
  136097. private _cascadeMinExtents;
  136098. private _cascadeMaxExtents;
  136099. /**
  136100. * Gets a cascade minimum extents
  136101. * @param cascadeIndex index of the cascade
  136102. * @returns the minimum cascade extents
  136103. */
  136104. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  136105. /**
  136106. * Gets a cascade maximum extents
  136107. * @param cascadeIndex index of the cascade
  136108. * @returns the maximum cascade extents
  136109. */
  136110. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  136111. private _cascades;
  136112. private _currentLayer;
  136113. private _viewSpaceFrustumsZ;
  136114. private _viewMatrices;
  136115. private _projectionMatrices;
  136116. private _transformMatrices;
  136117. private _transformMatricesAsArray;
  136118. private _frustumLengths;
  136119. private _lightSizeUVCorrection;
  136120. private _depthCorrection;
  136121. private _frustumCornersWorldSpace;
  136122. private _frustumCenter;
  136123. private _shadowCameraPos;
  136124. private _shadowMaxZ;
  136125. /**
  136126. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  136127. * It defaults to camera.maxZ
  136128. */
  136129. get shadowMaxZ(): number;
  136130. /**
  136131. * Sets the shadow max z distance.
  136132. */
  136133. set shadowMaxZ(value: number);
  136134. protected _debug: boolean;
  136135. /**
  136136. * Gets or sets the debug flag.
  136137. * When enabled, the cascades are materialized by different colors on the screen.
  136138. */
  136139. get debug(): boolean;
  136140. set debug(dbg: boolean);
  136141. private _depthClamp;
  136142. /**
  136143. * Gets or sets the depth clamping value.
  136144. *
  136145. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  136146. * to account for the shadow casters far away.
  136147. *
  136148. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  136149. */
  136150. get depthClamp(): boolean;
  136151. set depthClamp(value: boolean);
  136152. private _cascadeBlendPercentage;
  136153. /**
  136154. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  136155. * It defaults to 0.1 (10% blending).
  136156. */
  136157. get cascadeBlendPercentage(): number;
  136158. set cascadeBlendPercentage(value: number);
  136159. private _lambda;
  136160. /**
  136161. * Gets or set the lambda parameter.
  136162. * This parameter is used to split the camera frustum and create the cascades.
  136163. * 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.
  136164. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  136165. */
  136166. get lambda(): number;
  136167. set lambda(value: number);
  136168. /**
  136169. * Gets the view matrix corresponding to a given cascade
  136170. * @param cascadeNum cascade to retrieve the view matrix from
  136171. * @returns the cascade view matrix
  136172. */
  136173. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  136174. /**
  136175. * Gets the projection matrix corresponding to a given cascade
  136176. * @param cascadeNum cascade to retrieve the projection matrix from
  136177. * @returns the cascade projection matrix
  136178. */
  136179. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  136180. /**
  136181. * Gets the transformation matrix corresponding to a given cascade
  136182. * @param cascadeNum cascade to retrieve the transformation matrix from
  136183. * @returns the cascade transformation matrix
  136184. */
  136185. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  136186. private _depthRenderer;
  136187. /**
  136188. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  136189. *
  136190. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  136191. *
  136192. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  136193. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  136194. * @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
  136195. */
  136196. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  136197. private _depthReducer;
  136198. private _autoCalcDepthBounds;
  136199. /**
  136200. * Gets or sets the autoCalcDepthBounds property.
  136201. *
  136202. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  136203. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  136204. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  136205. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  136206. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  136207. */
  136208. get autoCalcDepthBounds(): boolean;
  136209. set autoCalcDepthBounds(value: boolean);
  136210. /**
  136211. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  136212. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136213. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  136214. * for setting the refresh rate on the renderer yourself!
  136215. */
  136216. get autoCalcDepthBoundsRefreshRate(): number;
  136217. set autoCalcDepthBoundsRefreshRate(value: number);
  136218. /**
  136219. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  136220. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  136221. * you change the camera near/far planes!
  136222. */
  136223. splitFrustum(): void;
  136224. private _splitFrustum;
  136225. private _computeMatrices;
  136226. private _computeFrustumInWorldSpace;
  136227. private _computeCascadeFrustum;
  136228. /**
  136229. * Support test.
  136230. */
  136231. static get IsSupported(): boolean;
  136232. /** @hidden */
  136233. static _SceneComponentInitialization: (scene: Scene) => void;
  136234. /**
  136235. * Creates a Cascaded Shadow Generator object.
  136236. * A ShadowGenerator is the required tool to use the shadows.
  136237. * Each directional light casting shadows needs to use its own ShadowGenerator.
  136238. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136239. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  136240. * @param light The directional light object generating the shadows.
  136241. * @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.
  136242. */
  136243. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  136244. protected _initializeGenerator(): void;
  136245. protected _createTargetRenderTexture(): void;
  136246. protected _initializeShadowMap(): void;
  136247. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  136248. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  136249. /**
  136250. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  136251. * @param defines Defines of the material we want to update
  136252. * @param lightIndex Index of the light in the enabled light list of the material
  136253. */
  136254. prepareDefines(defines: any, lightIndex: number): void;
  136255. /**
  136256. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  136257. * defined in the generator but impacting the effect).
  136258. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  136259. * @param effect The effect we are binfing the information for
  136260. */
  136261. bindShadowLight(lightIndex: string, effect: Effect): void;
  136262. /**
  136263. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  136264. * (eq to view projection * shadow projection matrices)
  136265. * @returns The transform matrix used to create the shadow map
  136266. */
  136267. getTransformMatrix(): Matrix;
  136268. /**
  136269. * Disposes the ShadowGenerator.
  136270. * Returns nothing.
  136271. */
  136272. dispose(): void;
  136273. /**
  136274. * Serializes the shadow generator setup to a json object.
  136275. * @returns The serialized JSON object
  136276. */
  136277. serialize(): any;
  136278. /**
  136279. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  136280. * @param parsedShadowGenerator The JSON object to parse
  136281. * @param scene The scene to create the shadow map for
  136282. * @returns The parsed shadow generator
  136283. */
  136284. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  136285. }
  136286. }
  136287. declare module BABYLON {
  136288. /**
  136289. * Defines the shadow generator component responsible to manage any shadow generators
  136290. * in a given scene.
  136291. */
  136292. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  136293. /**
  136294. * The component name helpfull to identify the component in the list of scene components.
  136295. */
  136296. readonly name: string;
  136297. /**
  136298. * The scene the component belongs to.
  136299. */
  136300. scene: Scene;
  136301. /**
  136302. * Creates a new instance of the component for the given scene
  136303. * @param scene Defines the scene to register the component in
  136304. */
  136305. constructor(scene: Scene);
  136306. /**
  136307. * Registers the component in a given scene
  136308. */
  136309. register(): void;
  136310. /**
  136311. * Rebuilds the elements related to this component in case of
  136312. * context lost for instance.
  136313. */
  136314. rebuild(): void;
  136315. /**
  136316. * Serializes the component data to the specified json object
  136317. * @param serializationObject The object to serialize to
  136318. */
  136319. serialize(serializationObject: any): void;
  136320. /**
  136321. * Adds all the elements from the container to the scene
  136322. * @param container the container holding the elements
  136323. */
  136324. addFromContainer(container: AbstractScene): void;
  136325. /**
  136326. * Removes all the elements in the container from the scene
  136327. * @param container contains the elements to remove
  136328. * @param dispose if the removed element should be disposed (default: false)
  136329. */
  136330. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136331. /**
  136332. * Rebuilds the elements related to this component in case of
  136333. * context lost for instance.
  136334. */
  136335. dispose(): void;
  136336. private _gatherRenderTargets;
  136337. }
  136338. }
  136339. declare module BABYLON {
  136340. /**
  136341. * A point light is a light defined by an unique point in world space.
  136342. * The light is emitted in every direction from this point.
  136343. * A good example of a point light is a standard light bulb.
  136344. * Documentation: https://doc.babylonjs.com/babylon101/lights
  136345. */
  136346. export class PointLight extends ShadowLight {
  136347. private _shadowAngle;
  136348. /**
  136349. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136350. * This specifies what angle the shadow will use to be created.
  136351. *
  136352. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136353. */
  136354. get shadowAngle(): number;
  136355. /**
  136356. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136357. * This specifies what angle the shadow will use to be created.
  136358. *
  136359. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136360. */
  136361. set shadowAngle(value: number);
  136362. /**
  136363. * Gets the direction if it has been set.
  136364. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136365. */
  136366. get direction(): Vector3;
  136367. /**
  136368. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136369. */
  136370. set direction(value: Vector3);
  136371. /**
  136372. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  136373. * A PointLight emits the light in every direction.
  136374. * It can cast shadows.
  136375. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  136376. * ```javascript
  136377. * var pointLight = new PointLight("pl", camera.position, scene);
  136378. * ```
  136379. * Documentation : https://doc.babylonjs.com/babylon101/lights
  136380. * @param name The light friendly name
  136381. * @param position The position of the point light in the scene
  136382. * @param scene The scene the lights belongs to
  136383. */
  136384. constructor(name: string, position: Vector3, scene: Scene);
  136385. /**
  136386. * Returns the string "PointLight"
  136387. * @returns the class name
  136388. */
  136389. getClassName(): string;
  136390. /**
  136391. * Returns the integer 0.
  136392. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  136393. */
  136394. getTypeID(): number;
  136395. /**
  136396. * Specifies wether or not the shadowmap should be a cube texture.
  136397. * @returns true if the shadowmap needs to be a cube texture.
  136398. */
  136399. needCube(): boolean;
  136400. /**
  136401. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  136402. * @param faceIndex The index of the face we are computed the direction to generate shadow
  136403. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  136404. */
  136405. getShadowDirection(faceIndex?: number): Vector3;
  136406. /**
  136407. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  136408. * - fov = PI / 2
  136409. * - aspect ratio : 1.0
  136410. * - z-near and far equal to the active camera minZ and maxZ.
  136411. * Returns the PointLight.
  136412. */
  136413. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  136414. protected _buildUniformLayout(): void;
  136415. /**
  136416. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  136417. * @param effect The effect to update
  136418. * @param lightIndex The index of the light in the effect to update
  136419. * @returns The point light
  136420. */
  136421. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  136422. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  136423. /**
  136424. * Prepares the list of defines specific to the light type.
  136425. * @param defines the list of defines
  136426. * @param lightIndex defines the index of the light for the effect
  136427. */
  136428. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  136429. }
  136430. }
  136431. declare module BABYLON {
  136432. /**
  136433. * Header information of HDR texture files.
  136434. */
  136435. export interface HDRInfo {
  136436. /**
  136437. * The height of the texture in pixels.
  136438. */
  136439. height: number;
  136440. /**
  136441. * The width of the texture in pixels.
  136442. */
  136443. width: number;
  136444. /**
  136445. * The index of the beginning of the data in the binary file.
  136446. */
  136447. dataPosition: number;
  136448. }
  136449. /**
  136450. * This groups tools to convert HDR texture to native colors array.
  136451. */
  136452. export class HDRTools {
  136453. private static Ldexp;
  136454. private static Rgbe2float;
  136455. private static readStringLine;
  136456. /**
  136457. * Reads header information from an RGBE texture stored in a native array.
  136458. * More information on this format are available here:
  136459. * https://en.wikipedia.org/wiki/RGBE_image_format
  136460. *
  136461. * @param uint8array The binary file stored in native array.
  136462. * @return The header information.
  136463. */
  136464. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  136465. /**
  136466. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  136467. * This RGBE texture needs to store the information as a panorama.
  136468. *
  136469. * More information on this format are available here:
  136470. * https://en.wikipedia.org/wiki/RGBE_image_format
  136471. *
  136472. * @param buffer The binary file stored in an array buffer.
  136473. * @param size The expected size of the extracted cubemap.
  136474. * @return The Cube Map information.
  136475. */
  136476. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  136477. /**
  136478. * Returns the pixels data extracted from an RGBE texture.
  136479. * This pixels will be stored left to right up to down in the R G B order in one array.
  136480. *
  136481. * More information on this format are available here:
  136482. * https://en.wikipedia.org/wiki/RGBE_image_format
  136483. *
  136484. * @param uint8array The binary file stored in an array buffer.
  136485. * @param hdrInfo The header information of the file.
  136486. * @return The pixels data in RGB right to left up to down order.
  136487. */
  136488. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  136489. private static RGBE_ReadPixels_RLE;
  136490. }
  136491. }
  136492. declare module BABYLON {
  136493. /**
  136494. * Effect Render Options
  136495. */
  136496. export interface IEffectRendererOptions {
  136497. /**
  136498. * Defines the vertices positions.
  136499. */
  136500. positions?: number[];
  136501. /**
  136502. * Defines the indices.
  136503. */
  136504. indices?: number[];
  136505. }
  136506. /**
  136507. * Helper class to render one or more effects.
  136508. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  136509. */
  136510. export class EffectRenderer {
  136511. private engine;
  136512. private static _DefaultOptions;
  136513. private _vertexBuffers;
  136514. private _indexBuffer;
  136515. private _fullscreenViewport;
  136516. /**
  136517. * Creates an effect renderer
  136518. * @param engine the engine to use for rendering
  136519. * @param options defines the options of the effect renderer
  136520. */
  136521. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  136522. /**
  136523. * Sets the current viewport in normalized coordinates 0-1
  136524. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  136525. */
  136526. setViewport(viewport?: Viewport): void;
  136527. /**
  136528. * Binds the embedded attributes buffer to the effect.
  136529. * @param effect Defines the effect to bind the attributes for
  136530. */
  136531. bindBuffers(effect: Effect): void;
  136532. /**
  136533. * Sets the current effect wrapper to use during draw.
  136534. * The effect needs to be ready before calling this api.
  136535. * This also sets the default full screen position attribute.
  136536. * @param effectWrapper Defines the effect to draw with
  136537. */
  136538. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  136539. /**
  136540. * Restores engine states
  136541. */
  136542. restoreStates(): void;
  136543. /**
  136544. * Draws a full screen quad.
  136545. */
  136546. draw(): void;
  136547. private isRenderTargetTexture;
  136548. /**
  136549. * renders one or more effects to a specified texture
  136550. * @param effectWrapper the effect to renderer
  136551. * @param outputTexture texture to draw to, if null it will render to the screen.
  136552. */
  136553. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  136554. /**
  136555. * Disposes of the effect renderer
  136556. */
  136557. dispose(): void;
  136558. }
  136559. /**
  136560. * Options to create an EffectWrapper
  136561. */
  136562. interface EffectWrapperCreationOptions {
  136563. /**
  136564. * Engine to use to create the effect
  136565. */
  136566. engine: ThinEngine;
  136567. /**
  136568. * Fragment shader for the effect
  136569. */
  136570. fragmentShader: string;
  136571. /**
  136572. * Use the shader store instead of direct source code
  136573. */
  136574. useShaderStore?: boolean;
  136575. /**
  136576. * Vertex shader for the effect
  136577. */
  136578. vertexShader?: string;
  136579. /**
  136580. * Attributes to use in the shader
  136581. */
  136582. attributeNames?: Array<string>;
  136583. /**
  136584. * Uniforms to use in the shader
  136585. */
  136586. uniformNames?: Array<string>;
  136587. /**
  136588. * Texture sampler names to use in the shader
  136589. */
  136590. samplerNames?: Array<string>;
  136591. /**
  136592. * Defines to use in the shader
  136593. */
  136594. defines?: Array<string>;
  136595. /**
  136596. * Callback when effect is compiled
  136597. */
  136598. onCompiled?: Nullable<(effect: Effect) => void>;
  136599. /**
  136600. * The friendly name of the effect displayed in Spector.
  136601. */
  136602. name?: string;
  136603. }
  136604. /**
  136605. * Wraps an effect to be used for rendering
  136606. */
  136607. export class EffectWrapper {
  136608. /**
  136609. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  136610. */
  136611. onApplyObservable: Observable<{}>;
  136612. /**
  136613. * The underlying effect
  136614. */
  136615. effect: Effect;
  136616. /**
  136617. * Creates an effect to be renderer
  136618. * @param creationOptions options to create the effect
  136619. */
  136620. constructor(creationOptions: EffectWrapperCreationOptions);
  136621. /**
  136622. * Disposes of the effect wrapper
  136623. */
  136624. dispose(): void;
  136625. }
  136626. }
  136627. declare module BABYLON {
  136628. /** @hidden */
  136629. export var hdrFilteringVertexShader: {
  136630. name: string;
  136631. shader: string;
  136632. };
  136633. }
  136634. declare module BABYLON {
  136635. /** @hidden */
  136636. export var hdrFilteringPixelShader: {
  136637. name: string;
  136638. shader: string;
  136639. };
  136640. }
  136641. declare module BABYLON {
  136642. /**
  136643. * Options for texture filtering
  136644. */
  136645. interface IHDRFilteringOptions {
  136646. /**
  136647. * Scales pixel intensity for the input HDR map.
  136648. */
  136649. hdrScale?: number;
  136650. /**
  136651. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  136652. */
  136653. quality?: number;
  136654. }
  136655. /**
  136656. * Filters HDR maps to get correct renderings of PBR reflections
  136657. */
  136658. export class HDRFiltering {
  136659. private _engine;
  136660. private _effectRenderer;
  136661. private _effectWrapper;
  136662. private _lodGenerationOffset;
  136663. private _lodGenerationScale;
  136664. /**
  136665. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  136666. * you care about baking speed.
  136667. */
  136668. quality: number;
  136669. /**
  136670. * Scales pixel intensity for the input HDR map.
  136671. */
  136672. hdrScale: number;
  136673. /**
  136674. * Instantiates HDR filter for reflection maps
  136675. *
  136676. * @param engine Thin engine
  136677. * @param options Options
  136678. */
  136679. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  136680. private _createRenderTarget;
  136681. private _prefilterInternal;
  136682. private _createEffect;
  136683. /**
  136684. * Get a value indicating if the filter is ready to be used
  136685. * @param texture Texture to filter
  136686. * @returns true if the filter is ready
  136687. */
  136688. isReady(texture: BaseTexture): boolean;
  136689. /**
  136690. * Prefilters a cube texture to have mipmap levels representing roughness values.
  136691. * Prefiltering will be invoked at the end of next rendering pass.
  136692. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  136693. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  136694. * @param texture Texture to filter
  136695. * @param onFinished Callback when filtering is done
  136696. * @return Promise called when prefiltering is done
  136697. */
  136698. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  136699. }
  136700. }
  136701. declare module BABYLON {
  136702. /**
  136703. * This represents a texture coming from an HDR input.
  136704. *
  136705. * The only supported format is currently panorama picture stored in RGBE format.
  136706. * Example of such files can be found on HDRLib: http://hdrlib.com/
  136707. */
  136708. export class HDRCubeTexture extends BaseTexture {
  136709. private static _facesMapping;
  136710. private _generateHarmonics;
  136711. private _noMipmap;
  136712. private _prefilterOnLoad;
  136713. private _textureMatrix;
  136714. private _size;
  136715. private _onLoad;
  136716. private _onError;
  136717. /**
  136718. * The texture URL.
  136719. */
  136720. url: string;
  136721. /**
  136722. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  136723. */
  136724. coordinatesMode: number;
  136725. protected _isBlocking: boolean;
  136726. /**
  136727. * Sets wether or not the texture is blocking during loading.
  136728. */
  136729. set isBlocking(value: boolean);
  136730. /**
  136731. * Gets wether or not the texture is blocking during loading.
  136732. */
  136733. get isBlocking(): boolean;
  136734. protected _rotationY: number;
  136735. /**
  136736. * Sets texture matrix rotation angle around Y axis in radians.
  136737. */
  136738. set rotationY(value: number);
  136739. /**
  136740. * Gets texture matrix rotation angle around Y axis radians.
  136741. */
  136742. get rotationY(): number;
  136743. /**
  136744. * Gets or sets the center of the bounding box associated with the cube texture
  136745. * It must define where the camera used to render the texture was set
  136746. */
  136747. boundingBoxPosition: Vector3;
  136748. private _boundingBoxSize;
  136749. /**
  136750. * Gets or sets the size of the bounding box associated with the cube texture
  136751. * When defined, the cubemap will switch to local mode
  136752. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  136753. * @example https://www.babylonjs-playground.com/#RNASML
  136754. */
  136755. set boundingBoxSize(value: Vector3);
  136756. get boundingBoxSize(): Vector3;
  136757. /**
  136758. * Instantiates an HDRTexture from the following parameters.
  136759. *
  136760. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  136761. * @param sceneOrEngine The scene or engine the texture will be used in
  136762. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  136763. * @param noMipmap Forces to not generate the mipmap if true
  136764. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  136765. * @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)
  136766. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  136767. */
  136768. 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>);
  136769. /**
  136770. * Get the current class name of the texture useful for serialization or dynamic coding.
  136771. * @returns "HDRCubeTexture"
  136772. */
  136773. getClassName(): string;
  136774. /**
  136775. * Occurs when the file is raw .hdr file.
  136776. */
  136777. private loadTexture;
  136778. clone(): HDRCubeTexture;
  136779. delayLoad(): void;
  136780. /**
  136781. * Get the texture reflection matrix used to rotate/transform the reflection.
  136782. * @returns the reflection matrix
  136783. */
  136784. getReflectionTextureMatrix(): Matrix;
  136785. /**
  136786. * Set the texture reflection matrix used to rotate/transform the reflection.
  136787. * @param value Define the reflection matrix to set
  136788. */
  136789. setReflectionTextureMatrix(value: Matrix): void;
  136790. /**
  136791. * Parses a JSON representation of an HDR Texture in order to create the texture
  136792. * @param parsedTexture Define the JSON representation
  136793. * @param scene Define the scene the texture should be created in
  136794. * @param rootUrl Define the root url in case we need to load relative dependencies
  136795. * @returns the newly created texture after parsing
  136796. */
  136797. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  136798. serialize(): any;
  136799. }
  136800. }
  136801. declare module BABYLON {
  136802. /**
  136803. * Class used to control physics engine
  136804. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136805. */
  136806. export class PhysicsEngine implements IPhysicsEngine {
  136807. private _physicsPlugin;
  136808. /**
  136809. * Global value used to control the smallest number supported by the simulation
  136810. */
  136811. static Epsilon: number;
  136812. private _impostors;
  136813. private _joints;
  136814. private _subTimeStep;
  136815. /**
  136816. * Gets the gravity vector used by the simulation
  136817. */
  136818. gravity: Vector3;
  136819. /**
  136820. * Factory used to create the default physics plugin.
  136821. * @returns The default physics plugin
  136822. */
  136823. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  136824. /**
  136825. * Creates a new Physics Engine
  136826. * @param gravity defines the gravity vector used by the simulation
  136827. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  136828. */
  136829. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  136830. /**
  136831. * Sets the gravity vector used by the simulation
  136832. * @param gravity defines the gravity vector to use
  136833. */
  136834. setGravity(gravity: Vector3): void;
  136835. /**
  136836. * Set the time step of the physics engine.
  136837. * Default is 1/60.
  136838. * To slow it down, enter 1/600 for example.
  136839. * To speed it up, 1/30
  136840. * @param newTimeStep defines the new timestep to apply to this world.
  136841. */
  136842. setTimeStep(newTimeStep?: number): void;
  136843. /**
  136844. * Get the time step of the physics engine.
  136845. * @returns the current time step
  136846. */
  136847. getTimeStep(): number;
  136848. /**
  136849. * Set the sub time step of the physics engine.
  136850. * Default is 0 meaning there is no sub steps
  136851. * To increase physics resolution precision, set a small value (like 1 ms)
  136852. * @param subTimeStep defines the new sub timestep used for physics resolution.
  136853. */
  136854. setSubTimeStep(subTimeStep?: number): void;
  136855. /**
  136856. * Get the sub time step of the physics engine.
  136857. * @returns the current sub time step
  136858. */
  136859. getSubTimeStep(): number;
  136860. /**
  136861. * Release all resources
  136862. */
  136863. dispose(): void;
  136864. /**
  136865. * Gets the name of the current physics plugin
  136866. * @returns the name of the plugin
  136867. */
  136868. getPhysicsPluginName(): string;
  136869. /**
  136870. * Adding a new impostor for the impostor tracking.
  136871. * This will be done by the impostor itself.
  136872. * @param impostor the impostor to add
  136873. */
  136874. addImpostor(impostor: PhysicsImpostor): void;
  136875. /**
  136876. * Remove an impostor from the engine.
  136877. * This impostor and its mesh will not longer be updated by the physics engine.
  136878. * @param impostor the impostor to remove
  136879. */
  136880. removeImpostor(impostor: PhysicsImpostor): void;
  136881. /**
  136882. * Add a joint to the physics engine
  136883. * @param mainImpostor defines the main impostor to which the joint is added.
  136884. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  136885. * @param joint defines the joint that will connect both impostors.
  136886. */
  136887. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136888. /**
  136889. * Removes a joint from the simulation
  136890. * @param mainImpostor defines the impostor used with the joint
  136891. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  136892. * @param joint defines the joint to remove
  136893. */
  136894. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136895. /**
  136896. * Called by the scene. No need to call it.
  136897. * @param delta defines the timespam between frames
  136898. */
  136899. _step(delta: number): void;
  136900. /**
  136901. * Gets the current plugin used to run the simulation
  136902. * @returns current plugin
  136903. */
  136904. getPhysicsPlugin(): IPhysicsEnginePlugin;
  136905. /**
  136906. * Gets the list of physic impostors
  136907. * @returns an array of PhysicsImpostor
  136908. */
  136909. getImpostors(): Array<PhysicsImpostor>;
  136910. /**
  136911. * Gets the impostor for a physics enabled object
  136912. * @param object defines the object impersonated by the impostor
  136913. * @returns the PhysicsImpostor or null if not found
  136914. */
  136915. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  136916. /**
  136917. * Gets the impostor for a physics body object
  136918. * @param body defines physics body used by the impostor
  136919. * @returns the PhysicsImpostor or null if not found
  136920. */
  136921. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  136922. /**
  136923. * Does a raycast in the physics world
  136924. * @param from when should the ray start?
  136925. * @param to when should the ray end?
  136926. * @returns PhysicsRaycastResult
  136927. */
  136928. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136929. }
  136930. }
  136931. declare module BABYLON {
  136932. /** @hidden */
  136933. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  136934. private _useDeltaForWorldStep;
  136935. world: any;
  136936. name: string;
  136937. private _physicsMaterials;
  136938. private _fixedTimeStep;
  136939. private _cannonRaycastResult;
  136940. private _raycastResult;
  136941. private _physicsBodysToRemoveAfterStep;
  136942. private _firstFrame;
  136943. BJSCANNON: any;
  136944. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  136945. setGravity(gravity: Vector3): void;
  136946. setTimeStep(timeStep: number): void;
  136947. getTimeStep(): number;
  136948. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136949. private _removeMarkedPhysicsBodiesFromWorld;
  136950. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136951. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136952. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136953. private _processChildMeshes;
  136954. removePhysicsBody(impostor: PhysicsImpostor): void;
  136955. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136956. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136957. private _addMaterial;
  136958. private _checkWithEpsilon;
  136959. private _createShape;
  136960. private _createHeightmap;
  136961. private _minus90X;
  136962. private _plus90X;
  136963. private _tmpPosition;
  136964. private _tmpDeltaPosition;
  136965. private _tmpUnityRotation;
  136966. private _updatePhysicsBodyTransformation;
  136967. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136968. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136969. isSupported(): boolean;
  136970. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136971. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136972. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136973. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136974. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136975. getBodyMass(impostor: PhysicsImpostor): number;
  136976. getBodyFriction(impostor: PhysicsImpostor): number;
  136977. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136978. getBodyRestitution(impostor: PhysicsImpostor): number;
  136979. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136980. sleepBody(impostor: PhysicsImpostor): void;
  136981. wakeUpBody(impostor: PhysicsImpostor): void;
  136982. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  136983. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136984. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136985. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136986. getRadius(impostor: PhysicsImpostor): number;
  136987. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136988. dispose(): void;
  136989. private _extendNamespace;
  136990. /**
  136991. * Does a raycast in the physics world
  136992. * @param from when should the ray start?
  136993. * @param to when should the ray end?
  136994. * @returns PhysicsRaycastResult
  136995. */
  136996. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136997. }
  136998. }
  136999. declare module BABYLON {
  137000. /** @hidden */
  137001. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  137002. private _useDeltaForWorldStep;
  137003. world: any;
  137004. name: string;
  137005. BJSOIMO: any;
  137006. private _raycastResult;
  137007. private _fixedTimeStep;
  137008. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  137009. setGravity(gravity: Vector3): void;
  137010. setTimeStep(timeStep: number): void;
  137011. getTimeStep(): number;
  137012. private _tmpImpostorsArray;
  137013. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137014. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137015. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137016. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137017. private _tmpPositionVector;
  137018. removePhysicsBody(impostor: PhysicsImpostor): void;
  137019. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137020. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137021. isSupported(): boolean;
  137022. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137023. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137024. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137025. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137026. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137027. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137028. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137029. getBodyMass(impostor: PhysicsImpostor): number;
  137030. getBodyFriction(impostor: PhysicsImpostor): number;
  137031. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137032. getBodyRestitution(impostor: PhysicsImpostor): number;
  137033. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137034. sleepBody(impostor: PhysicsImpostor): void;
  137035. wakeUpBody(impostor: PhysicsImpostor): void;
  137036. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137037. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  137038. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  137039. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137040. getRadius(impostor: PhysicsImpostor): number;
  137041. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137042. dispose(): void;
  137043. /**
  137044. * Does a raycast in the physics world
  137045. * @param from when should the ray start?
  137046. * @param to when should the ray end?
  137047. * @returns PhysicsRaycastResult
  137048. */
  137049. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137050. }
  137051. }
  137052. declare module BABYLON {
  137053. /**
  137054. * Class containing static functions to help procedurally build meshes
  137055. */
  137056. export class RibbonBuilder {
  137057. /**
  137058. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137059. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137060. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137061. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137062. * * 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
  137063. * * 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
  137064. * * 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
  137065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137066. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137067. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137068. * * 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
  137069. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137070. * * 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
  137071. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137073. * @param name defines the name of the mesh
  137074. * @param options defines the options used to create the mesh
  137075. * @param scene defines the hosting scene
  137076. * @returns the ribbon mesh
  137077. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137078. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137079. */
  137080. static CreateRibbon(name: string, options: {
  137081. pathArray: Vector3[][];
  137082. closeArray?: boolean;
  137083. closePath?: boolean;
  137084. offset?: number;
  137085. updatable?: boolean;
  137086. sideOrientation?: number;
  137087. frontUVs?: Vector4;
  137088. backUVs?: Vector4;
  137089. instance?: Mesh;
  137090. invertUV?: boolean;
  137091. uvs?: Vector2[];
  137092. colors?: Color4[];
  137093. }, scene?: Nullable<Scene>): Mesh;
  137094. }
  137095. }
  137096. declare module BABYLON {
  137097. /**
  137098. * Class containing static functions to help procedurally build meshes
  137099. */
  137100. export class ShapeBuilder {
  137101. /**
  137102. * 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.
  137103. * * 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.
  137104. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137105. * * 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.
  137106. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137107. * * 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
  137108. * * 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
  137109. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137112. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137114. * @param name defines the name of the mesh
  137115. * @param options defines the options used to create the mesh
  137116. * @param scene defines the hosting scene
  137117. * @returns the extruded shape mesh
  137118. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137120. */
  137121. static ExtrudeShape(name: string, options: {
  137122. shape: Vector3[];
  137123. path: Vector3[];
  137124. scale?: number;
  137125. rotation?: number;
  137126. cap?: number;
  137127. updatable?: boolean;
  137128. sideOrientation?: number;
  137129. frontUVs?: Vector4;
  137130. backUVs?: Vector4;
  137131. instance?: Mesh;
  137132. invertUV?: boolean;
  137133. }, scene?: Nullable<Scene>): Mesh;
  137134. /**
  137135. * Creates an custom extruded shape mesh.
  137136. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137137. * * 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.
  137138. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137139. * * 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
  137140. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137141. * * 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
  137142. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137143. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137144. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137145. * * 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
  137146. * * 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
  137147. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137152. * @param name defines the name of the mesh
  137153. * @param options defines the options used to create the mesh
  137154. * @param scene defines the hosting scene
  137155. * @returns the custom extruded shape mesh
  137156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137159. */
  137160. static ExtrudeShapeCustom(name: string, options: {
  137161. shape: Vector3[];
  137162. path: Vector3[];
  137163. scaleFunction?: any;
  137164. rotationFunction?: any;
  137165. ribbonCloseArray?: boolean;
  137166. ribbonClosePath?: boolean;
  137167. cap?: number;
  137168. updatable?: boolean;
  137169. sideOrientation?: number;
  137170. frontUVs?: Vector4;
  137171. backUVs?: Vector4;
  137172. instance?: Mesh;
  137173. invertUV?: boolean;
  137174. }, scene?: Nullable<Scene>): Mesh;
  137175. private static _ExtrudeShapeGeneric;
  137176. }
  137177. }
  137178. declare module BABYLON {
  137179. /**
  137180. * AmmoJS Physics plugin
  137181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137182. * @see https://github.com/kripken/ammo.js/
  137183. */
  137184. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  137185. private _useDeltaForWorldStep;
  137186. /**
  137187. * Reference to the Ammo library
  137188. */
  137189. bjsAMMO: any;
  137190. /**
  137191. * Created ammoJS world which physics bodies are added to
  137192. */
  137193. world: any;
  137194. /**
  137195. * Name of the plugin
  137196. */
  137197. name: string;
  137198. private _timeStep;
  137199. private _fixedTimeStep;
  137200. private _maxSteps;
  137201. private _tmpQuaternion;
  137202. private _tmpAmmoTransform;
  137203. private _tmpAmmoQuaternion;
  137204. private _tmpAmmoConcreteContactResultCallback;
  137205. private _collisionConfiguration;
  137206. private _dispatcher;
  137207. private _overlappingPairCache;
  137208. private _solver;
  137209. private _softBodySolver;
  137210. private _tmpAmmoVectorA;
  137211. private _tmpAmmoVectorB;
  137212. private _tmpAmmoVectorC;
  137213. private _tmpAmmoVectorD;
  137214. private _tmpContactCallbackResult;
  137215. private _tmpAmmoVectorRCA;
  137216. private _tmpAmmoVectorRCB;
  137217. private _raycastResult;
  137218. private static readonly DISABLE_COLLISION_FLAG;
  137219. private static readonly KINEMATIC_FLAG;
  137220. private static readonly DISABLE_DEACTIVATION_FLAG;
  137221. /**
  137222. * Initializes the ammoJS plugin
  137223. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  137224. * @param ammoInjection can be used to inject your own ammo reference
  137225. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  137226. */
  137227. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  137228. /**
  137229. * Sets the gravity of the physics world (m/(s^2))
  137230. * @param gravity Gravity to set
  137231. */
  137232. setGravity(gravity: Vector3): void;
  137233. /**
  137234. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  137235. * @param timeStep timestep to use in seconds
  137236. */
  137237. setTimeStep(timeStep: number): void;
  137238. /**
  137239. * 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)
  137240. * @param fixedTimeStep fixedTimeStep to use in seconds
  137241. */
  137242. setFixedTimeStep(fixedTimeStep: number): void;
  137243. /**
  137244. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  137245. * @param maxSteps the maximum number of steps by the physics engine per frame
  137246. */
  137247. setMaxSteps(maxSteps: number): void;
  137248. /**
  137249. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  137250. * @returns the current timestep in seconds
  137251. */
  137252. getTimeStep(): number;
  137253. /**
  137254. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  137255. */
  137256. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  137257. private _isImpostorInContact;
  137258. private _isImpostorPairInContact;
  137259. private _stepSimulation;
  137260. /**
  137261. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  137262. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  137263. * After the step the babylon meshes are set to the position of the physics imposters
  137264. * @param delta amount of time to step forward
  137265. * @param impostors array of imposters to update before/after the step
  137266. */
  137267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137268. /**
  137269. * Update babylon mesh to match physics world object
  137270. * @param impostor imposter to match
  137271. */
  137272. private _afterSoftStep;
  137273. /**
  137274. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137275. * @param impostor imposter to match
  137276. */
  137277. private _ropeStep;
  137278. /**
  137279. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137280. * @param impostor imposter to match
  137281. */
  137282. private _softbodyOrClothStep;
  137283. private _tmpMatrix;
  137284. /**
  137285. * Applies an impulse on the imposter
  137286. * @param impostor imposter to apply impulse to
  137287. * @param force amount of force to be applied to the imposter
  137288. * @param contactPoint the location to apply the impulse on the imposter
  137289. */
  137290. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137291. /**
  137292. * Applies a force on the imposter
  137293. * @param impostor imposter to apply force
  137294. * @param force amount of force to be applied to the imposter
  137295. * @param contactPoint the location to apply the force on the imposter
  137296. */
  137297. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137298. /**
  137299. * Creates a physics body using the plugin
  137300. * @param impostor the imposter to create the physics body on
  137301. */
  137302. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137303. /**
  137304. * Removes the physics body from the imposter and disposes of the body's memory
  137305. * @param impostor imposter to remove the physics body from
  137306. */
  137307. removePhysicsBody(impostor: PhysicsImpostor): void;
  137308. /**
  137309. * Generates a joint
  137310. * @param impostorJoint the imposter joint to create the joint with
  137311. */
  137312. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137313. /**
  137314. * Removes a joint
  137315. * @param impostorJoint the imposter joint to remove the joint from
  137316. */
  137317. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137318. private _addMeshVerts;
  137319. /**
  137320. * Initialise the soft body vertices to match its object's (mesh) vertices
  137321. * Softbody vertices (nodes) are in world space and to match this
  137322. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  137323. * @param impostor to create the softbody for
  137324. */
  137325. private _softVertexData;
  137326. /**
  137327. * Create an impostor's soft body
  137328. * @param impostor to create the softbody for
  137329. */
  137330. private _createSoftbody;
  137331. /**
  137332. * Create cloth for an impostor
  137333. * @param impostor to create the softbody for
  137334. */
  137335. private _createCloth;
  137336. /**
  137337. * Create rope for an impostor
  137338. * @param impostor to create the softbody for
  137339. */
  137340. private _createRope;
  137341. /**
  137342. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  137343. * @param impostor to create the custom physics shape for
  137344. */
  137345. private _createCustom;
  137346. private _addHullVerts;
  137347. private _createShape;
  137348. /**
  137349. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  137350. * @param impostor imposter containing the physics body and babylon object
  137351. */
  137352. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137353. /**
  137354. * Sets the babylon object's position/rotation from the physics body's position/rotation
  137355. * @param impostor imposter containing the physics body and babylon object
  137356. * @param newPosition new position
  137357. * @param newRotation new rotation
  137358. */
  137359. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137360. /**
  137361. * If this plugin is supported
  137362. * @returns true if its supported
  137363. */
  137364. isSupported(): boolean;
  137365. /**
  137366. * Sets the linear velocity of the physics body
  137367. * @param impostor imposter to set the velocity on
  137368. * @param velocity velocity to set
  137369. */
  137370. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137371. /**
  137372. * Sets the angular velocity of the physics body
  137373. * @param impostor imposter to set the velocity on
  137374. * @param velocity velocity to set
  137375. */
  137376. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137377. /**
  137378. * gets the linear velocity
  137379. * @param impostor imposter to get linear velocity from
  137380. * @returns linear velocity
  137381. */
  137382. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137383. /**
  137384. * gets the angular velocity
  137385. * @param impostor imposter to get angular velocity from
  137386. * @returns angular velocity
  137387. */
  137388. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137389. /**
  137390. * Sets the mass of physics body
  137391. * @param impostor imposter to set the mass on
  137392. * @param mass mass to set
  137393. */
  137394. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137395. /**
  137396. * Gets the mass of the physics body
  137397. * @param impostor imposter to get the mass from
  137398. * @returns mass
  137399. */
  137400. getBodyMass(impostor: PhysicsImpostor): number;
  137401. /**
  137402. * Gets friction of the impostor
  137403. * @param impostor impostor to get friction from
  137404. * @returns friction value
  137405. */
  137406. getBodyFriction(impostor: PhysicsImpostor): number;
  137407. /**
  137408. * Sets friction of the impostor
  137409. * @param impostor impostor to set friction on
  137410. * @param friction friction value
  137411. */
  137412. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137413. /**
  137414. * Gets restitution of the impostor
  137415. * @param impostor impostor to get restitution from
  137416. * @returns restitution value
  137417. */
  137418. getBodyRestitution(impostor: PhysicsImpostor): number;
  137419. /**
  137420. * Sets resitution of the impostor
  137421. * @param impostor impostor to set resitution on
  137422. * @param restitution resitution value
  137423. */
  137424. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137425. /**
  137426. * Gets pressure inside the impostor
  137427. * @param impostor impostor to get pressure from
  137428. * @returns pressure value
  137429. */
  137430. getBodyPressure(impostor: PhysicsImpostor): number;
  137431. /**
  137432. * Sets pressure inside a soft body impostor
  137433. * Cloth and rope must remain 0 pressure
  137434. * @param impostor impostor to set pressure on
  137435. * @param pressure pressure value
  137436. */
  137437. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  137438. /**
  137439. * Gets stiffness of the impostor
  137440. * @param impostor impostor to get stiffness from
  137441. * @returns pressure value
  137442. */
  137443. getBodyStiffness(impostor: PhysicsImpostor): number;
  137444. /**
  137445. * Sets stiffness of the impostor
  137446. * @param impostor impostor to set stiffness on
  137447. * @param stiffness stiffness value from 0 to 1
  137448. */
  137449. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  137450. /**
  137451. * Gets velocityIterations of the impostor
  137452. * @param impostor impostor to get velocity iterations from
  137453. * @returns velocityIterations value
  137454. */
  137455. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  137456. /**
  137457. * Sets velocityIterations of the impostor
  137458. * @param impostor impostor to set velocity iterations on
  137459. * @param velocityIterations velocityIterations value
  137460. */
  137461. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  137462. /**
  137463. * Gets positionIterations of the impostor
  137464. * @param impostor impostor to get position iterations from
  137465. * @returns positionIterations value
  137466. */
  137467. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  137468. /**
  137469. * Sets positionIterations of the impostor
  137470. * @param impostor impostor to set position on
  137471. * @param positionIterations positionIterations value
  137472. */
  137473. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  137474. /**
  137475. * Append an anchor to a cloth object
  137476. * @param impostor is the cloth impostor to add anchor to
  137477. * @param otherImpostor is the rigid impostor to anchor to
  137478. * @param width ratio across width from 0 to 1
  137479. * @param height ratio up height from 0 to 1
  137480. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  137481. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137482. */
  137483. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137484. /**
  137485. * Append an hook to a rope object
  137486. * @param impostor is the rope impostor to add hook to
  137487. * @param otherImpostor is the rigid impostor to hook to
  137488. * @param length ratio along the rope from 0 to 1
  137489. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  137490. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137491. */
  137492. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137493. /**
  137494. * Sleeps the physics body and stops it from being active
  137495. * @param impostor impostor to sleep
  137496. */
  137497. sleepBody(impostor: PhysicsImpostor): void;
  137498. /**
  137499. * Activates the physics body
  137500. * @param impostor impostor to activate
  137501. */
  137502. wakeUpBody(impostor: PhysicsImpostor): void;
  137503. /**
  137504. * Updates the distance parameters of the joint
  137505. * @param joint joint to update
  137506. * @param maxDistance maximum distance of the joint
  137507. * @param minDistance minimum distance of the joint
  137508. */
  137509. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137510. /**
  137511. * Sets a motor on the joint
  137512. * @param joint joint to set motor on
  137513. * @param speed speed of the motor
  137514. * @param maxForce maximum force of the motor
  137515. * @param motorIndex index of the motor
  137516. */
  137517. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137518. /**
  137519. * Sets the motors limit
  137520. * @param joint joint to set limit on
  137521. * @param upperLimit upper limit
  137522. * @param lowerLimit lower limit
  137523. */
  137524. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137525. /**
  137526. * Syncs the position and rotation of a mesh with the impostor
  137527. * @param mesh mesh to sync
  137528. * @param impostor impostor to update the mesh with
  137529. */
  137530. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137531. /**
  137532. * Gets the radius of the impostor
  137533. * @param impostor impostor to get radius from
  137534. * @returns the radius
  137535. */
  137536. getRadius(impostor: PhysicsImpostor): number;
  137537. /**
  137538. * Gets the box size of the impostor
  137539. * @param impostor impostor to get box size from
  137540. * @param result the resulting box size
  137541. */
  137542. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137543. /**
  137544. * Disposes of the impostor
  137545. */
  137546. dispose(): void;
  137547. /**
  137548. * Does a raycast in the physics world
  137549. * @param from when should the ray start?
  137550. * @param to when should the ray end?
  137551. * @returns PhysicsRaycastResult
  137552. */
  137553. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137554. }
  137555. }
  137556. declare module BABYLON {
  137557. interface AbstractScene {
  137558. /**
  137559. * The list of reflection probes added to the scene
  137560. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137561. */
  137562. reflectionProbes: Array<ReflectionProbe>;
  137563. /**
  137564. * Removes the given reflection probe from this scene.
  137565. * @param toRemove The reflection probe to remove
  137566. * @returns The index of the removed reflection probe
  137567. */
  137568. removeReflectionProbe(toRemove: ReflectionProbe): number;
  137569. /**
  137570. * Adds the given reflection probe to this scene.
  137571. * @param newReflectionProbe The reflection probe to add
  137572. */
  137573. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  137574. }
  137575. /**
  137576. * Class used to generate realtime reflection / refraction cube textures
  137577. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137578. */
  137579. export class ReflectionProbe {
  137580. /** defines the name of the probe */
  137581. name: string;
  137582. private _scene;
  137583. private _renderTargetTexture;
  137584. private _projectionMatrix;
  137585. private _viewMatrix;
  137586. private _target;
  137587. private _add;
  137588. private _attachedMesh;
  137589. private _invertYAxis;
  137590. /** Gets or sets probe position (center of the cube map) */
  137591. position: Vector3;
  137592. /**
  137593. * Creates a new reflection probe
  137594. * @param name defines the name of the probe
  137595. * @param size defines the texture resolution (for each face)
  137596. * @param scene defines the hosting scene
  137597. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  137598. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  137599. */
  137600. constructor(
  137601. /** defines the name of the probe */
  137602. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  137603. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  137604. get samples(): number;
  137605. set samples(value: number);
  137606. /** Gets or sets the refresh rate to use (on every frame by default) */
  137607. get refreshRate(): number;
  137608. set refreshRate(value: number);
  137609. /**
  137610. * Gets the hosting scene
  137611. * @returns a Scene
  137612. */
  137613. getScene(): Scene;
  137614. /** Gets the internal CubeTexture used to render to */
  137615. get cubeTexture(): RenderTargetTexture;
  137616. /** Gets the list of meshes to render */
  137617. get renderList(): Nullable<AbstractMesh[]>;
  137618. /**
  137619. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  137620. * @param mesh defines the mesh to attach to
  137621. */
  137622. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137623. /**
  137624. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  137625. * @param renderingGroupId The rendering group id corresponding to its index
  137626. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  137627. */
  137628. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  137629. /**
  137630. * Clean all associated resources
  137631. */
  137632. dispose(): void;
  137633. /**
  137634. * Converts the reflection probe information to a readable string for debug purpose.
  137635. * @param fullDetails Supports for multiple levels of logging within scene loading
  137636. * @returns the human readable reflection probe info
  137637. */
  137638. toString(fullDetails?: boolean): string;
  137639. /**
  137640. * Get the class name of the relfection probe.
  137641. * @returns "ReflectionProbe"
  137642. */
  137643. getClassName(): string;
  137644. /**
  137645. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  137646. * @returns The JSON representation of the texture
  137647. */
  137648. serialize(): any;
  137649. /**
  137650. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  137651. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  137652. * @param scene Define the scene the parsed reflection probe should be instantiated in
  137653. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  137654. * @returns The parsed reflection probe if successful
  137655. */
  137656. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  137657. }
  137658. }
  137659. declare module BABYLON {
  137660. /** @hidden */
  137661. export var _BabylonLoaderRegistered: boolean;
  137662. /**
  137663. * Helps setting up some configuration for the babylon file loader.
  137664. */
  137665. export class BabylonFileLoaderConfiguration {
  137666. /**
  137667. * The loader does not allow injecting custom physix engine into the plugins.
  137668. * Unfortunately in ES6, we need to manually inject them into the plugin.
  137669. * So you could set this variable to your engine import to make it work.
  137670. */
  137671. static LoaderInjectedPhysicsEngine: any;
  137672. }
  137673. }
  137674. declare module BABYLON {
  137675. /**
  137676. * The Physically based simple base material of BJS.
  137677. *
  137678. * This enables better naming and convention enforcements on top of the pbrMaterial.
  137679. * It is used as the base class for both the specGloss and metalRough conventions.
  137680. */
  137681. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  137682. /**
  137683. * Number of Simultaneous lights allowed on the material.
  137684. */
  137685. maxSimultaneousLights: number;
  137686. /**
  137687. * If sets to true, disables all the lights affecting the material.
  137688. */
  137689. disableLighting: boolean;
  137690. /**
  137691. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  137692. */
  137693. environmentTexture: BaseTexture;
  137694. /**
  137695. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137696. */
  137697. invertNormalMapX: boolean;
  137698. /**
  137699. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137700. */
  137701. invertNormalMapY: boolean;
  137702. /**
  137703. * Normal map used in the model.
  137704. */
  137705. normalTexture: BaseTexture;
  137706. /**
  137707. * Emissivie color used to self-illuminate the model.
  137708. */
  137709. emissiveColor: Color3;
  137710. /**
  137711. * Emissivie texture used to self-illuminate the model.
  137712. */
  137713. emissiveTexture: BaseTexture;
  137714. /**
  137715. * Occlusion Channel Strenght.
  137716. */
  137717. occlusionStrength: number;
  137718. /**
  137719. * Occlusion Texture of the material (adding extra occlusion effects).
  137720. */
  137721. occlusionTexture: BaseTexture;
  137722. /**
  137723. * Defines the alpha limits in alpha test mode.
  137724. */
  137725. alphaCutOff: number;
  137726. /**
  137727. * Gets the current double sided mode.
  137728. */
  137729. get doubleSided(): boolean;
  137730. /**
  137731. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137732. */
  137733. set doubleSided(value: boolean);
  137734. /**
  137735. * Stores the pre-calculated light information of a mesh in a texture.
  137736. */
  137737. lightmapTexture: BaseTexture;
  137738. /**
  137739. * If true, the light map contains occlusion information instead of lighting info.
  137740. */
  137741. useLightmapAsShadowmap: boolean;
  137742. /**
  137743. * Instantiates a new PBRMaterial instance.
  137744. *
  137745. * @param name The material name
  137746. * @param scene The scene the material will be use in.
  137747. */
  137748. constructor(name: string, scene: Scene);
  137749. getClassName(): string;
  137750. }
  137751. }
  137752. declare module BABYLON {
  137753. /**
  137754. * The PBR material of BJS following the metal roughness convention.
  137755. *
  137756. * This fits to the PBR convention in the GLTF definition:
  137757. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  137758. */
  137759. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  137760. /**
  137761. * The base color has two different interpretations depending on the value of metalness.
  137762. * When the material is a metal, the base color is the specific measured reflectance value
  137763. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  137764. * of the material.
  137765. */
  137766. baseColor: Color3;
  137767. /**
  137768. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  137769. * well as opacity information in the alpha channel.
  137770. */
  137771. baseTexture: BaseTexture;
  137772. /**
  137773. * Specifies the metallic scalar value of the material.
  137774. * Can also be used to scale the metalness values of the metallic texture.
  137775. */
  137776. metallic: number;
  137777. /**
  137778. * Specifies the roughness scalar value of the material.
  137779. * Can also be used to scale the roughness values of the metallic texture.
  137780. */
  137781. roughness: number;
  137782. /**
  137783. * Texture containing both the metallic value in the B channel and the
  137784. * roughness value in the G channel to keep better precision.
  137785. */
  137786. metallicRoughnessTexture: BaseTexture;
  137787. /**
  137788. * Instantiates a new PBRMetalRoughnessMaterial instance.
  137789. *
  137790. * @param name The material name
  137791. * @param scene The scene the material will be use in.
  137792. */
  137793. constructor(name: string, scene: Scene);
  137794. /**
  137795. * Return the currrent class name of the material.
  137796. */
  137797. getClassName(): string;
  137798. /**
  137799. * Makes a duplicate of the current material.
  137800. * @param name - name to use for the new material.
  137801. */
  137802. clone(name: string): PBRMetallicRoughnessMaterial;
  137803. /**
  137804. * Serialize the material to a parsable JSON object.
  137805. */
  137806. serialize(): any;
  137807. /**
  137808. * Parses a JSON object correponding to the serialize function.
  137809. */
  137810. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  137811. }
  137812. }
  137813. declare module BABYLON {
  137814. /**
  137815. * The PBR material of BJS following the specular glossiness convention.
  137816. *
  137817. * This fits to the PBR convention in the GLTF definition:
  137818. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  137819. */
  137820. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  137821. /**
  137822. * Specifies the diffuse color of the material.
  137823. */
  137824. diffuseColor: Color3;
  137825. /**
  137826. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  137827. * channel.
  137828. */
  137829. diffuseTexture: BaseTexture;
  137830. /**
  137831. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  137832. */
  137833. specularColor: Color3;
  137834. /**
  137835. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  137836. */
  137837. glossiness: number;
  137838. /**
  137839. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  137840. */
  137841. specularGlossinessTexture: BaseTexture;
  137842. /**
  137843. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  137844. *
  137845. * @param name The material name
  137846. * @param scene The scene the material will be use in.
  137847. */
  137848. constructor(name: string, scene: Scene);
  137849. /**
  137850. * Return the currrent class name of the material.
  137851. */
  137852. getClassName(): string;
  137853. /**
  137854. * Makes a duplicate of the current material.
  137855. * @param name - name to use for the new material.
  137856. */
  137857. clone(name: string): PBRSpecularGlossinessMaterial;
  137858. /**
  137859. * Serialize the material to a parsable JSON object.
  137860. */
  137861. serialize(): any;
  137862. /**
  137863. * Parses a JSON object correponding to the serialize function.
  137864. */
  137865. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  137866. }
  137867. }
  137868. declare module BABYLON {
  137869. /**
  137870. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  137871. * It can help converting any input color in a desired output one. This can then be used to create effects
  137872. * from sepia, black and white to sixties or futuristic rendering...
  137873. *
  137874. * The only supported format is currently 3dl.
  137875. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  137876. */
  137877. export class ColorGradingTexture extends BaseTexture {
  137878. /**
  137879. * The texture URL.
  137880. */
  137881. url: string;
  137882. /**
  137883. * Empty line regex stored for GC.
  137884. */
  137885. private static _noneEmptyLineRegex;
  137886. private _textureMatrix;
  137887. private _onLoad;
  137888. /**
  137889. * Instantiates a ColorGradingTexture from the following parameters.
  137890. *
  137891. * @param url The location of the color gradind data (currently only supporting 3dl)
  137892. * @param sceneOrEngine The scene or engine the texture will be used in
  137893. * @param onLoad defines a callback triggered when the texture has been loaded
  137894. */
  137895. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  137896. /**
  137897. * Fires the onload event from the constructor if requested.
  137898. */
  137899. private _triggerOnLoad;
  137900. /**
  137901. * Returns the texture matrix used in most of the material.
  137902. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  137903. */
  137904. getTextureMatrix(): Matrix;
  137905. /**
  137906. * Occurs when the file being loaded is a .3dl LUT file.
  137907. */
  137908. private load3dlTexture;
  137909. /**
  137910. * Starts the loading process of the texture.
  137911. */
  137912. private loadTexture;
  137913. /**
  137914. * Clones the color gradind texture.
  137915. */
  137916. clone(): ColorGradingTexture;
  137917. /**
  137918. * Called during delayed load for textures.
  137919. */
  137920. delayLoad(): void;
  137921. /**
  137922. * Parses a color grading texture serialized by Babylon.
  137923. * @param parsedTexture The texture information being parsedTexture
  137924. * @param scene The scene to load the texture in
  137925. * @param rootUrl The root url of the data assets to load
  137926. * @return A color gradind texture
  137927. */
  137928. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  137929. /**
  137930. * Serializes the LUT texture to json format.
  137931. */
  137932. serialize(): any;
  137933. }
  137934. }
  137935. declare module BABYLON {
  137936. /**
  137937. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  137938. */
  137939. export class EquiRectangularCubeTexture extends BaseTexture {
  137940. /** The six faces of the cube. */
  137941. private static _FacesMapping;
  137942. private _noMipmap;
  137943. private _onLoad;
  137944. private _onError;
  137945. /** The size of the cubemap. */
  137946. private _size;
  137947. /** The buffer of the image. */
  137948. private _buffer;
  137949. /** The width of the input image. */
  137950. private _width;
  137951. /** The height of the input image. */
  137952. private _height;
  137953. /** The URL to the image. */
  137954. url: string;
  137955. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  137956. coordinatesMode: number;
  137957. /**
  137958. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  137959. * @param url The location of the image
  137960. * @param scene The scene the texture will be used in
  137961. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137962. * @param noMipmap Forces to not generate the mipmap if true
  137963. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  137964. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  137965. * @param onLoad — defines a callback called when texture is loaded
  137966. * @param onError — defines a callback called if there is an error
  137967. */
  137968. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  137969. /**
  137970. * Load the image data, by putting the image on a canvas and extracting its buffer.
  137971. */
  137972. private loadImage;
  137973. /**
  137974. * Convert the image buffer into a cubemap and create a CubeTexture.
  137975. */
  137976. private loadTexture;
  137977. /**
  137978. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  137979. * @param buffer The ArrayBuffer that should be converted.
  137980. * @returns The buffer as Float32Array.
  137981. */
  137982. private getFloat32ArrayFromArrayBuffer;
  137983. /**
  137984. * Get the current class name of the texture useful for serialization or dynamic coding.
  137985. * @returns "EquiRectangularCubeTexture"
  137986. */
  137987. getClassName(): string;
  137988. /**
  137989. * Create a clone of the current EquiRectangularCubeTexture and return it.
  137990. * @returns A clone of the current EquiRectangularCubeTexture.
  137991. */
  137992. clone(): EquiRectangularCubeTexture;
  137993. }
  137994. }
  137995. declare module BABYLON {
  137996. /**
  137997. * Defines the options related to the creation of an HtmlElementTexture
  137998. */
  137999. export interface IHtmlElementTextureOptions {
  138000. /**
  138001. * Defines wether mip maps should be created or not.
  138002. */
  138003. generateMipMaps?: boolean;
  138004. /**
  138005. * Defines the sampling mode of the texture.
  138006. */
  138007. samplingMode?: number;
  138008. /**
  138009. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  138010. */
  138011. engine: Nullable<ThinEngine>;
  138012. /**
  138013. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  138014. */
  138015. scene: Nullable<Scene>;
  138016. }
  138017. /**
  138018. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  138019. * To be as efficient as possible depending on your constraints nothing aside the first upload
  138020. * is automatically managed.
  138021. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  138022. * in your application.
  138023. *
  138024. * As the update is not automatic, you need to call them manually.
  138025. */
  138026. export class HtmlElementTexture extends BaseTexture {
  138027. /**
  138028. * The texture URL.
  138029. */
  138030. element: HTMLVideoElement | HTMLCanvasElement;
  138031. private static readonly DefaultOptions;
  138032. private _textureMatrix;
  138033. private _isVideo;
  138034. private _generateMipMaps;
  138035. private _samplingMode;
  138036. /**
  138037. * Instantiates a HtmlElementTexture from the following parameters.
  138038. *
  138039. * @param name Defines the name of the texture
  138040. * @param element Defines the video or canvas the texture is filled with
  138041. * @param options Defines the other none mandatory texture creation options
  138042. */
  138043. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  138044. private _createInternalTexture;
  138045. /**
  138046. * Returns the texture matrix used in most of the material.
  138047. */
  138048. getTextureMatrix(): Matrix;
  138049. /**
  138050. * Updates the content of the texture.
  138051. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  138052. */
  138053. update(invertY?: Nullable<boolean>): void;
  138054. }
  138055. }
  138056. declare module BABYLON {
  138057. /**
  138058. * Based on jsTGALoader - Javascript loader for TGA file
  138059. * By Vincent Thibault
  138060. * @see http://blog.robrowser.com/javascript-tga-loader.html
  138061. */
  138062. export class TGATools {
  138063. private static _TYPE_INDEXED;
  138064. private static _TYPE_RGB;
  138065. private static _TYPE_GREY;
  138066. private static _TYPE_RLE_INDEXED;
  138067. private static _TYPE_RLE_RGB;
  138068. private static _TYPE_RLE_GREY;
  138069. private static _ORIGIN_MASK;
  138070. private static _ORIGIN_SHIFT;
  138071. private static _ORIGIN_BL;
  138072. private static _ORIGIN_BR;
  138073. private static _ORIGIN_UL;
  138074. private static _ORIGIN_UR;
  138075. /**
  138076. * Gets the header of a TGA file
  138077. * @param data defines the TGA data
  138078. * @returns the header
  138079. */
  138080. static GetTGAHeader(data: Uint8Array): any;
  138081. /**
  138082. * Uploads TGA content to a Babylon Texture
  138083. * @hidden
  138084. */
  138085. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  138086. /** @hidden */
  138087. 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;
  138088. /** @hidden */
  138089. 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;
  138090. /** @hidden */
  138091. 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;
  138092. /** @hidden */
  138093. 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;
  138094. /** @hidden */
  138095. 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;
  138096. /** @hidden */
  138097. 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;
  138098. }
  138099. }
  138100. declare module BABYLON {
  138101. /**
  138102. * Implementation of the TGA Texture Loader.
  138103. * @hidden
  138104. */
  138105. export class _TGATextureLoader implements IInternalTextureLoader {
  138106. /**
  138107. * Defines wether the loader supports cascade loading the different faces.
  138108. */
  138109. readonly supportCascades: boolean;
  138110. /**
  138111. * This returns if the loader support the current file information.
  138112. * @param extension defines the file extension of the file being loaded
  138113. * @returns true if the loader can load the specified file
  138114. */
  138115. canLoad(extension: string): boolean;
  138116. /**
  138117. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138118. * @param data contains the texture data
  138119. * @param texture defines the BabylonJS internal texture
  138120. * @param createPolynomials will be true if polynomials have been requested
  138121. * @param onLoad defines the callback to trigger once the texture is ready
  138122. * @param onError defines the callback to trigger in case of error
  138123. */
  138124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138125. /**
  138126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138127. * @param data contains the texture data
  138128. * @param texture defines the BabylonJS internal texture
  138129. * @param callback defines the method to call once ready to upload
  138130. */
  138131. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138132. }
  138133. }
  138134. declare module BABYLON {
  138135. /**
  138136. * Info about the .basis files
  138137. */
  138138. class BasisFileInfo {
  138139. /**
  138140. * If the file has alpha
  138141. */
  138142. hasAlpha: boolean;
  138143. /**
  138144. * Info about each image of the basis file
  138145. */
  138146. images: Array<{
  138147. levels: Array<{
  138148. width: number;
  138149. height: number;
  138150. transcodedPixels: ArrayBufferView;
  138151. }>;
  138152. }>;
  138153. }
  138154. /**
  138155. * Result of transcoding a basis file
  138156. */
  138157. class TranscodeResult {
  138158. /**
  138159. * Info about the .basis file
  138160. */
  138161. fileInfo: BasisFileInfo;
  138162. /**
  138163. * Format to use when loading the file
  138164. */
  138165. format: number;
  138166. }
  138167. /**
  138168. * Configuration options for the Basis transcoder
  138169. */
  138170. export class BasisTranscodeConfiguration {
  138171. /**
  138172. * Supported compression formats used to determine the supported output format of the transcoder
  138173. */
  138174. supportedCompressionFormats?: {
  138175. /**
  138176. * etc1 compression format
  138177. */
  138178. etc1?: boolean;
  138179. /**
  138180. * s3tc compression format
  138181. */
  138182. s3tc?: boolean;
  138183. /**
  138184. * pvrtc compression format
  138185. */
  138186. pvrtc?: boolean;
  138187. /**
  138188. * etc2 compression format
  138189. */
  138190. etc2?: boolean;
  138191. };
  138192. /**
  138193. * If mipmap levels should be loaded for transcoded images (Default: true)
  138194. */
  138195. loadMipmapLevels?: boolean;
  138196. /**
  138197. * Index of a single image to load (Default: all images)
  138198. */
  138199. loadSingleImage?: number;
  138200. }
  138201. /**
  138202. * Used to load .Basis files
  138203. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  138204. */
  138205. export class BasisTools {
  138206. private static _IgnoreSupportedFormats;
  138207. /**
  138208. * URL to use when loading the basis transcoder
  138209. */
  138210. static JSModuleURL: string;
  138211. /**
  138212. * URL to use when loading the wasm module for the transcoder
  138213. */
  138214. static WasmModuleURL: string;
  138215. /**
  138216. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  138217. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  138218. * @returns internal format corresponding to the Basis format
  138219. */
  138220. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  138221. private static _WorkerPromise;
  138222. private static _Worker;
  138223. private static _actionId;
  138224. private static _CreateWorkerAsync;
  138225. /**
  138226. * Transcodes a loaded image file to compressed pixel data
  138227. * @param data image data to transcode
  138228. * @param config configuration options for the transcoding
  138229. * @returns a promise resulting in the transcoded image
  138230. */
  138231. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  138232. /**
  138233. * Loads a texture from the transcode result
  138234. * @param texture texture load to
  138235. * @param transcodeResult the result of transcoding the basis file to load from
  138236. */
  138237. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  138238. }
  138239. }
  138240. declare module BABYLON {
  138241. /**
  138242. * Loader for .basis file format
  138243. */
  138244. export class _BasisTextureLoader implements IInternalTextureLoader {
  138245. /**
  138246. * Defines whether the loader supports cascade loading the different faces.
  138247. */
  138248. readonly supportCascades: boolean;
  138249. /**
  138250. * This returns if the loader support the current file information.
  138251. * @param extension defines the file extension of the file being loaded
  138252. * @returns true if the loader can load the specified file
  138253. */
  138254. canLoad(extension: string): boolean;
  138255. /**
  138256. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138257. * @param data contains the texture data
  138258. * @param texture defines the BabylonJS internal texture
  138259. * @param createPolynomials will be true if polynomials have been requested
  138260. * @param onLoad defines the callback to trigger once the texture is ready
  138261. * @param onError defines the callback to trigger in case of error
  138262. */
  138263. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138264. /**
  138265. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138266. * @param data contains the texture data
  138267. * @param texture defines the BabylonJS internal texture
  138268. * @param callback defines the method to call once ready to upload
  138269. */
  138270. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138271. }
  138272. }
  138273. declare module BABYLON {
  138274. /**
  138275. * Defines the basic options interface of a TexturePacker Frame
  138276. */
  138277. export interface ITexturePackerFrame {
  138278. /**
  138279. * The frame ID
  138280. */
  138281. id: number;
  138282. /**
  138283. * The frames Scale
  138284. */
  138285. scale: Vector2;
  138286. /**
  138287. * The Frames offset
  138288. */
  138289. offset: Vector2;
  138290. }
  138291. /**
  138292. * This is a support class for frame Data on texture packer sets.
  138293. */
  138294. export class TexturePackerFrame implements ITexturePackerFrame {
  138295. /**
  138296. * The frame ID
  138297. */
  138298. id: number;
  138299. /**
  138300. * The frames Scale
  138301. */
  138302. scale: Vector2;
  138303. /**
  138304. * The Frames offset
  138305. */
  138306. offset: Vector2;
  138307. /**
  138308. * Initializes a texture package frame.
  138309. * @param id The numerical frame identifier
  138310. * @param scale Scalar Vector2 for UV frame
  138311. * @param offset Vector2 for the frame position in UV units.
  138312. * @returns TexturePackerFrame
  138313. */
  138314. constructor(id: number, scale: Vector2, offset: Vector2);
  138315. }
  138316. }
  138317. declare module BABYLON {
  138318. /**
  138319. * Defines the basic options interface of a TexturePacker
  138320. */
  138321. export interface ITexturePackerOptions {
  138322. /**
  138323. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  138324. */
  138325. map?: string[];
  138326. /**
  138327. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  138328. */
  138329. uvsIn?: string;
  138330. /**
  138331. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  138332. */
  138333. uvsOut?: string;
  138334. /**
  138335. * number representing the layout style. Defaults to LAYOUT_STRIP
  138336. */
  138337. layout?: number;
  138338. /**
  138339. * number of columns if using custom column count layout(2). This defaults to 4.
  138340. */
  138341. colnum?: number;
  138342. /**
  138343. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  138344. */
  138345. updateInputMeshes?: boolean;
  138346. /**
  138347. * boolean flag to dispose all the source textures. Defaults to true.
  138348. */
  138349. disposeSources?: boolean;
  138350. /**
  138351. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  138352. */
  138353. fillBlanks?: boolean;
  138354. /**
  138355. * string value representing the context fill style color. Defaults to 'black'.
  138356. */
  138357. customFillColor?: string;
  138358. /**
  138359. * Width and Height Value of each Frame in the TexturePacker Sets
  138360. */
  138361. frameSize?: number;
  138362. /**
  138363. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  138364. */
  138365. paddingRatio?: number;
  138366. /**
  138367. * Number that declares the fill method for the padding gutter.
  138368. */
  138369. paddingMode?: number;
  138370. /**
  138371. * If in SUBUV_COLOR padding mode what color to use.
  138372. */
  138373. paddingColor?: Color3 | Color4;
  138374. }
  138375. /**
  138376. * Defines the basic interface of a TexturePacker JSON File
  138377. */
  138378. export interface ITexturePackerJSON {
  138379. /**
  138380. * The frame ID
  138381. */
  138382. name: string;
  138383. /**
  138384. * The base64 channel data
  138385. */
  138386. sets: any;
  138387. /**
  138388. * The options of the Packer
  138389. */
  138390. options: ITexturePackerOptions;
  138391. /**
  138392. * The frame data of the Packer
  138393. */
  138394. frames: Array<number>;
  138395. }
  138396. /**
  138397. * This is a support class that generates a series of packed texture sets.
  138398. * @see https://doc.babylonjs.com/babylon101/materials
  138399. */
  138400. export class TexturePacker {
  138401. /** Packer Layout Constant 0 */
  138402. static readonly LAYOUT_STRIP: number;
  138403. /** Packer Layout Constant 1 */
  138404. static readonly LAYOUT_POWER2: number;
  138405. /** Packer Layout Constant 2 */
  138406. static readonly LAYOUT_COLNUM: number;
  138407. /** Packer Layout Constant 0 */
  138408. static readonly SUBUV_WRAP: number;
  138409. /** Packer Layout Constant 1 */
  138410. static readonly SUBUV_EXTEND: number;
  138411. /** Packer Layout Constant 2 */
  138412. static readonly SUBUV_COLOR: number;
  138413. /** The Name of the Texture Package */
  138414. name: string;
  138415. /** The scene scope of the TexturePacker */
  138416. scene: Scene;
  138417. /** The Meshes to target */
  138418. meshes: AbstractMesh[];
  138419. /** Arguments passed with the Constructor */
  138420. options: ITexturePackerOptions;
  138421. /** The promise that is started upon initialization */
  138422. promise: Nullable<Promise<TexturePacker | string>>;
  138423. /** The Container object for the channel sets that are generated */
  138424. sets: object;
  138425. /** The Container array for the frames that are generated */
  138426. frames: TexturePackerFrame[];
  138427. /** The expected number of textures the system is parsing. */
  138428. private _expecting;
  138429. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  138430. private _paddingValue;
  138431. /**
  138432. * Initializes a texture package series from an array of meshes or a single mesh.
  138433. * @param name The name of the package
  138434. * @param meshes The target meshes to compose the package from
  138435. * @param options The arguments that texture packer should follow while building.
  138436. * @param scene The scene which the textures are scoped to.
  138437. * @returns TexturePacker
  138438. */
  138439. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  138440. /**
  138441. * Starts the package process
  138442. * @param resolve The promises resolution function
  138443. * @returns TexturePacker
  138444. */
  138445. private _createFrames;
  138446. /**
  138447. * Calculates the Size of the Channel Sets
  138448. * @returns Vector2
  138449. */
  138450. private _calculateSize;
  138451. /**
  138452. * Calculates the UV data for the frames.
  138453. * @param baseSize the base frameSize
  138454. * @param padding the base frame padding
  138455. * @param dtSize size of the Dynamic Texture for that channel
  138456. * @param dtUnits is 1/dtSize
  138457. * @param update flag to update the input meshes
  138458. */
  138459. private _calculateMeshUVFrames;
  138460. /**
  138461. * Calculates the frames Offset.
  138462. * @param index of the frame
  138463. * @returns Vector2
  138464. */
  138465. private _getFrameOffset;
  138466. /**
  138467. * Updates a Mesh to the frame data
  138468. * @param mesh that is the target
  138469. * @param frameID or the frame index
  138470. */
  138471. private _updateMeshUV;
  138472. /**
  138473. * Updates a Meshes materials to use the texture packer channels
  138474. * @param m is the mesh to target
  138475. * @param force all channels on the packer to be set.
  138476. */
  138477. private _updateTextureReferences;
  138478. /**
  138479. * Public method to set a Mesh to a frame
  138480. * @param m that is the target
  138481. * @param frameID or the frame index
  138482. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  138483. */
  138484. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  138485. /**
  138486. * Starts the async promise to compile the texture packer.
  138487. * @returns Promise<void>
  138488. */
  138489. processAsync(): Promise<void>;
  138490. /**
  138491. * Disposes all textures associated with this packer
  138492. */
  138493. dispose(): void;
  138494. /**
  138495. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  138496. * @param imageType is the image type to use.
  138497. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  138498. */
  138499. download(imageType?: string, quality?: number): void;
  138500. /**
  138501. * Public method to load a texturePacker JSON file.
  138502. * @param data of the JSON file in string format.
  138503. */
  138504. updateFromJSON(data: string): void;
  138505. }
  138506. }
  138507. declare module BABYLON {
  138508. /**
  138509. * 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.
  138510. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138511. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138512. */
  138513. export class CustomProceduralTexture extends ProceduralTexture {
  138514. private _animate;
  138515. private _time;
  138516. private _config;
  138517. private _texturePath;
  138518. /**
  138519. * Instantiates a new Custom Procedural Texture.
  138520. * 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.
  138521. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138522. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138523. * @param name Define the name of the texture
  138524. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  138525. * @param size Define the size of the texture to create
  138526. * @param scene Define the scene the texture belongs to
  138527. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  138528. * @param generateMipMaps Define if the texture should creates mip maps or not
  138529. */
  138530. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138531. private _loadJson;
  138532. /**
  138533. * Is the texture ready to be used ? (rendered at least once)
  138534. * @returns true if ready, otherwise, false.
  138535. */
  138536. isReady(): boolean;
  138537. /**
  138538. * Render the texture to its associated render target.
  138539. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  138540. */
  138541. render(useCameraPostProcess?: boolean): void;
  138542. /**
  138543. * Update the list of dependant textures samplers in the shader.
  138544. */
  138545. updateTextures(): void;
  138546. /**
  138547. * Update the uniform values of the procedural texture in the shader.
  138548. */
  138549. updateShaderUniforms(): void;
  138550. /**
  138551. * Define if the texture animates or not.
  138552. */
  138553. get animate(): boolean;
  138554. set animate(value: boolean);
  138555. }
  138556. }
  138557. declare module BABYLON {
  138558. /** @hidden */
  138559. export var noisePixelShader: {
  138560. name: string;
  138561. shader: string;
  138562. };
  138563. }
  138564. declare module BABYLON {
  138565. /**
  138566. * Class used to generate noise procedural textures
  138567. */
  138568. export class NoiseProceduralTexture extends ProceduralTexture {
  138569. private _time;
  138570. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  138571. brightness: number;
  138572. /** Defines the number of octaves to process */
  138573. octaves: number;
  138574. /** Defines the level of persistence (0.8 by default) */
  138575. persistence: number;
  138576. /** Gets or sets animation speed factor (default is 1) */
  138577. animationSpeedFactor: number;
  138578. /**
  138579. * Creates a new NoiseProceduralTexture
  138580. * @param name defines the name fo the texture
  138581. * @param size defines the size of the texture (default is 256)
  138582. * @param scene defines the hosting scene
  138583. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  138584. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  138585. */
  138586. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138587. private _updateShaderUniforms;
  138588. protected _getDefines(): string;
  138589. /** Generate the current state of the procedural texture */
  138590. render(useCameraPostProcess?: boolean): void;
  138591. /**
  138592. * Serializes this noise procedural texture
  138593. * @returns a serialized noise procedural texture object
  138594. */
  138595. serialize(): any;
  138596. /**
  138597. * Clone the texture.
  138598. * @returns the cloned texture
  138599. */
  138600. clone(): NoiseProceduralTexture;
  138601. /**
  138602. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  138603. * @param parsedTexture defines parsed texture data
  138604. * @param scene defines the current scene
  138605. * @param rootUrl defines the root URL containing noise procedural texture information
  138606. * @returns a parsed NoiseProceduralTexture
  138607. */
  138608. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  138609. }
  138610. }
  138611. declare module BABYLON {
  138612. /**
  138613. * Raw cube texture where the raw buffers are passed in
  138614. */
  138615. export class RawCubeTexture extends CubeTexture {
  138616. /**
  138617. * Creates a cube texture where the raw buffers are passed in.
  138618. * @param scene defines the scene the texture is attached to
  138619. * @param data defines the array of data to use to create each face
  138620. * @param size defines the size of the textures
  138621. * @param format defines the format of the data
  138622. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  138623. * @param generateMipMaps defines if the engine should generate the mip levels
  138624. * @param invertY defines if data must be stored with Y axis inverted
  138625. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  138626. * @param compression defines the compression used (null by default)
  138627. */
  138628. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  138629. /**
  138630. * Updates the raw cube texture.
  138631. * @param data defines the data to store
  138632. * @param format defines the data format
  138633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138634. * @param invertY defines if data must be stored with Y axis inverted
  138635. * @param compression defines the compression used (null by default)
  138636. * @param level defines which level of the texture to update
  138637. */
  138638. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  138639. /**
  138640. * Updates a raw cube texture with RGBD encoded data.
  138641. * @param data defines the array of data [mipmap][face] to use to create each face
  138642. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  138643. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138644. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138645. * @returns a promsie that resolves when the operation is complete
  138646. */
  138647. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  138648. /**
  138649. * Clones the raw cube texture.
  138650. * @return a new cube texture
  138651. */
  138652. clone(): CubeTexture;
  138653. /** @hidden */
  138654. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138655. }
  138656. }
  138657. declare module BABYLON {
  138658. /**
  138659. * Class used to store 2D array textures containing user data
  138660. */
  138661. export class RawTexture2DArray extends Texture {
  138662. /** Gets or sets the texture format to use */
  138663. format: number;
  138664. /**
  138665. * Create a new RawTexture2DArray
  138666. * @param data defines the data of the texture
  138667. * @param width defines the width of the texture
  138668. * @param height defines the height of the texture
  138669. * @param depth defines the number of layers of the texture
  138670. * @param format defines the texture format to use
  138671. * @param scene defines the hosting scene
  138672. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138673. * @param invertY defines if texture must be stored with Y axis inverted
  138674. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138675. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138676. */
  138677. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138678. /** Gets or sets the texture format to use */
  138679. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138680. /**
  138681. * Update the texture with new data
  138682. * @param data defines the data to store in the texture
  138683. */
  138684. update(data: ArrayBufferView): void;
  138685. }
  138686. }
  138687. declare module BABYLON {
  138688. /**
  138689. * Class used to store 3D textures containing user data
  138690. */
  138691. export class RawTexture3D extends Texture {
  138692. /** Gets or sets the texture format to use */
  138693. format: number;
  138694. /**
  138695. * Create a new RawTexture3D
  138696. * @param data defines the data of the texture
  138697. * @param width defines the width of the texture
  138698. * @param height defines the height of the texture
  138699. * @param depth defines the depth of the texture
  138700. * @param format defines the texture format to use
  138701. * @param scene defines the hosting scene
  138702. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138703. * @param invertY defines if texture must be stored with Y axis inverted
  138704. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138705. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138706. */
  138707. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138708. /** Gets or sets the texture format to use */
  138709. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138710. /**
  138711. * Update the texture with new data
  138712. * @param data defines the data to store in the texture
  138713. */
  138714. update(data: ArrayBufferView): void;
  138715. }
  138716. }
  138717. declare module BABYLON {
  138718. /**
  138719. * Creates a refraction texture used by refraction channel of the standard material.
  138720. * It is like a mirror but to see through a material.
  138721. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138722. */
  138723. export class RefractionTexture extends RenderTargetTexture {
  138724. /**
  138725. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  138726. * 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.
  138727. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138728. */
  138729. refractionPlane: Plane;
  138730. /**
  138731. * Define how deep under the surface we should see.
  138732. */
  138733. depth: number;
  138734. /**
  138735. * Creates a refraction texture used by refraction channel of the standard material.
  138736. * It is like a mirror but to see through a material.
  138737. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138738. * @param name Define the texture name
  138739. * @param size Define the size of the underlying texture
  138740. * @param scene Define the scene the refraction belongs to
  138741. * @param generateMipMaps Define if we need to generate mips level for the refraction
  138742. */
  138743. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  138744. /**
  138745. * Clone the refraction texture.
  138746. * @returns the cloned texture
  138747. */
  138748. clone(): RefractionTexture;
  138749. /**
  138750. * Serialize the texture to a JSON representation you could use in Parse later on
  138751. * @returns the serialized JSON representation
  138752. */
  138753. serialize(): any;
  138754. }
  138755. }
  138756. declare module BABYLON {
  138757. /**
  138758. * Block used to add support for vertex skinning (bones)
  138759. */
  138760. export class BonesBlock extends NodeMaterialBlock {
  138761. /**
  138762. * Creates a new BonesBlock
  138763. * @param name defines the block name
  138764. */
  138765. constructor(name: string);
  138766. /**
  138767. * Initialize the block and prepare the context for build
  138768. * @param state defines the state that will be used for the build
  138769. */
  138770. initialize(state: NodeMaterialBuildState): void;
  138771. /**
  138772. * Gets the current class name
  138773. * @returns the class name
  138774. */
  138775. getClassName(): string;
  138776. /**
  138777. * Gets the matrix indices input component
  138778. */
  138779. get matricesIndices(): NodeMaterialConnectionPoint;
  138780. /**
  138781. * Gets the matrix weights input component
  138782. */
  138783. get matricesWeights(): NodeMaterialConnectionPoint;
  138784. /**
  138785. * Gets the extra matrix indices input component
  138786. */
  138787. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  138788. /**
  138789. * Gets the extra matrix weights input component
  138790. */
  138791. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  138792. /**
  138793. * Gets the world input component
  138794. */
  138795. get world(): NodeMaterialConnectionPoint;
  138796. /**
  138797. * Gets the output component
  138798. */
  138799. get output(): NodeMaterialConnectionPoint;
  138800. autoConfigure(material: NodeMaterial): void;
  138801. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  138802. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138803. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138804. protected _buildBlock(state: NodeMaterialBuildState): this;
  138805. }
  138806. }
  138807. declare module BABYLON {
  138808. /**
  138809. * Block used to add support for instances
  138810. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  138811. */
  138812. export class InstancesBlock extends NodeMaterialBlock {
  138813. /**
  138814. * Creates a new InstancesBlock
  138815. * @param name defines the block name
  138816. */
  138817. constructor(name: string);
  138818. /**
  138819. * Gets the current class name
  138820. * @returns the class name
  138821. */
  138822. getClassName(): string;
  138823. /**
  138824. * Gets the first world row input component
  138825. */
  138826. get world0(): NodeMaterialConnectionPoint;
  138827. /**
  138828. * Gets the second world row input component
  138829. */
  138830. get world1(): NodeMaterialConnectionPoint;
  138831. /**
  138832. * Gets the third world row input component
  138833. */
  138834. get world2(): NodeMaterialConnectionPoint;
  138835. /**
  138836. * Gets the forth world row input component
  138837. */
  138838. get world3(): NodeMaterialConnectionPoint;
  138839. /**
  138840. * Gets the world input component
  138841. */
  138842. get world(): NodeMaterialConnectionPoint;
  138843. /**
  138844. * Gets the output component
  138845. */
  138846. get output(): NodeMaterialConnectionPoint;
  138847. /**
  138848. * Gets the isntanceID component
  138849. */
  138850. get instanceID(): NodeMaterialConnectionPoint;
  138851. autoConfigure(material: NodeMaterial): void;
  138852. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  138853. protected _buildBlock(state: NodeMaterialBuildState): this;
  138854. }
  138855. }
  138856. declare module BABYLON {
  138857. /**
  138858. * Block used to add morph targets support to vertex shader
  138859. */
  138860. export class MorphTargetsBlock extends NodeMaterialBlock {
  138861. private _repeatableContentAnchor;
  138862. /**
  138863. * Create a new MorphTargetsBlock
  138864. * @param name defines the block name
  138865. */
  138866. constructor(name: string);
  138867. /**
  138868. * Gets the current class name
  138869. * @returns the class name
  138870. */
  138871. getClassName(): string;
  138872. /**
  138873. * Gets the position input component
  138874. */
  138875. get position(): NodeMaterialConnectionPoint;
  138876. /**
  138877. * Gets the normal input component
  138878. */
  138879. get normal(): NodeMaterialConnectionPoint;
  138880. /**
  138881. * Gets the tangent input component
  138882. */
  138883. get tangent(): NodeMaterialConnectionPoint;
  138884. /**
  138885. * Gets the tangent input component
  138886. */
  138887. get uv(): NodeMaterialConnectionPoint;
  138888. /**
  138889. * Gets the position output component
  138890. */
  138891. get positionOutput(): NodeMaterialConnectionPoint;
  138892. /**
  138893. * Gets the normal output component
  138894. */
  138895. get normalOutput(): NodeMaterialConnectionPoint;
  138896. /**
  138897. * Gets the tangent output component
  138898. */
  138899. get tangentOutput(): NodeMaterialConnectionPoint;
  138900. /**
  138901. * Gets the tangent output component
  138902. */
  138903. get uvOutput(): NodeMaterialConnectionPoint;
  138904. initialize(state: NodeMaterialBuildState): void;
  138905. autoConfigure(material: NodeMaterial): void;
  138906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138907. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138908. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  138909. protected _buildBlock(state: NodeMaterialBuildState): this;
  138910. }
  138911. }
  138912. declare module BABYLON {
  138913. /**
  138914. * Block used to get data information from a light
  138915. */
  138916. export class LightInformationBlock extends NodeMaterialBlock {
  138917. private _lightDataUniformName;
  138918. private _lightColorUniformName;
  138919. private _lightTypeDefineName;
  138920. /**
  138921. * Gets or sets the light associated with this block
  138922. */
  138923. light: Nullable<Light>;
  138924. /**
  138925. * Creates a new LightInformationBlock
  138926. * @param name defines the block name
  138927. */
  138928. constructor(name: string);
  138929. /**
  138930. * Gets the current class name
  138931. * @returns the class name
  138932. */
  138933. getClassName(): string;
  138934. /**
  138935. * Gets the world position input component
  138936. */
  138937. get worldPosition(): NodeMaterialConnectionPoint;
  138938. /**
  138939. * Gets the direction output component
  138940. */
  138941. get direction(): NodeMaterialConnectionPoint;
  138942. /**
  138943. * Gets the direction output component
  138944. */
  138945. get color(): NodeMaterialConnectionPoint;
  138946. /**
  138947. * Gets the direction output component
  138948. */
  138949. get intensity(): NodeMaterialConnectionPoint;
  138950. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138952. protected _buildBlock(state: NodeMaterialBuildState): this;
  138953. serialize(): any;
  138954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138955. }
  138956. }
  138957. declare module BABYLON {
  138958. /**
  138959. * Block used to add image processing support to fragment shader
  138960. */
  138961. export class ImageProcessingBlock extends NodeMaterialBlock {
  138962. /**
  138963. * Create a new ImageProcessingBlock
  138964. * @param name defines the block name
  138965. */
  138966. constructor(name: string);
  138967. /**
  138968. * Gets the current class name
  138969. * @returns the class name
  138970. */
  138971. getClassName(): string;
  138972. /**
  138973. * Gets the color input component
  138974. */
  138975. get color(): NodeMaterialConnectionPoint;
  138976. /**
  138977. * Gets the output component
  138978. */
  138979. get output(): NodeMaterialConnectionPoint;
  138980. /**
  138981. * Initialize the block and prepare the context for build
  138982. * @param state defines the state that will be used for the build
  138983. */
  138984. initialize(state: NodeMaterialBuildState): void;
  138985. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  138986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138987. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138988. protected _buildBlock(state: NodeMaterialBuildState): this;
  138989. }
  138990. }
  138991. declare module BABYLON {
  138992. /**
  138993. * Block used to pertub normals based on a normal map
  138994. */
  138995. export class PerturbNormalBlock extends NodeMaterialBlock {
  138996. private _tangentSpaceParameterName;
  138997. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  138998. invertX: boolean;
  138999. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  139000. invertY: boolean;
  139001. /**
  139002. * Create a new PerturbNormalBlock
  139003. * @param name defines the block name
  139004. */
  139005. constructor(name: string);
  139006. /**
  139007. * Gets the current class name
  139008. * @returns the class name
  139009. */
  139010. getClassName(): string;
  139011. /**
  139012. * Gets the world position input component
  139013. */
  139014. get worldPosition(): NodeMaterialConnectionPoint;
  139015. /**
  139016. * Gets the world normal input component
  139017. */
  139018. get worldNormal(): NodeMaterialConnectionPoint;
  139019. /**
  139020. * Gets the world tangent input component
  139021. */
  139022. get worldTangent(): NodeMaterialConnectionPoint;
  139023. /**
  139024. * Gets the uv input component
  139025. */
  139026. get uv(): NodeMaterialConnectionPoint;
  139027. /**
  139028. * Gets the normal map color input component
  139029. */
  139030. get normalMapColor(): NodeMaterialConnectionPoint;
  139031. /**
  139032. * Gets the strength input component
  139033. */
  139034. get strength(): NodeMaterialConnectionPoint;
  139035. /**
  139036. * Gets the output component
  139037. */
  139038. get output(): NodeMaterialConnectionPoint;
  139039. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139040. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139041. autoConfigure(material: NodeMaterial): void;
  139042. protected _buildBlock(state: NodeMaterialBuildState): this;
  139043. protected _dumpPropertiesCode(): string;
  139044. serialize(): any;
  139045. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139046. }
  139047. }
  139048. declare module BABYLON {
  139049. /**
  139050. * Block used to discard a pixel if a value is smaller than a cutoff
  139051. */
  139052. export class DiscardBlock extends NodeMaterialBlock {
  139053. /**
  139054. * Create a new DiscardBlock
  139055. * @param name defines the block name
  139056. */
  139057. constructor(name: string);
  139058. /**
  139059. * Gets the current class name
  139060. * @returns the class name
  139061. */
  139062. getClassName(): string;
  139063. /**
  139064. * Gets the color input component
  139065. */
  139066. get value(): NodeMaterialConnectionPoint;
  139067. /**
  139068. * Gets the cutoff input component
  139069. */
  139070. get cutoff(): NodeMaterialConnectionPoint;
  139071. protected _buildBlock(state: NodeMaterialBuildState): this;
  139072. }
  139073. }
  139074. declare module BABYLON {
  139075. /**
  139076. * Block used to test if the fragment shader is front facing
  139077. */
  139078. export class FrontFacingBlock extends NodeMaterialBlock {
  139079. /**
  139080. * Creates a new FrontFacingBlock
  139081. * @param name defines the block name
  139082. */
  139083. constructor(name: string);
  139084. /**
  139085. * Gets the current class name
  139086. * @returns the class name
  139087. */
  139088. getClassName(): string;
  139089. /**
  139090. * Gets the output component
  139091. */
  139092. get output(): NodeMaterialConnectionPoint;
  139093. protected _buildBlock(state: NodeMaterialBuildState): this;
  139094. }
  139095. }
  139096. declare module BABYLON {
  139097. /**
  139098. * Block used to get the derivative value on x and y of a given input
  139099. */
  139100. export class DerivativeBlock extends NodeMaterialBlock {
  139101. /**
  139102. * Create a new DerivativeBlock
  139103. * @param name defines the block name
  139104. */
  139105. constructor(name: string);
  139106. /**
  139107. * Gets the current class name
  139108. * @returns the class name
  139109. */
  139110. getClassName(): string;
  139111. /**
  139112. * Gets the input component
  139113. */
  139114. get input(): NodeMaterialConnectionPoint;
  139115. /**
  139116. * Gets the derivative output on x
  139117. */
  139118. get dx(): NodeMaterialConnectionPoint;
  139119. /**
  139120. * Gets the derivative output on y
  139121. */
  139122. get dy(): NodeMaterialConnectionPoint;
  139123. protected _buildBlock(state: NodeMaterialBuildState): this;
  139124. }
  139125. }
  139126. declare module BABYLON {
  139127. /**
  139128. * Block used to make gl_FragCoord available
  139129. */
  139130. export class FragCoordBlock extends NodeMaterialBlock {
  139131. /**
  139132. * Creates a new FragCoordBlock
  139133. * @param name defines the block name
  139134. */
  139135. constructor(name: string);
  139136. /**
  139137. * Gets the current class name
  139138. * @returns the class name
  139139. */
  139140. getClassName(): string;
  139141. /**
  139142. * Gets the xy component
  139143. */
  139144. get xy(): NodeMaterialConnectionPoint;
  139145. /**
  139146. * Gets the xyz component
  139147. */
  139148. get xyz(): NodeMaterialConnectionPoint;
  139149. /**
  139150. * Gets the xyzw component
  139151. */
  139152. get xyzw(): NodeMaterialConnectionPoint;
  139153. /**
  139154. * Gets the x component
  139155. */
  139156. get x(): NodeMaterialConnectionPoint;
  139157. /**
  139158. * Gets the y component
  139159. */
  139160. get y(): NodeMaterialConnectionPoint;
  139161. /**
  139162. * Gets the z component
  139163. */
  139164. get z(): NodeMaterialConnectionPoint;
  139165. /**
  139166. * Gets the w component
  139167. */
  139168. get output(): NodeMaterialConnectionPoint;
  139169. protected writeOutputs(state: NodeMaterialBuildState): string;
  139170. protected _buildBlock(state: NodeMaterialBuildState): this;
  139171. }
  139172. }
  139173. declare module BABYLON {
  139174. /**
  139175. * Block used to get the screen sizes
  139176. */
  139177. export class ScreenSizeBlock extends NodeMaterialBlock {
  139178. private _varName;
  139179. private _scene;
  139180. /**
  139181. * Creates a new ScreenSizeBlock
  139182. * @param name defines the block name
  139183. */
  139184. constructor(name: string);
  139185. /**
  139186. * Gets the current class name
  139187. * @returns the class name
  139188. */
  139189. getClassName(): string;
  139190. /**
  139191. * Gets the xy component
  139192. */
  139193. get xy(): NodeMaterialConnectionPoint;
  139194. /**
  139195. * Gets the x component
  139196. */
  139197. get x(): NodeMaterialConnectionPoint;
  139198. /**
  139199. * Gets the y component
  139200. */
  139201. get y(): NodeMaterialConnectionPoint;
  139202. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139203. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  139204. protected _buildBlock(state: NodeMaterialBuildState): this;
  139205. }
  139206. }
  139207. declare module BABYLON {
  139208. /**
  139209. * Block used to add support for scene fog
  139210. */
  139211. export class FogBlock extends NodeMaterialBlock {
  139212. private _fogDistanceName;
  139213. private _fogParameters;
  139214. /**
  139215. * Create a new FogBlock
  139216. * @param name defines the block name
  139217. */
  139218. constructor(name: string);
  139219. /**
  139220. * Gets the current class name
  139221. * @returns the class name
  139222. */
  139223. getClassName(): string;
  139224. /**
  139225. * Gets the world position input component
  139226. */
  139227. get worldPosition(): NodeMaterialConnectionPoint;
  139228. /**
  139229. * Gets the view input component
  139230. */
  139231. get view(): NodeMaterialConnectionPoint;
  139232. /**
  139233. * Gets the color input component
  139234. */
  139235. get input(): NodeMaterialConnectionPoint;
  139236. /**
  139237. * Gets the fog color input component
  139238. */
  139239. get fogColor(): NodeMaterialConnectionPoint;
  139240. /**
  139241. * Gets the output component
  139242. */
  139243. get output(): NodeMaterialConnectionPoint;
  139244. autoConfigure(material: NodeMaterial): void;
  139245. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139246. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139247. protected _buildBlock(state: NodeMaterialBuildState): this;
  139248. }
  139249. }
  139250. declare module BABYLON {
  139251. /**
  139252. * Block used to add light in the fragment shader
  139253. */
  139254. export class LightBlock extends NodeMaterialBlock {
  139255. private _lightId;
  139256. /**
  139257. * Gets or sets the light associated with this block
  139258. */
  139259. light: Nullable<Light>;
  139260. /**
  139261. * Create a new LightBlock
  139262. * @param name defines the block name
  139263. */
  139264. constructor(name: string);
  139265. /**
  139266. * Gets the current class name
  139267. * @returns the class name
  139268. */
  139269. getClassName(): string;
  139270. /**
  139271. * Gets the world position input component
  139272. */
  139273. get worldPosition(): NodeMaterialConnectionPoint;
  139274. /**
  139275. * Gets the world normal input component
  139276. */
  139277. get worldNormal(): NodeMaterialConnectionPoint;
  139278. /**
  139279. * Gets the camera (or eye) position component
  139280. */
  139281. get cameraPosition(): NodeMaterialConnectionPoint;
  139282. /**
  139283. * Gets the glossiness component
  139284. */
  139285. get glossiness(): NodeMaterialConnectionPoint;
  139286. /**
  139287. * Gets the glossinness power component
  139288. */
  139289. get glossPower(): NodeMaterialConnectionPoint;
  139290. /**
  139291. * Gets the diffuse color component
  139292. */
  139293. get diffuseColor(): NodeMaterialConnectionPoint;
  139294. /**
  139295. * Gets the specular color component
  139296. */
  139297. get specularColor(): NodeMaterialConnectionPoint;
  139298. /**
  139299. * Gets the diffuse output component
  139300. */
  139301. get diffuseOutput(): NodeMaterialConnectionPoint;
  139302. /**
  139303. * Gets the specular output component
  139304. */
  139305. get specularOutput(): NodeMaterialConnectionPoint;
  139306. /**
  139307. * Gets the shadow output component
  139308. */
  139309. get shadow(): NodeMaterialConnectionPoint;
  139310. autoConfigure(material: NodeMaterial): void;
  139311. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139312. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  139313. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139314. private _injectVertexCode;
  139315. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139316. serialize(): any;
  139317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139318. }
  139319. }
  139320. declare module BABYLON {
  139321. /**
  139322. * Block used to read a reflection texture from a sampler
  139323. */
  139324. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  139325. /**
  139326. * Create a new ReflectionTextureBlock
  139327. * @param name defines the block name
  139328. */
  139329. constructor(name: string);
  139330. /**
  139331. * Gets the current class name
  139332. * @returns the class name
  139333. */
  139334. getClassName(): string;
  139335. /**
  139336. * Gets the world position input component
  139337. */
  139338. get position(): NodeMaterialConnectionPoint;
  139339. /**
  139340. * Gets the world position input component
  139341. */
  139342. get worldPosition(): NodeMaterialConnectionPoint;
  139343. /**
  139344. * Gets the world normal input component
  139345. */
  139346. get worldNormal(): NodeMaterialConnectionPoint;
  139347. /**
  139348. * Gets the world input component
  139349. */
  139350. get world(): NodeMaterialConnectionPoint;
  139351. /**
  139352. * Gets the camera (or eye) position component
  139353. */
  139354. get cameraPosition(): NodeMaterialConnectionPoint;
  139355. /**
  139356. * Gets the view input component
  139357. */
  139358. get view(): NodeMaterialConnectionPoint;
  139359. /**
  139360. * Gets the rgb output component
  139361. */
  139362. get rgb(): NodeMaterialConnectionPoint;
  139363. /**
  139364. * Gets the r output component
  139365. */
  139366. get r(): NodeMaterialConnectionPoint;
  139367. /**
  139368. * Gets the g output component
  139369. */
  139370. get g(): NodeMaterialConnectionPoint;
  139371. /**
  139372. * Gets the b output component
  139373. */
  139374. get b(): NodeMaterialConnectionPoint;
  139375. autoConfigure(material: NodeMaterial): void;
  139376. protected _buildBlock(state: NodeMaterialBuildState): this;
  139377. }
  139378. }
  139379. declare module BABYLON {
  139380. /**
  139381. * Block used to add 2 vectors
  139382. */
  139383. export class AddBlock extends NodeMaterialBlock {
  139384. /**
  139385. * Creates a new AddBlock
  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 output component
  139404. */
  139405. get output(): NodeMaterialConnectionPoint;
  139406. protected _buildBlock(state: NodeMaterialBuildState): this;
  139407. }
  139408. }
  139409. declare module BABYLON {
  139410. /**
  139411. * Block used to scale a vector by a float
  139412. */
  139413. export class ScaleBlock extends NodeMaterialBlock {
  139414. /**
  139415. * Creates a new ScaleBlock
  139416. * @param name defines the block name
  139417. */
  139418. constructor(name: string);
  139419. /**
  139420. * Gets the current class name
  139421. * @returns the class name
  139422. */
  139423. getClassName(): string;
  139424. /**
  139425. * Gets the input component
  139426. */
  139427. get input(): NodeMaterialConnectionPoint;
  139428. /**
  139429. * Gets the factor input component
  139430. */
  139431. get factor(): NodeMaterialConnectionPoint;
  139432. /**
  139433. * Gets the output component
  139434. */
  139435. get output(): NodeMaterialConnectionPoint;
  139436. protected _buildBlock(state: NodeMaterialBuildState): this;
  139437. }
  139438. }
  139439. declare module BABYLON {
  139440. /**
  139441. * Block used to clamp a float
  139442. */
  139443. export class ClampBlock extends NodeMaterialBlock {
  139444. /** Gets or sets the minimum range */
  139445. minimum: number;
  139446. /** Gets or sets the maximum range */
  139447. maximum: number;
  139448. /**
  139449. * Creates a new ClampBlock
  139450. * @param name defines the block name
  139451. */
  139452. constructor(name: string);
  139453. /**
  139454. * Gets the current class name
  139455. * @returns the class name
  139456. */
  139457. getClassName(): string;
  139458. /**
  139459. * Gets the value input component
  139460. */
  139461. get value(): NodeMaterialConnectionPoint;
  139462. /**
  139463. * Gets the output component
  139464. */
  139465. get output(): NodeMaterialConnectionPoint;
  139466. protected _buildBlock(state: NodeMaterialBuildState): this;
  139467. protected _dumpPropertiesCode(): string;
  139468. serialize(): any;
  139469. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139470. }
  139471. }
  139472. declare module BABYLON {
  139473. /**
  139474. * Block used to apply a cross product between 2 vectors
  139475. */
  139476. export class CrossBlock extends NodeMaterialBlock {
  139477. /**
  139478. * Creates a new CrossBlock
  139479. * @param name defines the block name
  139480. */
  139481. constructor(name: string);
  139482. /**
  139483. * Gets the current class name
  139484. * @returns the class name
  139485. */
  139486. getClassName(): string;
  139487. /**
  139488. * Gets the left operand input component
  139489. */
  139490. get left(): NodeMaterialConnectionPoint;
  139491. /**
  139492. * Gets the right operand input component
  139493. */
  139494. get right(): NodeMaterialConnectionPoint;
  139495. /**
  139496. * Gets the output component
  139497. */
  139498. get output(): NodeMaterialConnectionPoint;
  139499. protected _buildBlock(state: NodeMaterialBuildState): this;
  139500. }
  139501. }
  139502. declare module BABYLON {
  139503. /**
  139504. * Block used to apply a dot product between 2 vectors
  139505. */
  139506. export class DotBlock extends NodeMaterialBlock {
  139507. /**
  139508. * Creates a new DotBlock
  139509. * @param name defines the block name
  139510. */
  139511. constructor(name: string);
  139512. /**
  139513. * Gets the current class name
  139514. * @returns the class name
  139515. */
  139516. getClassName(): string;
  139517. /**
  139518. * Gets the left operand input component
  139519. */
  139520. get left(): NodeMaterialConnectionPoint;
  139521. /**
  139522. * Gets the right operand input component
  139523. */
  139524. get right(): NodeMaterialConnectionPoint;
  139525. /**
  139526. * Gets the output component
  139527. */
  139528. get output(): NodeMaterialConnectionPoint;
  139529. protected _buildBlock(state: NodeMaterialBuildState): this;
  139530. }
  139531. }
  139532. declare module BABYLON {
  139533. /**
  139534. * Block used to normalize a vector
  139535. */
  139536. export class NormalizeBlock extends NodeMaterialBlock {
  139537. /**
  139538. * Creates a new NormalizeBlock
  139539. * @param name defines the block name
  139540. */
  139541. constructor(name: string);
  139542. /**
  139543. * Gets the current class name
  139544. * @returns the class name
  139545. */
  139546. getClassName(): string;
  139547. /**
  139548. * Gets the input component
  139549. */
  139550. get input(): NodeMaterialConnectionPoint;
  139551. /**
  139552. * Gets the output component
  139553. */
  139554. get output(): NodeMaterialConnectionPoint;
  139555. protected _buildBlock(state: NodeMaterialBuildState): this;
  139556. }
  139557. }
  139558. declare module BABYLON {
  139559. /**
  139560. * Operations supported by the Trigonometry block
  139561. */
  139562. export enum TrigonometryBlockOperations {
  139563. /** Cos */
  139564. Cos = 0,
  139565. /** Sin */
  139566. Sin = 1,
  139567. /** Abs */
  139568. Abs = 2,
  139569. /** Exp */
  139570. Exp = 3,
  139571. /** Exp2 */
  139572. Exp2 = 4,
  139573. /** Round */
  139574. Round = 5,
  139575. /** Floor */
  139576. Floor = 6,
  139577. /** Ceiling */
  139578. Ceiling = 7,
  139579. /** Square root */
  139580. Sqrt = 8,
  139581. /** Log */
  139582. Log = 9,
  139583. /** Tangent */
  139584. Tan = 10,
  139585. /** Arc tangent */
  139586. ArcTan = 11,
  139587. /** Arc cosinus */
  139588. ArcCos = 12,
  139589. /** Arc sinus */
  139590. ArcSin = 13,
  139591. /** Fraction */
  139592. Fract = 14,
  139593. /** Sign */
  139594. Sign = 15,
  139595. /** To radians (from degrees) */
  139596. Radians = 16,
  139597. /** To degrees (from radians) */
  139598. Degrees = 17
  139599. }
  139600. /**
  139601. * Block used to apply trigonometry operation to floats
  139602. */
  139603. export class TrigonometryBlock extends NodeMaterialBlock {
  139604. /**
  139605. * Gets or sets the operation applied by the block
  139606. */
  139607. operation: TrigonometryBlockOperations;
  139608. /**
  139609. * Creates a new TrigonometryBlock
  139610. * @param name defines the block name
  139611. */
  139612. constructor(name: string);
  139613. /**
  139614. * Gets the current class name
  139615. * @returns the class name
  139616. */
  139617. getClassName(): string;
  139618. /**
  139619. * Gets the input component
  139620. */
  139621. get input(): NodeMaterialConnectionPoint;
  139622. /**
  139623. * Gets the output component
  139624. */
  139625. get output(): NodeMaterialConnectionPoint;
  139626. protected _buildBlock(state: NodeMaterialBuildState): this;
  139627. serialize(): any;
  139628. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139629. protected _dumpPropertiesCode(): string;
  139630. }
  139631. }
  139632. declare module BABYLON {
  139633. /**
  139634. * Block used to create a Color3/4 out of individual inputs (one for each component)
  139635. */
  139636. export class ColorMergerBlock extends NodeMaterialBlock {
  139637. /**
  139638. * Create a new ColorMergerBlock
  139639. * @param name defines the block name
  139640. */
  139641. constructor(name: string);
  139642. /**
  139643. * Gets the current class name
  139644. * @returns the class name
  139645. */
  139646. getClassName(): string;
  139647. /**
  139648. * Gets the rgb component (input)
  139649. */
  139650. get rgbIn(): NodeMaterialConnectionPoint;
  139651. /**
  139652. * Gets the r component (input)
  139653. */
  139654. get r(): NodeMaterialConnectionPoint;
  139655. /**
  139656. * Gets the g component (input)
  139657. */
  139658. get g(): NodeMaterialConnectionPoint;
  139659. /**
  139660. * Gets the b component (input)
  139661. */
  139662. get b(): NodeMaterialConnectionPoint;
  139663. /**
  139664. * Gets the a component (input)
  139665. */
  139666. get a(): NodeMaterialConnectionPoint;
  139667. /**
  139668. * Gets the rgba component (output)
  139669. */
  139670. get rgba(): NodeMaterialConnectionPoint;
  139671. /**
  139672. * Gets the rgb component (output)
  139673. */
  139674. get rgbOut(): NodeMaterialConnectionPoint;
  139675. /**
  139676. * Gets the rgb component (output)
  139677. * @deprecated Please use rgbOut instead.
  139678. */
  139679. get rgb(): NodeMaterialConnectionPoint;
  139680. protected _buildBlock(state: NodeMaterialBuildState): this;
  139681. }
  139682. }
  139683. declare module BABYLON {
  139684. /**
  139685. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  139686. */
  139687. export class VectorSplitterBlock extends NodeMaterialBlock {
  139688. /**
  139689. * Create a new VectorSplitterBlock
  139690. * @param name defines the block name
  139691. */
  139692. constructor(name: string);
  139693. /**
  139694. * Gets the current class name
  139695. * @returns the class name
  139696. */
  139697. getClassName(): string;
  139698. /**
  139699. * Gets the xyzw component (input)
  139700. */
  139701. get xyzw(): NodeMaterialConnectionPoint;
  139702. /**
  139703. * Gets the xyz component (input)
  139704. */
  139705. get xyzIn(): NodeMaterialConnectionPoint;
  139706. /**
  139707. * Gets the xy component (input)
  139708. */
  139709. get xyIn(): NodeMaterialConnectionPoint;
  139710. /**
  139711. * Gets the xyz component (output)
  139712. */
  139713. get xyzOut(): NodeMaterialConnectionPoint;
  139714. /**
  139715. * Gets the xy component (output)
  139716. */
  139717. get xyOut(): NodeMaterialConnectionPoint;
  139718. /**
  139719. * Gets the x component (output)
  139720. */
  139721. get x(): NodeMaterialConnectionPoint;
  139722. /**
  139723. * Gets the y component (output)
  139724. */
  139725. get y(): NodeMaterialConnectionPoint;
  139726. /**
  139727. * Gets the z component (output)
  139728. */
  139729. get z(): NodeMaterialConnectionPoint;
  139730. /**
  139731. * Gets the w component (output)
  139732. */
  139733. get w(): NodeMaterialConnectionPoint;
  139734. protected _inputRename(name: string): string;
  139735. protected _outputRename(name: string): string;
  139736. protected _buildBlock(state: NodeMaterialBuildState): this;
  139737. }
  139738. }
  139739. declare module BABYLON {
  139740. /**
  139741. * Block used to lerp between 2 values
  139742. */
  139743. export class LerpBlock extends NodeMaterialBlock {
  139744. /**
  139745. * Creates a new LerpBlock
  139746. * @param name defines the block name
  139747. */
  139748. constructor(name: string);
  139749. /**
  139750. * Gets the current class name
  139751. * @returns the class name
  139752. */
  139753. getClassName(): string;
  139754. /**
  139755. * Gets the left operand input component
  139756. */
  139757. get left(): NodeMaterialConnectionPoint;
  139758. /**
  139759. * Gets the right operand input component
  139760. */
  139761. get right(): NodeMaterialConnectionPoint;
  139762. /**
  139763. * Gets the gradient operand input component
  139764. */
  139765. get gradient(): NodeMaterialConnectionPoint;
  139766. /**
  139767. * Gets the output component
  139768. */
  139769. get output(): NodeMaterialConnectionPoint;
  139770. protected _buildBlock(state: NodeMaterialBuildState): this;
  139771. }
  139772. }
  139773. declare module BABYLON {
  139774. /**
  139775. * Block used to divide 2 vectors
  139776. */
  139777. export class DivideBlock extends NodeMaterialBlock {
  139778. /**
  139779. * Creates a new DivideBlock
  139780. * @param name defines the block name
  139781. */
  139782. constructor(name: string);
  139783. /**
  139784. * Gets the current class name
  139785. * @returns the class name
  139786. */
  139787. getClassName(): string;
  139788. /**
  139789. * Gets the left operand input component
  139790. */
  139791. get left(): NodeMaterialConnectionPoint;
  139792. /**
  139793. * Gets the right operand input component
  139794. */
  139795. get right(): NodeMaterialConnectionPoint;
  139796. /**
  139797. * Gets the output component
  139798. */
  139799. get output(): NodeMaterialConnectionPoint;
  139800. protected _buildBlock(state: NodeMaterialBuildState): this;
  139801. }
  139802. }
  139803. declare module BABYLON {
  139804. /**
  139805. * Block used to subtract 2 vectors
  139806. */
  139807. export class SubtractBlock extends NodeMaterialBlock {
  139808. /**
  139809. * Creates a new SubtractBlock
  139810. * @param name defines the block name
  139811. */
  139812. constructor(name: string);
  139813. /**
  139814. * Gets the current class name
  139815. * @returns the class name
  139816. */
  139817. getClassName(): string;
  139818. /**
  139819. * Gets the left operand input component
  139820. */
  139821. get left(): NodeMaterialConnectionPoint;
  139822. /**
  139823. * Gets the right operand input component
  139824. */
  139825. get right(): NodeMaterialConnectionPoint;
  139826. /**
  139827. * Gets the output component
  139828. */
  139829. get output(): NodeMaterialConnectionPoint;
  139830. protected _buildBlock(state: NodeMaterialBuildState): this;
  139831. }
  139832. }
  139833. declare module BABYLON {
  139834. /**
  139835. * Block used to step a value
  139836. */
  139837. export class StepBlock extends NodeMaterialBlock {
  139838. /**
  139839. * Creates a new StepBlock
  139840. * @param name defines the block name
  139841. */
  139842. constructor(name: string);
  139843. /**
  139844. * Gets the current class name
  139845. * @returns the class name
  139846. */
  139847. getClassName(): string;
  139848. /**
  139849. * Gets the value operand input component
  139850. */
  139851. get value(): NodeMaterialConnectionPoint;
  139852. /**
  139853. * Gets the edge operand input component
  139854. */
  139855. get edge(): NodeMaterialConnectionPoint;
  139856. /**
  139857. * Gets the output component
  139858. */
  139859. get output(): NodeMaterialConnectionPoint;
  139860. protected _buildBlock(state: NodeMaterialBuildState): this;
  139861. }
  139862. }
  139863. declare module BABYLON {
  139864. /**
  139865. * Block used to get the opposite (1 - x) of a value
  139866. */
  139867. export class OneMinusBlock extends NodeMaterialBlock {
  139868. /**
  139869. * Creates a new OneMinusBlock
  139870. * @param name defines the block name
  139871. */
  139872. constructor(name: string);
  139873. /**
  139874. * Gets the current class name
  139875. * @returns the class name
  139876. */
  139877. getClassName(): string;
  139878. /**
  139879. * Gets the input component
  139880. */
  139881. get input(): NodeMaterialConnectionPoint;
  139882. /**
  139883. * Gets the output component
  139884. */
  139885. get output(): NodeMaterialConnectionPoint;
  139886. protected _buildBlock(state: NodeMaterialBuildState): this;
  139887. }
  139888. }
  139889. declare module BABYLON {
  139890. /**
  139891. * Block used to get the view direction
  139892. */
  139893. export class ViewDirectionBlock extends NodeMaterialBlock {
  139894. /**
  139895. * Creates a new ViewDirectionBlock
  139896. * @param name defines the block name
  139897. */
  139898. constructor(name: string);
  139899. /**
  139900. * Gets the current class name
  139901. * @returns the class name
  139902. */
  139903. getClassName(): string;
  139904. /**
  139905. * Gets the world position component
  139906. */
  139907. get worldPosition(): NodeMaterialConnectionPoint;
  139908. /**
  139909. * Gets the camera position component
  139910. */
  139911. get cameraPosition(): NodeMaterialConnectionPoint;
  139912. /**
  139913. * Gets the output component
  139914. */
  139915. get output(): NodeMaterialConnectionPoint;
  139916. autoConfigure(material: NodeMaterial): void;
  139917. protected _buildBlock(state: NodeMaterialBuildState): this;
  139918. }
  139919. }
  139920. declare module BABYLON {
  139921. /**
  139922. * Block used to compute fresnel value
  139923. */
  139924. export class FresnelBlock extends NodeMaterialBlock {
  139925. /**
  139926. * Create a new FresnelBlock
  139927. * @param name defines the block name
  139928. */
  139929. constructor(name: string);
  139930. /**
  139931. * Gets the current class name
  139932. * @returns the class name
  139933. */
  139934. getClassName(): string;
  139935. /**
  139936. * Gets the world normal input component
  139937. */
  139938. get worldNormal(): NodeMaterialConnectionPoint;
  139939. /**
  139940. * Gets the view direction input component
  139941. */
  139942. get viewDirection(): NodeMaterialConnectionPoint;
  139943. /**
  139944. * Gets the bias input component
  139945. */
  139946. get bias(): NodeMaterialConnectionPoint;
  139947. /**
  139948. * Gets the camera (or eye) position component
  139949. */
  139950. get power(): NodeMaterialConnectionPoint;
  139951. /**
  139952. * Gets the fresnel output component
  139953. */
  139954. get fresnel(): NodeMaterialConnectionPoint;
  139955. autoConfigure(material: NodeMaterial): void;
  139956. protected _buildBlock(state: NodeMaterialBuildState): this;
  139957. }
  139958. }
  139959. declare module BABYLON {
  139960. /**
  139961. * Block used to get the max of 2 values
  139962. */
  139963. export class MaxBlock extends NodeMaterialBlock {
  139964. /**
  139965. * Creates a new MaxBlock
  139966. * @param name defines the block name
  139967. */
  139968. constructor(name: string);
  139969. /**
  139970. * Gets the current class name
  139971. * @returns the class name
  139972. */
  139973. getClassName(): string;
  139974. /**
  139975. * Gets the left operand input component
  139976. */
  139977. get left(): NodeMaterialConnectionPoint;
  139978. /**
  139979. * Gets the right operand input component
  139980. */
  139981. get right(): NodeMaterialConnectionPoint;
  139982. /**
  139983. * Gets the output component
  139984. */
  139985. get output(): NodeMaterialConnectionPoint;
  139986. protected _buildBlock(state: NodeMaterialBuildState): this;
  139987. }
  139988. }
  139989. declare module BABYLON {
  139990. /**
  139991. * Block used to get the min of 2 values
  139992. */
  139993. export class MinBlock extends NodeMaterialBlock {
  139994. /**
  139995. * Creates a new MinBlock
  139996. * @param name defines the block name
  139997. */
  139998. constructor(name: string);
  139999. /**
  140000. * Gets the current class name
  140001. * @returns the class name
  140002. */
  140003. getClassName(): string;
  140004. /**
  140005. * Gets the left operand input component
  140006. */
  140007. get left(): NodeMaterialConnectionPoint;
  140008. /**
  140009. * Gets the right operand input component
  140010. */
  140011. get right(): NodeMaterialConnectionPoint;
  140012. /**
  140013. * Gets the output component
  140014. */
  140015. get output(): NodeMaterialConnectionPoint;
  140016. protected _buildBlock(state: NodeMaterialBuildState): this;
  140017. }
  140018. }
  140019. declare module BABYLON {
  140020. /**
  140021. * Block used to get the distance between 2 values
  140022. */
  140023. export class DistanceBlock extends NodeMaterialBlock {
  140024. /**
  140025. * Creates a new DistanceBlock
  140026. * @param name defines the block name
  140027. */
  140028. constructor(name: string);
  140029. /**
  140030. * Gets the current class name
  140031. * @returns the class name
  140032. */
  140033. getClassName(): string;
  140034. /**
  140035. * Gets the left operand input component
  140036. */
  140037. get left(): NodeMaterialConnectionPoint;
  140038. /**
  140039. * Gets the right operand input component
  140040. */
  140041. get right(): NodeMaterialConnectionPoint;
  140042. /**
  140043. * Gets the output component
  140044. */
  140045. get output(): NodeMaterialConnectionPoint;
  140046. protected _buildBlock(state: NodeMaterialBuildState): this;
  140047. }
  140048. }
  140049. declare module BABYLON {
  140050. /**
  140051. * Block used to get the length of a vector
  140052. */
  140053. export class LengthBlock extends NodeMaterialBlock {
  140054. /**
  140055. * Creates a new LengthBlock
  140056. * @param name defines the block name
  140057. */
  140058. constructor(name: string);
  140059. /**
  140060. * Gets the current class name
  140061. * @returns the class name
  140062. */
  140063. getClassName(): string;
  140064. /**
  140065. * Gets the value input component
  140066. */
  140067. get value(): NodeMaterialConnectionPoint;
  140068. /**
  140069. * Gets the output component
  140070. */
  140071. get output(): NodeMaterialConnectionPoint;
  140072. protected _buildBlock(state: NodeMaterialBuildState): this;
  140073. }
  140074. }
  140075. declare module BABYLON {
  140076. /**
  140077. * Block used to get negative version of a value (i.e. x * -1)
  140078. */
  140079. export class NegateBlock extends NodeMaterialBlock {
  140080. /**
  140081. * Creates a new NegateBlock
  140082. * @param name defines the block name
  140083. */
  140084. constructor(name: string);
  140085. /**
  140086. * Gets the current class name
  140087. * @returns the class name
  140088. */
  140089. getClassName(): string;
  140090. /**
  140091. * Gets the value input component
  140092. */
  140093. get value(): NodeMaterialConnectionPoint;
  140094. /**
  140095. * Gets the output component
  140096. */
  140097. get output(): NodeMaterialConnectionPoint;
  140098. protected _buildBlock(state: NodeMaterialBuildState): this;
  140099. }
  140100. }
  140101. declare module BABYLON {
  140102. /**
  140103. * Block used to get the value of the first parameter raised to the power of the second
  140104. */
  140105. export class PowBlock extends NodeMaterialBlock {
  140106. /**
  140107. * Creates a new PowBlock
  140108. * @param name defines the block name
  140109. */
  140110. constructor(name: string);
  140111. /**
  140112. * Gets the current class name
  140113. * @returns the class name
  140114. */
  140115. getClassName(): string;
  140116. /**
  140117. * Gets the value operand input component
  140118. */
  140119. get value(): NodeMaterialConnectionPoint;
  140120. /**
  140121. * Gets the power operand input component
  140122. */
  140123. get power(): NodeMaterialConnectionPoint;
  140124. /**
  140125. * Gets the output component
  140126. */
  140127. get output(): NodeMaterialConnectionPoint;
  140128. protected _buildBlock(state: NodeMaterialBuildState): this;
  140129. }
  140130. }
  140131. declare module BABYLON {
  140132. /**
  140133. * Block used to get a random number
  140134. */
  140135. export class RandomNumberBlock extends NodeMaterialBlock {
  140136. /**
  140137. * Creates a new RandomNumberBlock
  140138. * @param name defines the block name
  140139. */
  140140. constructor(name: string);
  140141. /**
  140142. * Gets the current class name
  140143. * @returns the class name
  140144. */
  140145. getClassName(): string;
  140146. /**
  140147. * Gets the seed input component
  140148. */
  140149. get seed(): NodeMaterialConnectionPoint;
  140150. /**
  140151. * Gets the output component
  140152. */
  140153. get output(): NodeMaterialConnectionPoint;
  140154. protected _buildBlock(state: NodeMaterialBuildState): this;
  140155. }
  140156. }
  140157. declare module BABYLON {
  140158. /**
  140159. * Block used to compute arc tangent of 2 values
  140160. */
  140161. export class ArcTan2Block extends NodeMaterialBlock {
  140162. /**
  140163. * Creates a new ArcTan2Block
  140164. * @param name defines the block name
  140165. */
  140166. constructor(name: string);
  140167. /**
  140168. * Gets the current class name
  140169. * @returns the class name
  140170. */
  140171. getClassName(): string;
  140172. /**
  140173. * Gets the x operand input component
  140174. */
  140175. get x(): NodeMaterialConnectionPoint;
  140176. /**
  140177. * Gets the y operand input component
  140178. */
  140179. get y(): NodeMaterialConnectionPoint;
  140180. /**
  140181. * Gets the output component
  140182. */
  140183. get output(): NodeMaterialConnectionPoint;
  140184. protected _buildBlock(state: NodeMaterialBuildState): this;
  140185. }
  140186. }
  140187. declare module BABYLON {
  140188. /**
  140189. * Block used to smooth step a value
  140190. */
  140191. export class SmoothStepBlock extends NodeMaterialBlock {
  140192. /**
  140193. * Creates a new SmoothStepBlock
  140194. * @param name defines the block name
  140195. */
  140196. constructor(name: string);
  140197. /**
  140198. * Gets the current class name
  140199. * @returns the class name
  140200. */
  140201. getClassName(): string;
  140202. /**
  140203. * Gets the value operand input component
  140204. */
  140205. get value(): NodeMaterialConnectionPoint;
  140206. /**
  140207. * Gets the first edge operand input component
  140208. */
  140209. get edge0(): NodeMaterialConnectionPoint;
  140210. /**
  140211. * Gets the second edge operand input component
  140212. */
  140213. get edge1(): NodeMaterialConnectionPoint;
  140214. /**
  140215. * Gets the output component
  140216. */
  140217. get output(): NodeMaterialConnectionPoint;
  140218. protected _buildBlock(state: NodeMaterialBuildState): this;
  140219. }
  140220. }
  140221. declare module BABYLON {
  140222. /**
  140223. * Block used to get the reciprocal (1 / x) of a value
  140224. */
  140225. export class ReciprocalBlock extends NodeMaterialBlock {
  140226. /**
  140227. * Creates a new ReciprocalBlock
  140228. * @param name defines the block name
  140229. */
  140230. constructor(name: string);
  140231. /**
  140232. * Gets the current class name
  140233. * @returns the class name
  140234. */
  140235. getClassName(): string;
  140236. /**
  140237. * Gets the input component
  140238. */
  140239. get input(): NodeMaterialConnectionPoint;
  140240. /**
  140241. * Gets the output component
  140242. */
  140243. get output(): NodeMaterialConnectionPoint;
  140244. protected _buildBlock(state: NodeMaterialBuildState): this;
  140245. }
  140246. }
  140247. declare module BABYLON {
  140248. /**
  140249. * Block used to replace a color by another one
  140250. */
  140251. export class ReplaceColorBlock extends NodeMaterialBlock {
  140252. /**
  140253. * Creates a new ReplaceColorBlock
  140254. * @param name defines the block name
  140255. */
  140256. constructor(name: string);
  140257. /**
  140258. * Gets the current class name
  140259. * @returns the class name
  140260. */
  140261. getClassName(): string;
  140262. /**
  140263. * Gets the value input component
  140264. */
  140265. get value(): NodeMaterialConnectionPoint;
  140266. /**
  140267. * Gets the reference input component
  140268. */
  140269. get reference(): NodeMaterialConnectionPoint;
  140270. /**
  140271. * Gets the distance input component
  140272. */
  140273. get distance(): NodeMaterialConnectionPoint;
  140274. /**
  140275. * Gets the replacement input component
  140276. */
  140277. get replacement(): NodeMaterialConnectionPoint;
  140278. /**
  140279. * Gets the output component
  140280. */
  140281. get output(): NodeMaterialConnectionPoint;
  140282. protected _buildBlock(state: NodeMaterialBuildState): this;
  140283. }
  140284. }
  140285. declare module BABYLON {
  140286. /**
  140287. * Block used to posterize a value
  140288. * @see https://en.wikipedia.org/wiki/Posterization
  140289. */
  140290. export class PosterizeBlock extends NodeMaterialBlock {
  140291. /**
  140292. * Creates a new PosterizeBlock
  140293. * @param name defines the block name
  140294. */
  140295. constructor(name: string);
  140296. /**
  140297. * Gets the current class name
  140298. * @returns the class name
  140299. */
  140300. getClassName(): string;
  140301. /**
  140302. * Gets the value input component
  140303. */
  140304. get value(): NodeMaterialConnectionPoint;
  140305. /**
  140306. * Gets the steps input component
  140307. */
  140308. get steps(): NodeMaterialConnectionPoint;
  140309. /**
  140310. * Gets the output component
  140311. */
  140312. get output(): NodeMaterialConnectionPoint;
  140313. protected _buildBlock(state: NodeMaterialBuildState): this;
  140314. }
  140315. }
  140316. declare module BABYLON {
  140317. /**
  140318. * Operations supported by the Wave block
  140319. */
  140320. export enum WaveBlockKind {
  140321. /** SawTooth */
  140322. SawTooth = 0,
  140323. /** Square */
  140324. Square = 1,
  140325. /** Triangle */
  140326. Triangle = 2
  140327. }
  140328. /**
  140329. * Block used to apply wave operation to floats
  140330. */
  140331. export class WaveBlock extends NodeMaterialBlock {
  140332. /**
  140333. * Gets or sets the kibnd of wave to be applied by the block
  140334. */
  140335. kind: WaveBlockKind;
  140336. /**
  140337. * Creates a new WaveBlock
  140338. * @param name defines the block name
  140339. */
  140340. constructor(name: string);
  140341. /**
  140342. * Gets the current class name
  140343. * @returns the class name
  140344. */
  140345. getClassName(): string;
  140346. /**
  140347. * Gets the input component
  140348. */
  140349. get input(): NodeMaterialConnectionPoint;
  140350. /**
  140351. * Gets the output component
  140352. */
  140353. get output(): NodeMaterialConnectionPoint;
  140354. protected _buildBlock(state: NodeMaterialBuildState): this;
  140355. serialize(): any;
  140356. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140357. }
  140358. }
  140359. declare module BABYLON {
  140360. /**
  140361. * Class used to store a color step for the GradientBlock
  140362. */
  140363. export class GradientBlockColorStep {
  140364. /**
  140365. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140366. */
  140367. step: number;
  140368. /**
  140369. * Gets or sets the color associated with this step
  140370. */
  140371. color: Color3;
  140372. /**
  140373. * Creates a new GradientBlockColorStep
  140374. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  140375. * @param color defines the color associated with this step
  140376. */
  140377. constructor(
  140378. /**
  140379. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140380. */
  140381. step: number,
  140382. /**
  140383. * Gets or sets the color associated with this step
  140384. */
  140385. color: Color3);
  140386. }
  140387. /**
  140388. * Block used to return a color from a gradient based on an input value between 0 and 1
  140389. */
  140390. export class GradientBlock extends NodeMaterialBlock {
  140391. /**
  140392. * Gets or sets the list of color steps
  140393. */
  140394. colorSteps: GradientBlockColorStep[];
  140395. /**
  140396. * Creates a new GradientBlock
  140397. * @param name defines the block name
  140398. */
  140399. constructor(name: string);
  140400. /**
  140401. * Gets the current class name
  140402. * @returns the class name
  140403. */
  140404. getClassName(): string;
  140405. /**
  140406. * Gets the gradient input component
  140407. */
  140408. get gradient(): NodeMaterialConnectionPoint;
  140409. /**
  140410. * Gets the output component
  140411. */
  140412. get output(): NodeMaterialConnectionPoint;
  140413. private _writeColorConstant;
  140414. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140415. serialize(): any;
  140416. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140417. protected _dumpPropertiesCode(): string;
  140418. }
  140419. }
  140420. declare module BABYLON {
  140421. /**
  140422. * Block used to normalize lerp between 2 values
  140423. */
  140424. export class NLerpBlock extends NodeMaterialBlock {
  140425. /**
  140426. * Creates a new NLerpBlock
  140427. * @param name defines the block name
  140428. */
  140429. constructor(name: string);
  140430. /**
  140431. * Gets the current class name
  140432. * @returns the class name
  140433. */
  140434. getClassName(): string;
  140435. /**
  140436. * Gets the left operand input component
  140437. */
  140438. get left(): NodeMaterialConnectionPoint;
  140439. /**
  140440. * Gets the right operand input component
  140441. */
  140442. get right(): NodeMaterialConnectionPoint;
  140443. /**
  140444. * Gets the gradient operand input component
  140445. */
  140446. get gradient(): NodeMaterialConnectionPoint;
  140447. /**
  140448. * Gets the output component
  140449. */
  140450. get output(): NodeMaterialConnectionPoint;
  140451. protected _buildBlock(state: NodeMaterialBuildState): this;
  140452. }
  140453. }
  140454. declare module BABYLON {
  140455. /**
  140456. * block used to Generate a Worley Noise 3D Noise Pattern
  140457. */
  140458. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  140459. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140460. manhattanDistance: boolean;
  140461. /**
  140462. * Creates a new WorleyNoise3DBlock
  140463. * @param name defines the block name
  140464. */
  140465. constructor(name: string);
  140466. /**
  140467. * Gets the current class name
  140468. * @returns the class name
  140469. */
  140470. getClassName(): string;
  140471. /**
  140472. * Gets the seed input component
  140473. */
  140474. get seed(): NodeMaterialConnectionPoint;
  140475. /**
  140476. * Gets the jitter input component
  140477. */
  140478. get jitter(): NodeMaterialConnectionPoint;
  140479. /**
  140480. * Gets the output component
  140481. */
  140482. get output(): NodeMaterialConnectionPoint;
  140483. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140484. /**
  140485. * Exposes the properties to the UI?
  140486. */
  140487. protected _dumpPropertiesCode(): string;
  140488. /**
  140489. * Exposes the properties to the Seralize?
  140490. */
  140491. serialize(): any;
  140492. /**
  140493. * Exposes the properties to the deseralize?
  140494. */
  140495. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140496. }
  140497. }
  140498. declare module BABYLON {
  140499. /**
  140500. * block used to Generate a Simplex Perlin 3d Noise Pattern
  140501. */
  140502. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  140503. /**
  140504. * Creates a new SimplexPerlin3DBlock
  140505. * @param name defines the block name
  140506. */
  140507. constructor(name: string);
  140508. /**
  140509. * Gets the current class name
  140510. * @returns the class name
  140511. */
  140512. getClassName(): string;
  140513. /**
  140514. * Gets the seed operand input component
  140515. */
  140516. get seed(): NodeMaterialConnectionPoint;
  140517. /**
  140518. * Gets the output component
  140519. */
  140520. get output(): NodeMaterialConnectionPoint;
  140521. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140522. }
  140523. }
  140524. declare module BABYLON {
  140525. /**
  140526. * Block used to blend normals
  140527. */
  140528. export class NormalBlendBlock extends NodeMaterialBlock {
  140529. /**
  140530. * Creates a new NormalBlendBlock
  140531. * @param name defines the block name
  140532. */
  140533. constructor(name: string);
  140534. /**
  140535. * Gets the current class name
  140536. * @returns the class name
  140537. */
  140538. getClassName(): string;
  140539. /**
  140540. * Gets the first input component
  140541. */
  140542. get normalMap0(): NodeMaterialConnectionPoint;
  140543. /**
  140544. * Gets the second input component
  140545. */
  140546. get normalMap1(): NodeMaterialConnectionPoint;
  140547. /**
  140548. * Gets the output component
  140549. */
  140550. get output(): NodeMaterialConnectionPoint;
  140551. protected _buildBlock(state: NodeMaterialBuildState): this;
  140552. }
  140553. }
  140554. declare module BABYLON {
  140555. /**
  140556. * Block used to rotate a 2d vector by a given angle
  140557. */
  140558. export class Rotate2dBlock extends NodeMaterialBlock {
  140559. /**
  140560. * Creates a new Rotate2dBlock
  140561. * @param name defines the block name
  140562. */
  140563. constructor(name: string);
  140564. /**
  140565. * Gets the current class name
  140566. * @returns the class name
  140567. */
  140568. getClassName(): string;
  140569. /**
  140570. * Gets the input vector
  140571. */
  140572. get input(): NodeMaterialConnectionPoint;
  140573. /**
  140574. * Gets the input angle
  140575. */
  140576. get angle(): NodeMaterialConnectionPoint;
  140577. /**
  140578. * Gets the output component
  140579. */
  140580. get output(): NodeMaterialConnectionPoint;
  140581. autoConfigure(material: NodeMaterial): void;
  140582. protected _buildBlock(state: NodeMaterialBuildState): this;
  140583. }
  140584. }
  140585. declare module BABYLON {
  140586. /**
  140587. * Block used to get the reflected vector from a direction and a normal
  140588. */
  140589. export class ReflectBlock extends NodeMaterialBlock {
  140590. /**
  140591. * Creates a new ReflectBlock
  140592. * @param name defines the block name
  140593. */
  140594. constructor(name: string);
  140595. /**
  140596. * Gets the current class name
  140597. * @returns the class name
  140598. */
  140599. getClassName(): string;
  140600. /**
  140601. * Gets the incident component
  140602. */
  140603. get incident(): NodeMaterialConnectionPoint;
  140604. /**
  140605. * Gets the normal component
  140606. */
  140607. get normal(): NodeMaterialConnectionPoint;
  140608. /**
  140609. * Gets the output component
  140610. */
  140611. get output(): NodeMaterialConnectionPoint;
  140612. protected _buildBlock(state: NodeMaterialBuildState): this;
  140613. }
  140614. }
  140615. declare module BABYLON {
  140616. /**
  140617. * Block used to get the refracted vector from a direction and a normal
  140618. */
  140619. export class RefractBlock extends NodeMaterialBlock {
  140620. /**
  140621. * Creates a new RefractBlock
  140622. * @param name defines the block name
  140623. */
  140624. constructor(name: string);
  140625. /**
  140626. * Gets the current class name
  140627. * @returns the class name
  140628. */
  140629. getClassName(): string;
  140630. /**
  140631. * Gets the incident component
  140632. */
  140633. get incident(): NodeMaterialConnectionPoint;
  140634. /**
  140635. * Gets the normal component
  140636. */
  140637. get normal(): NodeMaterialConnectionPoint;
  140638. /**
  140639. * Gets the index of refraction component
  140640. */
  140641. get ior(): NodeMaterialConnectionPoint;
  140642. /**
  140643. * Gets the output component
  140644. */
  140645. get output(): NodeMaterialConnectionPoint;
  140646. protected _buildBlock(state: NodeMaterialBuildState): this;
  140647. }
  140648. }
  140649. declare module BABYLON {
  140650. /**
  140651. * Block used to desaturate a color
  140652. */
  140653. export class DesaturateBlock extends NodeMaterialBlock {
  140654. /**
  140655. * Creates a new DesaturateBlock
  140656. * @param name defines the block name
  140657. */
  140658. constructor(name: string);
  140659. /**
  140660. * Gets the current class name
  140661. * @returns the class name
  140662. */
  140663. getClassName(): string;
  140664. /**
  140665. * Gets the color operand input component
  140666. */
  140667. get color(): NodeMaterialConnectionPoint;
  140668. /**
  140669. * Gets the level operand input component
  140670. */
  140671. get level(): NodeMaterialConnectionPoint;
  140672. /**
  140673. * Gets the output component
  140674. */
  140675. get output(): NodeMaterialConnectionPoint;
  140676. protected _buildBlock(state: NodeMaterialBuildState): this;
  140677. }
  140678. }
  140679. declare module BABYLON {
  140680. /**
  140681. * Block used to implement the ambient occlusion module of the PBR material
  140682. */
  140683. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  140684. /**
  140685. * Create a new AmbientOcclusionBlock
  140686. * @param name defines the block name
  140687. */
  140688. constructor(name: string);
  140689. /**
  140690. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  140691. */
  140692. useAmbientInGrayScale: boolean;
  140693. /**
  140694. * Initialize the block and prepare the context for build
  140695. * @param state defines the state that will be used for the build
  140696. */
  140697. initialize(state: NodeMaterialBuildState): void;
  140698. /**
  140699. * Gets the current class name
  140700. * @returns the class name
  140701. */
  140702. getClassName(): string;
  140703. /**
  140704. * Gets the texture input component
  140705. */
  140706. get texture(): NodeMaterialConnectionPoint;
  140707. /**
  140708. * Gets the texture intensity component
  140709. */
  140710. get intensity(): NodeMaterialConnectionPoint;
  140711. /**
  140712. * Gets the direct light intensity input component
  140713. */
  140714. get directLightIntensity(): NodeMaterialConnectionPoint;
  140715. /**
  140716. * Gets the ambient occlusion object output component
  140717. */
  140718. get ambientOcclusion(): NodeMaterialConnectionPoint;
  140719. /**
  140720. * Gets the main code of the block (fragment side)
  140721. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  140722. * @returns the shader code
  140723. */
  140724. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  140725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140726. protected _buildBlock(state: NodeMaterialBuildState): this;
  140727. protected _dumpPropertiesCode(): string;
  140728. serialize(): any;
  140729. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140730. }
  140731. }
  140732. declare module BABYLON {
  140733. /**
  140734. * Block used to implement the reflection module of the PBR material
  140735. */
  140736. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  140737. /** @hidden */
  140738. _defineLODReflectionAlpha: string;
  140739. /** @hidden */
  140740. _defineLinearSpecularReflection: string;
  140741. private _vEnvironmentIrradianceName;
  140742. /** @hidden */
  140743. _vReflectionMicrosurfaceInfosName: string;
  140744. /** @hidden */
  140745. _vReflectionInfosName: string;
  140746. /** @hidden */
  140747. _vReflectionFilteringInfoName: string;
  140748. private _scene;
  140749. /**
  140750. * The three properties below are set by the main PBR block prior to calling methods of this class.
  140751. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  140752. * It's less burden on the user side in the editor part.
  140753. */
  140754. /** @hidden */
  140755. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  140756. /** @hidden */
  140757. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  140758. /** @hidden */
  140759. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  140760. /**
  140761. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  140762. * diffuse part of the IBL.
  140763. */
  140764. useSphericalHarmonics: boolean;
  140765. /**
  140766. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  140767. */
  140768. forceIrradianceInFragment: boolean;
  140769. /**
  140770. * Create a new ReflectionBlock
  140771. * @param name defines the block name
  140772. */
  140773. constructor(name: string);
  140774. /**
  140775. * Gets the current class name
  140776. * @returns the class name
  140777. */
  140778. getClassName(): string;
  140779. /**
  140780. * Gets the position input component
  140781. */
  140782. get position(): NodeMaterialConnectionPoint;
  140783. /**
  140784. * Gets the world position input component
  140785. */
  140786. get worldPosition(): NodeMaterialConnectionPoint;
  140787. /**
  140788. * Gets the world normal input component
  140789. */
  140790. get worldNormal(): NodeMaterialConnectionPoint;
  140791. /**
  140792. * Gets the world input component
  140793. */
  140794. get world(): NodeMaterialConnectionPoint;
  140795. /**
  140796. * Gets the camera (or eye) position component
  140797. */
  140798. get cameraPosition(): NodeMaterialConnectionPoint;
  140799. /**
  140800. * Gets the view input component
  140801. */
  140802. get view(): NodeMaterialConnectionPoint;
  140803. /**
  140804. * Gets the color input component
  140805. */
  140806. get color(): NodeMaterialConnectionPoint;
  140807. /**
  140808. * Gets the reflection object output component
  140809. */
  140810. get reflection(): NodeMaterialConnectionPoint;
  140811. /**
  140812. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  140813. */
  140814. get hasTexture(): boolean;
  140815. /**
  140816. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  140817. */
  140818. get reflectionColor(): string;
  140819. protected _getTexture(): Nullable<BaseTexture>;
  140820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140822. /**
  140823. * Gets the code to inject in the vertex shader
  140824. * @param state current state of the node material building
  140825. * @returns the shader code
  140826. */
  140827. handleVertexSide(state: NodeMaterialBuildState): string;
  140828. /**
  140829. * Gets the main code of the block (fragment side)
  140830. * @param state current state of the node material building
  140831. * @param normalVarName name of the existing variable corresponding to the normal
  140832. * @returns the shader code
  140833. */
  140834. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  140835. protected _buildBlock(state: NodeMaterialBuildState): this;
  140836. protected _dumpPropertiesCode(): string;
  140837. serialize(): any;
  140838. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140839. }
  140840. }
  140841. declare module BABYLON {
  140842. /**
  140843. * Block used to implement the sheen module of the PBR material
  140844. */
  140845. export class SheenBlock extends NodeMaterialBlock {
  140846. /**
  140847. * Create a new SheenBlock
  140848. * @param name defines the block name
  140849. */
  140850. constructor(name: string);
  140851. /**
  140852. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  140853. * It allows the strength of the sheen effect to not depend on the base color of the material,
  140854. * making it easier to setup and tweak the effect
  140855. */
  140856. albedoScaling: boolean;
  140857. /**
  140858. * Defines if the sheen is linked to the sheen color.
  140859. */
  140860. linkSheenWithAlbedo: boolean;
  140861. /**
  140862. * Initialize the block and prepare the context for build
  140863. * @param state defines the state that will be used for the build
  140864. */
  140865. initialize(state: NodeMaterialBuildState): void;
  140866. /**
  140867. * Gets the current class name
  140868. * @returns the class name
  140869. */
  140870. getClassName(): string;
  140871. /**
  140872. * Gets the intensity input component
  140873. */
  140874. get intensity(): NodeMaterialConnectionPoint;
  140875. /**
  140876. * Gets the color input component
  140877. */
  140878. get color(): NodeMaterialConnectionPoint;
  140879. /**
  140880. * Gets the roughness input component
  140881. */
  140882. get roughness(): NodeMaterialConnectionPoint;
  140883. /**
  140884. * Gets the sheen object output component
  140885. */
  140886. get sheen(): NodeMaterialConnectionPoint;
  140887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140888. /**
  140889. * Gets the main code of the block (fragment side)
  140890. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140891. * @returns the shader code
  140892. */
  140893. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  140894. protected _buildBlock(state: NodeMaterialBuildState): this;
  140895. protected _dumpPropertiesCode(): string;
  140896. serialize(): any;
  140897. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140898. }
  140899. }
  140900. declare module BABYLON {
  140901. /**
  140902. * Block used to implement the reflectivity module of the PBR material
  140903. */
  140904. export class ReflectivityBlock extends NodeMaterialBlock {
  140905. private _metallicReflectanceColor;
  140906. private _metallicF0Factor;
  140907. /** @hidden */
  140908. _vMetallicReflectanceFactorsName: string;
  140909. /**
  140910. * The property below is set by the main PBR block prior to calling methods of this class.
  140911. */
  140912. /** @hidden */
  140913. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  140914. /**
  140915. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  140916. */
  140917. useAmbientOcclusionFromMetallicTextureRed: boolean;
  140918. /**
  140919. * Specifies if the metallic texture contains the metallness information in its blue channel.
  140920. */
  140921. useMetallnessFromMetallicTextureBlue: boolean;
  140922. /**
  140923. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  140924. */
  140925. useRoughnessFromMetallicTextureAlpha: boolean;
  140926. /**
  140927. * Specifies if the metallic texture contains the roughness information in its green channel.
  140928. */
  140929. useRoughnessFromMetallicTextureGreen: boolean;
  140930. /**
  140931. * Create a new ReflectivityBlock
  140932. * @param name defines the block name
  140933. */
  140934. constructor(name: string);
  140935. /**
  140936. * Initialize the block and prepare the context for build
  140937. * @param state defines the state that will be used for the build
  140938. */
  140939. initialize(state: NodeMaterialBuildState): void;
  140940. /**
  140941. * Gets the current class name
  140942. * @returns the class name
  140943. */
  140944. getClassName(): string;
  140945. /**
  140946. * Gets the metallic input component
  140947. */
  140948. get metallic(): NodeMaterialConnectionPoint;
  140949. /**
  140950. * Gets the roughness input component
  140951. */
  140952. get roughness(): NodeMaterialConnectionPoint;
  140953. /**
  140954. * Gets the texture input component
  140955. */
  140956. get texture(): NodeMaterialConnectionPoint;
  140957. /**
  140958. * Gets the reflectivity object output component
  140959. */
  140960. get reflectivity(): NodeMaterialConnectionPoint;
  140961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140962. /**
  140963. * Gets the main code of the block (fragment side)
  140964. * @param state current state of the node material building
  140965. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  140966. * @returns the shader code
  140967. */
  140968. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  140969. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140970. protected _buildBlock(state: NodeMaterialBuildState): this;
  140971. protected _dumpPropertiesCode(): string;
  140972. serialize(): any;
  140973. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140974. }
  140975. }
  140976. declare module BABYLON {
  140977. /**
  140978. * Block used to implement the anisotropy module of the PBR material
  140979. */
  140980. export class AnisotropyBlock extends NodeMaterialBlock {
  140981. /**
  140982. * The two properties below are set by the main PBR block prior to calling methods of this class.
  140983. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  140984. * It's less burden on the user side in the editor part.
  140985. */
  140986. /** @hidden */
  140987. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  140988. /** @hidden */
  140989. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  140990. /**
  140991. * Create a new AnisotropyBlock
  140992. * @param name defines the block name
  140993. */
  140994. constructor(name: string);
  140995. /**
  140996. * Initialize the block and prepare the context for build
  140997. * @param state defines the state that will be used for the build
  140998. */
  140999. initialize(state: NodeMaterialBuildState): void;
  141000. /**
  141001. * Gets the current class name
  141002. * @returns the class name
  141003. */
  141004. getClassName(): string;
  141005. /**
  141006. * Gets the intensity input component
  141007. */
  141008. get intensity(): NodeMaterialConnectionPoint;
  141009. /**
  141010. * Gets the direction input component
  141011. */
  141012. get direction(): NodeMaterialConnectionPoint;
  141013. /**
  141014. * Gets the texture input component
  141015. */
  141016. get texture(): NodeMaterialConnectionPoint;
  141017. /**
  141018. * Gets the uv input component
  141019. */
  141020. get uv(): NodeMaterialConnectionPoint;
  141021. /**
  141022. * Gets the worldTangent input component
  141023. */
  141024. get worldTangent(): NodeMaterialConnectionPoint;
  141025. /**
  141026. * Gets the anisotropy object output component
  141027. */
  141028. get anisotropy(): NodeMaterialConnectionPoint;
  141029. private _generateTBNSpace;
  141030. /**
  141031. * Gets the main code of the block (fragment side)
  141032. * @param state current state of the node material building
  141033. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141034. * @returns the shader code
  141035. */
  141036. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  141037. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141038. protected _buildBlock(state: NodeMaterialBuildState): this;
  141039. }
  141040. }
  141041. declare module BABYLON {
  141042. /**
  141043. * Block used to implement the clear coat module of the PBR material
  141044. */
  141045. export class ClearCoatBlock extends NodeMaterialBlock {
  141046. private _scene;
  141047. /**
  141048. * Create a new ClearCoatBlock
  141049. * @param name defines the block name
  141050. */
  141051. constructor(name: string);
  141052. /**
  141053. * Initialize the block and prepare the context for build
  141054. * @param state defines the state that will be used for the build
  141055. */
  141056. initialize(state: NodeMaterialBuildState): void;
  141057. /**
  141058. * Gets the current class name
  141059. * @returns the class name
  141060. */
  141061. getClassName(): string;
  141062. /**
  141063. * Gets the intensity input component
  141064. */
  141065. get intensity(): NodeMaterialConnectionPoint;
  141066. /**
  141067. * Gets the roughness input component
  141068. */
  141069. get roughness(): NodeMaterialConnectionPoint;
  141070. /**
  141071. * Gets the ior input component
  141072. */
  141073. get ior(): NodeMaterialConnectionPoint;
  141074. /**
  141075. * Gets the texture input component
  141076. */
  141077. get texture(): NodeMaterialConnectionPoint;
  141078. /**
  141079. * Gets the bump texture input component
  141080. */
  141081. get bumpTexture(): NodeMaterialConnectionPoint;
  141082. /**
  141083. * Gets the uv input component
  141084. */
  141085. get uv(): NodeMaterialConnectionPoint;
  141086. /**
  141087. * Gets the tint color input component
  141088. */
  141089. get tintColor(): NodeMaterialConnectionPoint;
  141090. /**
  141091. * Gets the tint "at distance" input component
  141092. */
  141093. get tintAtDistance(): NodeMaterialConnectionPoint;
  141094. /**
  141095. * Gets the tint thickness input component
  141096. */
  141097. get tintThickness(): NodeMaterialConnectionPoint;
  141098. /**
  141099. * Gets the world tangent input component
  141100. */
  141101. get worldTangent(): NodeMaterialConnectionPoint;
  141102. /**
  141103. * Gets the clear coat object output component
  141104. */
  141105. get clearcoat(): NodeMaterialConnectionPoint;
  141106. autoConfigure(material: NodeMaterial): void;
  141107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141108. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141109. private _generateTBNSpace;
  141110. /**
  141111. * Gets the main code of the block (fragment side)
  141112. * @param state current state of the node material building
  141113. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  141114. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141115. * @param worldPosVarName name of the variable holding the world position
  141116. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141117. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  141118. * @param worldNormalVarName name of the variable holding the world normal
  141119. * @returns the shader code
  141120. */
  141121. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  141122. protected _buildBlock(state: NodeMaterialBuildState): this;
  141123. }
  141124. }
  141125. declare module BABYLON {
  141126. /**
  141127. * Block used to implement the sub surface module of the PBR material
  141128. */
  141129. export class SubSurfaceBlock extends NodeMaterialBlock {
  141130. /**
  141131. * Create a new SubSurfaceBlock
  141132. * @param name defines the block name
  141133. */
  141134. constructor(name: string);
  141135. /**
  141136. * Stores the intensity of the different subsurface effects in the thickness texture.
  141137. * * the green channel is the translucency intensity.
  141138. * * the blue channel is the scattering intensity.
  141139. * * the alpha channel is the refraction intensity.
  141140. */
  141141. useMaskFromThicknessTexture: boolean;
  141142. /**
  141143. * Initialize the block and prepare the context for build
  141144. * @param state defines the state that will be used for the build
  141145. */
  141146. initialize(state: NodeMaterialBuildState): void;
  141147. /**
  141148. * Gets the current class name
  141149. * @returns the class name
  141150. */
  141151. getClassName(): string;
  141152. /**
  141153. * Gets the min thickness input component
  141154. */
  141155. get minThickness(): NodeMaterialConnectionPoint;
  141156. /**
  141157. * Gets the max thickness input component
  141158. */
  141159. get maxThickness(): NodeMaterialConnectionPoint;
  141160. /**
  141161. * Gets the thickness texture component
  141162. */
  141163. get thicknessTexture(): NodeMaterialConnectionPoint;
  141164. /**
  141165. * Gets the tint color input component
  141166. */
  141167. get tintColor(): NodeMaterialConnectionPoint;
  141168. /**
  141169. * Gets the translucency intensity input component
  141170. */
  141171. get translucencyIntensity(): NodeMaterialConnectionPoint;
  141172. /**
  141173. * Gets the translucency diffusion distance input component
  141174. */
  141175. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  141176. /**
  141177. * Gets the refraction object parameters
  141178. */
  141179. get refraction(): NodeMaterialConnectionPoint;
  141180. /**
  141181. * Gets the sub surface object output component
  141182. */
  141183. get subsurface(): NodeMaterialConnectionPoint;
  141184. autoConfigure(material: NodeMaterial): void;
  141185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141186. /**
  141187. * Gets the main code of the block (fragment side)
  141188. * @param state current state of the node material building
  141189. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  141190. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141191. * @param worldPosVarName name of the variable holding the world position
  141192. * @returns the shader code
  141193. */
  141194. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  141195. protected _buildBlock(state: NodeMaterialBuildState): this;
  141196. }
  141197. }
  141198. declare module BABYLON {
  141199. /**
  141200. * Block used to implement the PBR metallic/roughness model
  141201. */
  141202. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  141203. /**
  141204. * Gets or sets the light associated with this block
  141205. */
  141206. light: Nullable<Light>;
  141207. private _lightId;
  141208. private _scene;
  141209. private _environmentBRDFTexture;
  141210. private _environmentBrdfSamplerName;
  141211. private _vNormalWName;
  141212. private _invertNormalName;
  141213. /**
  141214. * Create a new ReflectionBlock
  141215. * @param name defines the block name
  141216. */
  141217. constructor(name: string);
  141218. /**
  141219. * Intensity of the direct lights e.g. the four lights available in your scene.
  141220. * This impacts both the direct diffuse and specular highlights.
  141221. */
  141222. directIntensity: number;
  141223. /**
  141224. * Intensity of the environment e.g. how much the environment will light the object
  141225. * either through harmonics for rough material or through the refelction for shiny ones.
  141226. */
  141227. environmentIntensity: number;
  141228. /**
  141229. * This is a special control allowing the reduction of the specular highlights coming from the
  141230. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  141231. */
  141232. specularIntensity: number;
  141233. /**
  141234. * Defines the falloff type used in this material.
  141235. * It by default is Physical.
  141236. */
  141237. lightFalloff: number;
  141238. /**
  141239. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  141240. */
  141241. useAlphaFromAlbedoTexture: boolean;
  141242. /**
  141243. * Specifies that alpha test should be used
  141244. */
  141245. useAlphaTest: boolean;
  141246. /**
  141247. * Defines the alpha limits in alpha test mode.
  141248. */
  141249. alphaTestCutoff: number;
  141250. /**
  141251. * Specifies that alpha blending should be used
  141252. */
  141253. useAlphaBlending: boolean;
  141254. /**
  141255. * Defines if the alpha value should be determined via the rgb values.
  141256. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  141257. */
  141258. opacityRGB: boolean;
  141259. /**
  141260. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  141261. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  141262. */
  141263. useRadianceOverAlpha: boolean;
  141264. /**
  141265. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  141266. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  141267. */
  141268. useSpecularOverAlpha: boolean;
  141269. /**
  141270. * Enables specular anti aliasing in the PBR shader.
  141271. * It will both interacts on the Geometry for analytical and IBL lighting.
  141272. * It also prefilter the roughness map based on the bump values.
  141273. */
  141274. enableSpecularAntiAliasing: boolean;
  141275. /**
  141276. * Enables realtime filtering on the texture.
  141277. */
  141278. realTimeFiltering: boolean;
  141279. /**
  141280. * Quality switch for realtime filtering
  141281. */
  141282. realTimeFilteringQuality: number;
  141283. /**
  141284. * Defines if the material uses energy conservation.
  141285. */
  141286. useEnergyConservation: boolean;
  141287. /**
  141288. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  141289. * too much the area relying on ambient texture to define their ambient occlusion.
  141290. */
  141291. useRadianceOcclusion: boolean;
  141292. /**
  141293. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  141294. * makes the reflect vector face the model (under horizon).
  141295. */
  141296. useHorizonOcclusion: boolean;
  141297. /**
  141298. * If set to true, no lighting calculations will be applied.
  141299. */
  141300. unlit: boolean;
  141301. /**
  141302. * Force normal to face away from face.
  141303. */
  141304. forceNormalForward: boolean;
  141305. /**
  141306. * Defines the material debug mode.
  141307. * It helps seeing only some components of the material while troubleshooting.
  141308. */
  141309. debugMode: number;
  141310. /**
  141311. * Specify from where on screen the debug mode should start.
  141312. * The value goes from -1 (full screen) to 1 (not visible)
  141313. * It helps with side by side comparison against the final render
  141314. * This defaults to 0
  141315. */
  141316. debugLimit: number;
  141317. /**
  141318. * As the default viewing range might not be enough (if the ambient is really small for instance)
  141319. * You can use the factor to better multiply the final value.
  141320. */
  141321. debugFactor: number;
  141322. /**
  141323. * Initialize the block and prepare the context for build
  141324. * @param state defines the state that will be used for the build
  141325. */
  141326. initialize(state: NodeMaterialBuildState): void;
  141327. /**
  141328. * Gets the current class name
  141329. * @returns the class name
  141330. */
  141331. getClassName(): string;
  141332. /**
  141333. * Gets the world position input component
  141334. */
  141335. get worldPosition(): NodeMaterialConnectionPoint;
  141336. /**
  141337. * Gets the world normal input component
  141338. */
  141339. get worldNormal(): NodeMaterialConnectionPoint;
  141340. /**
  141341. * Gets the perturbed normal input component
  141342. */
  141343. get perturbedNormal(): NodeMaterialConnectionPoint;
  141344. /**
  141345. * Gets the camera position input component
  141346. */
  141347. get cameraPosition(): NodeMaterialConnectionPoint;
  141348. /**
  141349. * Gets the base color input component
  141350. */
  141351. get baseColor(): NodeMaterialConnectionPoint;
  141352. /**
  141353. * Gets the opacity texture input component
  141354. */
  141355. get opacityTexture(): NodeMaterialConnectionPoint;
  141356. /**
  141357. * Gets the ambient color input component
  141358. */
  141359. get ambientColor(): NodeMaterialConnectionPoint;
  141360. /**
  141361. * Gets the reflectivity object parameters
  141362. */
  141363. get reflectivity(): NodeMaterialConnectionPoint;
  141364. /**
  141365. * Gets the ambient occlusion object parameters
  141366. */
  141367. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141368. /**
  141369. * Gets the reflection object parameters
  141370. */
  141371. get reflection(): NodeMaterialConnectionPoint;
  141372. /**
  141373. * Gets the sheen object parameters
  141374. */
  141375. get sheen(): NodeMaterialConnectionPoint;
  141376. /**
  141377. * Gets the clear coat object parameters
  141378. */
  141379. get clearcoat(): NodeMaterialConnectionPoint;
  141380. /**
  141381. * Gets the sub surface object parameters
  141382. */
  141383. get subsurface(): NodeMaterialConnectionPoint;
  141384. /**
  141385. * Gets the anisotropy object parameters
  141386. */
  141387. get anisotropy(): NodeMaterialConnectionPoint;
  141388. /**
  141389. * Gets the ambient output component
  141390. */
  141391. get ambient(): NodeMaterialConnectionPoint;
  141392. /**
  141393. * Gets the diffuse output component
  141394. */
  141395. get diffuse(): NodeMaterialConnectionPoint;
  141396. /**
  141397. * Gets the specular output component
  141398. */
  141399. get specular(): NodeMaterialConnectionPoint;
  141400. /**
  141401. * Gets the sheen output component
  141402. */
  141403. get sheenDir(): NodeMaterialConnectionPoint;
  141404. /**
  141405. * Gets the clear coat output component
  141406. */
  141407. get clearcoatDir(): NodeMaterialConnectionPoint;
  141408. /**
  141409. * Gets the indirect diffuse output component
  141410. */
  141411. get diffuseIndirect(): NodeMaterialConnectionPoint;
  141412. /**
  141413. * Gets the indirect specular output component
  141414. */
  141415. get specularIndirect(): NodeMaterialConnectionPoint;
  141416. /**
  141417. * Gets the indirect sheen output component
  141418. */
  141419. get sheenIndirect(): NodeMaterialConnectionPoint;
  141420. /**
  141421. * Gets the indirect clear coat output component
  141422. */
  141423. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  141424. /**
  141425. * Gets the refraction output component
  141426. */
  141427. get refraction(): NodeMaterialConnectionPoint;
  141428. /**
  141429. * Gets the global lighting output component
  141430. */
  141431. get lighting(): NodeMaterialConnectionPoint;
  141432. /**
  141433. * Gets the shadow output component
  141434. */
  141435. get shadow(): NodeMaterialConnectionPoint;
  141436. /**
  141437. * Gets the alpha output component
  141438. */
  141439. get alpha(): NodeMaterialConnectionPoint;
  141440. autoConfigure(material: NodeMaterial): void;
  141441. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141442. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141443. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141444. private _injectVertexCode;
  141445. /**
  141446. * Gets the code corresponding to the albedo/opacity module
  141447. * @returns the shader code
  141448. */
  141449. getAlbedoOpacityCode(): string;
  141450. protected _buildBlock(state: NodeMaterialBuildState): this;
  141451. protected _dumpPropertiesCode(): string;
  141452. serialize(): any;
  141453. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141454. }
  141455. }
  141456. declare module BABYLON {
  141457. /**
  141458. * Block used to compute value of one parameter modulo another
  141459. */
  141460. export class ModBlock extends NodeMaterialBlock {
  141461. /**
  141462. * Creates a new ModBlock
  141463. * @param name defines the block name
  141464. */
  141465. constructor(name: string);
  141466. /**
  141467. * Gets the current class name
  141468. * @returns the class name
  141469. */
  141470. getClassName(): string;
  141471. /**
  141472. * Gets the left operand input component
  141473. */
  141474. get left(): NodeMaterialConnectionPoint;
  141475. /**
  141476. * Gets the right operand input component
  141477. */
  141478. get right(): NodeMaterialConnectionPoint;
  141479. /**
  141480. * Gets the output component
  141481. */
  141482. get output(): NodeMaterialConnectionPoint;
  141483. protected _buildBlock(state: NodeMaterialBuildState): this;
  141484. }
  141485. }
  141486. declare module BABYLON {
  141487. /**
  141488. * Helper class to push actions to a pool of workers.
  141489. */
  141490. export class WorkerPool implements IDisposable {
  141491. private _workerInfos;
  141492. private _pendingActions;
  141493. /**
  141494. * Constructor
  141495. * @param workers Array of workers to use for actions
  141496. */
  141497. constructor(workers: Array<Worker>);
  141498. /**
  141499. * Terminates all workers and clears any pending actions.
  141500. */
  141501. dispose(): void;
  141502. /**
  141503. * Pushes an action to the worker pool. If all the workers are active, the action will be
  141504. * pended until a worker has completed its action.
  141505. * @param action The action to perform. Call onComplete when the action is complete.
  141506. */
  141507. push(action: (worker: Worker, onComplete: () => void) => void): void;
  141508. private _execute;
  141509. }
  141510. }
  141511. declare module BABYLON {
  141512. /**
  141513. * Configuration for Draco compression
  141514. */
  141515. export interface IDracoCompressionConfiguration {
  141516. /**
  141517. * Configuration for the decoder.
  141518. */
  141519. decoder: {
  141520. /**
  141521. * The url to the WebAssembly module.
  141522. */
  141523. wasmUrl?: string;
  141524. /**
  141525. * The url to the WebAssembly binary.
  141526. */
  141527. wasmBinaryUrl?: string;
  141528. /**
  141529. * The url to the fallback JavaScript module.
  141530. */
  141531. fallbackUrl?: string;
  141532. };
  141533. }
  141534. /**
  141535. * Draco compression (https://google.github.io/draco/)
  141536. *
  141537. * This class wraps the Draco module.
  141538. *
  141539. * **Encoder**
  141540. *
  141541. * The encoder is not currently implemented.
  141542. *
  141543. * **Decoder**
  141544. *
  141545. * 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.
  141546. *
  141547. * To update the configuration, use the following code:
  141548. * ```javascript
  141549. * DracoCompression.Configuration = {
  141550. * decoder: {
  141551. * wasmUrl: "<url to the WebAssembly library>",
  141552. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  141553. * fallbackUrl: "<url to the fallback JavaScript library>",
  141554. * }
  141555. * };
  141556. * ```
  141557. *
  141558. * 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.
  141559. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  141560. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  141561. *
  141562. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  141563. * ```javascript
  141564. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  141565. * ```
  141566. *
  141567. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  141568. */
  141569. export class DracoCompression implements IDisposable {
  141570. private _workerPoolPromise?;
  141571. private _decoderModulePromise?;
  141572. /**
  141573. * The configuration. Defaults to the following urls:
  141574. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  141575. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  141576. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  141577. */
  141578. static Configuration: IDracoCompressionConfiguration;
  141579. /**
  141580. * Returns true if the decoder configuration is available.
  141581. */
  141582. static get DecoderAvailable(): boolean;
  141583. /**
  141584. * Default number of workers to create when creating the draco compression object.
  141585. */
  141586. static DefaultNumWorkers: number;
  141587. private static GetDefaultNumWorkers;
  141588. private static _Default;
  141589. /**
  141590. * Default instance for the draco compression object.
  141591. */
  141592. static get Default(): DracoCompression;
  141593. /**
  141594. * Constructor
  141595. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  141596. */
  141597. constructor(numWorkers?: number);
  141598. /**
  141599. * Stop all async operations and release resources.
  141600. */
  141601. dispose(): void;
  141602. /**
  141603. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  141604. * @returns a promise that resolves when ready
  141605. */
  141606. whenReadyAsync(): Promise<void>;
  141607. /**
  141608. * Decode Draco compressed mesh data to vertex data.
  141609. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  141610. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  141611. * @returns A promise that resolves with the decoded vertex data
  141612. */
  141613. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  141614. [kind: string]: number;
  141615. }): Promise<VertexData>;
  141616. }
  141617. }
  141618. declare module BABYLON {
  141619. /**
  141620. * Class for building Constructive Solid Geometry
  141621. */
  141622. export class CSG {
  141623. private polygons;
  141624. /**
  141625. * The world matrix
  141626. */
  141627. matrix: Matrix;
  141628. /**
  141629. * Stores the position
  141630. */
  141631. position: Vector3;
  141632. /**
  141633. * Stores the rotation
  141634. */
  141635. rotation: Vector3;
  141636. /**
  141637. * Stores the rotation quaternion
  141638. */
  141639. rotationQuaternion: Nullable<Quaternion>;
  141640. /**
  141641. * Stores the scaling vector
  141642. */
  141643. scaling: Vector3;
  141644. /**
  141645. * Convert the Mesh to CSG
  141646. * @param mesh The Mesh to convert to CSG
  141647. * @returns A new CSG from the Mesh
  141648. */
  141649. static FromMesh(mesh: Mesh): CSG;
  141650. /**
  141651. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  141652. * @param polygons Polygons used to construct a CSG solid
  141653. */
  141654. private static FromPolygons;
  141655. /**
  141656. * Clones, or makes a deep copy, of the CSG
  141657. * @returns A new CSG
  141658. */
  141659. clone(): CSG;
  141660. /**
  141661. * Unions this CSG with another CSG
  141662. * @param csg The CSG to union against this CSG
  141663. * @returns The unioned CSG
  141664. */
  141665. union(csg: CSG): CSG;
  141666. /**
  141667. * Unions this CSG with another CSG in place
  141668. * @param csg The CSG to union against this CSG
  141669. */
  141670. unionInPlace(csg: CSG): void;
  141671. /**
  141672. * Subtracts this CSG with another CSG
  141673. * @param csg The CSG to subtract against this CSG
  141674. * @returns A new CSG
  141675. */
  141676. subtract(csg: CSG): CSG;
  141677. /**
  141678. * Subtracts this CSG with another CSG in place
  141679. * @param csg The CSG to subtact against this CSG
  141680. */
  141681. subtractInPlace(csg: CSG): void;
  141682. /**
  141683. * Intersect this CSG with another CSG
  141684. * @param csg The CSG to intersect against this CSG
  141685. * @returns A new CSG
  141686. */
  141687. intersect(csg: CSG): CSG;
  141688. /**
  141689. * Intersects this CSG with another CSG in place
  141690. * @param csg The CSG to intersect against this CSG
  141691. */
  141692. intersectInPlace(csg: CSG): void;
  141693. /**
  141694. * Return a new CSG solid with solid and empty space switched. This solid is
  141695. * not modified.
  141696. * @returns A new CSG solid with solid and empty space switched
  141697. */
  141698. inverse(): CSG;
  141699. /**
  141700. * Inverses the CSG in place
  141701. */
  141702. inverseInPlace(): void;
  141703. /**
  141704. * This is used to keep meshes transformations so they can be restored
  141705. * when we build back a Babylon Mesh
  141706. * NB : All CSG operations are performed in world coordinates
  141707. * @param csg The CSG to copy the transform attributes from
  141708. * @returns This CSG
  141709. */
  141710. copyTransformAttributes(csg: CSG): CSG;
  141711. /**
  141712. * Build Raw mesh from CSG
  141713. * Coordinates here are in world space
  141714. * @param name The name of the mesh geometry
  141715. * @param scene The Scene
  141716. * @param keepSubMeshes Specifies if the submeshes should be kept
  141717. * @returns A new Mesh
  141718. */
  141719. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  141720. /**
  141721. * Build Mesh from CSG taking material and transforms into account
  141722. * @param name The name of the Mesh
  141723. * @param material The material of the Mesh
  141724. * @param scene The Scene
  141725. * @param keepSubMeshes Specifies if submeshes should be kept
  141726. * @returns The new Mesh
  141727. */
  141728. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  141729. }
  141730. }
  141731. declare module BABYLON {
  141732. /**
  141733. * Class used to create a trail following a mesh
  141734. */
  141735. export class TrailMesh extends Mesh {
  141736. private _generator;
  141737. private _autoStart;
  141738. private _running;
  141739. private _diameter;
  141740. private _length;
  141741. private _sectionPolygonPointsCount;
  141742. private _sectionVectors;
  141743. private _sectionNormalVectors;
  141744. private _beforeRenderObserver;
  141745. /**
  141746. * @constructor
  141747. * @param name The value used by scene.getMeshByName() to do a lookup.
  141748. * @param generator The mesh or transform node to generate a trail.
  141749. * @param scene The scene to add this mesh to.
  141750. * @param diameter Diameter of trailing mesh. Default is 1.
  141751. * @param length Length of trailing mesh. Default is 60.
  141752. * @param autoStart Automatically start trailing mesh. Default true.
  141753. */
  141754. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  141755. /**
  141756. * "TrailMesh"
  141757. * @returns "TrailMesh"
  141758. */
  141759. getClassName(): string;
  141760. private _createMesh;
  141761. /**
  141762. * Start trailing mesh.
  141763. */
  141764. start(): void;
  141765. /**
  141766. * Stop trailing mesh.
  141767. */
  141768. stop(): void;
  141769. /**
  141770. * Update trailing mesh geometry.
  141771. */
  141772. update(): void;
  141773. /**
  141774. * Returns a new TrailMesh object.
  141775. * @param name is a string, the name given to the new mesh
  141776. * @param newGenerator use new generator object for cloned trail mesh
  141777. * @returns a new mesh
  141778. */
  141779. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  141780. /**
  141781. * Serializes this trail mesh
  141782. * @param serializationObject object to write serialization to
  141783. */
  141784. serialize(serializationObject: any): void;
  141785. /**
  141786. * Parses a serialized trail mesh
  141787. * @param parsedMesh the serialized mesh
  141788. * @param scene the scene to create the trail mesh in
  141789. * @returns the created trail mesh
  141790. */
  141791. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  141792. }
  141793. }
  141794. declare module BABYLON {
  141795. /**
  141796. * Class containing static functions to help procedurally build meshes
  141797. */
  141798. export class TiledBoxBuilder {
  141799. /**
  141800. * Creates a box mesh
  141801. * 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)
  141802. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141806. * @param name defines the name of the mesh
  141807. * @param options defines the options used to create the mesh
  141808. * @param scene defines the hosting scene
  141809. * @returns the box mesh
  141810. */
  141811. static CreateTiledBox(name: string, options: {
  141812. pattern?: number;
  141813. width?: number;
  141814. height?: number;
  141815. depth?: number;
  141816. tileSize?: number;
  141817. tileWidth?: number;
  141818. tileHeight?: number;
  141819. alignHorizontal?: number;
  141820. alignVertical?: number;
  141821. faceUV?: Vector4[];
  141822. faceColors?: Color4[];
  141823. sideOrientation?: number;
  141824. updatable?: boolean;
  141825. }, scene?: Nullable<Scene>): Mesh;
  141826. }
  141827. }
  141828. declare module BABYLON {
  141829. /**
  141830. * Class containing static functions to help procedurally build meshes
  141831. */
  141832. export class TorusKnotBuilder {
  141833. /**
  141834. * Creates a torus knot mesh
  141835. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141836. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141837. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141838. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141840. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141842. * @param name defines the name of the mesh
  141843. * @param options defines the options used to create the mesh
  141844. * @param scene defines the hosting scene
  141845. * @returns the torus knot mesh
  141846. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141847. */
  141848. static CreateTorusKnot(name: string, options: {
  141849. radius?: number;
  141850. tube?: number;
  141851. radialSegments?: number;
  141852. tubularSegments?: number;
  141853. p?: number;
  141854. q?: number;
  141855. updatable?: boolean;
  141856. sideOrientation?: number;
  141857. frontUVs?: Vector4;
  141858. backUVs?: Vector4;
  141859. }, scene: any): Mesh;
  141860. }
  141861. }
  141862. declare module BABYLON {
  141863. /**
  141864. * Polygon
  141865. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  141866. */
  141867. export class Polygon {
  141868. /**
  141869. * Creates a rectangle
  141870. * @param xmin bottom X coord
  141871. * @param ymin bottom Y coord
  141872. * @param xmax top X coord
  141873. * @param ymax top Y coord
  141874. * @returns points that make the resulting rectation
  141875. */
  141876. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  141877. /**
  141878. * Creates a circle
  141879. * @param radius radius of circle
  141880. * @param cx scale in x
  141881. * @param cy scale in y
  141882. * @param numberOfSides number of sides that make up the circle
  141883. * @returns points that make the resulting circle
  141884. */
  141885. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  141886. /**
  141887. * Creates a polygon from input string
  141888. * @param input Input polygon data
  141889. * @returns the parsed points
  141890. */
  141891. static Parse(input: string): Vector2[];
  141892. /**
  141893. * Starts building a polygon from x and y coordinates
  141894. * @param x x coordinate
  141895. * @param y y coordinate
  141896. * @returns the started path2
  141897. */
  141898. static StartingAt(x: number, y: number): Path2;
  141899. }
  141900. /**
  141901. * Builds a polygon
  141902. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  141903. */
  141904. export class PolygonMeshBuilder {
  141905. private _points;
  141906. private _outlinepoints;
  141907. private _holes;
  141908. private _name;
  141909. private _scene;
  141910. private _epoints;
  141911. private _eholes;
  141912. private _addToepoint;
  141913. /**
  141914. * Babylon reference to the earcut plugin.
  141915. */
  141916. bjsEarcut: any;
  141917. /**
  141918. * Creates a PolygonMeshBuilder
  141919. * @param name name of the builder
  141920. * @param contours Path of the polygon
  141921. * @param scene scene to add to when creating the mesh
  141922. * @param earcutInjection can be used to inject your own earcut reference
  141923. */
  141924. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  141925. /**
  141926. * Adds a whole within the polygon
  141927. * @param hole Array of points defining the hole
  141928. * @returns this
  141929. */
  141930. addHole(hole: Vector2[]): PolygonMeshBuilder;
  141931. /**
  141932. * Creates the polygon
  141933. * @param updatable If the mesh should be updatable
  141934. * @param depth The depth of the mesh created
  141935. * @returns the created mesh
  141936. */
  141937. build(updatable?: boolean, depth?: number): Mesh;
  141938. /**
  141939. * Creates the polygon
  141940. * @param depth The depth of the mesh created
  141941. * @returns the created VertexData
  141942. */
  141943. buildVertexData(depth?: number): VertexData;
  141944. /**
  141945. * Adds a side to the polygon
  141946. * @param positions points that make the polygon
  141947. * @param normals normals of the polygon
  141948. * @param uvs uvs of the polygon
  141949. * @param indices indices of the polygon
  141950. * @param bounds bounds of the polygon
  141951. * @param points points of the polygon
  141952. * @param depth depth of the polygon
  141953. * @param flip flip of the polygon
  141954. */
  141955. private addSide;
  141956. }
  141957. }
  141958. declare module BABYLON {
  141959. /**
  141960. * Class containing static functions to help procedurally build meshes
  141961. */
  141962. export class PolygonBuilder {
  141963. /**
  141964. * Creates a polygon mesh
  141965. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141966. * * 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
  141967. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141970. * * Remember you can only change the shape positions, not their number when updating a polygon
  141971. * @param name defines the name of the mesh
  141972. * @param options defines the options used to create the mesh
  141973. * @param scene defines the hosting scene
  141974. * @param earcutInjection can be used to inject your own earcut reference
  141975. * @returns the polygon mesh
  141976. */
  141977. static CreatePolygon(name: string, options: {
  141978. shape: Vector3[];
  141979. holes?: Vector3[][];
  141980. depth?: number;
  141981. faceUV?: Vector4[];
  141982. faceColors?: Color4[];
  141983. updatable?: boolean;
  141984. sideOrientation?: number;
  141985. frontUVs?: Vector4;
  141986. backUVs?: Vector4;
  141987. wrap?: boolean;
  141988. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141989. /**
  141990. * Creates an extruded polygon mesh, with depth in the Y direction.
  141991. * * 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)
  141992. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141993. * @param name defines the name of the mesh
  141994. * @param options defines the options used to create the mesh
  141995. * @param scene defines the hosting scene
  141996. * @param earcutInjection can be used to inject your own earcut reference
  141997. * @returns the polygon mesh
  141998. */
  141999. static ExtrudePolygon(name: string, options: {
  142000. shape: Vector3[];
  142001. holes?: Vector3[][];
  142002. depth?: number;
  142003. faceUV?: Vector4[];
  142004. faceColors?: Color4[];
  142005. updatable?: boolean;
  142006. sideOrientation?: number;
  142007. frontUVs?: Vector4;
  142008. backUVs?: Vector4;
  142009. wrap?: boolean;
  142010. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142011. }
  142012. }
  142013. declare module BABYLON {
  142014. /**
  142015. * Class containing static functions to help procedurally build meshes
  142016. */
  142017. export class LatheBuilder {
  142018. /**
  142019. * Creates lathe mesh.
  142020. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142021. * * 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
  142022. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142023. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142024. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142025. * * 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
  142026. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142027. * * 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
  142028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142030. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142032. * @param name defines the name of the mesh
  142033. * @param options defines the options used to create the mesh
  142034. * @param scene defines the hosting scene
  142035. * @returns the lathe mesh
  142036. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142037. */
  142038. static CreateLathe(name: string, options: {
  142039. shape: Vector3[];
  142040. radius?: number;
  142041. tessellation?: number;
  142042. clip?: number;
  142043. arc?: number;
  142044. closed?: boolean;
  142045. updatable?: boolean;
  142046. sideOrientation?: number;
  142047. frontUVs?: Vector4;
  142048. backUVs?: Vector4;
  142049. cap?: number;
  142050. invertUV?: boolean;
  142051. }, scene?: Nullable<Scene>): Mesh;
  142052. }
  142053. }
  142054. declare module BABYLON {
  142055. /**
  142056. * Class containing static functions to help procedurally build meshes
  142057. */
  142058. export class TiledPlaneBuilder {
  142059. /**
  142060. * Creates a tiled plane mesh
  142061. * * The parameter `pattern` will, depending on value, do nothing or
  142062. * * * flip (reflect about central vertical) alternate tiles across and up
  142063. * * * flip every tile on alternate rows
  142064. * * * rotate (180 degs) alternate tiles across and up
  142065. * * * rotate every tile on alternate rows
  142066. * * * flip and rotate alternate tiles across and up
  142067. * * * flip and rotate every tile on alternate rows
  142068. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  142069. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  142070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142072. * * 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)
  142073. * * 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)
  142074. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142075. * @param name defines the name of the mesh
  142076. * @param options defines the options used to create the mesh
  142077. * @param scene defines the hosting scene
  142078. * @returns the box mesh
  142079. */
  142080. static CreateTiledPlane(name: string, options: {
  142081. pattern?: number;
  142082. tileSize?: number;
  142083. tileWidth?: number;
  142084. tileHeight?: number;
  142085. size?: number;
  142086. width?: number;
  142087. height?: number;
  142088. alignHorizontal?: number;
  142089. alignVertical?: number;
  142090. sideOrientation?: number;
  142091. frontUVs?: Vector4;
  142092. backUVs?: Vector4;
  142093. updatable?: boolean;
  142094. }, scene?: Nullable<Scene>): Mesh;
  142095. }
  142096. }
  142097. declare module BABYLON {
  142098. /**
  142099. * Class containing static functions to help procedurally build meshes
  142100. */
  142101. export class TubeBuilder {
  142102. /**
  142103. * Creates a tube mesh.
  142104. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142105. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142106. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142107. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142108. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142109. * * 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)
  142110. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142111. * * 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
  142112. * * 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
  142113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142114. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142115. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142117. * @param name defines the name of the mesh
  142118. * @param options defines the options used to create the mesh
  142119. * @param scene defines the hosting scene
  142120. * @returns the tube mesh
  142121. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142122. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142123. */
  142124. static CreateTube(name: string, options: {
  142125. path: Vector3[];
  142126. radius?: number;
  142127. tessellation?: number;
  142128. radiusFunction?: {
  142129. (i: number, distance: number): number;
  142130. };
  142131. cap?: number;
  142132. arc?: number;
  142133. updatable?: boolean;
  142134. sideOrientation?: number;
  142135. frontUVs?: Vector4;
  142136. backUVs?: Vector4;
  142137. instance?: Mesh;
  142138. invertUV?: boolean;
  142139. }, scene?: Nullable<Scene>): Mesh;
  142140. }
  142141. }
  142142. declare module BABYLON {
  142143. /**
  142144. * Class containing static functions to help procedurally build meshes
  142145. */
  142146. export class IcoSphereBuilder {
  142147. /**
  142148. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142149. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142150. * * 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`)
  142151. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142152. * * 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
  142153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142154. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142156. * @param name defines the name of the mesh
  142157. * @param options defines the options used to create the mesh
  142158. * @param scene defines the hosting scene
  142159. * @returns the icosahedron mesh
  142160. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142161. */
  142162. static CreateIcoSphere(name: string, options: {
  142163. radius?: number;
  142164. radiusX?: number;
  142165. radiusY?: number;
  142166. radiusZ?: number;
  142167. flat?: boolean;
  142168. subdivisions?: number;
  142169. sideOrientation?: number;
  142170. frontUVs?: Vector4;
  142171. backUVs?: Vector4;
  142172. updatable?: boolean;
  142173. }, scene?: Nullable<Scene>): Mesh;
  142174. }
  142175. }
  142176. declare module BABYLON {
  142177. /**
  142178. * Class containing static functions to help procedurally build meshes
  142179. */
  142180. export class DecalBuilder {
  142181. /**
  142182. * Creates a decal mesh.
  142183. * 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
  142184. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142185. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142186. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142187. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142188. * @param name defines the name of the mesh
  142189. * @param sourceMesh defines the mesh where the decal must be applied
  142190. * @param options defines the options used to create the mesh
  142191. * @param scene defines the hosting scene
  142192. * @returns the decal mesh
  142193. * @see https://doc.babylonjs.com/how_to/decals
  142194. */
  142195. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142196. position?: Vector3;
  142197. normal?: Vector3;
  142198. size?: Vector3;
  142199. angle?: number;
  142200. }): Mesh;
  142201. }
  142202. }
  142203. declare module BABYLON {
  142204. /**
  142205. * Class containing static functions to help procedurally build meshes
  142206. */
  142207. export class MeshBuilder {
  142208. /**
  142209. * Creates a box mesh
  142210. * * The parameter `size` sets the size (float) of each box side (default 1)
  142211. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142212. * * 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)
  142213. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142217. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142218. * @param name defines the name of the mesh
  142219. * @param options defines the options used to create the mesh
  142220. * @param scene defines the hosting scene
  142221. * @returns the box mesh
  142222. */
  142223. static CreateBox(name: string, options: {
  142224. size?: number;
  142225. width?: number;
  142226. height?: number;
  142227. depth?: number;
  142228. faceUV?: Vector4[];
  142229. faceColors?: Color4[];
  142230. sideOrientation?: number;
  142231. frontUVs?: Vector4;
  142232. backUVs?: Vector4;
  142233. wrap?: boolean;
  142234. topBaseAt?: number;
  142235. bottomBaseAt?: number;
  142236. updatable?: boolean;
  142237. }, scene?: Nullable<Scene>): Mesh;
  142238. /**
  142239. * Creates a tiled box mesh
  142240. * * faceTiles sets the pattern, tile size and number of tiles for a face
  142241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142242. * @param name defines the name of the mesh
  142243. * @param options defines the options used to create the mesh
  142244. * @param scene defines the hosting scene
  142245. * @returns the tiled box mesh
  142246. */
  142247. static CreateTiledBox(name: string, options: {
  142248. pattern?: number;
  142249. size?: number;
  142250. width?: number;
  142251. height?: number;
  142252. depth: number;
  142253. tileSize?: number;
  142254. tileWidth?: number;
  142255. tileHeight?: number;
  142256. faceUV?: Vector4[];
  142257. faceColors?: Color4[];
  142258. alignHorizontal?: number;
  142259. alignVertical?: number;
  142260. sideOrientation?: number;
  142261. updatable?: boolean;
  142262. }, scene?: Nullable<Scene>): Mesh;
  142263. /**
  142264. * Creates a sphere mesh
  142265. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  142266. * * 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`)
  142267. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  142268. * * 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
  142269. * * 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)
  142270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142273. * @param name defines the name of the mesh
  142274. * @param options defines the options used to create the mesh
  142275. * @param scene defines the hosting scene
  142276. * @returns the sphere mesh
  142277. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  142278. */
  142279. static CreateSphere(name: string, options: {
  142280. segments?: number;
  142281. diameter?: number;
  142282. diameterX?: number;
  142283. diameterY?: number;
  142284. diameterZ?: number;
  142285. arc?: number;
  142286. slice?: number;
  142287. sideOrientation?: number;
  142288. frontUVs?: Vector4;
  142289. backUVs?: Vector4;
  142290. updatable?: boolean;
  142291. }, scene?: Nullable<Scene>): Mesh;
  142292. /**
  142293. * Creates a plane polygonal mesh. By default, this is a disc
  142294. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  142295. * * 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
  142296. * * 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
  142297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142300. * @param name defines the name of the mesh
  142301. * @param options defines the options used to create the mesh
  142302. * @param scene defines the hosting scene
  142303. * @returns the plane polygonal mesh
  142304. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  142305. */
  142306. static CreateDisc(name: string, options: {
  142307. radius?: number;
  142308. tessellation?: number;
  142309. arc?: number;
  142310. updatable?: boolean;
  142311. sideOrientation?: number;
  142312. frontUVs?: Vector4;
  142313. backUVs?: Vector4;
  142314. }, scene?: Nullable<Scene>): Mesh;
  142315. /**
  142316. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142317. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142318. * * 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`)
  142319. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142320. * * 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
  142321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142324. * @param name defines the name of the mesh
  142325. * @param options defines the options used to create the mesh
  142326. * @param scene defines the hosting scene
  142327. * @returns the icosahedron mesh
  142328. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142329. */
  142330. static CreateIcoSphere(name: string, options: {
  142331. radius?: number;
  142332. radiusX?: number;
  142333. radiusY?: number;
  142334. radiusZ?: number;
  142335. flat?: boolean;
  142336. subdivisions?: number;
  142337. sideOrientation?: number;
  142338. frontUVs?: Vector4;
  142339. backUVs?: Vector4;
  142340. updatable?: boolean;
  142341. }, scene?: Nullable<Scene>): Mesh;
  142342. /**
  142343. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142344. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  142345. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  142346. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  142347. * * 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
  142348. * * 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
  142349. * * 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
  142350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142352. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142353. * * 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
  142354. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  142355. * * 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
  142356. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  142357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142358. * @param name defines the name of the mesh
  142359. * @param options defines the options used to create the mesh
  142360. * @param scene defines the hosting scene
  142361. * @returns the ribbon mesh
  142362. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  142363. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142364. */
  142365. static CreateRibbon(name: string, options: {
  142366. pathArray: Vector3[][];
  142367. closeArray?: boolean;
  142368. closePath?: boolean;
  142369. offset?: number;
  142370. updatable?: boolean;
  142371. sideOrientation?: number;
  142372. frontUVs?: Vector4;
  142373. backUVs?: Vector4;
  142374. instance?: Mesh;
  142375. invertUV?: boolean;
  142376. uvs?: Vector2[];
  142377. colors?: Color4[];
  142378. }, scene?: Nullable<Scene>): Mesh;
  142379. /**
  142380. * Creates a cylinder or a cone mesh
  142381. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  142382. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  142383. * * 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.
  142384. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  142385. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  142386. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  142387. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  142388. * * 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).
  142389. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  142390. * * 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).
  142391. * * 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
  142392. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  142393. * * 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
  142394. * * 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.
  142395. * * If `enclose` is false, a ring surface is one element.
  142396. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  142397. * * 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
  142398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142401. * @param name defines the name of the mesh
  142402. * @param options defines the options used to create the mesh
  142403. * @param scene defines the hosting scene
  142404. * @returns the cylinder mesh
  142405. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  142406. */
  142407. static CreateCylinder(name: string, options: {
  142408. height?: number;
  142409. diameterTop?: number;
  142410. diameterBottom?: number;
  142411. diameter?: number;
  142412. tessellation?: number;
  142413. subdivisions?: number;
  142414. arc?: number;
  142415. faceColors?: Color4[];
  142416. faceUV?: Vector4[];
  142417. updatable?: boolean;
  142418. hasRings?: boolean;
  142419. enclose?: boolean;
  142420. cap?: number;
  142421. sideOrientation?: number;
  142422. frontUVs?: Vector4;
  142423. backUVs?: Vector4;
  142424. }, scene?: Nullable<Scene>): Mesh;
  142425. /**
  142426. * Creates a torus mesh
  142427. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  142428. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  142429. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  142430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142433. * @param name defines the name of the mesh
  142434. * @param options defines the options used to create the mesh
  142435. * @param scene defines the hosting scene
  142436. * @returns the torus mesh
  142437. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  142438. */
  142439. static CreateTorus(name: string, options: {
  142440. diameter?: number;
  142441. thickness?: number;
  142442. tessellation?: number;
  142443. updatable?: boolean;
  142444. sideOrientation?: number;
  142445. frontUVs?: Vector4;
  142446. backUVs?: Vector4;
  142447. }, scene?: Nullable<Scene>): Mesh;
  142448. /**
  142449. * Creates a torus knot mesh
  142450. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142451. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142452. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142453. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142457. * @param name defines the name of the mesh
  142458. * @param options defines the options used to create the mesh
  142459. * @param scene defines the hosting scene
  142460. * @returns the torus knot mesh
  142461. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142462. */
  142463. static CreateTorusKnot(name: string, options: {
  142464. radius?: number;
  142465. tube?: number;
  142466. radialSegments?: number;
  142467. tubularSegments?: number;
  142468. p?: number;
  142469. q?: number;
  142470. updatable?: boolean;
  142471. sideOrientation?: number;
  142472. frontUVs?: Vector4;
  142473. backUVs?: Vector4;
  142474. }, scene?: Nullable<Scene>): Mesh;
  142475. /**
  142476. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  142477. * * 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
  142478. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  142479. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  142480. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  142481. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  142482. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  142483. * * 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
  142484. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  142485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  142487. * @param name defines the name of the new line system
  142488. * @param options defines the options used to create the line system
  142489. * @param scene defines the hosting scene
  142490. * @returns a new line system mesh
  142491. */
  142492. static CreateLineSystem(name: string, options: {
  142493. lines: Vector3[][];
  142494. updatable?: boolean;
  142495. instance?: Nullable<LinesMesh>;
  142496. colors?: Nullable<Color4[][]>;
  142497. useVertexAlpha?: boolean;
  142498. }, scene: Nullable<Scene>): LinesMesh;
  142499. /**
  142500. * Creates a line mesh
  142501. * 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
  142502. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142503. * * The parameter `points` is an array successive Vector3
  142504. * * 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
  142505. * * The optional parameter `colors` is an array of successive Color4, one per line point
  142506. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  142507. * * When updating an instance, remember that only point positions can change, not the number of points
  142508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  142510. * @param name defines the name of the new line system
  142511. * @param options defines the options used to create the line system
  142512. * @param scene defines the hosting scene
  142513. * @returns a new line mesh
  142514. */
  142515. static CreateLines(name: string, options: {
  142516. points: Vector3[];
  142517. updatable?: boolean;
  142518. instance?: Nullable<LinesMesh>;
  142519. colors?: Color4[];
  142520. useVertexAlpha?: boolean;
  142521. }, scene?: Nullable<Scene>): LinesMesh;
  142522. /**
  142523. * Creates a dashed line mesh
  142524. * * 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
  142525. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142526. * * The parameter `points` is an array successive Vector3
  142527. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  142528. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  142529. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  142530. * * 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
  142531. * * When updating an instance, remember that only point positions can change, not the number of points
  142532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142533. * @param name defines the name of the mesh
  142534. * @param options defines the options used to create the mesh
  142535. * @param scene defines the hosting scene
  142536. * @returns the dashed line mesh
  142537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  142538. */
  142539. static CreateDashedLines(name: string, options: {
  142540. points: Vector3[];
  142541. dashSize?: number;
  142542. gapSize?: number;
  142543. dashNb?: number;
  142544. updatable?: boolean;
  142545. instance?: LinesMesh;
  142546. }, scene?: Nullable<Scene>): LinesMesh;
  142547. /**
  142548. * 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.
  142549. * * 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.
  142550. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142551. * * 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.
  142552. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  142553. * * 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
  142554. * * 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
  142555. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  142556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142558. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  142559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142560. * @param name defines the name of the mesh
  142561. * @param options defines the options used to create the mesh
  142562. * @param scene defines the hosting scene
  142563. * @returns the extruded shape mesh
  142564. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142566. */
  142567. static ExtrudeShape(name: string, options: {
  142568. shape: Vector3[];
  142569. path: Vector3[];
  142570. scale?: number;
  142571. rotation?: number;
  142572. cap?: number;
  142573. updatable?: boolean;
  142574. sideOrientation?: number;
  142575. frontUVs?: Vector4;
  142576. backUVs?: Vector4;
  142577. instance?: Mesh;
  142578. invertUV?: boolean;
  142579. }, scene?: Nullable<Scene>): Mesh;
  142580. /**
  142581. * Creates an custom extruded shape mesh.
  142582. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  142583. * * 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.
  142584. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142585. * * 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
  142586. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  142587. * * 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
  142588. * * It must returns a float value that will be the scale value applied to the shape on each path point
  142589. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  142590. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  142591. * * 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
  142592. * * 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
  142593. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  142594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142596. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142598. * @param name defines the name of the mesh
  142599. * @param options defines the options used to create the mesh
  142600. * @param scene defines the hosting scene
  142601. * @returns the custom extruded shape mesh
  142602. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  142603. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142605. */
  142606. static ExtrudeShapeCustom(name: string, options: {
  142607. shape: Vector3[];
  142608. path: Vector3[];
  142609. scaleFunction?: any;
  142610. rotationFunction?: any;
  142611. ribbonCloseArray?: boolean;
  142612. ribbonClosePath?: boolean;
  142613. cap?: number;
  142614. updatable?: boolean;
  142615. sideOrientation?: number;
  142616. frontUVs?: Vector4;
  142617. backUVs?: Vector4;
  142618. instance?: Mesh;
  142619. invertUV?: boolean;
  142620. }, scene?: Nullable<Scene>): Mesh;
  142621. /**
  142622. * Creates lathe mesh.
  142623. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142624. * * 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
  142625. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142626. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142627. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142628. * * 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
  142629. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142630. * * 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
  142631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142635. * @param name defines the name of the mesh
  142636. * @param options defines the options used to create the mesh
  142637. * @param scene defines the hosting scene
  142638. * @returns the lathe mesh
  142639. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142640. */
  142641. static CreateLathe(name: string, options: {
  142642. shape: Vector3[];
  142643. radius?: number;
  142644. tessellation?: number;
  142645. clip?: number;
  142646. arc?: number;
  142647. closed?: boolean;
  142648. updatable?: boolean;
  142649. sideOrientation?: number;
  142650. frontUVs?: Vector4;
  142651. backUVs?: Vector4;
  142652. cap?: number;
  142653. invertUV?: boolean;
  142654. }, scene?: Nullable<Scene>): Mesh;
  142655. /**
  142656. * Creates a tiled plane mesh
  142657. * * You can set a limited pattern arrangement with the tiles
  142658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142661. * @param name defines the name of the mesh
  142662. * @param options defines the options used to create the mesh
  142663. * @param scene defines the hosting scene
  142664. * @returns the plane mesh
  142665. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142666. */
  142667. static CreateTiledPlane(name: string, options: {
  142668. pattern?: number;
  142669. tileSize?: number;
  142670. tileWidth?: number;
  142671. tileHeight?: number;
  142672. size?: number;
  142673. width?: number;
  142674. height?: number;
  142675. alignHorizontal?: number;
  142676. alignVertical?: number;
  142677. sideOrientation?: number;
  142678. frontUVs?: Vector4;
  142679. backUVs?: Vector4;
  142680. updatable?: boolean;
  142681. }, scene?: Nullable<Scene>): Mesh;
  142682. /**
  142683. * Creates a plane mesh
  142684. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  142685. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  142686. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  142687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142690. * @param name defines the name of the mesh
  142691. * @param options defines the options used to create the mesh
  142692. * @param scene defines the hosting scene
  142693. * @returns the plane mesh
  142694. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142695. */
  142696. static CreatePlane(name: string, options: {
  142697. size?: number;
  142698. width?: number;
  142699. height?: number;
  142700. sideOrientation?: number;
  142701. frontUVs?: Vector4;
  142702. backUVs?: Vector4;
  142703. updatable?: boolean;
  142704. sourcePlane?: Plane;
  142705. }, scene?: Nullable<Scene>): Mesh;
  142706. /**
  142707. * Creates a ground mesh
  142708. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  142709. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  142710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142711. * @param name defines the name of the mesh
  142712. * @param options defines the options used to create the mesh
  142713. * @param scene defines the hosting scene
  142714. * @returns the ground mesh
  142715. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  142716. */
  142717. static CreateGround(name: string, options: {
  142718. width?: number;
  142719. height?: number;
  142720. subdivisions?: number;
  142721. subdivisionsX?: number;
  142722. subdivisionsY?: number;
  142723. updatable?: boolean;
  142724. }, scene?: Nullable<Scene>): Mesh;
  142725. /**
  142726. * Creates a tiled ground mesh
  142727. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  142728. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  142729. * * 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
  142730. * * 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
  142731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142732. * @param name defines the name of the mesh
  142733. * @param options defines the options used to create the mesh
  142734. * @param scene defines the hosting scene
  142735. * @returns the tiled ground mesh
  142736. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  142737. */
  142738. static CreateTiledGround(name: string, options: {
  142739. xmin: number;
  142740. zmin: number;
  142741. xmax: number;
  142742. zmax: number;
  142743. subdivisions?: {
  142744. w: number;
  142745. h: number;
  142746. };
  142747. precision?: {
  142748. w: number;
  142749. h: number;
  142750. };
  142751. updatable?: boolean;
  142752. }, scene?: Nullable<Scene>): Mesh;
  142753. /**
  142754. * Creates a ground mesh from a height map
  142755. * * The parameter `url` sets the URL of the height map image resource.
  142756. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  142757. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  142758. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  142759. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  142760. * * 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.
  142761. * * 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).
  142762. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  142763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142764. * @param name defines the name of the mesh
  142765. * @param url defines the url to the height map
  142766. * @param options defines the options used to create the mesh
  142767. * @param scene defines the hosting scene
  142768. * @returns the ground mesh
  142769. * @see https://doc.babylonjs.com/babylon101/height_map
  142770. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  142771. */
  142772. static CreateGroundFromHeightMap(name: string, url: string, options: {
  142773. width?: number;
  142774. height?: number;
  142775. subdivisions?: number;
  142776. minHeight?: number;
  142777. maxHeight?: number;
  142778. colorFilter?: Color3;
  142779. alphaFilter?: number;
  142780. updatable?: boolean;
  142781. onReady?: (mesh: GroundMesh) => void;
  142782. }, scene?: Nullable<Scene>): GroundMesh;
  142783. /**
  142784. * Creates a polygon mesh
  142785. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142786. * * 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
  142787. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  142790. * * Remember you can only change the shape positions, not their number when updating a polygon
  142791. * @param name defines the name of the mesh
  142792. * @param options defines the options used to create the mesh
  142793. * @param scene defines the hosting scene
  142794. * @param earcutInjection can be used to inject your own earcut reference
  142795. * @returns the polygon mesh
  142796. */
  142797. static CreatePolygon(name: string, options: {
  142798. shape: Vector3[];
  142799. holes?: Vector3[][];
  142800. depth?: number;
  142801. faceUV?: Vector4[];
  142802. faceColors?: Color4[];
  142803. updatable?: boolean;
  142804. sideOrientation?: number;
  142805. frontUVs?: Vector4;
  142806. backUVs?: Vector4;
  142807. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142808. /**
  142809. * Creates an extruded polygon mesh, with depth in the Y direction.
  142810. * * 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)
  142811. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142812. * @param name defines the name of the mesh
  142813. * @param options defines the options used to create the mesh
  142814. * @param scene defines the hosting scene
  142815. * @param earcutInjection can be used to inject your own earcut reference
  142816. * @returns the polygon mesh
  142817. */
  142818. static ExtrudePolygon(name: string, options: {
  142819. shape: Vector3[];
  142820. holes?: Vector3[][];
  142821. depth?: number;
  142822. faceUV?: Vector4[];
  142823. faceColors?: Color4[];
  142824. updatable?: boolean;
  142825. sideOrientation?: number;
  142826. frontUVs?: Vector4;
  142827. backUVs?: Vector4;
  142828. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142829. /**
  142830. * Creates a tube mesh.
  142831. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142832. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142833. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142834. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142835. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142836. * * 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)
  142837. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142838. * * 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
  142839. * * 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
  142840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142842. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142844. * @param name defines the name of the mesh
  142845. * @param options defines the options used to create the mesh
  142846. * @param scene defines the hosting scene
  142847. * @returns the tube mesh
  142848. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142849. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142850. */
  142851. static CreateTube(name: string, options: {
  142852. path: Vector3[];
  142853. radius?: number;
  142854. tessellation?: number;
  142855. radiusFunction?: {
  142856. (i: number, distance: number): number;
  142857. };
  142858. cap?: number;
  142859. arc?: number;
  142860. updatable?: boolean;
  142861. sideOrientation?: number;
  142862. frontUVs?: Vector4;
  142863. backUVs?: Vector4;
  142864. instance?: Mesh;
  142865. invertUV?: boolean;
  142866. }, scene?: Nullable<Scene>): Mesh;
  142867. /**
  142868. * Creates a polyhedron mesh
  142869. * * 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
  142870. * * The parameter `size` (positive float, default 1) sets the polygon size
  142871. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  142872. * * 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`
  142873. * * 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
  142874. * * 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)`)
  142875. * * 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
  142876. * * 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
  142877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142878. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142880. * @param name defines the name of the mesh
  142881. * @param options defines the options used to create the mesh
  142882. * @param scene defines the hosting scene
  142883. * @returns the polyhedron mesh
  142884. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  142885. */
  142886. static CreatePolyhedron(name: string, options: {
  142887. type?: number;
  142888. size?: number;
  142889. sizeX?: number;
  142890. sizeY?: number;
  142891. sizeZ?: number;
  142892. custom?: any;
  142893. faceUV?: Vector4[];
  142894. faceColors?: Color4[];
  142895. flat?: boolean;
  142896. updatable?: boolean;
  142897. sideOrientation?: number;
  142898. frontUVs?: Vector4;
  142899. backUVs?: Vector4;
  142900. }, scene?: Nullable<Scene>): Mesh;
  142901. /**
  142902. * Creates a decal mesh.
  142903. * 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
  142904. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142905. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142906. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142907. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142908. * @param name defines the name of the mesh
  142909. * @param sourceMesh defines the mesh where the decal must be applied
  142910. * @param options defines the options used to create the mesh
  142911. * @param scene defines the hosting scene
  142912. * @returns the decal mesh
  142913. * @see https://doc.babylonjs.com/how_to/decals
  142914. */
  142915. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142916. position?: Vector3;
  142917. normal?: Vector3;
  142918. size?: Vector3;
  142919. angle?: number;
  142920. }): Mesh;
  142921. }
  142922. }
  142923. declare module BABYLON {
  142924. /**
  142925. * A simplifier interface for future simplification implementations
  142926. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142927. */
  142928. export interface ISimplifier {
  142929. /**
  142930. * Simplification of a given mesh according to the given settings.
  142931. * Since this requires computation, it is assumed that the function runs async.
  142932. * @param settings The settings of the simplification, including quality and distance
  142933. * @param successCallback A callback that will be called after the mesh was simplified.
  142934. * @param errorCallback in case of an error, this callback will be called. optional.
  142935. */
  142936. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  142937. }
  142938. /**
  142939. * Expected simplification settings.
  142940. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  142941. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142942. */
  142943. export interface ISimplificationSettings {
  142944. /**
  142945. * Gets or sets the expected quality
  142946. */
  142947. quality: number;
  142948. /**
  142949. * Gets or sets the distance when this optimized version should be used
  142950. */
  142951. distance: number;
  142952. /**
  142953. * Gets an already optimized mesh
  142954. */
  142955. optimizeMesh?: boolean;
  142956. }
  142957. /**
  142958. * Class used to specify simplification options
  142959. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142960. */
  142961. export class SimplificationSettings implements ISimplificationSettings {
  142962. /** expected quality */
  142963. quality: number;
  142964. /** distance when this optimized version should be used */
  142965. distance: number;
  142966. /** already optimized mesh */
  142967. optimizeMesh?: boolean | undefined;
  142968. /**
  142969. * Creates a SimplificationSettings
  142970. * @param quality expected quality
  142971. * @param distance distance when this optimized version should be used
  142972. * @param optimizeMesh already optimized mesh
  142973. */
  142974. constructor(
  142975. /** expected quality */
  142976. quality: number,
  142977. /** distance when this optimized version should be used */
  142978. distance: number,
  142979. /** already optimized mesh */
  142980. optimizeMesh?: boolean | undefined);
  142981. }
  142982. /**
  142983. * Interface used to define a simplification task
  142984. */
  142985. export interface ISimplificationTask {
  142986. /**
  142987. * Array of settings
  142988. */
  142989. settings: Array<ISimplificationSettings>;
  142990. /**
  142991. * Simplification type
  142992. */
  142993. simplificationType: SimplificationType;
  142994. /**
  142995. * Mesh to simplify
  142996. */
  142997. mesh: Mesh;
  142998. /**
  142999. * Callback called on success
  143000. */
  143001. successCallback?: () => void;
  143002. /**
  143003. * Defines if parallel processing can be used
  143004. */
  143005. parallelProcessing: boolean;
  143006. }
  143007. /**
  143008. * Queue used to order the simplification tasks
  143009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143010. */
  143011. export class SimplificationQueue {
  143012. private _simplificationArray;
  143013. /**
  143014. * Gets a boolean indicating that the process is still running
  143015. */
  143016. running: boolean;
  143017. /**
  143018. * Creates a new queue
  143019. */
  143020. constructor();
  143021. /**
  143022. * Adds a new simplification task
  143023. * @param task defines a task to add
  143024. */
  143025. addTask(task: ISimplificationTask): void;
  143026. /**
  143027. * Execute next task
  143028. */
  143029. executeNext(): void;
  143030. /**
  143031. * Execute a simplification task
  143032. * @param task defines the task to run
  143033. */
  143034. runSimplification(task: ISimplificationTask): void;
  143035. private getSimplifier;
  143036. }
  143037. /**
  143038. * The implemented types of simplification
  143039. * At the moment only Quadratic Error Decimation is implemented
  143040. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143041. */
  143042. export enum SimplificationType {
  143043. /** Quadratic error decimation */
  143044. QUADRATIC = 0
  143045. }
  143046. /**
  143047. * An implementation of the Quadratic Error simplification algorithm.
  143048. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  143049. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  143050. * @author RaananW
  143051. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143052. */
  143053. export class QuadraticErrorSimplification implements ISimplifier {
  143054. private _mesh;
  143055. private triangles;
  143056. private vertices;
  143057. private references;
  143058. private _reconstructedMesh;
  143059. /** Gets or sets the number pf sync interations */
  143060. syncIterations: number;
  143061. /** Gets or sets the aggressiveness of the simplifier */
  143062. aggressiveness: number;
  143063. /** Gets or sets the number of allowed iterations for decimation */
  143064. decimationIterations: number;
  143065. /** Gets or sets the espilon to use for bounding box computation */
  143066. boundingBoxEpsilon: number;
  143067. /**
  143068. * Creates a new QuadraticErrorSimplification
  143069. * @param _mesh defines the target mesh
  143070. */
  143071. constructor(_mesh: Mesh);
  143072. /**
  143073. * Simplification of a given mesh according to the given settings.
  143074. * Since this requires computation, it is assumed that the function runs async.
  143075. * @param settings The settings of the simplification, including quality and distance
  143076. * @param successCallback A callback that will be called after the mesh was simplified.
  143077. */
  143078. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  143079. private runDecimation;
  143080. private initWithMesh;
  143081. private init;
  143082. private reconstructMesh;
  143083. private initDecimatedMesh;
  143084. private isFlipped;
  143085. private updateTriangles;
  143086. private identifyBorder;
  143087. private updateMesh;
  143088. private vertexError;
  143089. private calculateError;
  143090. }
  143091. }
  143092. declare module BABYLON {
  143093. interface Scene {
  143094. /** @hidden (Backing field) */
  143095. _simplificationQueue: SimplificationQueue;
  143096. /**
  143097. * Gets or sets the simplification queue attached to the scene
  143098. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143099. */
  143100. simplificationQueue: SimplificationQueue;
  143101. }
  143102. interface Mesh {
  143103. /**
  143104. * Simplify the mesh according to the given array of settings.
  143105. * Function will return immediately and will simplify async
  143106. * @param settings a collection of simplification settings
  143107. * @param parallelProcessing should all levels calculate parallel or one after the other
  143108. * @param simplificationType the type of simplification to run
  143109. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  143110. * @returns the current mesh
  143111. */
  143112. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  143113. }
  143114. /**
  143115. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  143116. * created in a scene
  143117. */
  143118. export class SimplicationQueueSceneComponent implements ISceneComponent {
  143119. /**
  143120. * The component name helpfull to identify the component in the list of scene components.
  143121. */
  143122. readonly name: string;
  143123. /**
  143124. * The scene the component belongs to.
  143125. */
  143126. scene: Scene;
  143127. /**
  143128. * Creates a new instance of the component for the given scene
  143129. * @param scene Defines the scene to register the component in
  143130. */
  143131. constructor(scene: Scene);
  143132. /**
  143133. * Registers the component in a given scene
  143134. */
  143135. register(): void;
  143136. /**
  143137. * Rebuilds the elements related to this component in case of
  143138. * context lost for instance.
  143139. */
  143140. rebuild(): void;
  143141. /**
  143142. * Disposes the component and the associated ressources
  143143. */
  143144. dispose(): void;
  143145. private _beforeCameraUpdate;
  143146. }
  143147. }
  143148. declare module BABYLON {
  143149. interface Mesh {
  143150. /**
  143151. * Creates a new thin instance
  143152. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  143153. * @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
  143154. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  143155. */
  143156. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  143157. /**
  143158. * Adds the transformation (matrix) of the current mesh as a thin instance
  143159. * @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
  143160. * @returns the thin instance index number
  143161. */
  143162. thinInstanceAddSelf(refresh: boolean): number;
  143163. /**
  143164. * Registers a custom attribute to be used with thin instances
  143165. * @param kind name of the attribute
  143166. * @param stride size in floats of the attribute
  143167. */
  143168. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  143169. /**
  143170. * Sets the matrix of a thin instance
  143171. * @param index index of the thin instance
  143172. * @param matrix matrix to set
  143173. * @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
  143174. */
  143175. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  143176. /**
  143177. * Sets the value of a custom attribute for a thin instance
  143178. * @param kind name of the attribute
  143179. * @param index index of the thin instance
  143180. * @param value value to set
  143181. * @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
  143182. */
  143183. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  143184. /**
  143185. * 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.
  143186. */
  143187. thinInstanceCount: number;
  143188. /**
  143189. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  143190. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  143191. * @param buffer buffer to set
  143192. * @param stride size in floats of each value of the buffer
  143193. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  143194. */
  143195. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  143196. /**
  143197. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  143198. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  143199. */
  143200. thinInstanceBufferUpdated(kind: string): void;
  143201. /**
  143202. * Refreshes the bounding info, taking into account all the thin instances defined
  143203. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  143204. */
  143205. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  143206. /** @hidden */
  143207. _thinInstanceInitializeUserStorage(): void;
  143208. /** @hidden */
  143209. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  143210. /** @hidden */
  143211. _userThinInstanceBuffersStorage: {
  143212. data: {
  143213. [key: string]: Float32Array;
  143214. };
  143215. sizes: {
  143216. [key: string]: number;
  143217. };
  143218. vertexBuffers: {
  143219. [key: string]: Nullable<VertexBuffer>;
  143220. };
  143221. strides: {
  143222. [key: string]: number;
  143223. };
  143224. };
  143225. }
  143226. }
  143227. declare module BABYLON {
  143228. /**
  143229. * Navigation plugin interface to add navigation constrained by a navigation mesh
  143230. */
  143231. export interface INavigationEnginePlugin {
  143232. /**
  143233. * plugin name
  143234. */
  143235. name: string;
  143236. /**
  143237. * Creates a navigation mesh
  143238. * @param meshes array of all the geometry used to compute the navigatio mesh
  143239. * @param parameters bunch of parameters used to filter geometry
  143240. */
  143241. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143242. /**
  143243. * Create a navigation mesh debug mesh
  143244. * @param scene is where the mesh will be added
  143245. * @returns debug display mesh
  143246. */
  143247. createDebugNavMesh(scene: Scene): Mesh;
  143248. /**
  143249. * Get a navigation mesh constrained position, closest to the parameter position
  143250. * @param position world position
  143251. * @returns the closest point to position constrained by the navigation mesh
  143252. */
  143253. getClosestPoint(position: Vector3): Vector3;
  143254. /**
  143255. * Get a navigation mesh constrained position, closest to the parameter position
  143256. * @param position world position
  143257. * @param result output the closest point to position constrained by the navigation mesh
  143258. */
  143259. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143260. /**
  143261. * Get a navigation mesh constrained position, within a particular radius
  143262. * @param position world position
  143263. * @param maxRadius the maximum distance to the constrained world position
  143264. * @returns the closest point to position constrained by the navigation mesh
  143265. */
  143266. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143267. /**
  143268. * Get a navigation mesh constrained position, within a particular radius
  143269. * @param position world position
  143270. * @param maxRadius the maximum distance to the constrained world position
  143271. * @param result output the closest point to position constrained by the navigation mesh
  143272. */
  143273. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143274. /**
  143275. * Compute the final position from a segment made of destination-position
  143276. * @param position world position
  143277. * @param destination world position
  143278. * @returns the resulting point along the navmesh
  143279. */
  143280. moveAlong(position: Vector3, destination: Vector3): Vector3;
  143281. /**
  143282. * Compute the final position from a segment made of destination-position
  143283. * @param position world position
  143284. * @param destination world position
  143285. * @param result output the resulting point along the navmesh
  143286. */
  143287. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  143288. /**
  143289. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  143290. * @param start world position
  143291. * @param end world position
  143292. * @returns array containing world position composing the path
  143293. */
  143294. computePath(start: Vector3, end: Vector3): Vector3[];
  143295. /**
  143296. * If this plugin is supported
  143297. * @returns true if plugin is supported
  143298. */
  143299. isSupported(): boolean;
  143300. /**
  143301. * Create a new Crowd so you can add agents
  143302. * @param maxAgents the maximum agent count in the crowd
  143303. * @param maxAgentRadius the maximum radius an agent can have
  143304. * @param scene to attach the crowd to
  143305. * @returns the crowd you can add agents to
  143306. */
  143307. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  143308. /**
  143309. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143310. * The queries will try to find a solution within those bounds
  143311. * default is (1,1,1)
  143312. * @param extent x,y,z value that define the extent around the queries point of reference
  143313. */
  143314. setDefaultQueryExtent(extent: Vector3): void;
  143315. /**
  143316. * Get the Bounding box extent specified by setDefaultQueryExtent
  143317. * @returns the box extent values
  143318. */
  143319. getDefaultQueryExtent(): Vector3;
  143320. /**
  143321. * build the navmesh from a previously saved state using getNavmeshData
  143322. * @param data the Uint8Array returned by getNavmeshData
  143323. */
  143324. buildFromNavmeshData(data: Uint8Array): void;
  143325. /**
  143326. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  143327. * @returns data the Uint8Array that can be saved and reused
  143328. */
  143329. getNavmeshData(): Uint8Array;
  143330. /**
  143331. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143332. * @param result output the box extent values
  143333. */
  143334. getDefaultQueryExtentToRef(result: Vector3): void;
  143335. /**
  143336. * Release all resources
  143337. */
  143338. dispose(): void;
  143339. }
  143340. /**
  143341. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  143342. */
  143343. export interface ICrowd {
  143344. /**
  143345. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143346. * You can attach anything to that node. The node position is updated in the scene update tick.
  143347. * @param pos world position that will be constrained by the navigation mesh
  143348. * @param parameters agent parameters
  143349. * @param transform hooked to the agent that will be update by the scene
  143350. * @returns agent index
  143351. */
  143352. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143353. /**
  143354. * Returns the agent position in world space
  143355. * @param index agent index returned by addAgent
  143356. * @returns world space position
  143357. */
  143358. getAgentPosition(index: number): Vector3;
  143359. /**
  143360. * Gets the agent position result in world space
  143361. * @param index agent index returned by addAgent
  143362. * @param result output world space position
  143363. */
  143364. getAgentPositionToRef(index: number, result: Vector3): void;
  143365. /**
  143366. * Gets the agent velocity in world space
  143367. * @param index agent index returned by addAgent
  143368. * @returns world space velocity
  143369. */
  143370. getAgentVelocity(index: number): Vector3;
  143371. /**
  143372. * Gets the agent velocity result in world space
  143373. * @param index agent index returned by addAgent
  143374. * @param result output world space velocity
  143375. */
  143376. getAgentVelocityToRef(index: number, result: Vector3): void;
  143377. /**
  143378. * remove a particular agent previously created
  143379. * @param index agent index returned by addAgent
  143380. */
  143381. removeAgent(index: number): void;
  143382. /**
  143383. * get the list of all agents attached to this crowd
  143384. * @returns list of agent indices
  143385. */
  143386. getAgents(): number[];
  143387. /**
  143388. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  143389. * @param deltaTime in seconds
  143390. */
  143391. update(deltaTime: number): void;
  143392. /**
  143393. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  143394. * @param index agent index returned by addAgent
  143395. * @param destination targeted world position
  143396. */
  143397. agentGoto(index: number, destination: Vector3): void;
  143398. /**
  143399. * Teleport the agent to a new position
  143400. * @param index agent index returned by addAgent
  143401. * @param destination targeted world position
  143402. */
  143403. agentTeleport(index: number, destination: Vector3): void;
  143404. /**
  143405. * Update agent parameters
  143406. * @param index agent index returned by addAgent
  143407. * @param parameters agent parameters
  143408. */
  143409. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  143410. /**
  143411. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143412. * The queries will try to find a solution within those bounds
  143413. * default is (1,1,1)
  143414. * @param extent x,y,z value that define the extent around the queries point of reference
  143415. */
  143416. setDefaultQueryExtent(extent: Vector3): void;
  143417. /**
  143418. * Get the Bounding box extent specified by setDefaultQueryExtent
  143419. * @returns the box extent values
  143420. */
  143421. getDefaultQueryExtent(): Vector3;
  143422. /**
  143423. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143424. * @param result output the box extent values
  143425. */
  143426. getDefaultQueryExtentToRef(result: Vector3): void;
  143427. /**
  143428. * Release all resources
  143429. */
  143430. dispose(): void;
  143431. }
  143432. /**
  143433. * Configures an agent
  143434. */
  143435. export interface IAgentParameters {
  143436. /**
  143437. * Agent radius. [Limit: >= 0]
  143438. */
  143439. radius: number;
  143440. /**
  143441. * Agent height. [Limit: > 0]
  143442. */
  143443. height: number;
  143444. /**
  143445. * Maximum allowed acceleration. [Limit: >= 0]
  143446. */
  143447. maxAcceleration: number;
  143448. /**
  143449. * Maximum allowed speed. [Limit: >= 0]
  143450. */
  143451. maxSpeed: number;
  143452. /**
  143453. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  143454. */
  143455. collisionQueryRange: number;
  143456. /**
  143457. * The path visibility optimization range. [Limit: > 0]
  143458. */
  143459. pathOptimizationRange: number;
  143460. /**
  143461. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  143462. */
  143463. separationWeight: number;
  143464. }
  143465. /**
  143466. * Configures the navigation mesh creation
  143467. */
  143468. export interface INavMeshParameters {
  143469. /**
  143470. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  143471. */
  143472. cs: number;
  143473. /**
  143474. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  143475. */
  143476. ch: number;
  143477. /**
  143478. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  143479. */
  143480. walkableSlopeAngle: number;
  143481. /**
  143482. * Minimum floor to 'ceiling' height that will still allow the floor area to
  143483. * be considered walkable. [Limit: >= 3] [Units: vx]
  143484. */
  143485. walkableHeight: number;
  143486. /**
  143487. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  143488. */
  143489. walkableClimb: number;
  143490. /**
  143491. * The distance to erode/shrink the walkable area of the heightfield away from
  143492. * obstructions. [Limit: >=0] [Units: vx]
  143493. */
  143494. walkableRadius: number;
  143495. /**
  143496. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  143497. */
  143498. maxEdgeLen: number;
  143499. /**
  143500. * The maximum distance a simplfied contour's border edges should deviate
  143501. * the original raw contour. [Limit: >=0] [Units: vx]
  143502. */
  143503. maxSimplificationError: number;
  143504. /**
  143505. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  143506. */
  143507. minRegionArea: number;
  143508. /**
  143509. * Any regions with a span count smaller than this value will, if possible,
  143510. * be merged with larger regions. [Limit: >=0] [Units: vx]
  143511. */
  143512. mergeRegionArea: number;
  143513. /**
  143514. * The maximum number of vertices allowed for polygons generated during the
  143515. * contour to polygon conversion process. [Limit: >= 3]
  143516. */
  143517. maxVertsPerPoly: number;
  143518. /**
  143519. * Sets the sampling distance to use when generating the detail mesh.
  143520. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  143521. */
  143522. detailSampleDist: number;
  143523. /**
  143524. * The maximum distance the detail mesh surface should deviate from heightfield
  143525. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  143526. */
  143527. detailSampleMaxError: number;
  143528. }
  143529. }
  143530. declare module BABYLON {
  143531. /**
  143532. * RecastJS navigation plugin
  143533. */
  143534. export class RecastJSPlugin implements INavigationEnginePlugin {
  143535. /**
  143536. * Reference to the Recast library
  143537. */
  143538. bjsRECAST: any;
  143539. /**
  143540. * plugin name
  143541. */
  143542. name: string;
  143543. /**
  143544. * the first navmesh created. We might extend this to support multiple navmeshes
  143545. */
  143546. navMesh: any;
  143547. /**
  143548. * Initializes the recastJS plugin
  143549. * @param recastInjection can be used to inject your own recast reference
  143550. */
  143551. constructor(recastInjection?: any);
  143552. /**
  143553. * Creates a navigation mesh
  143554. * @param meshes array of all the geometry used to compute the navigatio mesh
  143555. * @param parameters bunch of parameters used to filter geometry
  143556. */
  143557. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143558. /**
  143559. * Create a navigation mesh debug mesh
  143560. * @param scene is where the mesh will be added
  143561. * @returns debug display mesh
  143562. */
  143563. createDebugNavMesh(scene: Scene): Mesh;
  143564. /**
  143565. * Get a navigation mesh constrained position, closest to the parameter position
  143566. * @param position world position
  143567. * @returns the closest point to position constrained by the navigation mesh
  143568. */
  143569. getClosestPoint(position: Vector3): Vector3;
  143570. /**
  143571. * Get a navigation mesh constrained position, closest to the parameter position
  143572. * @param position world position
  143573. * @param result output the closest point to position constrained by the navigation mesh
  143574. */
  143575. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143576. /**
  143577. * Get a navigation mesh constrained position, within a particular radius
  143578. * @param position world position
  143579. * @param maxRadius the maximum distance to the constrained world position
  143580. * @returns the closest point to position constrained by the navigation mesh
  143581. */
  143582. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143583. /**
  143584. * Get a navigation mesh constrained position, within a particular radius
  143585. * @param position world position
  143586. * @param maxRadius the maximum distance to the constrained world position
  143587. * @param result output the closest point to position constrained by the navigation mesh
  143588. */
  143589. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143590. /**
  143591. * Compute the final position from a segment made of destination-position
  143592. * @param position world position
  143593. * @param destination world position
  143594. * @returns the resulting point along the navmesh
  143595. */
  143596. moveAlong(position: Vector3, destination: Vector3): Vector3;
  143597. /**
  143598. * Compute the final position from a segment made of destination-position
  143599. * @param position world position
  143600. * @param destination world position
  143601. * @param result output the resulting point along the navmesh
  143602. */
  143603. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  143604. /**
  143605. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  143606. * @param start world position
  143607. * @param end world position
  143608. * @returns array containing world position composing the path
  143609. */
  143610. computePath(start: Vector3, end: Vector3): Vector3[];
  143611. /**
  143612. * Create a new Crowd so you can add agents
  143613. * @param maxAgents the maximum agent count in the crowd
  143614. * @param maxAgentRadius the maximum radius an agent can have
  143615. * @param scene to attach the crowd to
  143616. * @returns the crowd you can add agents to
  143617. */
  143618. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  143619. /**
  143620. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143621. * The queries will try to find a solution within those bounds
  143622. * default is (1,1,1)
  143623. * @param extent x,y,z value that define the extent around the queries point of reference
  143624. */
  143625. setDefaultQueryExtent(extent: Vector3): void;
  143626. /**
  143627. * Get the Bounding box extent specified by setDefaultQueryExtent
  143628. * @returns the box extent values
  143629. */
  143630. getDefaultQueryExtent(): Vector3;
  143631. /**
  143632. * build the navmesh from a previously saved state using getNavmeshData
  143633. * @param data the Uint8Array returned by getNavmeshData
  143634. */
  143635. buildFromNavmeshData(data: Uint8Array): void;
  143636. /**
  143637. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  143638. * @returns data the Uint8Array that can be saved and reused
  143639. */
  143640. getNavmeshData(): Uint8Array;
  143641. /**
  143642. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143643. * @param result output the box extent values
  143644. */
  143645. getDefaultQueryExtentToRef(result: Vector3): void;
  143646. /**
  143647. * Disposes
  143648. */
  143649. dispose(): void;
  143650. /**
  143651. * If this plugin is supported
  143652. * @returns true if plugin is supported
  143653. */
  143654. isSupported(): boolean;
  143655. }
  143656. /**
  143657. * Recast detour crowd implementation
  143658. */
  143659. export class RecastJSCrowd implements ICrowd {
  143660. /**
  143661. * Recast/detour plugin
  143662. */
  143663. bjsRECASTPlugin: RecastJSPlugin;
  143664. /**
  143665. * Link to the detour crowd
  143666. */
  143667. recastCrowd: any;
  143668. /**
  143669. * One transform per agent
  143670. */
  143671. transforms: TransformNode[];
  143672. /**
  143673. * All agents created
  143674. */
  143675. agents: number[];
  143676. /**
  143677. * Link to the scene is kept to unregister the crowd from the scene
  143678. */
  143679. private _scene;
  143680. /**
  143681. * Observer for crowd updates
  143682. */
  143683. private _onBeforeAnimationsObserver;
  143684. /**
  143685. * Constructor
  143686. * @param plugin recastJS plugin
  143687. * @param maxAgents the maximum agent count in the crowd
  143688. * @param maxAgentRadius the maximum radius an agent can have
  143689. * @param scene to attach the crowd to
  143690. * @returns the crowd you can add agents to
  143691. */
  143692. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  143693. /**
  143694. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143695. * You can attach anything to that node. The node position is updated in the scene update tick.
  143696. * @param pos world position that will be constrained by the navigation mesh
  143697. * @param parameters agent parameters
  143698. * @param transform hooked to the agent that will be update by the scene
  143699. * @returns agent index
  143700. */
  143701. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143702. /**
  143703. * Returns the agent position in world space
  143704. * @param index agent index returned by addAgent
  143705. * @returns world space position
  143706. */
  143707. getAgentPosition(index: number): Vector3;
  143708. /**
  143709. * Returns the agent position result in world space
  143710. * @param index agent index returned by addAgent
  143711. * @param result output world space position
  143712. */
  143713. getAgentPositionToRef(index: number, result: Vector3): void;
  143714. /**
  143715. * Returns the agent velocity in world space
  143716. * @param index agent index returned by addAgent
  143717. * @returns world space velocity
  143718. */
  143719. getAgentVelocity(index: number): Vector3;
  143720. /**
  143721. * Returns the agent velocity result in world space
  143722. * @param index agent index returned by addAgent
  143723. * @param result output world space velocity
  143724. */
  143725. getAgentVelocityToRef(index: number, result: Vector3): void;
  143726. /**
  143727. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  143728. * @param index agent index returned by addAgent
  143729. * @param destination targeted world position
  143730. */
  143731. agentGoto(index: number, destination: Vector3): void;
  143732. /**
  143733. * Teleport the agent to a new position
  143734. * @param index agent index returned by addAgent
  143735. * @param destination targeted world position
  143736. */
  143737. agentTeleport(index: number, destination: Vector3): void;
  143738. /**
  143739. * Update agent parameters
  143740. * @param index agent index returned by addAgent
  143741. * @param parameters agent parameters
  143742. */
  143743. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  143744. /**
  143745. * remove a particular agent previously created
  143746. * @param index agent index returned by addAgent
  143747. */
  143748. removeAgent(index: number): void;
  143749. /**
  143750. * get the list of all agents attached to this crowd
  143751. * @returns list of agent indices
  143752. */
  143753. getAgents(): number[];
  143754. /**
  143755. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  143756. * @param deltaTime in seconds
  143757. */
  143758. update(deltaTime: number): void;
  143759. /**
  143760. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143761. * The queries will try to find a solution within those bounds
  143762. * default is (1,1,1)
  143763. * @param extent x,y,z value that define the extent around the queries point of reference
  143764. */
  143765. setDefaultQueryExtent(extent: Vector3): void;
  143766. /**
  143767. * Get the Bounding box extent specified by setDefaultQueryExtent
  143768. * @returns the box extent values
  143769. */
  143770. getDefaultQueryExtent(): Vector3;
  143771. /**
  143772. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143773. * @param result output the box extent values
  143774. */
  143775. getDefaultQueryExtentToRef(result: Vector3): void;
  143776. /**
  143777. * Release all resources
  143778. */
  143779. dispose(): void;
  143780. }
  143781. }
  143782. declare module BABYLON {
  143783. /**
  143784. * Class used to enable access to IndexedDB
  143785. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  143786. */
  143787. export class Database implements IOfflineProvider {
  143788. private _callbackManifestChecked;
  143789. private _currentSceneUrl;
  143790. private _db;
  143791. private _enableSceneOffline;
  143792. private _enableTexturesOffline;
  143793. private _manifestVersionFound;
  143794. private _mustUpdateRessources;
  143795. private _hasReachedQuota;
  143796. private _isSupported;
  143797. private _idbFactory;
  143798. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  143799. private static IsUASupportingBlobStorage;
  143800. /**
  143801. * Gets a boolean indicating if Database storate is enabled (off by default)
  143802. */
  143803. static IDBStorageEnabled: boolean;
  143804. /**
  143805. * Gets a boolean indicating if scene must be saved in the database
  143806. */
  143807. get enableSceneOffline(): boolean;
  143808. /**
  143809. * Gets a boolean indicating if textures must be saved in the database
  143810. */
  143811. get enableTexturesOffline(): boolean;
  143812. /**
  143813. * Creates a new Database
  143814. * @param urlToScene defines the url to load the scene
  143815. * @param callbackManifestChecked defines the callback to use when manifest is checked
  143816. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  143817. */
  143818. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  143819. private static _ParseURL;
  143820. private static _ReturnFullUrlLocation;
  143821. private _checkManifestFile;
  143822. /**
  143823. * Open the database and make it available
  143824. * @param successCallback defines the callback to call on success
  143825. * @param errorCallback defines the callback to call on error
  143826. */
  143827. open(successCallback: () => void, errorCallback: () => void): void;
  143828. /**
  143829. * Loads an image from the database
  143830. * @param url defines the url to load from
  143831. * @param image defines the target DOM image
  143832. */
  143833. loadImage(url: string, image: HTMLImageElement): void;
  143834. private _loadImageFromDBAsync;
  143835. private _saveImageIntoDBAsync;
  143836. private _checkVersionFromDB;
  143837. private _loadVersionFromDBAsync;
  143838. private _saveVersionIntoDBAsync;
  143839. /**
  143840. * Loads a file from database
  143841. * @param url defines the URL to load from
  143842. * @param sceneLoaded defines a callback to call on success
  143843. * @param progressCallBack defines a callback to call when progress changed
  143844. * @param errorCallback defines a callback to call on error
  143845. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  143846. */
  143847. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  143848. private _loadFileAsync;
  143849. private _saveFileAsync;
  143850. /**
  143851. * Validates if xhr data is correct
  143852. * @param xhr defines the request to validate
  143853. * @param dataType defines the expected data type
  143854. * @returns true if data is correct
  143855. */
  143856. private static _ValidateXHRData;
  143857. }
  143858. }
  143859. declare module BABYLON {
  143860. /** @hidden */
  143861. export var gpuUpdateParticlesPixelShader: {
  143862. name: string;
  143863. shader: string;
  143864. };
  143865. }
  143866. declare module BABYLON {
  143867. /** @hidden */
  143868. export var gpuUpdateParticlesVertexShader: {
  143869. name: string;
  143870. shader: string;
  143871. };
  143872. }
  143873. declare module BABYLON {
  143874. /** @hidden */
  143875. export var clipPlaneFragmentDeclaration2: {
  143876. name: string;
  143877. shader: string;
  143878. };
  143879. }
  143880. declare module BABYLON {
  143881. /** @hidden */
  143882. export var gpuRenderParticlesPixelShader: {
  143883. name: string;
  143884. shader: string;
  143885. };
  143886. }
  143887. declare module BABYLON {
  143888. /** @hidden */
  143889. export var clipPlaneVertexDeclaration2: {
  143890. name: string;
  143891. shader: string;
  143892. };
  143893. }
  143894. declare module BABYLON {
  143895. /** @hidden */
  143896. export var gpuRenderParticlesVertexShader: {
  143897. name: string;
  143898. shader: string;
  143899. };
  143900. }
  143901. declare module BABYLON {
  143902. /**
  143903. * This represents a GPU particle system in Babylon
  143904. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  143905. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  143906. */
  143907. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  143908. /**
  143909. * The layer mask we are rendering the particles through.
  143910. */
  143911. layerMask: number;
  143912. private _capacity;
  143913. private _activeCount;
  143914. private _currentActiveCount;
  143915. private _accumulatedCount;
  143916. private _renderEffect;
  143917. private _updateEffect;
  143918. private _buffer0;
  143919. private _buffer1;
  143920. private _spriteBuffer;
  143921. private _updateVAO;
  143922. private _renderVAO;
  143923. private _targetIndex;
  143924. private _sourceBuffer;
  143925. private _targetBuffer;
  143926. private _engine;
  143927. private _currentRenderId;
  143928. private _started;
  143929. private _stopped;
  143930. private _timeDelta;
  143931. private _randomTexture;
  143932. private _randomTexture2;
  143933. private _attributesStrideSize;
  143934. private _updateEffectOptions;
  143935. private _randomTextureSize;
  143936. private _actualFrame;
  143937. private _customEffect;
  143938. private readonly _rawTextureWidth;
  143939. /**
  143940. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  143941. */
  143942. static get IsSupported(): boolean;
  143943. /**
  143944. * An event triggered when the system is disposed.
  143945. */
  143946. onDisposeObservable: Observable<IParticleSystem>;
  143947. /**
  143948. * Gets the maximum number of particles active at the same time.
  143949. * @returns The max number of active particles.
  143950. */
  143951. getCapacity(): number;
  143952. /**
  143953. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  143954. * to override the particles.
  143955. */
  143956. forceDepthWrite: boolean;
  143957. /**
  143958. * Gets or set the number of active particles
  143959. */
  143960. get activeParticleCount(): number;
  143961. set activeParticleCount(value: number);
  143962. private _preWarmDone;
  143963. /**
  143964. * Specifies if the particles are updated in emitter local space or world space.
  143965. */
  143966. isLocal: boolean;
  143967. /**
  143968. * Is this system ready to be used/rendered
  143969. * @return true if the system is ready
  143970. */
  143971. isReady(): boolean;
  143972. /**
  143973. * Gets if the system has been started. (Note: this will still be true after stop is called)
  143974. * @returns True if it has been started, otherwise false.
  143975. */
  143976. isStarted(): boolean;
  143977. /**
  143978. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  143979. * @returns True if it has been stopped, otherwise false.
  143980. */
  143981. isStopped(): boolean;
  143982. /**
  143983. * Gets a boolean indicating that the system is stopping
  143984. * @returns true if the system is currently stopping
  143985. */
  143986. isStopping(): boolean;
  143987. /**
  143988. * Gets the number of particles active at the same time.
  143989. * @returns The number of active particles.
  143990. */
  143991. getActiveCount(): number;
  143992. /**
  143993. * Starts the particle system and begins to emit
  143994. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  143995. */
  143996. start(delay?: number): void;
  143997. /**
  143998. * Stops the particle system.
  143999. */
  144000. stop(): void;
  144001. /**
  144002. * Remove all active particles
  144003. */
  144004. reset(): void;
  144005. /**
  144006. * Returns the string "GPUParticleSystem"
  144007. * @returns a string containing the class name
  144008. */
  144009. getClassName(): string;
  144010. /**
  144011. * Gets the custom effect used to render the particles
  144012. * @param blendMode Blend mode for which the effect should be retrieved
  144013. * @returns The effect
  144014. */
  144015. getCustomEffect(blendMode?: number): Nullable<Effect>;
  144016. /**
  144017. * Sets the custom effect used to render the particles
  144018. * @param effect The effect to set
  144019. * @param blendMode Blend mode for which the effect should be set
  144020. */
  144021. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  144022. /** @hidden */
  144023. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  144024. /**
  144025. * Observable that will be called just before the particles are drawn
  144026. */
  144027. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  144028. /**
  144029. * Gets the name of the particle vertex shader
  144030. */
  144031. get vertexShaderName(): string;
  144032. private _colorGradientsTexture;
  144033. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  144034. /**
  144035. * Adds a new color gradient
  144036. * @param gradient defines the gradient to use (between 0 and 1)
  144037. * @param color1 defines the color to affect to the specified gradient
  144038. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  144039. * @returns the current particle system
  144040. */
  144041. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  144042. private _refreshColorGradient;
  144043. /** Force the system to rebuild all gradients that need to be resync */
  144044. forceRefreshGradients(): void;
  144045. /**
  144046. * Remove a specific color gradient
  144047. * @param gradient defines the gradient to remove
  144048. * @returns the current particle system
  144049. */
  144050. removeColorGradient(gradient: number): GPUParticleSystem;
  144051. private _angularSpeedGradientsTexture;
  144052. private _sizeGradientsTexture;
  144053. private _velocityGradientsTexture;
  144054. private _limitVelocityGradientsTexture;
  144055. private _dragGradientsTexture;
  144056. private _addFactorGradient;
  144057. /**
  144058. * Adds a new size gradient
  144059. * @param gradient defines the gradient to use (between 0 and 1)
  144060. * @param factor defines the size factor to affect to the specified gradient
  144061. * @returns the current particle system
  144062. */
  144063. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  144064. /**
  144065. * Remove a specific size gradient
  144066. * @param gradient defines the gradient to remove
  144067. * @returns the current particle system
  144068. */
  144069. removeSizeGradient(gradient: number): GPUParticleSystem;
  144070. private _refreshFactorGradient;
  144071. /**
  144072. * Adds a new angular speed gradient
  144073. * @param gradient defines the gradient to use (between 0 and 1)
  144074. * @param factor defines the angular speed to affect to the specified gradient
  144075. * @returns the current particle system
  144076. */
  144077. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  144078. /**
  144079. * Remove a specific angular speed gradient
  144080. * @param gradient defines the gradient to remove
  144081. * @returns the current particle system
  144082. */
  144083. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  144084. /**
  144085. * Adds a new velocity gradient
  144086. * @param gradient defines the gradient to use (between 0 and 1)
  144087. * @param factor defines the velocity to affect to the specified gradient
  144088. * @returns the current particle system
  144089. */
  144090. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144091. /**
  144092. * Remove a specific velocity gradient
  144093. * @param gradient defines the gradient to remove
  144094. * @returns the current particle system
  144095. */
  144096. removeVelocityGradient(gradient: number): GPUParticleSystem;
  144097. /**
  144098. * Adds a new limit velocity gradient
  144099. * @param gradient defines the gradient to use (between 0 and 1)
  144100. * @param factor defines the limit velocity value to affect to the specified gradient
  144101. * @returns the current particle system
  144102. */
  144103. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144104. /**
  144105. * Remove a specific limit velocity gradient
  144106. * @param gradient defines the gradient to remove
  144107. * @returns the current particle system
  144108. */
  144109. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  144110. /**
  144111. * Adds a new drag gradient
  144112. * @param gradient defines the gradient to use (between 0 and 1)
  144113. * @param factor defines the drag value to affect to the specified gradient
  144114. * @returns the current particle system
  144115. */
  144116. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  144117. /**
  144118. * Remove a specific drag gradient
  144119. * @param gradient defines the gradient to remove
  144120. * @returns the current particle system
  144121. */
  144122. removeDragGradient(gradient: number): GPUParticleSystem;
  144123. /**
  144124. * Not supported by GPUParticleSystem
  144125. * @param gradient defines the gradient to use (between 0 and 1)
  144126. * @param factor defines the emit rate value to affect to the specified gradient
  144127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144128. * @returns the current particle system
  144129. */
  144130. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144131. /**
  144132. * Not supported by GPUParticleSystem
  144133. * @param gradient defines the gradient to remove
  144134. * @returns the current particle system
  144135. */
  144136. removeEmitRateGradient(gradient: number): IParticleSystem;
  144137. /**
  144138. * Not supported by GPUParticleSystem
  144139. * @param gradient defines the gradient to use (between 0 and 1)
  144140. * @param factor defines the start size value to affect to the specified gradient
  144141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144142. * @returns the current particle system
  144143. */
  144144. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144145. /**
  144146. * Not supported by GPUParticleSystem
  144147. * @param gradient defines the gradient to remove
  144148. * @returns the current particle system
  144149. */
  144150. removeStartSizeGradient(gradient: number): IParticleSystem;
  144151. /**
  144152. * Not supported by GPUParticleSystem
  144153. * @param gradient defines the gradient to use (between 0 and 1)
  144154. * @param min defines the color remap minimal range
  144155. * @param max defines the color remap maximal range
  144156. * @returns the current particle system
  144157. */
  144158. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144159. /**
  144160. * Not supported by GPUParticleSystem
  144161. * @param gradient defines the gradient to remove
  144162. * @returns the current particle system
  144163. */
  144164. removeColorRemapGradient(): IParticleSystem;
  144165. /**
  144166. * Not supported by GPUParticleSystem
  144167. * @param gradient defines the gradient to use (between 0 and 1)
  144168. * @param min defines the alpha remap minimal range
  144169. * @param max defines the alpha remap maximal range
  144170. * @returns the current particle system
  144171. */
  144172. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144173. /**
  144174. * Not supported by GPUParticleSystem
  144175. * @param gradient defines the gradient to remove
  144176. * @returns the current particle system
  144177. */
  144178. removeAlphaRemapGradient(): IParticleSystem;
  144179. /**
  144180. * Not supported by GPUParticleSystem
  144181. * @param gradient defines the gradient to use (between 0 and 1)
  144182. * @param color defines the color to affect to the specified gradient
  144183. * @returns the current particle system
  144184. */
  144185. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  144186. /**
  144187. * Not supported by GPUParticleSystem
  144188. * @param gradient defines the gradient to remove
  144189. * @returns the current particle system
  144190. */
  144191. removeRampGradient(): IParticleSystem;
  144192. /**
  144193. * Not supported by GPUParticleSystem
  144194. * @returns the list of ramp gradients
  144195. */
  144196. getRampGradients(): Nullable<Array<Color3Gradient>>;
  144197. /**
  144198. * Not supported by GPUParticleSystem
  144199. * Gets or sets a boolean indicating that ramp gradients must be used
  144200. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  144201. */
  144202. get useRampGradients(): boolean;
  144203. set useRampGradients(value: boolean);
  144204. /**
  144205. * Not supported by GPUParticleSystem
  144206. * @param gradient defines the gradient to use (between 0 and 1)
  144207. * @param factor defines the life time factor to affect to the specified gradient
  144208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144209. * @returns the current particle system
  144210. */
  144211. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144212. /**
  144213. * Not supported by GPUParticleSystem
  144214. * @param gradient defines the gradient to remove
  144215. * @returns the current particle system
  144216. */
  144217. removeLifeTimeGradient(gradient: number): IParticleSystem;
  144218. /**
  144219. * Instantiates a GPU particle system.
  144220. * 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.
  144221. * @param name The name of the particle system
  144222. * @param options The options used to create the system
  144223. * @param scene The scene the particle system belongs to
  144224. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  144225. * @param customEffect a custom effect used to change the way particles are rendered by default
  144226. */
  144227. constructor(name: string, options: Partial<{
  144228. capacity: number;
  144229. randomTextureSize: number;
  144230. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  144231. protected _reset(): void;
  144232. private _createUpdateVAO;
  144233. private _createRenderVAO;
  144234. private _initialize;
  144235. /** @hidden */
  144236. _recreateUpdateEffect(): void;
  144237. private _getEffect;
  144238. /**
  144239. * Fill the defines array according to the current settings of the particle system
  144240. * @param defines Array to be updated
  144241. * @param blendMode blend mode to take into account when updating the array
  144242. */
  144243. fillDefines(defines: Array<string>, blendMode?: number): void;
  144244. /**
  144245. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  144246. * @param uniforms Uniforms array to fill
  144247. * @param attributes Attributes array to fill
  144248. * @param samplers Samplers array to fill
  144249. */
  144250. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  144251. /** @hidden */
  144252. _recreateRenderEffect(): Effect;
  144253. /**
  144254. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  144255. * @param preWarm defines if we are in the pre-warmimg phase
  144256. */
  144257. animate(preWarm?: boolean): void;
  144258. private _createFactorGradientTexture;
  144259. private _createSizeGradientTexture;
  144260. private _createAngularSpeedGradientTexture;
  144261. private _createVelocityGradientTexture;
  144262. private _createLimitVelocityGradientTexture;
  144263. private _createDragGradientTexture;
  144264. private _createColorGradientTexture;
  144265. /**
  144266. * Renders the particle system in its current state
  144267. * @param preWarm defines if the system should only update the particles but not render them
  144268. * @returns the current number of particles
  144269. */
  144270. render(preWarm?: boolean): number;
  144271. /**
  144272. * Rebuilds the particle system
  144273. */
  144274. rebuild(): void;
  144275. private _releaseBuffers;
  144276. private _releaseVAOs;
  144277. /**
  144278. * Disposes the particle system and free the associated resources
  144279. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  144280. */
  144281. dispose(disposeTexture?: boolean): void;
  144282. /**
  144283. * Clones the particle system.
  144284. * @param name The name of the cloned object
  144285. * @param newEmitter The new emitter to use
  144286. * @returns the cloned particle system
  144287. */
  144288. clone(name: string, newEmitter: any): GPUParticleSystem;
  144289. /**
  144290. * Serializes the particle system to a JSON object
  144291. * @param serializeTexture defines if the texture must be serialized as well
  144292. * @returns the JSON object
  144293. */
  144294. serialize(serializeTexture?: boolean): any;
  144295. /**
  144296. * Parses a JSON object to create a GPU particle system.
  144297. * @param parsedParticleSystem The JSON object to parse
  144298. * @param scene The scene to create the particle system in
  144299. * @param rootUrl The root url to use to load external dependencies like texture
  144300. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  144301. * @returns the parsed GPU particle system
  144302. */
  144303. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  144304. }
  144305. }
  144306. declare module BABYLON {
  144307. /**
  144308. * Represents a set of particle systems working together to create a specific effect
  144309. */
  144310. export class ParticleSystemSet implements IDisposable {
  144311. /**
  144312. * Gets or sets base Assets URL
  144313. */
  144314. static BaseAssetsUrl: string;
  144315. private _emitterCreationOptions;
  144316. private _emitterNode;
  144317. /**
  144318. * Gets the particle system list
  144319. */
  144320. systems: IParticleSystem[];
  144321. /**
  144322. * Gets the emitter node used with this set
  144323. */
  144324. get emitterNode(): Nullable<TransformNode>;
  144325. /**
  144326. * Creates a new emitter mesh as a sphere
  144327. * @param options defines the options used to create the sphere
  144328. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  144329. * @param scene defines the hosting scene
  144330. */
  144331. setEmitterAsSphere(options: {
  144332. diameter: number;
  144333. segments: number;
  144334. color: Color3;
  144335. }, renderingGroupId: number, scene: Scene): void;
  144336. /**
  144337. * Starts all particle systems of the set
  144338. * @param emitter defines an optional mesh to use as emitter for the particle systems
  144339. */
  144340. start(emitter?: AbstractMesh): void;
  144341. /**
  144342. * Release all associated resources
  144343. */
  144344. dispose(): void;
  144345. /**
  144346. * Serialize the set into a JSON compatible object
  144347. * @param serializeTexture defines if the texture must be serialized as well
  144348. * @returns a JSON compatible representation of the set
  144349. */
  144350. serialize(serializeTexture?: boolean): any;
  144351. /**
  144352. * Parse a new ParticleSystemSet from a serialized source
  144353. * @param data defines a JSON compatible representation of the set
  144354. * @param scene defines the hosting scene
  144355. * @param gpu defines if we want GPU particles or CPU particles
  144356. * @returns a new ParticleSystemSet
  144357. */
  144358. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  144359. }
  144360. }
  144361. declare module BABYLON {
  144362. /**
  144363. * This class is made for on one-liner static method to help creating particle system set.
  144364. */
  144365. export class ParticleHelper {
  144366. /**
  144367. * Gets or sets base Assets URL
  144368. */
  144369. static BaseAssetsUrl: string;
  144370. /** Define the Url to load snippets */
  144371. static SnippetUrl: string;
  144372. /**
  144373. * Create a default particle system that you can tweak
  144374. * @param emitter defines the emitter to use
  144375. * @param capacity defines the system capacity (default is 500 particles)
  144376. * @param scene defines the hosting scene
  144377. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  144378. * @returns the new Particle system
  144379. */
  144380. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  144381. /**
  144382. * This is the main static method (one-liner) of this helper to create different particle systems
  144383. * @param type This string represents the type to the particle system to create
  144384. * @param scene The scene where the particle system should live
  144385. * @param gpu If the system will use gpu
  144386. * @returns the ParticleSystemSet created
  144387. */
  144388. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  144389. /**
  144390. * Static function used to export a particle system to a ParticleSystemSet variable.
  144391. * Please note that the emitter shape is not exported
  144392. * @param systems defines the particle systems to export
  144393. * @returns the created particle system set
  144394. */
  144395. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  144396. /**
  144397. * Creates a particle system from a snippet saved in a remote file
  144398. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  144399. * @param url defines the url to load from
  144400. * @param scene defines the hosting scene
  144401. * @param gpu If the system will use gpu
  144402. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144403. * @returns a promise that will resolve to the new particle system
  144404. */
  144405. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144406. /**
  144407. * Creates a particle system from a snippet saved by the particle system editor
  144408. * @param snippetId defines the snippet to load
  144409. * @param scene defines the hosting scene
  144410. * @param gpu If the system will use gpu
  144411. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144412. * @returns a promise that will resolve to the new particle system
  144413. */
  144414. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144415. }
  144416. }
  144417. declare module BABYLON {
  144418. interface Engine {
  144419. /**
  144420. * Create an effect to use with particle systems.
  144421. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  144422. * the particle system for which you want to create a custom effect in the last parameter
  144423. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  144424. * @param uniformsNames defines a list of attribute names
  144425. * @param samplers defines an array of string used to represent textures
  144426. * @param defines defines the string containing the defines to use to compile the shaders
  144427. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  144428. * @param onCompiled defines a function to call when the effect creation is successful
  144429. * @param onError defines a function to call when the effect creation has failed
  144430. * @param particleSystem the particle system you want to create the effect for
  144431. * @returns the new Effect
  144432. */
  144433. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  144434. }
  144435. interface Mesh {
  144436. /**
  144437. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  144438. * @returns an array of IParticleSystem
  144439. */
  144440. getEmittedParticleSystems(): IParticleSystem[];
  144441. /**
  144442. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  144443. * @returns an array of IParticleSystem
  144444. */
  144445. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  144446. }
  144447. }
  144448. declare module BABYLON {
  144449. /** Defines the 4 color options */
  144450. export enum PointColor {
  144451. /** color value */
  144452. Color = 2,
  144453. /** uv value */
  144454. UV = 1,
  144455. /** random value */
  144456. Random = 0,
  144457. /** stated value */
  144458. Stated = 3
  144459. }
  144460. /**
  144461. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  144462. * 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.
  144463. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  144464. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  144465. *
  144466. * Full documentation here : TO BE ENTERED
  144467. */
  144468. export class PointsCloudSystem implements IDisposable {
  144469. /**
  144470. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  144471. * Example : var p = SPS.particles[i];
  144472. */
  144473. particles: CloudPoint[];
  144474. /**
  144475. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  144476. */
  144477. nbParticles: number;
  144478. /**
  144479. * This a counter for your own usage. It's not set by any SPS functions.
  144480. */
  144481. counter: number;
  144482. /**
  144483. * The PCS name. This name is also given to the underlying mesh.
  144484. */
  144485. name: string;
  144486. /**
  144487. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  144488. */
  144489. mesh: Mesh;
  144490. /**
  144491. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  144492. * Please read :
  144493. */
  144494. vars: any;
  144495. /**
  144496. * @hidden
  144497. */
  144498. _size: number;
  144499. private _scene;
  144500. private _promises;
  144501. private _positions;
  144502. private _indices;
  144503. private _normals;
  144504. private _colors;
  144505. private _uvs;
  144506. private _indices32;
  144507. private _positions32;
  144508. private _colors32;
  144509. private _uvs32;
  144510. private _updatable;
  144511. private _isVisibilityBoxLocked;
  144512. private _alwaysVisible;
  144513. private _groups;
  144514. private _groupCounter;
  144515. private _computeParticleColor;
  144516. private _computeParticleTexture;
  144517. private _computeParticleRotation;
  144518. private _computeBoundingBox;
  144519. private _isReady;
  144520. /**
  144521. * Creates a PCS (Points Cloud System) object
  144522. * @param name (String) is the PCS name, this will be the underlying mesh name
  144523. * @param pointSize (number) is the size for each point
  144524. * @param scene (Scene) is the scene in which the PCS is added
  144525. * @param options defines the options of the PCS e.g.
  144526. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  144527. */
  144528. constructor(name: string, pointSize: number, scene: Scene, options?: {
  144529. updatable?: boolean;
  144530. });
  144531. /**
  144532. * Builds the PCS underlying mesh. Returns a standard Mesh.
  144533. * If no points were added to the PCS, the returned mesh is just a single point.
  144534. * @returns a promise for the created mesh
  144535. */
  144536. buildMeshAsync(): Promise<Mesh>;
  144537. /**
  144538. * @hidden
  144539. */
  144540. private _buildMesh;
  144541. private _addParticle;
  144542. private _randomUnitVector;
  144543. private _getColorIndicesForCoord;
  144544. private _setPointsColorOrUV;
  144545. private _colorFromTexture;
  144546. private _calculateDensity;
  144547. /**
  144548. * Adds points to the PCS in random positions within a unit sphere
  144549. * @param nb (positive integer) the number of particles to be created from this model
  144550. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  144551. * @returns the number of groups in the system
  144552. */
  144553. addPoints(nb: number, pointFunction?: any): number;
  144554. /**
  144555. * Adds points to the PCS from the surface of the model shape
  144556. * @param mesh is any Mesh object that will be used as a surface model for the points
  144557. * @param nb (positive integer) the number of particles to be created from this model
  144558. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144559. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144560. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144561. * @returns the number of groups in the system
  144562. */
  144563. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144564. /**
  144565. * Adds points to the PCS inside the model shape
  144566. * @param mesh is any Mesh object that will be used as a surface model for the points
  144567. * @param nb (positive integer) the number of particles to be created from this model
  144568. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144569. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144570. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144571. * @returns the number of groups in the system
  144572. */
  144573. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144574. /**
  144575. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  144576. * This method calls `updateParticle()` for each particle of the SPS.
  144577. * For an animated SPS, it is usually called within the render loop.
  144578. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  144579. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  144580. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  144581. * @returns the PCS.
  144582. */
  144583. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  144584. /**
  144585. * Disposes the PCS.
  144586. */
  144587. dispose(): void;
  144588. /**
  144589. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  144590. * doc :
  144591. * @returns the PCS.
  144592. */
  144593. refreshVisibleSize(): PointsCloudSystem;
  144594. /**
  144595. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  144596. * @param size the size (float) of the visibility box
  144597. * note : this doesn't lock the PCS mesh bounding box.
  144598. * doc :
  144599. */
  144600. setVisibilityBox(size: number): void;
  144601. /**
  144602. * Gets whether the PCS is always visible or not
  144603. * doc :
  144604. */
  144605. get isAlwaysVisible(): boolean;
  144606. /**
  144607. * Sets the PCS as always visible or not
  144608. * doc :
  144609. */
  144610. set isAlwaysVisible(val: boolean);
  144611. /**
  144612. * Tells to `setParticles()` to compute the particle rotations or not
  144613. * Default value : false. The PCS is faster when it's set to false
  144614. * Note : particle rotations are only applied to parent particles
  144615. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  144616. */
  144617. set computeParticleRotation(val: boolean);
  144618. /**
  144619. * Tells to `setParticles()` to compute the particle colors or not.
  144620. * Default value : true. The PCS is faster when it's set to false.
  144621. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144622. */
  144623. set computeParticleColor(val: boolean);
  144624. set computeParticleTexture(val: boolean);
  144625. /**
  144626. * Gets if `setParticles()` computes the particle colors or not.
  144627. * Default value : false. The PCS is faster when it's set to false.
  144628. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144629. */
  144630. get computeParticleColor(): boolean;
  144631. /**
  144632. * Gets if `setParticles()` computes the particle textures or not.
  144633. * Default value : false. The PCS is faster when it's set to false.
  144634. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  144635. */
  144636. get computeParticleTexture(): boolean;
  144637. /**
  144638. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  144639. */
  144640. set computeBoundingBox(val: boolean);
  144641. /**
  144642. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  144643. */
  144644. get computeBoundingBox(): boolean;
  144645. /**
  144646. * This function does nothing. It may be overwritten to set all the particle first values.
  144647. * The PCS doesn't call this function, you may have to call it by your own.
  144648. * doc :
  144649. */
  144650. initParticles(): void;
  144651. /**
  144652. * This function does nothing. It may be overwritten to recycle a particle
  144653. * The PCS doesn't call this function, you can to call it
  144654. * doc :
  144655. * @param particle The particle to recycle
  144656. * @returns the recycled particle
  144657. */
  144658. recycleParticle(particle: CloudPoint): CloudPoint;
  144659. /**
  144660. * Updates a particle : this function should be overwritten by the user.
  144661. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  144662. * doc :
  144663. * @example : just set a particle position or velocity and recycle conditions
  144664. * @param particle The particle to update
  144665. * @returns the updated particle
  144666. */
  144667. updateParticle(particle: CloudPoint): CloudPoint;
  144668. /**
  144669. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  144670. * This does nothing and may be overwritten by the user.
  144671. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144672. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144673. * @param update the boolean update value actually passed to setParticles()
  144674. */
  144675. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144676. /**
  144677. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  144678. * This will be passed three parameters.
  144679. * This does nothing and may be overwritten by the user.
  144680. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144681. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144682. * @param update the boolean update value actually passed to setParticles()
  144683. */
  144684. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144685. }
  144686. }
  144687. declare module BABYLON {
  144688. /**
  144689. * Represents one particle of a points cloud system.
  144690. */
  144691. export class CloudPoint {
  144692. /**
  144693. * particle global index
  144694. */
  144695. idx: number;
  144696. /**
  144697. * The color of the particle
  144698. */
  144699. color: Nullable<Color4>;
  144700. /**
  144701. * The world space position of the particle.
  144702. */
  144703. position: Vector3;
  144704. /**
  144705. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  144706. */
  144707. rotation: Vector3;
  144708. /**
  144709. * The world space rotation quaternion of the particle.
  144710. */
  144711. rotationQuaternion: Nullable<Quaternion>;
  144712. /**
  144713. * The uv of the particle.
  144714. */
  144715. uv: Nullable<Vector2>;
  144716. /**
  144717. * The current speed of the particle.
  144718. */
  144719. velocity: Vector3;
  144720. /**
  144721. * The pivot point in the particle local space.
  144722. */
  144723. pivot: Vector3;
  144724. /**
  144725. * Must the particle be translated from its pivot point in its local space ?
  144726. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  144727. * Default : false
  144728. */
  144729. translateFromPivot: boolean;
  144730. /**
  144731. * Index of this particle in the global "positions" array (Internal use)
  144732. * @hidden
  144733. */
  144734. _pos: number;
  144735. /**
  144736. * @hidden Index of this particle in the global "indices" array (Internal use)
  144737. */
  144738. _ind: number;
  144739. /**
  144740. * Group this particle belongs to
  144741. */
  144742. _group: PointsGroup;
  144743. /**
  144744. * Group id of this particle
  144745. */
  144746. groupId: number;
  144747. /**
  144748. * Index of the particle in its group id (Internal use)
  144749. */
  144750. idxInGroup: number;
  144751. /**
  144752. * @hidden Particle BoundingInfo object (Internal use)
  144753. */
  144754. _boundingInfo: BoundingInfo;
  144755. /**
  144756. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  144757. */
  144758. _pcs: PointsCloudSystem;
  144759. /**
  144760. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  144761. */
  144762. _stillInvisible: boolean;
  144763. /**
  144764. * @hidden Last computed particle rotation matrix
  144765. */
  144766. _rotationMatrix: number[];
  144767. /**
  144768. * Parent particle Id, if any.
  144769. * Default null.
  144770. */
  144771. parentId: Nullable<number>;
  144772. /**
  144773. * @hidden Internal global position in the PCS.
  144774. */
  144775. _globalPosition: Vector3;
  144776. /**
  144777. * Creates a Point Cloud object.
  144778. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  144779. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  144780. * @param group (PointsGroup) is the group the particle belongs to
  144781. * @param groupId (integer) is the group identifier in the PCS.
  144782. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  144783. * @param pcs defines the PCS it is associated to
  144784. */
  144785. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  144786. /**
  144787. * get point size
  144788. */
  144789. get size(): Vector3;
  144790. /**
  144791. * Set point size
  144792. */
  144793. set size(scale: Vector3);
  144794. /**
  144795. * Legacy support, changed quaternion to rotationQuaternion
  144796. */
  144797. get quaternion(): Nullable<Quaternion>;
  144798. /**
  144799. * Legacy support, changed quaternion to rotationQuaternion
  144800. */
  144801. set quaternion(q: Nullable<Quaternion>);
  144802. /**
  144803. * Returns a boolean. True if the particle intersects a mesh, else false
  144804. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  144805. * @param target is the object (point or mesh) what the intersection is computed against
  144806. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  144807. * @returns true if it intersects
  144808. */
  144809. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  144810. /**
  144811. * get the rotation matrix of the particle
  144812. * @hidden
  144813. */
  144814. getRotationMatrix(m: Matrix): void;
  144815. }
  144816. /**
  144817. * Represents a group of points in a points cloud system
  144818. * * PCS internal tool, don't use it manually.
  144819. */
  144820. export class PointsGroup {
  144821. /**
  144822. * The group id
  144823. * @hidden
  144824. */
  144825. groupID: number;
  144826. /**
  144827. * image data for group (internal use)
  144828. * @hidden
  144829. */
  144830. _groupImageData: Nullable<ArrayBufferView>;
  144831. /**
  144832. * Image Width (internal use)
  144833. * @hidden
  144834. */
  144835. _groupImgWidth: number;
  144836. /**
  144837. * Image Height (internal use)
  144838. * @hidden
  144839. */
  144840. _groupImgHeight: number;
  144841. /**
  144842. * Custom position function (internal use)
  144843. * @hidden
  144844. */
  144845. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  144846. /**
  144847. * density per facet for surface points
  144848. * @hidden
  144849. */
  144850. _groupDensity: number[];
  144851. /**
  144852. * Only when points are colored by texture carries pointer to texture list array
  144853. * @hidden
  144854. */
  144855. _textureNb: number;
  144856. /**
  144857. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  144858. * PCS internal tool, don't use it manually.
  144859. * @hidden
  144860. */
  144861. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  144862. }
  144863. }
  144864. declare module BABYLON {
  144865. interface Scene {
  144866. /** @hidden (Backing field) */
  144867. _physicsEngine: Nullable<IPhysicsEngine>;
  144868. /** @hidden */
  144869. _physicsTimeAccumulator: number;
  144870. /**
  144871. * Gets the current physics engine
  144872. * @returns a IPhysicsEngine or null if none attached
  144873. */
  144874. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  144875. /**
  144876. * Enables physics to the current scene
  144877. * @param gravity defines the scene's gravity for the physics engine
  144878. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  144879. * @return a boolean indicating if the physics engine was initialized
  144880. */
  144881. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  144882. /**
  144883. * Disables and disposes the physics engine associated with the scene
  144884. */
  144885. disablePhysicsEngine(): void;
  144886. /**
  144887. * Gets a boolean indicating if there is an active physics engine
  144888. * @returns a boolean indicating if there is an active physics engine
  144889. */
  144890. isPhysicsEnabled(): boolean;
  144891. /**
  144892. * Deletes a physics compound impostor
  144893. * @param compound defines the compound to delete
  144894. */
  144895. deleteCompoundImpostor(compound: any): void;
  144896. /**
  144897. * An event triggered when physic simulation is about to be run
  144898. */
  144899. onBeforePhysicsObservable: Observable<Scene>;
  144900. /**
  144901. * An event triggered when physic simulation has been done
  144902. */
  144903. onAfterPhysicsObservable: Observable<Scene>;
  144904. }
  144905. interface AbstractMesh {
  144906. /** @hidden */
  144907. _physicsImpostor: Nullable<PhysicsImpostor>;
  144908. /**
  144909. * Gets or sets impostor used for physic simulation
  144910. * @see http://doc.babylonjs.com/features/physics_engine
  144911. */
  144912. physicsImpostor: Nullable<PhysicsImpostor>;
  144913. /**
  144914. * Gets the current physics impostor
  144915. * @see http://doc.babylonjs.com/features/physics_engine
  144916. * @returns a physics impostor or null
  144917. */
  144918. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  144919. /** Apply a physic impulse to the mesh
  144920. * @param force defines the force to apply
  144921. * @param contactPoint defines where to apply the force
  144922. * @returns the current mesh
  144923. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  144924. */
  144925. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  144926. /**
  144927. * Creates a physic joint between two meshes
  144928. * @param otherMesh defines the other mesh to use
  144929. * @param pivot1 defines the pivot to use on this mesh
  144930. * @param pivot2 defines the pivot to use on the other mesh
  144931. * @param options defines additional options (can be plugin dependent)
  144932. * @returns the current mesh
  144933. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  144934. */
  144935. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  144936. /** @hidden */
  144937. _disposePhysicsObserver: Nullable<Observer<Node>>;
  144938. }
  144939. /**
  144940. * Defines the physics engine scene component responsible to manage a physics engine
  144941. */
  144942. export class PhysicsEngineSceneComponent implements ISceneComponent {
  144943. /**
  144944. * The component name helpful to identify the component in the list of scene components.
  144945. */
  144946. readonly name: string;
  144947. /**
  144948. * The scene the component belongs to.
  144949. */
  144950. scene: Scene;
  144951. /**
  144952. * Creates a new instance of the component for the given scene
  144953. * @param scene Defines the scene to register the component in
  144954. */
  144955. constructor(scene: Scene);
  144956. /**
  144957. * Registers the component in a given scene
  144958. */
  144959. register(): void;
  144960. /**
  144961. * Rebuilds the elements related to this component in case of
  144962. * context lost for instance.
  144963. */
  144964. rebuild(): void;
  144965. /**
  144966. * Disposes the component and the associated ressources
  144967. */
  144968. dispose(): void;
  144969. }
  144970. }
  144971. declare module BABYLON {
  144972. /**
  144973. * A helper for physics simulations
  144974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144975. */
  144976. export class PhysicsHelper {
  144977. private _scene;
  144978. private _physicsEngine;
  144979. /**
  144980. * Initializes the Physics helper
  144981. * @param scene Babylon.js scene
  144982. */
  144983. constructor(scene: Scene);
  144984. /**
  144985. * Applies a radial explosion impulse
  144986. * @param origin the origin of the explosion
  144987. * @param radiusOrEventOptions the radius or the options of radial explosion
  144988. * @param strength the explosion strength
  144989. * @param falloff possible options: Constant & Linear. Defaults to Constant
  144990. * @returns A physics radial explosion event, or null
  144991. */
  144992. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  144993. /**
  144994. * Applies a radial explosion force
  144995. * @param origin the origin of the explosion
  144996. * @param radiusOrEventOptions the radius or the options of radial explosion
  144997. * @param strength the explosion strength
  144998. * @param falloff possible options: Constant & Linear. Defaults to Constant
  144999. * @returns A physics radial explosion event, or null
  145000. */
  145001. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145002. /**
  145003. * Creates a gravitational field
  145004. * @param origin the origin of the explosion
  145005. * @param radiusOrEventOptions the radius or the options of radial explosion
  145006. * @param strength the explosion strength
  145007. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145008. * @returns A physics gravitational field event, or null
  145009. */
  145010. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  145011. /**
  145012. * Creates a physics updraft event
  145013. * @param origin the origin of the updraft
  145014. * @param radiusOrEventOptions the radius or the options of the updraft
  145015. * @param strength the strength of the updraft
  145016. * @param height the height of the updraft
  145017. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  145018. * @returns A physics updraft event, or null
  145019. */
  145020. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  145021. /**
  145022. * Creates a physics vortex event
  145023. * @param origin the of the vortex
  145024. * @param radiusOrEventOptions the radius or the options of the vortex
  145025. * @param strength the strength of the vortex
  145026. * @param height the height of the vortex
  145027. * @returns a Physics vortex event, or null
  145028. * A physics vortex event or null
  145029. */
  145030. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  145031. }
  145032. /**
  145033. * Represents a physics radial explosion event
  145034. */
  145035. class PhysicsRadialExplosionEvent {
  145036. private _scene;
  145037. private _options;
  145038. private _sphere;
  145039. private _dataFetched;
  145040. /**
  145041. * Initializes a radial explosioin event
  145042. * @param _scene BabylonJS scene
  145043. * @param _options The options for the vortex event
  145044. */
  145045. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  145046. /**
  145047. * Returns the data related to the radial explosion event (sphere).
  145048. * @returns The radial explosion event data
  145049. */
  145050. getData(): PhysicsRadialExplosionEventData;
  145051. /**
  145052. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  145053. * @param impostor A physics imposter
  145054. * @param origin the origin of the explosion
  145055. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  145056. */
  145057. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  145058. /**
  145059. * Triggers affecterd impostors callbacks
  145060. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  145061. */
  145062. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  145063. /**
  145064. * Disposes the sphere.
  145065. * @param force Specifies if the sphere should be disposed by force
  145066. */
  145067. dispose(force?: boolean): void;
  145068. /*** Helpers ***/
  145069. private _prepareSphere;
  145070. private _intersectsWithSphere;
  145071. }
  145072. /**
  145073. * Represents a gravitational field event
  145074. */
  145075. class PhysicsGravitationalFieldEvent {
  145076. private _physicsHelper;
  145077. private _scene;
  145078. private _origin;
  145079. private _options;
  145080. private _tickCallback;
  145081. private _sphere;
  145082. private _dataFetched;
  145083. /**
  145084. * Initializes the physics gravitational field event
  145085. * @param _physicsHelper A physics helper
  145086. * @param _scene BabylonJS scene
  145087. * @param _origin The origin position of the gravitational field event
  145088. * @param _options The options for the vortex event
  145089. */
  145090. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  145091. /**
  145092. * Returns the data related to the gravitational field event (sphere).
  145093. * @returns A gravitational field event
  145094. */
  145095. getData(): PhysicsGravitationalFieldEventData;
  145096. /**
  145097. * Enables the gravitational field.
  145098. */
  145099. enable(): void;
  145100. /**
  145101. * Disables the gravitational field.
  145102. */
  145103. disable(): void;
  145104. /**
  145105. * Disposes the sphere.
  145106. * @param force The force to dispose from the gravitational field event
  145107. */
  145108. dispose(force?: boolean): void;
  145109. private _tick;
  145110. }
  145111. /**
  145112. * Represents a physics updraft event
  145113. */
  145114. class PhysicsUpdraftEvent {
  145115. private _scene;
  145116. private _origin;
  145117. private _options;
  145118. private _physicsEngine;
  145119. private _originTop;
  145120. private _originDirection;
  145121. private _tickCallback;
  145122. private _cylinder;
  145123. private _cylinderPosition;
  145124. private _dataFetched;
  145125. /**
  145126. * Initializes the physics updraft event
  145127. * @param _scene BabylonJS scene
  145128. * @param _origin The origin position of the updraft
  145129. * @param _options The options for the updraft event
  145130. */
  145131. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  145132. /**
  145133. * Returns the data related to the updraft event (cylinder).
  145134. * @returns A physics updraft event
  145135. */
  145136. getData(): PhysicsUpdraftEventData;
  145137. /**
  145138. * Enables the updraft.
  145139. */
  145140. enable(): void;
  145141. /**
  145142. * Disables the updraft.
  145143. */
  145144. disable(): void;
  145145. /**
  145146. * Disposes the cylinder.
  145147. * @param force Specifies if the updraft should be disposed by force
  145148. */
  145149. dispose(force?: boolean): void;
  145150. private getImpostorHitData;
  145151. private _tick;
  145152. /*** Helpers ***/
  145153. private _prepareCylinder;
  145154. private _intersectsWithCylinder;
  145155. }
  145156. /**
  145157. * Represents a physics vortex event
  145158. */
  145159. class PhysicsVortexEvent {
  145160. private _scene;
  145161. private _origin;
  145162. private _options;
  145163. private _physicsEngine;
  145164. private _originTop;
  145165. private _tickCallback;
  145166. private _cylinder;
  145167. private _cylinderPosition;
  145168. private _dataFetched;
  145169. /**
  145170. * Initializes the physics vortex event
  145171. * @param _scene The BabylonJS scene
  145172. * @param _origin The origin position of the vortex
  145173. * @param _options The options for the vortex event
  145174. */
  145175. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  145176. /**
  145177. * Returns the data related to the vortex event (cylinder).
  145178. * @returns The physics vortex event data
  145179. */
  145180. getData(): PhysicsVortexEventData;
  145181. /**
  145182. * Enables the vortex.
  145183. */
  145184. enable(): void;
  145185. /**
  145186. * Disables the cortex.
  145187. */
  145188. disable(): void;
  145189. /**
  145190. * Disposes the sphere.
  145191. * @param force
  145192. */
  145193. dispose(force?: boolean): void;
  145194. private getImpostorHitData;
  145195. private _tick;
  145196. /*** Helpers ***/
  145197. private _prepareCylinder;
  145198. private _intersectsWithCylinder;
  145199. }
  145200. /**
  145201. * Options fot the radial explosion event
  145202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145203. */
  145204. export class PhysicsRadialExplosionEventOptions {
  145205. /**
  145206. * The radius of the sphere for the radial explosion.
  145207. */
  145208. radius: number;
  145209. /**
  145210. * The strenth of the explosion.
  145211. */
  145212. strength: number;
  145213. /**
  145214. * The strenght of the force in correspondence to the distance of the affected object
  145215. */
  145216. falloff: PhysicsRadialImpulseFalloff;
  145217. /**
  145218. * Sphere options for the radial explosion.
  145219. */
  145220. sphere: {
  145221. segments: number;
  145222. diameter: number;
  145223. };
  145224. /**
  145225. * Sphere options for the radial explosion.
  145226. */
  145227. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  145228. }
  145229. /**
  145230. * Options fot the updraft event
  145231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145232. */
  145233. export class PhysicsUpdraftEventOptions {
  145234. /**
  145235. * The radius of the cylinder for the vortex
  145236. */
  145237. radius: number;
  145238. /**
  145239. * The strenth of the updraft.
  145240. */
  145241. strength: number;
  145242. /**
  145243. * The height of the cylinder for the updraft.
  145244. */
  145245. height: number;
  145246. /**
  145247. * The mode for the the updraft.
  145248. */
  145249. updraftMode: PhysicsUpdraftMode;
  145250. }
  145251. /**
  145252. * Options fot the vortex event
  145253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145254. */
  145255. export class PhysicsVortexEventOptions {
  145256. /**
  145257. * The radius of the cylinder for the vortex
  145258. */
  145259. radius: number;
  145260. /**
  145261. * The strenth of the vortex.
  145262. */
  145263. strength: number;
  145264. /**
  145265. * The height of the cylinder for the vortex.
  145266. */
  145267. height: number;
  145268. /**
  145269. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  145270. */
  145271. centripetalForceThreshold: number;
  145272. /**
  145273. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  145274. */
  145275. centripetalForceMultiplier: number;
  145276. /**
  145277. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  145278. */
  145279. centrifugalForceMultiplier: number;
  145280. /**
  145281. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  145282. */
  145283. updraftForceMultiplier: number;
  145284. }
  145285. /**
  145286. * The strenght of the force in correspondence to the distance of the affected object
  145287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145288. */
  145289. export enum PhysicsRadialImpulseFalloff {
  145290. /** Defines that impulse is constant in strength across it's whole radius */
  145291. Constant = 0,
  145292. /** Defines that impulse gets weaker if it's further from the origin */
  145293. Linear = 1
  145294. }
  145295. /**
  145296. * The strength of the force in correspondence to the distance of the affected object
  145297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145298. */
  145299. export enum PhysicsUpdraftMode {
  145300. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  145301. Center = 0,
  145302. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  145303. Perpendicular = 1
  145304. }
  145305. /**
  145306. * Interface for a physics hit data
  145307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145308. */
  145309. export interface PhysicsHitData {
  145310. /**
  145311. * The force applied at the contact point
  145312. */
  145313. force: Vector3;
  145314. /**
  145315. * The contact point
  145316. */
  145317. contactPoint: Vector3;
  145318. /**
  145319. * The distance from the origin to the contact point
  145320. */
  145321. distanceFromOrigin: number;
  145322. }
  145323. /**
  145324. * Interface for radial explosion event data
  145325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145326. */
  145327. export interface PhysicsRadialExplosionEventData {
  145328. /**
  145329. * A sphere used for the radial explosion event
  145330. */
  145331. sphere: Mesh;
  145332. }
  145333. /**
  145334. * Interface for gravitational field event data
  145335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145336. */
  145337. export interface PhysicsGravitationalFieldEventData {
  145338. /**
  145339. * A sphere mesh used for the gravitational field event
  145340. */
  145341. sphere: Mesh;
  145342. }
  145343. /**
  145344. * Interface for updraft event data
  145345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145346. */
  145347. export interface PhysicsUpdraftEventData {
  145348. /**
  145349. * A cylinder used for the updraft event
  145350. */
  145351. cylinder: Mesh;
  145352. }
  145353. /**
  145354. * Interface for vortex event data
  145355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145356. */
  145357. export interface PhysicsVortexEventData {
  145358. /**
  145359. * A cylinder used for the vortex event
  145360. */
  145361. cylinder: Mesh;
  145362. }
  145363. /**
  145364. * Interface for an affected physics impostor
  145365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145366. */
  145367. export interface PhysicsAffectedImpostorWithData {
  145368. /**
  145369. * The impostor affected by the effect
  145370. */
  145371. impostor: PhysicsImpostor;
  145372. /**
  145373. * The data about the hit/horce from the explosion
  145374. */
  145375. hitData: PhysicsHitData;
  145376. }
  145377. }
  145378. declare module BABYLON {
  145379. /** @hidden */
  145380. export var blackAndWhitePixelShader: {
  145381. name: string;
  145382. shader: string;
  145383. };
  145384. }
  145385. declare module BABYLON {
  145386. /**
  145387. * Post process used to render in black and white
  145388. */
  145389. export class BlackAndWhitePostProcess extends PostProcess {
  145390. /**
  145391. * Linear about to convert he result to black and white (default: 1)
  145392. */
  145393. degree: number;
  145394. /**
  145395. * Creates a black and white post process
  145396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  145397. * @param name The name of the effect.
  145398. * @param options The required width/height ratio to downsize to before computing the render pass.
  145399. * @param camera The camera to apply the render pass to.
  145400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145401. * @param engine The engine which the post process will be applied. (default: current engine)
  145402. * @param reusable If the post process can be reused on the same frame. (default: false)
  145403. */
  145404. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145405. }
  145406. }
  145407. declare module BABYLON {
  145408. /**
  145409. * This represents a set of one or more post processes in Babylon.
  145410. * A post process can be used to apply a shader to a texture after it is rendered.
  145411. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145412. */
  145413. export class PostProcessRenderEffect {
  145414. private _postProcesses;
  145415. private _getPostProcesses;
  145416. private _singleInstance;
  145417. private _cameras;
  145418. private _indicesForCamera;
  145419. /**
  145420. * Name of the effect
  145421. * @hidden
  145422. */
  145423. _name: string;
  145424. /**
  145425. * Instantiates a post process render effect.
  145426. * A post process can be used to apply a shader to a texture after it is rendered.
  145427. * @param engine The engine the effect is tied to
  145428. * @param name The name of the effect
  145429. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  145430. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  145431. */
  145432. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  145433. /**
  145434. * Checks if all the post processes in the effect are supported.
  145435. */
  145436. get isSupported(): boolean;
  145437. /**
  145438. * Updates the current state of the effect
  145439. * @hidden
  145440. */
  145441. _update(): void;
  145442. /**
  145443. * Attaches the effect on cameras
  145444. * @param cameras The camera to attach to.
  145445. * @hidden
  145446. */
  145447. _attachCameras(cameras: Camera): void;
  145448. /**
  145449. * Attaches the effect on cameras
  145450. * @param cameras The camera to attach to.
  145451. * @hidden
  145452. */
  145453. _attachCameras(cameras: Camera[]): void;
  145454. /**
  145455. * Detaches the effect on cameras
  145456. * @param cameras The camera to detatch from.
  145457. * @hidden
  145458. */
  145459. _detachCameras(cameras: Camera): void;
  145460. /**
  145461. * Detatches the effect on cameras
  145462. * @param cameras The camera to detatch from.
  145463. * @hidden
  145464. */
  145465. _detachCameras(cameras: Camera[]): void;
  145466. /**
  145467. * Enables the effect on given cameras
  145468. * @param cameras The camera to enable.
  145469. * @hidden
  145470. */
  145471. _enable(cameras: Camera): void;
  145472. /**
  145473. * Enables the effect on given cameras
  145474. * @param cameras The camera to enable.
  145475. * @hidden
  145476. */
  145477. _enable(cameras: Nullable<Camera[]>): void;
  145478. /**
  145479. * Disables the effect on the given cameras
  145480. * @param cameras The camera to disable.
  145481. * @hidden
  145482. */
  145483. _disable(cameras: Camera): void;
  145484. /**
  145485. * Disables the effect on the given cameras
  145486. * @param cameras The camera to disable.
  145487. * @hidden
  145488. */
  145489. _disable(cameras: Nullable<Camera[]>): void;
  145490. /**
  145491. * Gets a list of the post processes contained in the effect.
  145492. * @param camera The camera to get the post processes on.
  145493. * @returns The list of the post processes in the effect.
  145494. */
  145495. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  145496. }
  145497. }
  145498. declare module BABYLON {
  145499. /** @hidden */
  145500. export var extractHighlightsPixelShader: {
  145501. name: string;
  145502. shader: string;
  145503. };
  145504. }
  145505. declare module BABYLON {
  145506. /**
  145507. * 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.
  145508. */
  145509. export class ExtractHighlightsPostProcess extends PostProcess {
  145510. /**
  145511. * The luminance threshold, pixels below this value will be set to black.
  145512. */
  145513. threshold: number;
  145514. /** @hidden */
  145515. _exposure: number;
  145516. /**
  145517. * Post process which has the input texture to be used when performing highlight extraction
  145518. * @hidden
  145519. */
  145520. _inputPostProcess: Nullable<PostProcess>;
  145521. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145522. }
  145523. }
  145524. declare module BABYLON {
  145525. /** @hidden */
  145526. export var bloomMergePixelShader: {
  145527. name: string;
  145528. shader: string;
  145529. };
  145530. }
  145531. declare module BABYLON {
  145532. /**
  145533. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145534. */
  145535. export class BloomMergePostProcess extends PostProcess {
  145536. /** Weight of the bloom to be added to the original input. */
  145537. weight: number;
  145538. /**
  145539. * Creates a new instance of @see BloomMergePostProcess
  145540. * @param name The name of the effect.
  145541. * @param originalFromInput Post process which's input will be used for the merge.
  145542. * @param blurred Blurred highlights post process which's output will be used.
  145543. * @param weight Weight of the bloom to be added to the original input.
  145544. * @param options The required width/height ratio to downsize to before computing the render pass.
  145545. * @param camera The camera to apply the render pass to.
  145546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145547. * @param engine The engine which the post process will be applied. (default: current engine)
  145548. * @param reusable If the post process can be reused on the same frame. (default: false)
  145549. * @param textureType Type of textures used when performing the post process. (default: 0)
  145550. * @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)
  145551. */
  145552. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  145553. /** Weight of the bloom to be added to the original input. */
  145554. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145555. }
  145556. }
  145557. declare module BABYLON {
  145558. /**
  145559. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  145560. */
  145561. export class BloomEffect extends PostProcessRenderEffect {
  145562. private bloomScale;
  145563. /**
  145564. * @hidden Internal
  145565. */
  145566. _effects: Array<PostProcess>;
  145567. /**
  145568. * @hidden Internal
  145569. */
  145570. _downscale: ExtractHighlightsPostProcess;
  145571. private _blurX;
  145572. private _blurY;
  145573. private _merge;
  145574. /**
  145575. * The luminance threshold to find bright areas of the image to bloom.
  145576. */
  145577. get threshold(): number;
  145578. set threshold(value: number);
  145579. /**
  145580. * The strength of the bloom.
  145581. */
  145582. get weight(): number;
  145583. set weight(value: number);
  145584. /**
  145585. * Specifies the size of the bloom blur kernel, relative to the final output size
  145586. */
  145587. get kernel(): number;
  145588. set kernel(value: number);
  145589. /**
  145590. * Creates a new instance of @see BloomEffect
  145591. * @param scene The scene the effect belongs to.
  145592. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  145593. * @param bloomKernel The size of the kernel to be used when applying the blur.
  145594. * @param bloomWeight The the strength of bloom.
  145595. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145596. * @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)
  145597. */
  145598. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  145599. /**
  145600. * Disposes each of the internal effects for a given camera.
  145601. * @param camera The camera to dispose the effect on.
  145602. */
  145603. disposeEffects(camera: Camera): void;
  145604. /**
  145605. * @hidden Internal
  145606. */
  145607. _updateEffects(): void;
  145608. /**
  145609. * Internal
  145610. * @returns if all the contained post processes are ready.
  145611. * @hidden
  145612. */
  145613. _isReady(): boolean;
  145614. }
  145615. }
  145616. declare module BABYLON {
  145617. /** @hidden */
  145618. export var chromaticAberrationPixelShader: {
  145619. name: string;
  145620. shader: string;
  145621. };
  145622. }
  145623. declare module BABYLON {
  145624. /**
  145625. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  145626. */
  145627. export class ChromaticAberrationPostProcess extends PostProcess {
  145628. /**
  145629. * The amount of seperation of rgb channels (default: 30)
  145630. */
  145631. aberrationAmount: number;
  145632. /**
  145633. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  145634. */
  145635. radialIntensity: number;
  145636. /**
  145637. * 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))
  145638. */
  145639. direction: Vector2;
  145640. /**
  145641. * 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))
  145642. */
  145643. centerPosition: Vector2;
  145644. /**
  145645. * Creates a new instance ChromaticAberrationPostProcess
  145646. * @param name The name of the effect.
  145647. * @param screenWidth The width of the screen to apply the effect on.
  145648. * @param screenHeight The height of the screen to apply the effect on.
  145649. * @param options The required width/height ratio to downsize to before computing the render pass.
  145650. * @param camera The camera to apply the render pass to.
  145651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145652. * @param engine The engine which the post process will be applied. (default: current engine)
  145653. * @param reusable If the post process can be reused on the same frame. (default: false)
  145654. * @param textureType Type of textures used when performing the post process. (default: 0)
  145655. * @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)
  145656. */
  145657. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145658. }
  145659. }
  145660. declare module BABYLON {
  145661. /** @hidden */
  145662. export var circleOfConfusionPixelShader: {
  145663. name: string;
  145664. shader: string;
  145665. };
  145666. }
  145667. declare module BABYLON {
  145668. /**
  145669. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  145670. */
  145671. export class CircleOfConfusionPostProcess extends PostProcess {
  145672. /**
  145673. * 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.
  145674. */
  145675. lensSize: number;
  145676. /**
  145677. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145678. */
  145679. fStop: number;
  145680. /**
  145681. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145682. */
  145683. focusDistance: number;
  145684. /**
  145685. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  145686. */
  145687. focalLength: number;
  145688. private _depthTexture;
  145689. /**
  145690. * Creates a new instance CircleOfConfusionPostProcess
  145691. * @param name The name of the effect.
  145692. * @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.
  145693. * @param options The required width/height ratio to downsize to before computing the render pass.
  145694. * @param camera The camera to apply the render pass to.
  145695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145696. * @param engine The engine which the post process will be applied. (default: current engine)
  145697. * @param reusable If the post process can be reused on the same frame. (default: false)
  145698. * @param textureType Type of textures used when performing the post process. (default: 0)
  145699. * @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)
  145700. */
  145701. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145702. /**
  145703. * 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.
  145704. */
  145705. set depthTexture(value: RenderTargetTexture);
  145706. }
  145707. }
  145708. declare module BABYLON {
  145709. /** @hidden */
  145710. export var colorCorrectionPixelShader: {
  145711. name: string;
  145712. shader: string;
  145713. };
  145714. }
  145715. declare module BABYLON {
  145716. /**
  145717. *
  145718. * This post-process allows the modification of rendered colors by using
  145719. * a 'look-up table' (LUT). This effect is also called Color Grading.
  145720. *
  145721. * The object needs to be provided an url to a texture containing the color
  145722. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  145723. * Use an image editing software to tweak the LUT to match your needs.
  145724. *
  145725. * For an example of a color LUT, see here:
  145726. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  145727. * For explanations on color grading, see here:
  145728. * @see http://udn.epicgames.com/Three/ColorGrading.html
  145729. *
  145730. */
  145731. export class ColorCorrectionPostProcess extends PostProcess {
  145732. private _colorTableTexture;
  145733. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145734. }
  145735. }
  145736. declare module BABYLON {
  145737. /** @hidden */
  145738. export var convolutionPixelShader: {
  145739. name: string;
  145740. shader: string;
  145741. };
  145742. }
  145743. declare module BABYLON {
  145744. /**
  145745. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  145746. * input texture to perform effects such as edge detection or sharpening
  145747. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  145748. */
  145749. export class ConvolutionPostProcess extends PostProcess {
  145750. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  145751. kernel: number[];
  145752. /**
  145753. * Creates a new instance ConvolutionPostProcess
  145754. * @param name The name of the effect.
  145755. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  145756. * @param options The required width/height ratio to downsize to before computing the render pass.
  145757. * @param camera The camera to apply the render pass to.
  145758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145759. * @param engine The engine which the post process will be applied. (default: current engine)
  145760. * @param reusable If the post process can be reused on the same frame. (default: false)
  145761. * @param textureType Type of textures used when performing the post process. (default: 0)
  145762. */
  145763. constructor(name: string,
  145764. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  145765. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145766. /**
  145767. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145768. */
  145769. static EdgeDetect0Kernel: number[];
  145770. /**
  145771. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145772. */
  145773. static EdgeDetect1Kernel: number[];
  145774. /**
  145775. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145776. */
  145777. static EdgeDetect2Kernel: number[];
  145778. /**
  145779. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145780. */
  145781. static SharpenKernel: number[];
  145782. /**
  145783. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145784. */
  145785. static EmbossKernel: number[];
  145786. /**
  145787. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145788. */
  145789. static GaussianKernel: number[];
  145790. }
  145791. }
  145792. declare module BABYLON {
  145793. /**
  145794. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  145795. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  145796. * based on samples that have a large difference in distance than the center pixel.
  145797. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  145798. */
  145799. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  145800. direction: Vector2;
  145801. /**
  145802. * Creates a new instance CircleOfConfusionPostProcess
  145803. * @param name The name of the effect.
  145804. * @param scene The scene the effect belongs to.
  145805. * @param direction The direction the blur should be applied.
  145806. * @param kernel The size of the kernel used to blur.
  145807. * @param options The required width/height ratio to downsize to before computing the render pass.
  145808. * @param camera The camera to apply the render pass to.
  145809. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  145810. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  145811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145812. * @param engine The engine which the post process will be applied. (default: current engine)
  145813. * @param reusable If the post process can be reused on the same frame. (default: false)
  145814. * @param textureType Type of textures used when performing the post process. (default: 0)
  145815. * @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)
  145816. */
  145817. 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);
  145818. }
  145819. }
  145820. declare module BABYLON {
  145821. /** @hidden */
  145822. export var depthOfFieldMergePixelShader: {
  145823. name: string;
  145824. shader: string;
  145825. };
  145826. }
  145827. declare module BABYLON {
  145828. /**
  145829. * Options to be set when merging outputs from the default pipeline.
  145830. */
  145831. export class DepthOfFieldMergePostProcessOptions {
  145832. /**
  145833. * The original image to merge on top of
  145834. */
  145835. originalFromInput: PostProcess;
  145836. /**
  145837. * Parameters to perform the merge of the depth of field effect
  145838. */
  145839. depthOfField?: {
  145840. circleOfConfusion: PostProcess;
  145841. blurSteps: Array<PostProcess>;
  145842. };
  145843. /**
  145844. * Parameters to perform the merge of bloom effect
  145845. */
  145846. bloom?: {
  145847. blurred: PostProcess;
  145848. weight: number;
  145849. };
  145850. }
  145851. /**
  145852. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145853. */
  145854. export class DepthOfFieldMergePostProcess extends PostProcess {
  145855. private blurSteps;
  145856. /**
  145857. * Creates a new instance of DepthOfFieldMergePostProcess
  145858. * @param name The name of the effect.
  145859. * @param originalFromInput Post process which's input will be used for the merge.
  145860. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  145861. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  145862. * @param options The required width/height ratio to downsize to before computing the render pass.
  145863. * @param camera The camera to apply the render pass to.
  145864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145865. * @param engine The engine which the post process will be applied. (default: current engine)
  145866. * @param reusable If the post process can be reused on the same frame. (default: false)
  145867. * @param textureType Type of textures used when performing the post process. (default: 0)
  145868. * @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)
  145869. */
  145870. 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);
  145871. /**
  145872. * Updates the effect with the current post process compile time values and recompiles the shader.
  145873. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  145874. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  145875. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  145876. * @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
  145877. * @param onCompiled Called when the shader has been compiled.
  145878. * @param onError Called if there is an error when compiling a shader.
  145879. */
  145880. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  145881. }
  145882. }
  145883. declare module BABYLON {
  145884. /**
  145885. * Specifies the level of max blur that should be applied when using the depth of field effect
  145886. */
  145887. export enum DepthOfFieldEffectBlurLevel {
  145888. /**
  145889. * Subtle blur
  145890. */
  145891. Low = 0,
  145892. /**
  145893. * Medium blur
  145894. */
  145895. Medium = 1,
  145896. /**
  145897. * Large blur
  145898. */
  145899. High = 2
  145900. }
  145901. /**
  145902. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  145903. */
  145904. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  145905. private _circleOfConfusion;
  145906. /**
  145907. * @hidden Internal, blurs from high to low
  145908. */
  145909. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  145910. private _depthOfFieldBlurY;
  145911. private _dofMerge;
  145912. /**
  145913. * @hidden Internal post processes in depth of field effect
  145914. */
  145915. _effects: Array<PostProcess>;
  145916. /**
  145917. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  145918. */
  145919. set focalLength(value: number);
  145920. get focalLength(): number;
  145921. /**
  145922. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145923. */
  145924. set fStop(value: number);
  145925. get fStop(): number;
  145926. /**
  145927. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145928. */
  145929. set focusDistance(value: number);
  145930. get focusDistance(): number;
  145931. /**
  145932. * 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.
  145933. */
  145934. set lensSize(value: number);
  145935. get lensSize(): number;
  145936. /**
  145937. * Creates a new instance DepthOfFieldEffect
  145938. * @param scene The scene the effect belongs to.
  145939. * @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.
  145940. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145941. * @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)
  145942. */
  145943. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  145944. /**
  145945. * Get the current class name of the current effet
  145946. * @returns "DepthOfFieldEffect"
  145947. */
  145948. getClassName(): string;
  145949. /**
  145950. * 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.
  145951. */
  145952. set depthTexture(value: RenderTargetTexture);
  145953. /**
  145954. * Disposes each of the internal effects for a given camera.
  145955. * @param camera The camera to dispose the effect on.
  145956. */
  145957. disposeEffects(camera: Camera): void;
  145958. /**
  145959. * @hidden Internal
  145960. */
  145961. _updateEffects(): void;
  145962. /**
  145963. * Internal
  145964. * @returns if all the contained post processes are ready.
  145965. * @hidden
  145966. */
  145967. _isReady(): boolean;
  145968. }
  145969. }
  145970. declare module BABYLON {
  145971. /** @hidden */
  145972. export var displayPassPixelShader: {
  145973. name: string;
  145974. shader: string;
  145975. };
  145976. }
  145977. declare module BABYLON {
  145978. /**
  145979. * DisplayPassPostProcess which produces an output the same as it's input
  145980. */
  145981. export class DisplayPassPostProcess extends PostProcess {
  145982. /**
  145983. * Creates the DisplayPassPostProcess
  145984. * @param name The name of the effect.
  145985. * @param options The required width/height ratio to downsize to before computing the render pass.
  145986. * @param camera The camera to apply the render pass to.
  145987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145988. * @param engine The engine which the post process will be applied. (default: current engine)
  145989. * @param reusable If the post process can be reused on the same frame. (default: false)
  145990. */
  145991. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145992. }
  145993. }
  145994. declare module BABYLON {
  145995. /** @hidden */
  145996. export var filterPixelShader: {
  145997. name: string;
  145998. shader: string;
  145999. };
  146000. }
  146001. declare module BABYLON {
  146002. /**
  146003. * Applies a kernel filter to the image
  146004. */
  146005. export class FilterPostProcess extends PostProcess {
  146006. /** The matrix to be applied to the image */
  146007. kernelMatrix: Matrix;
  146008. /**
  146009. *
  146010. * @param name The name of the effect.
  146011. * @param kernelMatrix The matrix to be applied to the image
  146012. * @param options The required width/height ratio to downsize to before computing the render pass.
  146013. * @param camera The camera to apply the render pass to.
  146014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146015. * @param engine The engine which the post process will be applied. (default: current engine)
  146016. * @param reusable If the post process can be reused on the same frame. (default: false)
  146017. */
  146018. constructor(name: string,
  146019. /** The matrix to be applied to the image */
  146020. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146021. }
  146022. }
  146023. declare module BABYLON {
  146024. /** @hidden */
  146025. export var fxaaPixelShader: {
  146026. name: string;
  146027. shader: string;
  146028. };
  146029. }
  146030. declare module BABYLON {
  146031. /** @hidden */
  146032. export var fxaaVertexShader: {
  146033. name: string;
  146034. shader: string;
  146035. };
  146036. }
  146037. declare module BABYLON {
  146038. /**
  146039. * Fxaa post process
  146040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  146041. */
  146042. export class FxaaPostProcess extends PostProcess {
  146043. /** @hidden */
  146044. texelWidth: number;
  146045. /** @hidden */
  146046. texelHeight: number;
  146047. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146048. private _getDefines;
  146049. }
  146050. }
  146051. declare module BABYLON {
  146052. /** @hidden */
  146053. export var grainPixelShader: {
  146054. name: string;
  146055. shader: string;
  146056. };
  146057. }
  146058. declare module BABYLON {
  146059. /**
  146060. * The GrainPostProcess adds noise to the image at mid luminance levels
  146061. */
  146062. export class GrainPostProcess extends PostProcess {
  146063. /**
  146064. * The intensity of the grain added (default: 30)
  146065. */
  146066. intensity: number;
  146067. /**
  146068. * If the grain should be randomized on every frame
  146069. */
  146070. animated: boolean;
  146071. /**
  146072. * Creates a new instance of @see GrainPostProcess
  146073. * @param name The name of the effect.
  146074. * @param options The required width/height ratio to downsize to before computing the render pass.
  146075. * @param camera The camera to apply the render pass to.
  146076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146077. * @param engine The engine which the post process will be applied. (default: current engine)
  146078. * @param reusable If the post process can be reused on the same frame. (default: false)
  146079. * @param textureType Type of textures used when performing the post process. (default: 0)
  146080. * @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)
  146081. */
  146082. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146083. }
  146084. }
  146085. declare module BABYLON {
  146086. /** @hidden */
  146087. export var highlightsPixelShader: {
  146088. name: string;
  146089. shader: string;
  146090. };
  146091. }
  146092. declare module BABYLON {
  146093. /**
  146094. * Extracts highlights from the image
  146095. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146096. */
  146097. export class HighlightsPostProcess extends PostProcess {
  146098. /**
  146099. * Extracts highlights from the image
  146100. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146101. * @param name The name of the effect.
  146102. * @param options The required width/height ratio to downsize to before computing the render pass.
  146103. * @param camera The camera to apply the render pass to.
  146104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146105. * @param engine The engine which the post process will be applied. (default: current engine)
  146106. * @param reusable If the post process can be reused on the same frame. (default: false)
  146107. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  146108. */
  146109. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146110. }
  146111. }
  146112. declare module BABYLON {
  146113. /** @hidden */
  146114. export var mrtFragmentDeclaration: {
  146115. name: string;
  146116. shader: string;
  146117. };
  146118. }
  146119. declare module BABYLON {
  146120. /** @hidden */
  146121. export var geometryPixelShader: {
  146122. name: string;
  146123. shader: string;
  146124. };
  146125. }
  146126. declare module BABYLON {
  146127. /** @hidden */
  146128. export var geometryVertexShader: {
  146129. name: string;
  146130. shader: string;
  146131. };
  146132. }
  146133. declare module BABYLON {
  146134. /** @hidden */
  146135. interface ISavedTransformationMatrix {
  146136. world: Matrix;
  146137. viewProjection: Matrix;
  146138. }
  146139. /**
  146140. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  146141. */
  146142. export class GeometryBufferRenderer {
  146143. /**
  146144. * Constant used to retrieve the position texture index in the G-Buffer textures array
  146145. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  146146. */
  146147. static readonly POSITION_TEXTURE_TYPE: number;
  146148. /**
  146149. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  146150. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  146151. */
  146152. static readonly VELOCITY_TEXTURE_TYPE: number;
  146153. /**
  146154. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  146155. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  146156. */
  146157. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  146158. /**
  146159. * Dictionary used to store the previous transformation matrices of each rendered mesh
  146160. * in order to compute objects velocities when enableVelocity is set to "true"
  146161. * @hidden
  146162. */
  146163. _previousTransformationMatrices: {
  146164. [index: number]: ISavedTransformationMatrix;
  146165. };
  146166. /**
  146167. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  146168. * in order to compute objects velocities when enableVelocity is set to "true"
  146169. * @hidden
  146170. */
  146171. _previousBonesTransformationMatrices: {
  146172. [index: number]: Float32Array;
  146173. };
  146174. /**
  146175. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  146176. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  146177. */
  146178. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  146179. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  146180. renderTransparentMeshes: boolean;
  146181. private _scene;
  146182. private _multiRenderTarget;
  146183. private _ratio;
  146184. private _enablePosition;
  146185. private _enableVelocity;
  146186. private _enableReflectivity;
  146187. private _positionIndex;
  146188. private _velocityIndex;
  146189. private _reflectivityIndex;
  146190. protected _effect: Effect;
  146191. protected _cachedDefines: string;
  146192. /**
  146193. * Set the render list (meshes to be rendered) used in the G buffer.
  146194. */
  146195. set renderList(meshes: Mesh[]);
  146196. /**
  146197. * Gets wether or not G buffer are supported by the running hardware.
  146198. * This requires draw buffer supports
  146199. */
  146200. get isSupported(): boolean;
  146201. /**
  146202. * Returns the index of the given texture type in the G-Buffer textures array
  146203. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  146204. * @returns the index of the given texture type in the G-Buffer textures array
  146205. */
  146206. getTextureIndex(textureType: number): number;
  146207. /**
  146208. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  146209. */
  146210. get enablePosition(): boolean;
  146211. /**
  146212. * Sets whether or not objects positions are enabled for the G buffer.
  146213. */
  146214. set enablePosition(enable: boolean);
  146215. /**
  146216. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  146217. */
  146218. get enableVelocity(): boolean;
  146219. /**
  146220. * Sets wether or not objects velocities are enabled for the G buffer.
  146221. */
  146222. set enableVelocity(enable: boolean);
  146223. /**
  146224. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  146225. */
  146226. get enableReflectivity(): boolean;
  146227. /**
  146228. * Sets wether or not objects roughness are enabled for the G buffer.
  146229. */
  146230. set enableReflectivity(enable: boolean);
  146231. /**
  146232. * Gets the scene associated with the buffer.
  146233. */
  146234. get scene(): Scene;
  146235. /**
  146236. * Gets the ratio used by the buffer during its creation.
  146237. * How big is the buffer related to the main canvas.
  146238. */
  146239. get ratio(): number;
  146240. /** @hidden */
  146241. static _SceneComponentInitialization: (scene: Scene) => void;
  146242. /**
  146243. * Creates a new G Buffer for the scene
  146244. * @param scene The scene the buffer belongs to
  146245. * @param ratio How big is the buffer related to the main canvas.
  146246. */
  146247. constructor(scene: Scene, ratio?: number);
  146248. /**
  146249. * Checks wether everything is ready to render a submesh to the G buffer.
  146250. * @param subMesh the submesh to check readiness for
  146251. * @param useInstances is the mesh drawn using instance or not
  146252. * @returns true if ready otherwise false
  146253. */
  146254. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146255. /**
  146256. * Gets the current underlying G Buffer.
  146257. * @returns the buffer
  146258. */
  146259. getGBuffer(): MultiRenderTarget;
  146260. /**
  146261. * Gets the number of samples used to render the buffer (anti aliasing).
  146262. */
  146263. get samples(): number;
  146264. /**
  146265. * Sets the number of samples used to render the buffer (anti aliasing).
  146266. */
  146267. set samples(value: number);
  146268. /**
  146269. * Disposes the renderer and frees up associated resources.
  146270. */
  146271. dispose(): void;
  146272. protected _createRenderTargets(): void;
  146273. private _copyBonesTransformationMatrices;
  146274. }
  146275. }
  146276. declare module BABYLON {
  146277. interface Scene {
  146278. /** @hidden (Backing field) */
  146279. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  146280. /**
  146281. * Gets or Sets the current geometry buffer associated to the scene.
  146282. */
  146283. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  146284. /**
  146285. * Enables a GeometryBufferRender and associates it with the scene
  146286. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  146287. * @returns the GeometryBufferRenderer
  146288. */
  146289. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  146290. /**
  146291. * Disables the GeometryBufferRender associated with the scene
  146292. */
  146293. disableGeometryBufferRenderer(): void;
  146294. }
  146295. /**
  146296. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  146297. * in several rendering techniques.
  146298. */
  146299. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  146300. /**
  146301. * The component name helpful to identify the component in the list of scene components.
  146302. */
  146303. readonly name: string;
  146304. /**
  146305. * The scene the component belongs to.
  146306. */
  146307. scene: Scene;
  146308. /**
  146309. * Creates a new instance of the component for the given scene
  146310. * @param scene Defines the scene to register the component in
  146311. */
  146312. constructor(scene: Scene);
  146313. /**
  146314. * Registers the component in a given scene
  146315. */
  146316. register(): void;
  146317. /**
  146318. * Rebuilds the elements related to this component in case of
  146319. * context lost for instance.
  146320. */
  146321. rebuild(): void;
  146322. /**
  146323. * Disposes the component and the associated ressources
  146324. */
  146325. dispose(): void;
  146326. private _gatherRenderTargets;
  146327. }
  146328. }
  146329. declare module BABYLON {
  146330. /** @hidden */
  146331. export var motionBlurPixelShader: {
  146332. name: string;
  146333. shader: string;
  146334. };
  146335. }
  146336. declare module BABYLON {
  146337. /**
  146338. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  146339. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  146340. * As an example, all you have to do is to create the post-process:
  146341. * var mb = new BABYLON.MotionBlurPostProcess(
  146342. * 'mb', // The name of the effect.
  146343. * scene, // The scene containing the objects to blur according to their velocity.
  146344. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  146345. * camera // The camera to apply the render pass to.
  146346. * );
  146347. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  146348. */
  146349. export class MotionBlurPostProcess extends PostProcess {
  146350. /**
  146351. * Defines how much the image is blurred by the movement. Default value is equal to 1
  146352. */
  146353. motionStrength: number;
  146354. /**
  146355. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  146356. */
  146357. get motionBlurSamples(): number;
  146358. /**
  146359. * Sets the number of iterations to be used for motion blur quality
  146360. */
  146361. set motionBlurSamples(samples: number);
  146362. private _motionBlurSamples;
  146363. private _geometryBufferRenderer;
  146364. /**
  146365. * Creates a new instance MotionBlurPostProcess
  146366. * @param name The name of the effect.
  146367. * @param scene The scene containing the objects to blur according to their velocity.
  146368. * @param options The required width/height ratio to downsize to before computing the render pass.
  146369. * @param camera The camera to apply the render pass to.
  146370. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146371. * @param engine The engine which the post process will be applied. (default: current engine)
  146372. * @param reusable If the post process can be reused on the same frame. (default: false)
  146373. * @param textureType Type of textures used when performing the post process. (default: 0)
  146374. * @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)
  146375. */
  146376. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146377. /**
  146378. * Excludes the given skinned mesh from computing bones velocities.
  146379. * 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.
  146380. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  146381. */
  146382. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146383. /**
  146384. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  146385. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  146386. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  146387. */
  146388. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146389. /**
  146390. * Disposes the post process.
  146391. * @param camera The camera to dispose the post process on.
  146392. */
  146393. dispose(camera?: Camera): void;
  146394. }
  146395. }
  146396. declare module BABYLON {
  146397. /** @hidden */
  146398. export var refractionPixelShader: {
  146399. name: string;
  146400. shader: string;
  146401. };
  146402. }
  146403. declare module BABYLON {
  146404. /**
  146405. * Post process which applies a refractin texture
  146406. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146407. */
  146408. export class RefractionPostProcess extends PostProcess {
  146409. /** the base color of the refraction (used to taint the rendering) */
  146410. color: Color3;
  146411. /** simulated refraction depth */
  146412. depth: number;
  146413. /** the coefficient of the base color (0 to remove base color tainting) */
  146414. colorLevel: number;
  146415. private _refTexture;
  146416. private _ownRefractionTexture;
  146417. /**
  146418. * Gets or sets the refraction texture
  146419. * Please note that you are responsible for disposing the texture if you set it manually
  146420. */
  146421. get refractionTexture(): Texture;
  146422. set refractionTexture(value: Texture);
  146423. /**
  146424. * Initializes the RefractionPostProcess
  146425. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146426. * @param name The name of the effect.
  146427. * @param refractionTextureUrl Url of the refraction texture to use
  146428. * @param color the base color of the refraction (used to taint the rendering)
  146429. * @param depth simulated refraction depth
  146430. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  146431. * @param camera The camera to apply the render pass to.
  146432. * @param options The required width/height ratio to downsize to before computing the render pass.
  146433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146434. * @param engine The engine which the post process will be applied. (default: current engine)
  146435. * @param reusable If the post process can be reused on the same frame. (default: false)
  146436. */
  146437. constructor(name: string, refractionTextureUrl: string,
  146438. /** the base color of the refraction (used to taint the rendering) */
  146439. color: Color3,
  146440. /** simulated refraction depth */
  146441. depth: number,
  146442. /** the coefficient of the base color (0 to remove base color tainting) */
  146443. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146444. /**
  146445. * Disposes of the post process
  146446. * @param camera Camera to dispose post process on
  146447. */
  146448. dispose(camera: Camera): void;
  146449. }
  146450. }
  146451. declare module BABYLON {
  146452. /** @hidden */
  146453. export var sharpenPixelShader: {
  146454. name: string;
  146455. shader: string;
  146456. };
  146457. }
  146458. declare module BABYLON {
  146459. /**
  146460. * The SharpenPostProcess applies a sharpen kernel to every pixel
  146461. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146462. */
  146463. export class SharpenPostProcess extends PostProcess {
  146464. /**
  146465. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  146466. */
  146467. colorAmount: number;
  146468. /**
  146469. * How much sharpness should be applied (default: 0.3)
  146470. */
  146471. edgeAmount: number;
  146472. /**
  146473. * Creates a new instance ConvolutionPostProcess
  146474. * @param name The name of the effect.
  146475. * @param options The required width/height ratio to downsize to before computing the render pass.
  146476. * @param camera The camera to apply the render pass to.
  146477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146478. * @param engine The engine which the post process will be applied. (default: current engine)
  146479. * @param reusable If the post process can be reused on the same frame. (default: false)
  146480. * @param textureType Type of textures used when performing the post process. (default: 0)
  146481. * @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)
  146482. */
  146483. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146484. }
  146485. }
  146486. declare module BABYLON {
  146487. /**
  146488. * PostProcessRenderPipeline
  146489. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146490. */
  146491. export class PostProcessRenderPipeline {
  146492. private engine;
  146493. private _renderEffects;
  146494. private _renderEffectsForIsolatedPass;
  146495. /**
  146496. * List of inspectable custom properties (used by the Inspector)
  146497. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  146498. */
  146499. inspectableCustomProperties: IInspectable[];
  146500. /**
  146501. * @hidden
  146502. */
  146503. protected _cameras: Camera[];
  146504. /** @hidden */
  146505. _name: string;
  146506. /**
  146507. * Gets pipeline name
  146508. */
  146509. get name(): string;
  146510. /** Gets the list of attached cameras */
  146511. get cameras(): Camera[];
  146512. /**
  146513. * Initializes a PostProcessRenderPipeline
  146514. * @param engine engine to add the pipeline to
  146515. * @param name name of the pipeline
  146516. */
  146517. constructor(engine: Engine, name: string);
  146518. /**
  146519. * Gets the class name
  146520. * @returns "PostProcessRenderPipeline"
  146521. */
  146522. getClassName(): string;
  146523. /**
  146524. * If all the render effects in the pipeline are supported
  146525. */
  146526. get isSupported(): boolean;
  146527. /**
  146528. * Adds an effect to the pipeline
  146529. * @param renderEffect the effect to add
  146530. */
  146531. addEffect(renderEffect: PostProcessRenderEffect): void;
  146532. /** @hidden */
  146533. _rebuild(): void;
  146534. /** @hidden */
  146535. _enableEffect(renderEffectName: string, cameras: Camera): void;
  146536. /** @hidden */
  146537. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  146538. /** @hidden */
  146539. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146540. /** @hidden */
  146541. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146542. /** @hidden */
  146543. _attachCameras(cameras: Camera, unique: boolean): void;
  146544. /** @hidden */
  146545. _attachCameras(cameras: Camera[], unique: boolean): void;
  146546. /** @hidden */
  146547. _detachCameras(cameras: Camera): void;
  146548. /** @hidden */
  146549. _detachCameras(cameras: Nullable<Camera[]>): void;
  146550. /** @hidden */
  146551. _update(): void;
  146552. /** @hidden */
  146553. _reset(): void;
  146554. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  146555. /**
  146556. * Disposes of the pipeline
  146557. */
  146558. dispose(): void;
  146559. }
  146560. }
  146561. declare module BABYLON {
  146562. /**
  146563. * PostProcessRenderPipelineManager class
  146564. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146565. */
  146566. export class PostProcessRenderPipelineManager {
  146567. private _renderPipelines;
  146568. /**
  146569. * Initializes a PostProcessRenderPipelineManager
  146570. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146571. */
  146572. constructor();
  146573. /**
  146574. * Gets the list of supported render pipelines
  146575. */
  146576. get supportedPipelines(): PostProcessRenderPipeline[];
  146577. /**
  146578. * Adds a pipeline to the manager
  146579. * @param renderPipeline The pipeline to add
  146580. */
  146581. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  146582. /**
  146583. * Attaches a camera to the pipeline
  146584. * @param renderPipelineName The name of the pipeline to attach to
  146585. * @param cameras the camera to attach
  146586. * @param unique if the camera can be attached multiple times to the pipeline
  146587. */
  146588. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  146589. /**
  146590. * Detaches a camera from the pipeline
  146591. * @param renderPipelineName The name of the pipeline to detach from
  146592. * @param cameras the camera to detach
  146593. */
  146594. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  146595. /**
  146596. * Enables an effect by name on a pipeline
  146597. * @param renderPipelineName the name of the pipeline to enable the effect in
  146598. * @param renderEffectName the name of the effect to enable
  146599. * @param cameras the cameras that the effect should be enabled on
  146600. */
  146601. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146602. /**
  146603. * Disables an effect by name on a pipeline
  146604. * @param renderPipelineName the name of the pipeline to disable the effect in
  146605. * @param renderEffectName the name of the effect to disable
  146606. * @param cameras the cameras that the effect should be disabled on
  146607. */
  146608. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146609. /**
  146610. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  146611. */
  146612. update(): void;
  146613. /** @hidden */
  146614. _rebuild(): void;
  146615. /**
  146616. * Disposes of the manager and pipelines
  146617. */
  146618. dispose(): void;
  146619. }
  146620. }
  146621. declare module BABYLON {
  146622. interface Scene {
  146623. /** @hidden (Backing field) */
  146624. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146625. /**
  146626. * Gets the postprocess render pipeline manager
  146627. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146628. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146629. */
  146630. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146631. }
  146632. /**
  146633. * Defines the Render Pipeline scene component responsible to rendering pipelines
  146634. */
  146635. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  146636. /**
  146637. * The component name helpfull to identify the component in the list of scene components.
  146638. */
  146639. readonly name: string;
  146640. /**
  146641. * The scene the component belongs to.
  146642. */
  146643. scene: Scene;
  146644. /**
  146645. * Creates a new instance of the component for the given scene
  146646. * @param scene Defines the scene to register the component in
  146647. */
  146648. constructor(scene: Scene);
  146649. /**
  146650. * Registers the component in a given scene
  146651. */
  146652. register(): void;
  146653. /**
  146654. * Rebuilds the elements related to this component in case of
  146655. * context lost for instance.
  146656. */
  146657. rebuild(): void;
  146658. /**
  146659. * Disposes the component and the associated ressources
  146660. */
  146661. dispose(): void;
  146662. private _gatherRenderTargets;
  146663. }
  146664. }
  146665. declare module BABYLON {
  146666. /**
  146667. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  146668. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146669. */
  146670. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  146671. private _scene;
  146672. private _camerasToBeAttached;
  146673. /**
  146674. * ID of the sharpen post process,
  146675. */
  146676. private readonly SharpenPostProcessId;
  146677. /**
  146678. * @ignore
  146679. * ID of the image processing post process;
  146680. */
  146681. readonly ImageProcessingPostProcessId: string;
  146682. /**
  146683. * @ignore
  146684. * ID of the Fast Approximate Anti-Aliasing post process;
  146685. */
  146686. readonly FxaaPostProcessId: string;
  146687. /**
  146688. * ID of the chromatic aberration post process,
  146689. */
  146690. private readonly ChromaticAberrationPostProcessId;
  146691. /**
  146692. * ID of the grain post process
  146693. */
  146694. private readonly GrainPostProcessId;
  146695. /**
  146696. * Sharpen post process which will apply a sharpen convolution to enhance edges
  146697. */
  146698. sharpen: SharpenPostProcess;
  146699. private _sharpenEffect;
  146700. private bloom;
  146701. /**
  146702. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  146703. */
  146704. depthOfField: DepthOfFieldEffect;
  146705. /**
  146706. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146707. */
  146708. fxaa: FxaaPostProcess;
  146709. /**
  146710. * Image post processing pass used to perform operations such as tone mapping or color grading.
  146711. */
  146712. imageProcessing: ImageProcessingPostProcess;
  146713. /**
  146714. * Chromatic aberration post process which will shift rgb colors in the image
  146715. */
  146716. chromaticAberration: ChromaticAberrationPostProcess;
  146717. private _chromaticAberrationEffect;
  146718. /**
  146719. * Grain post process which add noise to the image
  146720. */
  146721. grain: GrainPostProcess;
  146722. private _grainEffect;
  146723. /**
  146724. * Glow post process which adds a glow to emissive areas of the image
  146725. */
  146726. private _glowLayer;
  146727. /**
  146728. * Animations which can be used to tweak settings over a period of time
  146729. */
  146730. animations: Animation[];
  146731. private _imageProcessingConfigurationObserver;
  146732. private _sharpenEnabled;
  146733. private _bloomEnabled;
  146734. private _depthOfFieldEnabled;
  146735. private _depthOfFieldBlurLevel;
  146736. private _fxaaEnabled;
  146737. private _imageProcessingEnabled;
  146738. private _defaultPipelineTextureType;
  146739. private _bloomScale;
  146740. private _chromaticAberrationEnabled;
  146741. private _grainEnabled;
  146742. private _buildAllowed;
  146743. /**
  146744. * Gets active scene
  146745. */
  146746. get scene(): Scene;
  146747. /**
  146748. * Enable or disable the sharpen process from the pipeline
  146749. */
  146750. set sharpenEnabled(enabled: boolean);
  146751. get sharpenEnabled(): boolean;
  146752. private _resizeObserver;
  146753. private _hardwareScaleLevel;
  146754. private _bloomKernel;
  146755. /**
  146756. * Specifies the size of the bloom blur kernel, relative to the final output size
  146757. */
  146758. get bloomKernel(): number;
  146759. set bloomKernel(value: number);
  146760. /**
  146761. * Specifies the weight of the bloom in the final rendering
  146762. */
  146763. private _bloomWeight;
  146764. /**
  146765. * Specifies the luma threshold for the area that will be blurred by the bloom
  146766. */
  146767. private _bloomThreshold;
  146768. private _hdr;
  146769. /**
  146770. * The strength of the bloom.
  146771. */
  146772. set bloomWeight(value: number);
  146773. get bloomWeight(): number;
  146774. /**
  146775. * The strength of the bloom.
  146776. */
  146777. set bloomThreshold(value: number);
  146778. get bloomThreshold(): number;
  146779. /**
  146780. * The scale of the bloom, lower value will provide better performance.
  146781. */
  146782. set bloomScale(value: number);
  146783. get bloomScale(): number;
  146784. /**
  146785. * Enable or disable the bloom from the pipeline
  146786. */
  146787. set bloomEnabled(enabled: boolean);
  146788. get bloomEnabled(): boolean;
  146789. private _rebuildBloom;
  146790. /**
  146791. * If the depth of field is enabled.
  146792. */
  146793. get depthOfFieldEnabled(): boolean;
  146794. set depthOfFieldEnabled(enabled: boolean);
  146795. /**
  146796. * Blur level of the depth of field effect. (Higher blur will effect performance)
  146797. */
  146798. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  146799. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  146800. /**
  146801. * If the anti aliasing is enabled.
  146802. */
  146803. set fxaaEnabled(enabled: boolean);
  146804. get fxaaEnabled(): boolean;
  146805. private _samples;
  146806. /**
  146807. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  146808. */
  146809. set samples(sampleCount: number);
  146810. get samples(): number;
  146811. /**
  146812. * If image processing is enabled.
  146813. */
  146814. set imageProcessingEnabled(enabled: boolean);
  146815. get imageProcessingEnabled(): boolean;
  146816. /**
  146817. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  146818. */
  146819. set glowLayerEnabled(enabled: boolean);
  146820. get glowLayerEnabled(): boolean;
  146821. /**
  146822. * Gets the glow layer (or null if not defined)
  146823. */
  146824. get glowLayer(): Nullable<GlowLayer>;
  146825. /**
  146826. * Enable or disable the chromaticAberration process from the pipeline
  146827. */
  146828. set chromaticAberrationEnabled(enabled: boolean);
  146829. get chromaticAberrationEnabled(): boolean;
  146830. /**
  146831. * Enable or disable the grain process from the pipeline
  146832. */
  146833. set grainEnabled(enabled: boolean);
  146834. get grainEnabled(): boolean;
  146835. /**
  146836. * @constructor
  146837. * @param name - The rendering pipeline name (default: "")
  146838. * @param hdr - If high dynamic range textures should be used (default: true)
  146839. * @param scene - The scene linked to this pipeline (default: the last created scene)
  146840. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  146841. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  146842. */
  146843. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  146844. /**
  146845. * Get the class name
  146846. * @returns "DefaultRenderingPipeline"
  146847. */
  146848. getClassName(): string;
  146849. /**
  146850. * Force the compilation of the entire pipeline.
  146851. */
  146852. prepare(): void;
  146853. private _hasCleared;
  146854. private _prevPostProcess;
  146855. private _prevPrevPostProcess;
  146856. private _setAutoClearAndTextureSharing;
  146857. private _depthOfFieldSceneObserver;
  146858. private _buildPipeline;
  146859. private _disposePostProcesses;
  146860. /**
  146861. * Adds a camera to the pipeline
  146862. * @param camera the camera to be added
  146863. */
  146864. addCamera(camera: Camera): void;
  146865. /**
  146866. * Removes a camera from the pipeline
  146867. * @param camera the camera to remove
  146868. */
  146869. removeCamera(camera: Camera): void;
  146870. /**
  146871. * Dispose of the pipeline and stop all post processes
  146872. */
  146873. dispose(): void;
  146874. /**
  146875. * Serialize the rendering pipeline (Used when exporting)
  146876. * @returns the serialized object
  146877. */
  146878. serialize(): any;
  146879. /**
  146880. * Parse the serialized pipeline
  146881. * @param source Source pipeline.
  146882. * @param scene The scene to load the pipeline to.
  146883. * @param rootUrl The URL of the serialized pipeline.
  146884. * @returns An instantiated pipeline from the serialized object.
  146885. */
  146886. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  146887. }
  146888. }
  146889. declare module BABYLON {
  146890. /** @hidden */
  146891. export var lensHighlightsPixelShader: {
  146892. name: string;
  146893. shader: string;
  146894. };
  146895. }
  146896. declare module BABYLON {
  146897. /** @hidden */
  146898. export var depthOfFieldPixelShader: {
  146899. name: string;
  146900. shader: string;
  146901. };
  146902. }
  146903. declare module BABYLON {
  146904. /**
  146905. * BABYLON.JS Chromatic Aberration GLSL Shader
  146906. * Author: Olivier Guyot
  146907. * Separates very slightly R, G and B colors on the edges of the screen
  146908. * Inspired by Francois Tarlier & Martins Upitis
  146909. */
  146910. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  146911. /**
  146912. * @ignore
  146913. * The chromatic aberration PostProcess id in the pipeline
  146914. */
  146915. LensChromaticAberrationEffect: string;
  146916. /**
  146917. * @ignore
  146918. * The highlights enhancing PostProcess id in the pipeline
  146919. */
  146920. HighlightsEnhancingEffect: string;
  146921. /**
  146922. * @ignore
  146923. * The depth-of-field PostProcess id in the pipeline
  146924. */
  146925. LensDepthOfFieldEffect: string;
  146926. private _scene;
  146927. private _depthTexture;
  146928. private _grainTexture;
  146929. private _chromaticAberrationPostProcess;
  146930. private _highlightsPostProcess;
  146931. private _depthOfFieldPostProcess;
  146932. private _edgeBlur;
  146933. private _grainAmount;
  146934. private _chromaticAberration;
  146935. private _distortion;
  146936. private _highlightsGain;
  146937. private _highlightsThreshold;
  146938. private _dofDistance;
  146939. private _dofAperture;
  146940. private _dofDarken;
  146941. private _dofPentagon;
  146942. private _blurNoise;
  146943. /**
  146944. * @constructor
  146945. *
  146946. * Effect parameters are as follow:
  146947. * {
  146948. * chromatic_aberration: number; // from 0 to x (1 for realism)
  146949. * edge_blur: number; // from 0 to x (1 for realism)
  146950. * distortion: number; // from 0 to x (1 for realism)
  146951. * grain_amount: number; // from 0 to 1
  146952. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  146953. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  146954. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  146955. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  146956. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  146957. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  146958. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  146959. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  146960. * }
  146961. * Note: if an effect parameter is unset, effect is disabled
  146962. *
  146963. * @param name The rendering pipeline name
  146964. * @param parameters - An object containing all parameters (see above)
  146965. * @param scene The scene linked to this pipeline
  146966. * @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)
  146967. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146968. */
  146969. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  146970. /**
  146971. * Get the class name
  146972. * @returns "LensRenderingPipeline"
  146973. */
  146974. getClassName(): string;
  146975. /**
  146976. * Gets associated scene
  146977. */
  146978. get scene(): Scene;
  146979. /**
  146980. * Gets or sets the edge blur
  146981. */
  146982. get edgeBlur(): number;
  146983. set edgeBlur(value: number);
  146984. /**
  146985. * Gets or sets the grain amount
  146986. */
  146987. get grainAmount(): number;
  146988. set grainAmount(value: number);
  146989. /**
  146990. * Gets or sets the chromatic aberration amount
  146991. */
  146992. get chromaticAberration(): number;
  146993. set chromaticAberration(value: number);
  146994. /**
  146995. * Gets or sets the depth of field aperture
  146996. */
  146997. get dofAperture(): number;
  146998. set dofAperture(value: number);
  146999. /**
  147000. * Gets or sets the edge distortion
  147001. */
  147002. get edgeDistortion(): number;
  147003. set edgeDistortion(value: number);
  147004. /**
  147005. * Gets or sets the depth of field distortion
  147006. */
  147007. get dofDistortion(): number;
  147008. set dofDistortion(value: number);
  147009. /**
  147010. * Gets or sets the darken out of focus amount
  147011. */
  147012. get darkenOutOfFocus(): number;
  147013. set darkenOutOfFocus(value: number);
  147014. /**
  147015. * Gets or sets a boolean indicating if blur noise is enabled
  147016. */
  147017. get blurNoise(): boolean;
  147018. set blurNoise(value: boolean);
  147019. /**
  147020. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  147021. */
  147022. get pentagonBokeh(): boolean;
  147023. set pentagonBokeh(value: boolean);
  147024. /**
  147025. * Gets or sets the highlight grain amount
  147026. */
  147027. get highlightsGain(): number;
  147028. set highlightsGain(value: number);
  147029. /**
  147030. * Gets or sets the highlight threshold
  147031. */
  147032. get highlightsThreshold(): number;
  147033. set highlightsThreshold(value: number);
  147034. /**
  147035. * Sets the amount of blur at the edges
  147036. * @param amount blur amount
  147037. */
  147038. setEdgeBlur(amount: number): void;
  147039. /**
  147040. * Sets edge blur to 0
  147041. */
  147042. disableEdgeBlur(): void;
  147043. /**
  147044. * Sets the amout of grain
  147045. * @param amount Amount of grain
  147046. */
  147047. setGrainAmount(amount: number): void;
  147048. /**
  147049. * Set grain amount to 0
  147050. */
  147051. disableGrain(): void;
  147052. /**
  147053. * Sets the chromatic aberration amount
  147054. * @param amount amount of chromatic aberration
  147055. */
  147056. setChromaticAberration(amount: number): void;
  147057. /**
  147058. * Sets chromatic aberration amount to 0
  147059. */
  147060. disableChromaticAberration(): void;
  147061. /**
  147062. * Sets the EdgeDistortion amount
  147063. * @param amount amount of EdgeDistortion
  147064. */
  147065. setEdgeDistortion(amount: number): void;
  147066. /**
  147067. * Sets edge distortion to 0
  147068. */
  147069. disableEdgeDistortion(): void;
  147070. /**
  147071. * Sets the FocusDistance amount
  147072. * @param amount amount of FocusDistance
  147073. */
  147074. setFocusDistance(amount: number): void;
  147075. /**
  147076. * Disables depth of field
  147077. */
  147078. disableDepthOfField(): void;
  147079. /**
  147080. * Sets the Aperture amount
  147081. * @param amount amount of Aperture
  147082. */
  147083. setAperture(amount: number): void;
  147084. /**
  147085. * Sets the DarkenOutOfFocus amount
  147086. * @param amount amount of DarkenOutOfFocus
  147087. */
  147088. setDarkenOutOfFocus(amount: number): void;
  147089. private _pentagonBokehIsEnabled;
  147090. /**
  147091. * Creates a pentagon bokeh effect
  147092. */
  147093. enablePentagonBokeh(): void;
  147094. /**
  147095. * Disables the pentagon bokeh effect
  147096. */
  147097. disablePentagonBokeh(): void;
  147098. /**
  147099. * Enables noise blur
  147100. */
  147101. enableNoiseBlur(): void;
  147102. /**
  147103. * Disables noise blur
  147104. */
  147105. disableNoiseBlur(): void;
  147106. /**
  147107. * Sets the HighlightsGain amount
  147108. * @param amount amount of HighlightsGain
  147109. */
  147110. setHighlightsGain(amount: number): void;
  147111. /**
  147112. * Sets the HighlightsThreshold amount
  147113. * @param amount amount of HighlightsThreshold
  147114. */
  147115. setHighlightsThreshold(amount: number): void;
  147116. /**
  147117. * Disables highlights
  147118. */
  147119. disableHighlights(): void;
  147120. /**
  147121. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  147122. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  147123. */
  147124. dispose(disableDepthRender?: boolean): void;
  147125. private _createChromaticAberrationPostProcess;
  147126. private _createHighlightsPostProcess;
  147127. private _createDepthOfFieldPostProcess;
  147128. private _createGrainTexture;
  147129. }
  147130. }
  147131. declare module BABYLON {
  147132. /** @hidden */
  147133. export var ssao2PixelShader: {
  147134. name: string;
  147135. shader: string;
  147136. };
  147137. }
  147138. declare module BABYLON {
  147139. /** @hidden */
  147140. export var ssaoCombinePixelShader: {
  147141. name: string;
  147142. shader: string;
  147143. };
  147144. }
  147145. declare module BABYLON {
  147146. /**
  147147. * Render pipeline to produce ssao effect
  147148. */
  147149. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  147150. /**
  147151. * @ignore
  147152. * The PassPostProcess id in the pipeline that contains the original scene color
  147153. */
  147154. SSAOOriginalSceneColorEffect: string;
  147155. /**
  147156. * @ignore
  147157. * The SSAO PostProcess id in the pipeline
  147158. */
  147159. SSAORenderEffect: string;
  147160. /**
  147161. * @ignore
  147162. * The horizontal blur PostProcess id in the pipeline
  147163. */
  147164. SSAOBlurHRenderEffect: string;
  147165. /**
  147166. * @ignore
  147167. * The vertical blur PostProcess id in the pipeline
  147168. */
  147169. SSAOBlurVRenderEffect: string;
  147170. /**
  147171. * @ignore
  147172. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147173. */
  147174. SSAOCombineRenderEffect: string;
  147175. /**
  147176. * The output strength of the SSAO post-process. Default value is 1.0.
  147177. */
  147178. totalStrength: number;
  147179. /**
  147180. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  147181. */
  147182. maxZ: number;
  147183. /**
  147184. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  147185. */
  147186. minZAspect: number;
  147187. private _samples;
  147188. /**
  147189. * Number of samples used for the SSAO calculations. Default value is 8
  147190. */
  147191. set samples(n: number);
  147192. get samples(): number;
  147193. private _textureSamples;
  147194. /**
  147195. * Number of samples to use for antialiasing
  147196. */
  147197. set textureSamples(n: number);
  147198. get textureSamples(): number;
  147199. /**
  147200. * Ratio object used for SSAO ratio and blur ratio
  147201. */
  147202. private _ratio;
  147203. /**
  147204. * Dynamically generated sphere sampler.
  147205. */
  147206. private _sampleSphere;
  147207. /**
  147208. * Blur filter offsets
  147209. */
  147210. private _samplerOffsets;
  147211. private _expensiveBlur;
  147212. /**
  147213. * If bilateral blur should be used
  147214. */
  147215. set expensiveBlur(b: boolean);
  147216. get expensiveBlur(): boolean;
  147217. /**
  147218. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  147219. */
  147220. radius: number;
  147221. /**
  147222. * The base color of the SSAO post-process
  147223. * The final result is "base + ssao" between [0, 1]
  147224. */
  147225. base: number;
  147226. /**
  147227. * Support test.
  147228. */
  147229. static get IsSupported(): boolean;
  147230. private _scene;
  147231. private _depthTexture;
  147232. private _normalTexture;
  147233. private _randomTexture;
  147234. private _originalColorPostProcess;
  147235. private _ssaoPostProcess;
  147236. private _blurHPostProcess;
  147237. private _blurVPostProcess;
  147238. private _ssaoCombinePostProcess;
  147239. /**
  147240. * Gets active scene
  147241. */
  147242. get scene(): Scene;
  147243. /**
  147244. * @constructor
  147245. * @param name The rendering pipeline name
  147246. * @param scene The scene linked to this pipeline
  147247. * @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 }
  147248. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147249. */
  147250. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147251. /**
  147252. * Get the class name
  147253. * @returns "SSAO2RenderingPipeline"
  147254. */
  147255. getClassName(): string;
  147256. /**
  147257. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147258. */
  147259. dispose(disableGeometryBufferRenderer?: boolean): void;
  147260. private _createBlurPostProcess;
  147261. /** @hidden */
  147262. _rebuild(): void;
  147263. private _bits;
  147264. private _radicalInverse_VdC;
  147265. private _hammersley;
  147266. private _hemisphereSample_uniform;
  147267. private _generateHemisphere;
  147268. private _createSSAOPostProcess;
  147269. private _createSSAOCombinePostProcess;
  147270. private _createRandomTexture;
  147271. /**
  147272. * Serialize the rendering pipeline (Used when exporting)
  147273. * @returns the serialized object
  147274. */
  147275. serialize(): any;
  147276. /**
  147277. * Parse the serialized pipeline
  147278. * @param source Source pipeline.
  147279. * @param scene The scene to load the pipeline to.
  147280. * @param rootUrl The URL of the serialized pipeline.
  147281. * @returns An instantiated pipeline from the serialized object.
  147282. */
  147283. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  147284. }
  147285. }
  147286. declare module BABYLON {
  147287. /** @hidden */
  147288. export var ssaoPixelShader: {
  147289. name: string;
  147290. shader: string;
  147291. };
  147292. }
  147293. declare module BABYLON {
  147294. /**
  147295. * Render pipeline to produce ssao effect
  147296. */
  147297. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  147298. /**
  147299. * @ignore
  147300. * The PassPostProcess id in the pipeline that contains the original scene color
  147301. */
  147302. SSAOOriginalSceneColorEffect: string;
  147303. /**
  147304. * @ignore
  147305. * The SSAO PostProcess id in the pipeline
  147306. */
  147307. SSAORenderEffect: string;
  147308. /**
  147309. * @ignore
  147310. * The horizontal blur PostProcess id in the pipeline
  147311. */
  147312. SSAOBlurHRenderEffect: string;
  147313. /**
  147314. * @ignore
  147315. * The vertical blur PostProcess id in the pipeline
  147316. */
  147317. SSAOBlurVRenderEffect: string;
  147318. /**
  147319. * @ignore
  147320. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147321. */
  147322. SSAOCombineRenderEffect: string;
  147323. /**
  147324. * The output strength of the SSAO post-process. Default value is 1.0.
  147325. */
  147326. totalStrength: number;
  147327. /**
  147328. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  147329. */
  147330. radius: number;
  147331. /**
  147332. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  147333. * Must not be equal to fallOff and superior to fallOff.
  147334. * Default value is 0.0075
  147335. */
  147336. area: number;
  147337. /**
  147338. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  147339. * Must not be equal to area and inferior to area.
  147340. * Default value is 0.000001
  147341. */
  147342. fallOff: number;
  147343. /**
  147344. * The base color of the SSAO post-process
  147345. * The final result is "base + ssao" between [0, 1]
  147346. */
  147347. base: number;
  147348. private _scene;
  147349. private _depthTexture;
  147350. private _randomTexture;
  147351. private _originalColorPostProcess;
  147352. private _ssaoPostProcess;
  147353. private _blurHPostProcess;
  147354. private _blurVPostProcess;
  147355. private _ssaoCombinePostProcess;
  147356. private _firstUpdate;
  147357. /**
  147358. * Gets active scene
  147359. */
  147360. get scene(): Scene;
  147361. /**
  147362. * @constructor
  147363. * @param name - The rendering pipeline name
  147364. * @param scene - The scene linked to this pipeline
  147365. * @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 }
  147366. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  147367. */
  147368. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147369. /**
  147370. * Get the class name
  147371. * @returns "SSAORenderingPipeline"
  147372. */
  147373. getClassName(): string;
  147374. /**
  147375. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147376. */
  147377. dispose(disableDepthRender?: boolean): void;
  147378. private _createBlurPostProcess;
  147379. /** @hidden */
  147380. _rebuild(): void;
  147381. private _createSSAOPostProcess;
  147382. private _createSSAOCombinePostProcess;
  147383. private _createRandomTexture;
  147384. }
  147385. }
  147386. declare module BABYLON {
  147387. /** @hidden */
  147388. export var screenSpaceReflectionPixelShader: {
  147389. name: string;
  147390. shader: string;
  147391. };
  147392. }
  147393. declare module BABYLON {
  147394. /**
  147395. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  147396. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  147397. */
  147398. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  147399. /**
  147400. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  147401. */
  147402. threshold: number;
  147403. /**
  147404. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  147405. */
  147406. strength: number;
  147407. /**
  147408. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  147409. */
  147410. reflectionSpecularFalloffExponent: number;
  147411. /**
  147412. * 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]
  147413. */
  147414. step: number;
  147415. /**
  147416. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  147417. */
  147418. roughnessFactor: number;
  147419. private _geometryBufferRenderer;
  147420. private _enableSmoothReflections;
  147421. private _reflectionSamples;
  147422. private _smoothSteps;
  147423. /**
  147424. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  147425. * @param name The name of the effect.
  147426. * @param scene The scene containing the objects to calculate reflections.
  147427. * @param options The required width/height ratio to downsize to before computing the render pass.
  147428. * @param camera The camera to apply the render pass to.
  147429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147430. * @param engine The engine which the post process will be applied. (default: current engine)
  147431. * @param reusable If the post process can be reused on the same frame. (default: false)
  147432. * @param textureType Type of textures used when performing the post process. (default: 0)
  147433. * @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)
  147434. */
  147435. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147436. /**
  147437. * Gets wether or not smoothing reflections is enabled.
  147438. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147439. */
  147440. get enableSmoothReflections(): boolean;
  147441. /**
  147442. * Sets wether or not smoothing reflections is enabled.
  147443. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147444. */
  147445. set enableSmoothReflections(enabled: boolean);
  147446. /**
  147447. * Gets the number of samples taken while computing reflections. More samples count is high,
  147448. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147449. */
  147450. get reflectionSamples(): number;
  147451. /**
  147452. * Sets the number of samples taken while computing reflections. More samples count is high,
  147453. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147454. */
  147455. set reflectionSamples(samples: number);
  147456. /**
  147457. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  147458. * more the post-process will require GPU power and can generate a drop in FPS.
  147459. * Default value (5.0) work pretty well in all cases but can be adjusted.
  147460. */
  147461. get smoothSteps(): number;
  147462. set smoothSteps(steps: number);
  147463. private _updateEffectDefines;
  147464. }
  147465. }
  147466. declare module BABYLON {
  147467. /** @hidden */
  147468. export var standardPixelShader: {
  147469. name: string;
  147470. shader: string;
  147471. };
  147472. }
  147473. declare module BABYLON {
  147474. /**
  147475. * Standard rendering pipeline
  147476. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  147477. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  147478. */
  147479. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147480. /**
  147481. * Public members
  147482. */
  147483. /**
  147484. * Post-process which contains the original scene color before the pipeline applies all the effects
  147485. */
  147486. originalPostProcess: Nullable<PostProcess>;
  147487. /**
  147488. * Post-process used to down scale an image x4
  147489. */
  147490. downSampleX4PostProcess: Nullable<PostProcess>;
  147491. /**
  147492. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  147493. */
  147494. brightPassPostProcess: Nullable<PostProcess>;
  147495. /**
  147496. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  147497. */
  147498. blurHPostProcesses: PostProcess[];
  147499. /**
  147500. * Post-process array storing all the vertical blur post-processes used by the pipeline
  147501. */
  147502. blurVPostProcesses: PostProcess[];
  147503. /**
  147504. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  147505. */
  147506. textureAdderPostProcess: Nullable<PostProcess>;
  147507. /**
  147508. * Post-process used to create volumetric lighting effect
  147509. */
  147510. volumetricLightPostProcess: Nullable<PostProcess>;
  147511. /**
  147512. * Post-process used to smooth the previous volumetric light post-process on the X axis
  147513. */
  147514. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  147515. /**
  147516. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  147517. */
  147518. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  147519. /**
  147520. * Post-process used to merge the volumetric light effect and the real scene color
  147521. */
  147522. volumetricLightMergePostProces: Nullable<PostProcess>;
  147523. /**
  147524. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  147525. */
  147526. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  147527. /**
  147528. * Base post-process used to calculate the average luminance of the final image for HDR
  147529. */
  147530. luminancePostProcess: Nullable<PostProcess>;
  147531. /**
  147532. * Post-processes used to create down sample post-processes in order to get
  147533. * the average luminance of the final image for HDR
  147534. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  147535. */
  147536. luminanceDownSamplePostProcesses: PostProcess[];
  147537. /**
  147538. * Post-process used to create a HDR effect (light adaptation)
  147539. */
  147540. hdrPostProcess: Nullable<PostProcess>;
  147541. /**
  147542. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  147543. */
  147544. textureAdderFinalPostProcess: Nullable<PostProcess>;
  147545. /**
  147546. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  147547. */
  147548. lensFlareFinalPostProcess: Nullable<PostProcess>;
  147549. /**
  147550. * Post-process used to merge the final HDR post-process and the real scene color
  147551. */
  147552. hdrFinalPostProcess: Nullable<PostProcess>;
  147553. /**
  147554. * Post-process used to create a lens flare effect
  147555. */
  147556. lensFlarePostProcess: Nullable<PostProcess>;
  147557. /**
  147558. * Post-process that merges the result of the lens flare post-process and the real scene color
  147559. */
  147560. lensFlareComposePostProcess: Nullable<PostProcess>;
  147561. /**
  147562. * Post-process used to create a motion blur effect
  147563. */
  147564. motionBlurPostProcess: Nullable<PostProcess>;
  147565. /**
  147566. * Post-process used to create a depth of field effect
  147567. */
  147568. depthOfFieldPostProcess: Nullable<PostProcess>;
  147569. /**
  147570. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147571. */
  147572. fxaaPostProcess: Nullable<FxaaPostProcess>;
  147573. /**
  147574. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  147575. */
  147576. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  147577. /**
  147578. * Represents the brightness threshold in order to configure the illuminated surfaces
  147579. */
  147580. brightThreshold: number;
  147581. /**
  147582. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  147583. */
  147584. blurWidth: number;
  147585. /**
  147586. * Sets if the blur for highlighted surfaces must be only horizontal
  147587. */
  147588. horizontalBlur: boolean;
  147589. /**
  147590. * Gets the overall exposure used by the pipeline
  147591. */
  147592. get exposure(): number;
  147593. /**
  147594. * Sets the overall exposure used by the pipeline
  147595. */
  147596. set exposure(value: number);
  147597. /**
  147598. * Texture used typically to simulate "dirty" on camera lens
  147599. */
  147600. lensTexture: Nullable<Texture>;
  147601. /**
  147602. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  147603. */
  147604. volumetricLightCoefficient: number;
  147605. /**
  147606. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  147607. */
  147608. volumetricLightPower: number;
  147609. /**
  147610. * Used the set the blur intensity to smooth the volumetric lights
  147611. */
  147612. volumetricLightBlurScale: number;
  147613. /**
  147614. * Light (spot or directional) used to generate the volumetric lights rays
  147615. * The source light must have a shadow generate so the pipeline can get its
  147616. * depth map
  147617. */
  147618. sourceLight: Nullable<SpotLight | DirectionalLight>;
  147619. /**
  147620. * For eye adaptation, represents the minimum luminance the eye can see
  147621. */
  147622. hdrMinimumLuminance: number;
  147623. /**
  147624. * For eye adaptation, represents the decrease luminance speed
  147625. */
  147626. hdrDecreaseRate: number;
  147627. /**
  147628. * For eye adaptation, represents the increase luminance speed
  147629. */
  147630. hdrIncreaseRate: number;
  147631. /**
  147632. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147633. */
  147634. get hdrAutoExposure(): boolean;
  147635. /**
  147636. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147637. */
  147638. set hdrAutoExposure(value: boolean);
  147639. /**
  147640. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  147641. */
  147642. lensColorTexture: Nullable<Texture>;
  147643. /**
  147644. * The overall strengh for the lens flare effect
  147645. */
  147646. lensFlareStrength: number;
  147647. /**
  147648. * Dispersion coefficient for lens flare ghosts
  147649. */
  147650. lensFlareGhostDispersal: number;
  147651. /**
  147652. * Main lens flare halo width
  147653. */
  147654. lensFlareHaloWidth: number;
  147655. /**
  147656. * Based on the lens distortion effect, defines how much the lens flare result
  147657. * is distorted
  147658. */
  147659. lensFlareDistortionStrength: number;
  147660. /**
  147661. * Configures the blur intensity used for for lens flare (halo)
  147662. */
  147663. lensFlareBlurWidth: number;
  147664. /**
  147665. * Lens star texture must be used to simulate rays on the flares and is available
  147666. * in the documentation
  147667. */
  147668. lensStarTexture: Nullable<Texture>;
  147669. /**
  147670. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  147671. * flare effect by taking account of the dirt texture
  147672. */
  147673. lensFlareDirtTexture: Nullable<Texture>;
  147674. /**
  147675. * Represents the focal length for the depth of field effect
  147676. */
  147677. depthOfFieldDistance: number;
  147678. /**
  147679. * Represents the blur intensity for the blurred part of the depth of field effect
  147680. */
  147681. depthOfFieldBlurWidth: number;
  147682. /**
  147683. * Gets how much the image is blurred by the movement while using the motion blur post-process
  147684. */
  147685. get motionStrength(): number;
  147686. /**
  147687. * Sets how much the image is blurred by the movement while using the motion blur post-process
  147688. */
  147689. set motionStrength(strength: number);
  147690. /**
  147691. * Gets wether or not the motion blur post-process is object based or screen based.
  147692. */
  147693. get objectBasedMotionBlur(): boolean;
  147694. /**
  147695. * Sets wether or not the motion blur post-process should be object based or screen based
  147696. */
  147697. set objectBasedMotionBlur(value: boolean);
  147698. /**
  147699. * List of animations for the pipeline (IAnimatable implementation)
  147700. */
  147701. animations: Animation[];
  147702. /**
  147703. * Private members
  147704. */
  147705. private _scene;
  147706. private _currentDepthOfFieldSource;
  147707. private _basePostProcess;
  147708. private _fixedExposure;
  147709. private _currentExposure;
  147710. private _hdrAutoExposure;
  147711. private _hdrCurrentLuminance;
  147712. private _motionStrength;
  147713. private _isObjectBasedMotionBlur;
  147714. private _floatTextureType;
  147715. private _camerasToBeAttached;
  147716. private _ratio;
  147717. private _bloomEnabled;
  147718. private _depthOfFieldEnabled;
  147719. private _vlsEnabled;
  147720. private _lensFlareEnabled;
  147721. private _hdrEnabled;
  147722. private _motionBlurEnabled;
  147723. private _fxaaEnabled;
  147724. private _screenSpaceReflectionsEnabled;
  147725. private _motionBlurSamples;
  147726. private _volumetricLightStepsCount;
  147727. private _samples;
  147728. /**
  147729. * @ignore
  147730. * Specifies if the bloom pipeline is enabled
  147731. */
  147732. get BloomEnabled(): boolean;
  147733. set BloomEnabled(enabled: boolean);
  147734. /**
  147735. * @ignore
  147736. * Specifies if the depth of field pipeline is enabed
  147737. */
  147738. get DepthOfFieldEnabled(): boolean;
  147739. set DepthOfFieldEnabled(enabled: boolean);
  147740. /**
  147741. * @ignore
  147742. * Specifies if the lens flare pipeline is enabed
  147743. */
  147744. get LensFlareEnabled(): boolean;
  147745. set LensFlareEnabled(enabled: boolean);
  147746. /**
  147747. * @ignore
  147748. * Specifies if the HDR pipeline is enabled
  147749. */
  147750. get HDREnabled(): boolean;
  147751. set HDREnabled(enabled: boolean);
  147752. /**
  147753. * @ignore
  147754. * Specifies if the volumetric lights scattering effect is enabled
  147755. */
  147756. get VLSEnabled(): boolean;
  147757. set VLSEnabled(enabled: boolean);
  147758. /**
  147759. * @ignore
  147760. * Specifies if the motion blur effect is enabled
  147761. */
  147762. get MotionBlurEnabled(): boolean;
  147763. set MotionBlurEnabled(enabled: boolean);
  147764. /**
  147765. * Specifies if anti-aliasing is enabled
  147766. */
  147767. get fxaaEnabled(): boolean;
  147768. set fxaaEnabled(enabled: boolean);
  147769. /**
  147770. * Specifies if screen space reflections are enabled.
  147771. */
  147772. get screenSpaceReflectionsEnabled(): boolean;
  147773. set screenSpaceReflectionsEnabled(enabled: boolean);
  147774. /**
  147775. * Specifies the number of steps used to calculate the volumetric lights
  147776. * Typically in interval [50, 200]
  147777. */
  147778. get volumetricLightStepsCount(): number;
  147779. set volumetricLightStepsCount(count: number);
  147780. /**
  147781. * Specifies the number of samples used for the motion blur effect
  147782. * Typically in interval [16, 64]
  147783. */
  147784. get motionBlurSamples(): number;
  147785. set motionBlurSamples(samples: number);
  147786. /**
  147787. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147788. */
  147789. get samples(): number;
  147790. set samples(sampleCount: number);
  147791. /**
  147792. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  147793. * @constructor
  147794. * @param name The rendering pipeline name
  147795. * @param scene The scene linked to this pipeline
  147796. * @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)
  147797. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  147798. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147799. */
  147800. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  147801. private _buildPipeline;
  147802. private _createDownSampleX4PostProcess;
  147803. private _createBrightPassPostProcess;
  147804. private _createBlurPostProcesses;
  147805. private _createTextureAdderPostProcess;
  147806. private _createVolumetricLightPostProcess;
  147807. private _createLuminancePostProcesses;
  147808. private _createHdrPostProcess;
  147809. private _createLensFlarePostProcess;
  147810. private _createDepthOfFieldPostProcess;
  147811. private _createMotionBlurPostProcess;
  147812. private _getDepthTexture;
  147813. private _disposePostProcesses;
  147814. /**
  147815. * Dispose of the pipeline and stop all post processes
  147816. */
  147817. dispose(): void;
  147818. /**
  147819. * Serialize the rendering pipeline (Used when exporting)
  147820. * @returns the serialized object
  147821. */
  147822. serialize(): any;
  147823. /**
  147824. * Parse the serialized pipeline
  147825. * @param source Source pipeline.
  147826. * @param scene The scene to load the pipeline to.
  147827. * @param rootUrl The URL of the serialized pipeline.
  147828. * @returns An instantiated pipeline from the serialized object.
  147829. */
  147830. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  147831. /**
  147832. * Luminance steps
  147833. */
  147834. static LuminanceSteps: number;
  147835. }
  147836. }
  147837. declare module BABYLON {
  147838. /** @hidden */
  147839. export var stereoscopicInterlacePixelShader: {
  147840. name: string;
  147841. shader: string;
  147842. };
  147843. }
  147844. declare module BABYLON {
  147845. /**
  147846. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  147847. */
  147848. export class StereoscopicInterlacePostProcessI extends PostProcess {
  147849. private _stepSize;
  147850. private _passedProcess;
  147851. /**
  147852. * Initializes a StereoscopicInterlacePostProcessI
  147853. * @param name The name of the effect.
  147854. * @param rigCameras The rig cameras to be appled to the post process
  147855. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  147856. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  147857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147858. * @param engine The engine which the post process will be applied. (default: current engine)
  147859. * @param reusable If the post process can be reused on the same frame. (default: false)
  147860. */
  147861. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147862. }
  147863. /**
  147864. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  147865. */
  147866. export class StereoscopicInterlacePostProcess extends PostProcess {
  147867. private _stepSize;
  147868. private _passedProcess;
  147869. /**
  147870. * Initializes a StereoscopicInterlacePostProcess
  147871. * @param name The name of the effect.
  147872. * @param rigCameras The rig cameras to be appled to the post process
  147873. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  147874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147875. * @param engine The engine which the post process will be applied. (default: current engine)
  147876. * @param reusable If the post process can be reused on the same frame. (default: false)
  147877. */
  147878. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147879. }
  147880. }
  147881. declare module BABYLON {
  147882. /** @hidden */
  147883. export var tonemapPixelShader: {
  147884. name: string;
  147885. shader: string;
  147886. };
  147887. }
  147888. declare module BABYLON {
  147889. /** Defines operator used for tonemapping */
  147890. export enum TonemappingOperator {
  147891. /** Hable */
  147892. Hable = 0,
  147893. /** Reinhard */
  147894. Reinhard = 1,
  147895. /** HejiDawson */
  147896. HejiDawson = 2,
  147897. /** Photographic */
  147898. Photographic = 3
  147899. }
  147900. /**
  147901. * Defines a post process to apply tone mapping
  147902. */
  147903. export class TonemapPostProcess extends PostProcess {
  147904. private _operator;
  147905. /** Defines the required exposure adjustement */
  147906. exposureAdjustment: number;
  147907. /**
  147908. * Creates a new TonemapPostProcess
  147909. * @param name defines the name of the postprocess
  147910. * @param _operator defines the operator to use
  147911. * @param exposureAdjustment defines the required exposure adjustement
  147912. * @param camera defines the camera to use (can be null)
  147913. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  147914. * @param engine defines the hosting engine (can be ignore if camera is set)
  147915. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  147916. */
  147917. constructor(name: string, _operator: TonemappingOperator,
  147918. /** Defines the required exposure adjustement */
  147919. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  147920. }
  147921. }
  147922. declare module BABYLON {
  147923. /** @hidden */
  147924. export var volumetricLightScatteringPixelShader: {
  147925. name: string;
  147926. shader: string;
  147927. };
  147928. }
  147929. declare module BABYLON {
  147930. /** @hidden */
  147931. export var volumetricLightScatteringPassVertexShader: {
  147932. name: string;
  147933. shader: string;
  147934. };
  147935. }
  147936. declare module BABYLON {
  147937. /** @hidden */
  147938. export var volumetricLightScatteringPassPixelShader: {
  147939. name: string;
  147940. shader: string;
  147941. };
  147942. }
  147943. declare module BABYLON {
  147944. /**
  147945. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  147946. */
  147947. export class VolumetricLightScatteringPostProcess extends PostProcess {
  147948. private _volumetricLightScatteringPass;
  147949. private _volumetricLightScatteringRTT;
  147950. private _viewPort;
  147951. private _screenCoordinates;
  147952. private _cachedDefines;
  147953. /**
  147954. * If not undefined, the mesh position is computed from the attached node position
  147955. */
  147956. attachedNode: {
  147957. position: Vector3;
  147958. };
  147959. /**
  147960. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  147961. */
  147962. customMeshPosition: Vector3;
  147963. /**
  147964. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  147965. */
  147966. useCustomMeshPosition: boolean;
  147967. /**
  147968. * If the post-process should inverse the light scattering direction
  147969. */
  147970. invert: boolean;
  147971. /**
  147972. * The internal mesh used by the post-process
  147973. */
  147974. mesh: Mesh;
  147975. /**
  147976. * @hidden
  147977. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  147978. */
  147979. get useDiffuseColor(): boolean;
  147980. set useDiffuseColor(useDiffuseColor: boolean);
  147981. /**
  147982. * Array containing the excluded meshes not rendered in the internal pass
  147983. */
  147984. excludedMeshes: AbstractMesh[];
  147985. /**
  147986. * Controls the overall intensity of the post-process
  147987. */
  147988. exposure: number;
  147989. /**
  147990. * Dissipates each sample's contribution in range [0, 1]
  147991. */
  147992. decay: number;
  147993. /**
  147994. * Controls the overall intensity of each sample
  147995. */
  147996. weight: number;
  147997. /**
  147998. * Controls the density of each sample
  147999. */
  148000. density: number;
  148001. /**
  148002. * @constructor
  148003. * @param name The post-process name
  148004. * @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)
  148005. * @param camera The camera that the post-process will be attached to
  148006. * @param mesh The mesh used to create the light scattering
  148007. * @param samples The post-process quality, default 100
  148008. * @param samplingModeThe post-process filtering mode
  148009. * @param engine The babylon engine
  148010. * @param reusable If the post-process is reusable
  148011. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  148012. */
  148013. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  148014. /**
  148015. * Returns the string "VolumetricLightScatteringPostProcess"
  148016. * @returns "VolumetricLightScatteringPostProcess"
  148017. */
  148018. getClassName(): string;
  148019. private _isReady;
  148020. /**
  148021. * Sets the new light position for light scattering effect
  148022. * @param position The new custom light position
  148023. */
  148024. setCustomMeshPosition(position: Vector3): void;
  148025. /**
  148026. * Returns the light position for light scattering effect
  148027. * @return Vector3 The custom light position
  148028. */
  148029. getCustomMeshPosition(): Vector3;
  148030. /**
  148031. * Disposes the internal assets and detaches the post-process from the camera
  148032. */
  148033. dispose(camera: Camera): void;
  148034. /**
  148035. * Returns the render target texture used by the post-process
  148036. * @return the render target texture used by the post-process
  148037. */
  148038. getPass(): RenderTargetTexture;
  148039. private _meshExcluded;
  148040. private _createPass;
  148041. private _updateMeshScreenCoordinates;
  148042. /**
  148043. * Creates a default mesh for the Volumeric Light Scattering post-process
  148044. * @param name The mesh name
  148045. * @param scene The scene where to create the mesh
  148046. * @return the default mesh
  148047. */
  148048. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  148049. }
  148050. }
  148051. declare module BABYLON {
  148052. interface Scene {
  148053. /** @hidden (Backing field) */
  148054. _boundingBoxRenderer: BoundingBoxRenderer;
  148055. /** @hidden (Backing field) */
  148056. _forceShowBoundingBoxes: boolean;
  148057. /**
  148058. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  148059. */
  148060. forceShowBoundingBoxes: boolean;
  148061. /**
  148062. * Gets the bounding box renderer associated with the scene
  148063. * @returns a BoundingBoxRenderer
  148064. */
  148065. getBoundingBoxRenderer(): BoundingBoxRenderer;
  148066. }
  148067. interface AbstractMesh {
  148068. /** @hidden (Backing field) */
  148069. _showBoundingBox: boolean;
  148070. /**
  148071. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  148072. */
  148073. showBoundingBox: boolean;
  148074. }
  148075. /**
  148076. * Component responsible of rendering the bounding box of the meshes in a scene.
  148077. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  148078. */
  148079. export class BoundingBoxRenderer implements ISceneComponent {
  148080. /**
  148081. * The component name helpfull to identify the component in the list of scene components.
  148082. */
  148083. readonly name: string;
  148084. /**
  148085. * The scene the component belongs to.
  148086. */
  148087. scene: Scene;
  148088. /**
  148089. * Color of the bounding box lines placed in front of an object
  148090. */
  148091. frontColor: Color3;
  148092. /**
  148093. * Color of the bounding box lines placed behind an object
  148094. */
  148095. backColor: Color3;
  148096. /**
  148097. * Defines if the renderer should show the back lines or not
  148098. */
  148099. showBackLines: boolean;
  148100. /**
  148101. * Observable raised before rendering a bounding box
  148102. */
  148103. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  148104. /**
  148105. * Observable raised after rendering a bounding box
  148106. */
  148107. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  148108. /**
  148109. * @hidden
  148110. */
  148111. renderList: SmartArray<BoundingBox>;
  148112. private _colorShader;
  148113. private _vertexBuffers;
  148114. private _indexBuffer;
  148115. private _fillIndexBuffer;
  148116. private _fillIndexData;
  148117. /**
  148118. * Instantiates a new bounding box renderer in a scene.
  148119. * @param scene the scene the renderer renders in
  148120. */
  148121. constructor(scene: Scene);
  148122. /**
  148123. * Registers the component in a given scene
  148124. */
  148125. register(): void;
  148126. private _evaluateSubMesh;
  148127. private _activeMesh;
  148128. private _prepareRessources;
  148129. private _createIndexBuffer;
  148130. /**
  148131. * Rebuilds the elements related to this component in case of
  148132. * context lost for instance.
  148133. */
  148134. rebuild(): void;
  148135. /**
  148136. * @hidden
  148137. */
  148138. reset(): void;
  148139. /**
  148140. * Render the bounding boxes of a specific rendering group
  148141. * @param renderingGroupId defines the rendering group to render
  148142. */
  148143. render(renderingGroupId: number): void;
  148144. /**
  148145. * In case of occlusion queries, we can render the occlusion bounding box through this method
  148146. * @param mesh Define the mesh to render the occlusion bounding box for
  148147. */
  148148. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  148149. /**
  148150. * Dispose and release the resources attached to this renderer.
  148151. */
  148152. dispose(): void;
  148153. }
  148154. }
  148155. declare module BABYLON {
  148156. interface Scene {
  148157. /** @hidden (Backing field) */
  148158. _depthRenderer: {
  148159. [id: string]: DepthRenderer;
  148160. };
  148161. /**
  148162. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  148163. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  148164. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148165. * @returns the created depth renderer
  148166. */
  148167. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  148168. /**
  148169. * Disables a depth renderer for a given camera
  148170. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  148171. */
  148172. disableDepthRenderer(camera?: Nullable<Camera>): void;
  148173. }
  148174. /**
  148175. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  148176. * in several rendering techniques.
  148177. */
  148178. export class DepthRendererSceneComponent implements ISceneComponent {
  148179. /**
  148180. * The component name helpfull to identify the component in the list of scene components.
  148181. */
  148182. readonly name: string;
  148183. /**
  148184. * The scene the component belongs to.
  148185. */
  148186. scene: Scene;
  148187. /**
  148188. * Creates a new instance of the component for the given scene
  148189. * @param scene Defines the scene to register the component in
  148190. */
  148191. constructor(scene: Scene);
  148192. /**
  148193. * Registers the component in a given scene
  148194. */
  148195. register(): void;
  148196. /**
  148197. * Rebuilds the elements related to this component in case of
  148198. * context lost for instance.
  148199. */
  148200. rebuild(): void;
  148201. /**
  148202. * Disposes the component and the associated ressources
  148203. */
  148204. dispose(): void;
  148205. private _gatherRenderTargets;
  148206. private _gatherActiveCameraRenderTargets;
  148207. }
  148208. }
  148209. declare module BABYLON {
  148210. /** @hidden */
  148211. export var outlinePixelShader: {
  148212. name: string;
  148213. shader: string;
  148214. };
  148215. }
  148216. declare module BABYLON {
  148217. /** @hidden */
  148218. export var outlineVertexShader: {
  148219. name: string;
  148220. shader: string;
  148221. };
  148222. }
  148223. declare module BABYLON {
  148224. interface Scene {
  148225. /** @hidden */
  148226. _outlineRenderer: OutlineRenderer;
  148227. /**
  148228. * Gets the outline renderer associated with the scene
  148229. * @returns a OutlineRenderer
  148230. */
  148231. getOutlineRenderer(): OutlineRenderer;
  148232. }
  148233. interface AbstractMesh {
  148234. /** @hidden (Backing field) */
  148235. _renderOutline: boolean;
  148236. /**
  148237. * Gets or sets a boolean indicating if the outline must be rendered as well
  148238. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  148239. */
  148240. renderOutline: boolean;
  148241. /** @hidden (Backing field) */
  148242. _renderOverlay: boolean;
  148243. /**
  148244. * Gets or sets a boolean indicating if the overlay must be rendered as well
  148245. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  148246. */
  148247. renderOverlay: boolean;
  148248. }
  148249. /**
  148250. * This class is responsible to draw bothe outline/overlay of meshes.
  148251. * It should not be used directly but through the available method on mesh.
  148252. */
  148253. export class OutlineRenderer implements ISceneComponent {
  148254. /**
  148255. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  148256. */
  148257. private static _StencilReference;
  148258. /**
  148259. * The name of the component. Each component must have a unique name.
  148260. */
  148261. name: string;
  148262. /**
  148263. * The scene the component belongs to.
  148264. */
  148265. scene: Scene;
  148266. /**
  148267. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  148268. */
  148269. zOffset: number;
  148270. private _engine;
  148271. private _effect;
  148272. private _cachedDefines;
  148273. private _savedDepthWrite;
  148274. /**
  148275. * Instantiates a new outline renderer. (There could be only one per scene).
  148276. * @param scene Defines the scene it belongs to
  148277. */
  148278. constructor(scene: Scene);
  148279. /**
  148280. * Register the component to one instance of a scene.
  148281. */
  148282. register(): void;
  148283. /**
  148284. * Rebuilds the elements related to this component in case of
  148285. * context lost for instance.
  148286. */
  148287. rebuild(): void;
  148288. /**
  148289. * Disposes the component and the associated ressources.
  148290. */
  148291. dispose(): void;
  148292. /**
  148293. * Renders the outline in the canvas.
  148294. * @param subMesh Defines the sumesh to render
  148295. * @param batch Defines the batch of meshes in case of instances
  148296. * @param useOverlay Defines if the rendering is for the overlay or the outline
  148297. */
  148298. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  148299. /**
  148300. * Returns whether or not the outline renderer is ready for a given submesh.
  148301. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  148302. * @param subMesh Defines the submesh to check readyness for
  148303. * @param useInstances Defines wheter wee are trying to render instances or not
  148304. * @returns true if ready otherwise false
  148305. */
  148306. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148307. private _beforeRenderingMesh;
  148308. private _afterRenderingMesh;
  148309. }
  148310. }
  148311. declare module BABYLON {
  148312. /**
  148313. * Defines the basic options interface of a Sprite Frame Source Size.
  148314. */
  148315. export interface ISpriteJSONSpriteSourceSize {
  148316. /**
  148317. * number of the original width of the Frame
  148318. */
  148319. w: number;
  148320. /**
  148321. * number of the original height of the Frame
  148322. */
  148323. h: number;
  148324. }
  148325. /**
  148326. * Defines the basic options interface of a Sprite Frame Data.
  148327. */
  148328. export interface ISpriteJSONSpriteFrameData {
  148329. /**
  148330. * number of the x offset of the Frame
  148331. */
  148332. x: number;
  148333. /**
  148334. * number of the y offset of the Frame
  148335. */
  148336. y: number;
  148337. /**
  148338. * number of the width of the Frame
  148339. */
  148340. w: number;
  148341. /**
  148342. * number of the height of the Frame
  148343. */
  148344. h: number;
  148345. }
  148346. /**
  148347. * Defines the basic options interface of a JSON Sprite.
  148348. */
  148349. export interface ISpriteJSONSprite {
  148350. /**
  148351. * string name of the Frame
  148352. */
  148353. filename: string;
  148354. /**
  148355. * ISpriteJSONSpriteFrame basic object of the frame data
  148356. */
  148357. frame: ISpriteJSONSpriteFrameData;
  148358. /**
  148359. * boolean to flag is the frame was rotated.
  148360. */
  148361. rotated: boolean;
  148362. /**
  148363. * boolean to flag is the frame was trimmed.
  148364. */
  148365. trimmed: boolean;
  148366. /**
  148367. * ISpriteJSONSpriteFrame basic object of the source data
  148368. */
  148369. spriteSourceSize: ISpriteJSONSpriteFrameData;
  148370. /**
  148371. * ISpriteJSONSpriteFrame basic object of the source data
  148372. */
  148373. sourceSize: ISpriteJSONSpriteSourceSize;
  148374. }
  148375. /**
  148376. * Defines the basic options interface of a JSON atlas.
  148377. */
  148378. export interface ISpriteJSONAtlas {
  148379. /**
  148380. * Array of objects that contain the frame data.
  148381. */
  148382. frames: Array<ISpriteJSONSprite>;
  148383. /**
  148384. * object basic object containing the sprite meta data.
  148385. */
  148386. meta?: object;
  148387. }
  148388. }
  148389. declare module BABYLON {
  148390. /** @hidden */
  148391. export var spriteMapPixelShader: {
  148392. name: string;
  148393. shader: string;
  148394. };
  148395. }
  148396. declare module BABYLON {
  148397. /** @hidden */
  148398. export var spriteMapVertexShader: {
  148399. name: string;
  148400. shader: string;
  148401. };
  148402. }
  148403. declare module BABYLON {
  148404. /**
  148405. * Defines the basic options interface of a SpriteMap
  148406. */
  148407. export interface ISpriteMapOptions {
  148408. /**
  148409. * Vector2 of the number of cells in the grid.
  148410. */
  148411. stageSize?: Vector2;
  148412. /**
  148413. * Vector2 of the size of the output plane in World Units.
  148414. */
  148415. outputSize?: Vector2;
  148416. /**
  148417. * Vector3 of the position of the output plane in World Units.
  148418. */
  148419. outputPosition?: Vector3;
  148420. /**
  148421. * Vector3 of the rotation of the output plane.
  148422. */
  148423. outputRotation?: Vector3;
  148424. /**
  148425. * number of layers that the system will reserve in resources.
  148426. */
  148427. layerCount?: number;
  148428. /**
  148429. * number of max animation frames a single cell will reserve in resources.
  148430. */
  148431. maxAnimationFrames?: number;
  148432. /**
  148433. * number cell index of the base tile when the system compiles.
  148434. */
  148435. baseTile?: number;
  148436. /**
  148437. * boolean flip the sprite after its been repositioned by the framing data.
  148438. */
  148439. flipU?: boolean;
  148440. /**
  148441. * Vector3 scalar of the global RGB values of the SpriteMap.
  148442. */
  148443. colorMultiply?: Vector3;
  148444. }
  148445. /**
  148446. * Defines the IDisposable interface in order to be cleanable from resources.
  148447. */
  148448. export interface ISpriteMap extends IDisposable {
  148449. /**
  148450. * String name of the SpriteMap.
  148451. */
  148452. name: string;
  148453. /**
  148454. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  148455. */
  148456. atlasJSON: ISpriteJSONAtlas;
  148457. /**
  148458. * Texture of the SpriteMap.
  148459. */
  148460. spriteSheet: Texture;
  148461. /**
  148462. * The parameters to initialize the SpriteMap with.
  148463. */
  148464. options: ISpriteMapOptions;
  148465. }
  148466. /**
  148467. * Class used to manage a grid restricted sprite deployment on an Output plane.
  148468. */
  148469. export class SpriteMap implements ISpriteMap {
  148470. /** The Name of the spriteMap */
  148471. name: string;
  148472. /** The JSON file with the frame and meta data */
  148473. atlasJSON: ISpriteJSONAtlas;
  148474. /** The systems Sprite Sheet Texture */
  148475. spriteSheet: Texture;
  148476. /** Arguments passed with the Constructor */
  148477. options: ISpriteMapOptions;
  148478. /** Public Sprite Storage array, parsed from atlasJSON */
  148479. sprites: Array<ISpriteJSONSprite>;
  148480. /** Returns the Number of Sprites in the System */
  148481. get spriteCount(): number;
  148482. /** Returns the Position of Output Plane*/
  148483. get position(): Vector3;
  148484. /** Returns the Position of Output Plane*/
  148485. set position(v: Vector3);
  148486. /** Returns the Rotation of Output Plane*/
  148487. get rotation(): Vector3;
  148488. /** Returns the Rotation of Output Plane*/
  148489. set rotation(v: Vector3);
  148490. /** Sets the AnimationMap*/
  148491. get animationMap(): RawTexture;
  148492. /** Sets the AnimationMap*/
  148493. set animationMap(v: RawTexture);
  148494. /** Scene that the SpriteMap was created in */
  148495. private _scene;
  148496. /** Texture Buffer of Float32 that holds tile frame data*/
  148497. private _frameMap;
  148498. /** Texture Buffers of Float32 that holds tileMap data*/
  148499. private _tileMaps;
  148500. /** Texture Buffer of Float32 that holds Animation Data*/
  148501. private _animationMap;
  148502. /** Custom ShaderMaterial Central to the System*/
  148503. private _material;
  148504. /** Custom ShaderMaterial Central to the System*/
  148505. private _output;
  148506. /** Systems Time Ticker*/
  148507. private _time;
  148508. /**
  148509. * Creates a new SpriteMap
  148510. * @param name defines the SpriteMaps Name
  148511. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  148512. * @param spriteSheet is the Texture that the Sprites are on.
  148513. * @param options a basic deployment configuration
  148514. * @param scene The Scene that the map is deployed on
  148515. */
  148516. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  148517. /**
  148518. * Returns tileID location
  148519. * @returns Vector2 the cell position ID
  148520. */
  148521. getTileID(): Vector2;
  148522. /**
  148523. * Gets the UV location of the mouse over the SpriteMap.
  148524. * @returns Vector2 the UV position of the mouse interaction
  148525. */
  148526. getMousePosition(): Vector2;
  148527. /**
  148528. * Creates the "frame" texture Buffer
  148529. * -------------------------------------
  148530. * Structure of frames
  148531. * "filename": "Falling-Water-2.png",
  148532. * "frame": {"x":69,"y":103,"w":24,"h":32},
  148533. * "rotated": true,
  148534. * "trimmed": true,
  148535. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  148536. * "sourceSize": {"w":32,"h":32}
  148537. * @returns RawTexture of the frameMap
  148538. */
  148539. private _createFrameBuffer;
  148540. /**
  148541. * Creates the tileMap texture Buffer
  148542. * @param buffer normally and array of numbers, or a false to generate from scratch
  148543. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  148544. * @returns RawTexture of the tileMap
  148545. */
  148546. private _createTileBuffer;
  148547. /**
  148548. * Modifies the data of the tileMaps
  148549. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  148550. * @param pos is the iVector2 Coordinates of the Tile
  148551. * @param tile The SpriteIndex of the new Tile
  148552. */
  148553. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  148554. /**
  148555. * Creates the animationMap texture Buffer
  148556. * @param buffer normally and array of numbers, or a false to generate from scratch
  148557. * @returns RawTexture of the animationMap
  148558. */
  148559. private _createTileAnimationBuffer;
  148560. /**
  148561. * Modifies the data of the animationMap
  148562. * @param cellID is the Index of the Sprite
  148563. * @param _frame is the target Animation frame
  148564. * @param toCell is the Target Index of the next frame of the animation
  148565. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  148566. * @param speed is a global scalar of the time variable on the map.
  148567. */
  148568. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  148569. /**
  148570. * Exports the .tilemaps file
  148571. */
  148572. saveTileMaps(): void;
  148573. /**
  148574. * Imports the .tilemaps file
  148575. * @param url of the .tilemaps file
  148576. */
  148577. loadTileMaps(url: string): void;
  148578. /**
  148579. * Release associated resources
  148580. */
  148581. dispose(): void;
  148582. }
  148583. }
  148584. declare module BABYLON {
  148585. /**
  148586. * Class used to manage multiple sprites of different sizes on the same spritesheet
  148587. * @see http://doc.babylonjs.com/babylon101/sprites
  148588. */
  148589. export class SpritePackedManager extends SpriteManager {
  148590. /** defines the packed manager's name */
  148591. name: string;
  148592. /**
  148593. * Creates a new sprite manager from a packed sprite sheet
  148594. * @param name defines the manager's name
  148595. * @param imgUrl defines the sprite sheet url
  148596. * @param capacity defines the maximum allowed number of sprites
  148597. * @param scene defines the hosting scene
  148598. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  148599. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  148600. * @param samplingMode defines the smapling mode to use with spritesheet
  148601. * @param fromPacked set to true; do not alter
  148602. */
  148603. constructor(
  148604. /** defines the packed manager's name */
  148605. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  148606. }
  148607. }
  148608. declare module BABYLON {
  148609. /**
  148610. * Defines the list of states available for a task inside a AssetsManager
  148611. */
  148612. export enum AssetTaskState {
  148613. /**
  148614. * Initialization
  148615. */
  148616. INIT = 0,
  148617. /**
  148618. * Running
  148619. */
  148620. RUNNING = 1,
  148621. /**
  148622. * Done
  148623. */
  148624. DONE = 2,
  148625. /**
  148626. * Error
  148627. */
  148628. ERROR = 3
  148629. }
  148630. /**
  148631. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  148632. */
  148633. export abstract class AbstractAssetTask {
  148634. /**
  148635. * Task name
  148636. */ name: string;
  148637. /**
  148638. * Callback called when the task is successful
  148639. */
  148640. onSuccess: (task: any) => void;
  148641. /**
  148642. * Callback called when the task is not successful
  148643. */
  148644. onError: (task: any, message?: string, exception?: any) => void;
  148645. /**
  148646. * Creates a new AssetsManager
  148647. * @param name defines the name of the task
  148648. */
  148649. constructor(
  148650. /**
  148651. * Task name
  148652. */ name: string);
  148653. private _isCompleted;
  148654. private _taskState;
  148655. private _errorObject;
  148656. /**
  148657. * Get if the task is completed
  148658. */
  148659. get isCompleted(): boolean;
  148660. /**
  148661. * Gets the current state of the task
  148662. */
  148663. get taskState(): AssetTaskState;
  148664. /**
  148665. * Gets the current error object (if task is in error)
  148666. */
  148667. get errorObject(): {
  148668. message?: string;
  148669. exception?: any;
  148670. };
  148671. /**
  148672. * Internal only
  148673. * @hidden
  148674. */
  148675. _setErrorObject(message?: string, exception?: any): void;
  148676. /**
  148677. * Execute the current task
  148678. * @param scene defines the scene where you want your assets to be loaded
  148679. * @param onSuccess is a callback called when the task is successfully executed
  148680. * @param onError is a callback called if an error occurs
  148681. */
  148682. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148683. /**
  148684. * Execute the current task
  148685. * @param scene defines the scene where you want your assets to be loaded
  148686. * @param onSuccess is a callback called when the task is successfully executed
  148687. * @param onError is a callback called if an error occurs
  148688. */
  148689. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148690. /**
  148691. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  148692. * This can be used with failed tasks that have the reason for failure fixed.
  148693. */
  148694. reset(): void;
  148695. private onErrorCallback;
  148696. private onDoneCallback;
  148697. }
  148698. /**
  148699. * Define the interface used by progress events raised during assets loading
  148700. */
  148701. export interface IAssetsProgressEvent {
  148702. /**
  148703. * Defines the number of remaining tasks to process
  148704. */
  148705. remainingCount: number;
  148706. /**
  148707. * Defines the total number of tasks
  148708. */
  148709. totalCount: number;
  148710. /**
  148711. * Defines the task that was just processed
  148712. */
  148713. task: AbstractAssetTask;
  148714. }
  148715. /**
  148716. * Class used to share progress information about assets loading
  148717. */
  148718. export class AssetsProgressEvent implements IAssetsProgressEvent {
  148719. /**
  148720. * Defines the number of remaining tasks to process
  148721. */
  148722. remainingCount: number;
  148723. /**
  148724. * Defines the total number of tasks
  148725. */
  148726. totalCount: number;
  148727. /**
  148728. * Defines the task that was just processed
  148729. */
  148730. task: AbstractAssetTask;
  148731. /**
  148732. * Creates a AssetsProgressEvent
  148733. * @param remainingCount defines the number of remaining tasks to process
  148734. * @param totalCount defines the total number of tasks
  148735. * @param task defines the task that was just processed
  148736. */
  148737. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  148738. }
  148739. /**
  148740. * Define a task used by AssetsManager to load meshes
  148741. */
  148742. export class MeshAssetTask extends AbstractAssetTask {
  148743. /**
  148744. * Defines the name of the task
  148745. */
  148746. name: string;
  148747. /**
  148748. * Defines the list of mesh's names you want to load
  148749. */
  148750. meshesNames: any;
  148751. /**
  148752. * Defines the root url to use as a base to load your meshes and associated resources
  148753. */
  148754. rootUrl: string;
  148755. /**
  148756. * Defines the filename or File of the scene to load from
  148757. */
  148758. sceneFilename: string | File;
  148759. /**
  148760. * Gets the list of loaded meshes
  148761. */
  148762. loadedMeshes: Array<AbstractMesh>;
  148763. /**
  148764. * Gets the list of loaded particle systems
  148765. */
  148766. loadedParticleSystems: Array<IParticleSystem>;
  148767. /**
  148768. * Gets the list of loaded skeletons
  148769. */
  148770. loadedSkeletons: Array<Skeleton>;
  148771. /**
  148772. * Gets the list of loaded animation groups
  148773. */
  148774. loadedAnimationGroups: Array<AnimationGroup>;
  148775. /**
  148776. * Callback called when the task is successful
  148777. */
  148778. onSuccess: (task: MeshAssetTask) => void;
  148779. /**
  148780. * Callback called when the task is successful
  148781. */
  148782. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  148783. /**
  148784. * Creates a new MeshAssetTask
  148785. * @param name defines the name of the task
  148786. * @param meshesNames defines the list of mesh's names you want to load
  148787. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  148788. * @param sceneFilename defines the filename or File of the scene to load from
  148789. */
  148790. constructor(
  148791. /**
  148792. * Defines the name of the task
  148793. */
  148794. name: string,
  148795. /**
  148796. * Defines the list of mesh's names you want to load
  148797. */
  148798. meshesNames: any,
  148799. /**
  148800. * Defines the root url to use as a base to load your meshes and associated resources
  148801. */
  148802. rootUrl: string,
  148803. /**
  148804. * Defines the filename or File of the scene to load from
  148805. */
  148806. sceneFilename: string | File);
  148807. /**
  148808. * Execute the current task
  148809. * @param scene defines the scene where you want your assets to be loaded
  148810. * @param onSuccess is a callback called when the task is successfully executed
  148811. * @param onError is a callback called if an error occurs
  148812. */
  148813. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148814. }
  148815. /**
  148816. * Define a task used by AssetsManager to load text content
  148817. */
  148818. export class TextFileAssetTask extends AbstractAssetTask {
  148819. /**
  148820. * Defines the name of the task
  148821. */
  148822. name: string;
  148823. /**
  148824. * Defines the location of the file to load
  148825. */
  148826. url: string;
  148827. /**
  148828. * Gets the loaded text string
  148829. */
  148830. text: string;
  148831. /**
  148832. * Callback called when the task is successful
  148833. */
  148834. onSuccess: (task: TextFileAssetTask) => void;
  148835. /**
  148836. * Callback called when the task is successful
  148837. */
  148838. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  148839. /**
  148840. * Creates a new TextFileAssetTask object
  148841. * @param name defines the name of the task
  148842. * @param url defines the location of the file to load
  148843. */
  148844. constructor(
  148845. /**
  148846. * Defines the name of the task
  148847. */
  148848. name: string,
  148849. /**
  148850. * Defines the location of the file to load
  148851. */
  148852. url: string);
  148853. /**
  148854. * Execute the current task
  148855. * @param scene defines the scene where you want your assets to be loaded
  148856. * @param onSuccess is a callback called when the task is successfully executed
  148857. * @param onError is a callback called if an error occurs
  148858. */
  148859. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148860. }
  148861. /**
  148862. * Define a task used by AssetsManager to load binary data
  148863. */
  148864. export class BinaryFileAssetTask extends AbstractAssetTask {
  148865. /**
  148866. * Defines the name of the task
  148867. */
  148868. name: string;
  148869. /**
  148870. * Defines the location of the file to load
  148871. */
  148872. url: string;
  148873. /**
  148874. * Gets the lodaded data (as an array buffer)
  148875. */
  148876. data: ArrayBuffer;
  148877. /**
  148878. * Callback called when the task is successful
  148879. */
  148880. onSuccess: (task: BinaryFileAssetTask) => void;
  148881. /**
  148882. * Callback called when the task is successful
  148883. */
  148884. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  148885. /**
  148886. * Creates a new BinaryFileAssetTask object
  148887. * @param name defines the name of the new task
  148888. * @param url defines the location of the file to load
  148889. */
  148890. constructor(
  148891. /**
  148892. * Defines the name of the task
  148893. */
  148894. name: string,
  148895. /**
  148896. * Defines the location of the file to load
  148897. */
  148898. url: string);
  148899. /**
  148900. * Execute the current task
  148901. * @param scene defines the scene where you want your assets to be loaded
  148902. * @param onSuccess is a callback called when the task is successfully executed
  148903. * @param onError is a callback called if an error occurs
  148904. */
  148905. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148906. }
  148907. /**
  148908. * Define a task used by AssetsManager to load images
  148909. */
  148910. export class ImageAssetTask extends AbstractAssetTask {
  148911. /**
  148912. * Defines the name of the task
  148913. */
  148914. name: string;
  148915. /**
  148916. * Defines the location of the image to load
  148917. */
  148918. url: string;
  148919. /**
  148920. * Gets the loaded images
  148921. */
  148922. image: HTMLImageElement;
  148923. /**
  148924. * Callback called when the task is successful
  148925. */
  148926. onSuccess: (task: ImageAssetTask) => void;
  148927. /**
  148928. * Callback called when the task is successful
  148929. */
  148930. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  148931. /**
  148932. * Creates a new ImageAssetTask
  148933. * @param name defines the name of the task
  148934. * @param url defines the location of the image to load
  148935. */
  148936. constructor(
  148937. /**
  148938. * Defines the name of the task
  148939. */
  148940. name: string,
  148941. /**
  148942. * Defines the location of the image to load
  148943. */
  148944. url: string);
  148945. /**
  148946. * Execute the current task
  148947. * @param scene defines the scene where you want your assets to be loaded
  148948. * @param onSuccess is a callback called when the task is successfully executed
  148949. * @param onError is a callback called if an error occurs
  148950. */
  148951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148952. }
  148953. /**
  148954. * Defines the interface used by texture loading tasks
  148955. */
  148956. export interface ITextureAssetTask<TEX extends BaseTexture> {
  148957. /**
  148958. * Gets the loaded texture
  148959. */
  148960. texture: TEX;
  148961. }
  148962. /**
  148963. * Define a task used by AssetsManager to load 2D textures
  148964. */
  148965. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  148966. /**
  148967. * Defines the name of the task
  148968. */
  148969. name: string;
  148970. /**
  148971. * Defines the location of the file to load
  148972. */
  148973. url: string;
  148974. /**
  148975. * Defines if mipmap should not be generated (default is false)
  148976. */
  148977. noMipmap?: boolean | undefined;
  148978. /**
  148979. * Defines if texture must be inverted on Y axis (default is true)
  148980. */
  148981. invertY: boolean;
  148982. /**
  148983. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  148984. */
  148985. samplingMode: number;
  148986. /**
  148987. * Gets the loaded texture
  148988. */
  148989. texture: Texture;
  148990. /**
  148991. * Callback called when the task is successful
  148992. */
  148993. onSuccess: (task: TextureAssetTask) => void;
  148994. /**
  148995. * Callback called when the task is successful
  148996. */
  148997. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  148998. /**
  148999. * Creates a new TextureAssetTask object
  149000. * @param name defines the name of the task
  149001. * @param url defines the location of the file to load
  149002. * @param noMipmap defines if mipmap should not be generated (default is false)
  149003. * @param invertY defines if texture must be inverted on Y axis (default is true)
  149004. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149005. */
  149006. constructor(
  149007. /**
  149008. * Defines the name of the task
  149009. */
  149010. name: string,
  149011. /**
  149012. * Defines the location of the file to load
  149013. */
  149014. url: string,
  149015. /**
  149016. * Defines if mipmap should not be generated (default is false)
  149017. */
  149018. noMipmap?: boolean | undefined,
  149019. /**
  149020. * Defines if texture must be inverted on Y axis (default is true)
  149021. */
  149022. invertY?: boolean,
  149023. /**
  149024. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149025. */
  149026. samplingMode?: number);
  149027. /**
  149028. * Execute the current task
  149029. * @param scene defines the scene where you want your assets to be loaded
  149030. * @param onSuccess is a callback called when the task is successfully executed
  149031. * @param onError is a callback called if an error occurs
  149032. */
  149033. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149034. }
  149035. /**
  149036. * Define a task used by AssetsManager to load cube textures
  149037. */
  149038. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  149039. /**
  149040. * Defines the name of the task
  149041. */
  149042. name: string;
  149043. /**
  149044. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149045. */
  149046. url: string;
  149047. /**
  149048. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149049. */
  149050. extensions?: string[] | undefined;
  149051. /**
  149052. * Defines if mipmaps should not be generated (default is false)
  149053. */
  149054. noMipmap?: boolean | undefined;
  149055. /**
  149056. * Defines the explicit list of files (undefined by default)
  149057. */
  149058. files?: string[] | undefined;
  149059. /**
  149060. * Gets the loaded texture
  149061. */
  149062. texture: CubeTexture;
  149063. /**
  149064. * Callback called when the task is successful
  149065. */
  149066. onSuccess: (task: CubeTextureAssetTask) => void;
  149067. /**
  149068. * Callback called when the task is successful
  149069. */
  149070. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  149071. /**
  149072. * Creates a new CubeTextureAssetTask
  149073. * @param name defines the name of the task
  149074. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149075. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149076. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149077. * @param files defines the explicit list of files (undefined by default)
  149078. */
  149079. constructor(
  149080. /**
  149081. * Defines the name of the task
  149082. */
  149083. name: string,
  149084. /**
  149085. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149086. */
  149087. url: string,
  149088. /**
  149089. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149090. */
  149091. extensions?: string[] | undefined,
  149092. /**
  149093. * Defines if mipmaps should not be generated (default is false)
  149094. */
  149095. noMipmap?: boolean | undefined,
  149096. /**
  149097. * Defines the explicit list of files (undefined by default)
  149098. */
  149099. files?: string[] | undefined);
  149100. /**
  149101. * Execute the current task
  149102. * @param scene defines the scene where you want your assets to be loaded
  149103. * @param onSuccess is a callback called when the task is successfully executed
  149104. * @param onError is a callback called if an error occurs
  149105. */
  149106. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149107. }
  149108. /**
  149109. * Define a task used by AssetsManager to load HDR cube textures
  149110. */
  149111. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  149112. /**
  149113. * Defines the name of the task
  149114. */
  149115. name: string;
  149116. /**
  149117. * Defines the location of the file to load
  149118. */
  149119. url: string;
  149120. /**
  149121. * Defines the desired size (the more it increases the longer the generation will be)
  149122. */
  149123. size: number;
  149124. /**
  149125. * Defines if mipmaps should not be generated (default is false)
  149126. */
  149127. noMipmap: boolean;
  149128. /**
  149129. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149130. */
  149131. generateHarmonics: boolean;
  149132. /**
  149133. * 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)
  149134. */
  149135. gammaSpace: boolean;
  149136. /**
  149137. * Internal Use Only
  149138. */
  149139. reserved: boolean;
  149140. /**
  149141. * Gets the loaded texture
  149142. */
  149143. texture: HDRCubeTexture;
  149144. /**
  149145. * Callback called when the task is successful
  149146. */
  149147. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  149148. /**
  149149. * Callback called when the task is successful
  149150. */
  149151. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  149152. /**
  149153. * Creates a new HDRCubeTextureAssetTask object
  149154. * @param name defines the name of the task
  149155. * @param url defines the location of the file to load
  149156. * @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.
  149157. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149158. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149159. * @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)
  149160. * @param reserved Internal use only
  149161. */
  149162. constructor(
  149163. /**
  149164. * Defines the name of the task
  149165. */
  149166. name: string,
  149167. /**
  149168. * Defines the location of the file to load
  149169. */
  149170. url: string,
  149171. /**
  149172. * Defines the desired size (the more it increases the longer the generation will be)
  149173. */
  149174. size: number,
  149175. /**
  149176. * Defines if mipmaps should not be generated (default is false)
  149177. */
  149178. noMipmap?: boolean,
  149179. /**
  149180. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149181. */
  149182. generateHarmonics?: boolean,
  149183. /**
  149184. * 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)
  149185. */
  149186. gammaSpace?: boolean,
  149187. /**
  149188. * Internal Use Only
  149189. */
  149190. reserved?: boolean);
  149191. /**
  149192. * Execute the current task
  149193. * @param scene defines the scene where you want your assets to be loaded
  149194. * @param onSuccess is a callback called when the task is successfully executed
  149195. * @param onError is a callback called if an error occurs
  149196. */
  149197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149198. }
  149199. /**
  149200. * Define a task used by AssetsManager to load Equirectangular cube textures
  149201. */
  149202. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  149203. /**
  149204. * Defines the name of the task
  149205. */
  149206. name: string;
  149207. /**
  149208. * Defines the location of the file to load
  149209. */
  149210. url: string;
  149211. /**
  149212. * Defines the desired size (the more it increases the longer the generation will be)
  149213. */
  149214. size: number;
  149215. /**
  149216. * Defines if mipmaps should not be generated (default is false)
  149217. */
  149218. noMipmap: boolean;
  149219. /**
  149220. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  149221. * but the standard material would require them in Gamma space) (default is true)
  149222. */
  149223. gammaSpace: boolean;
  149224. /**
  149225. * Gets the loaded texture
  149226. */
  149227. texture: EquiRectangularCubeTexture;
  149228. /**
  149229. * Callback called when the task is successful
  149230. */
  149231. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  149232. /**
  149233. * Callback called when the task is successful
  149234. */
  149235. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  149236. /**
  149237. * Creates a new EquiRectangularCubeTextureAssetTask object
  149238. * @param name defines the name of the task
  149239. * @param url defines the location of the file to load
  149240. * @param size defines the desired size (the more it increases the longer the generation will be)
  149241. * If the size is omitted this implies you are using a preprocessed cubemap.
  149242. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149243. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  149244. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  149245. * (default is true)
  149246. */
  149247. constructor(
  149248. /**
  149249. * Defines the name of the task
  149250. */
  149251. name: string,
  149252. /**
  149253. * Defines the location of the file to load
  149254. */
  149255. url: string,
  149256. /**
  149257. * Defines the desired size (the more it increases the longer the generation will be)
  149258. */
  149259. size: number,
  149260. /**
  149261. * Defines if mipmaps should not be generated (default is false)
  149262. */
  149263. noMipmap?: boolean,
  149264. /**
  149265. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  149266. * but the standard material would require them in Gamma space) (default is true)
  149267. */
  149268. gammaSpace?: boolean);
  149269. /**
  149270. * Execute the current task
  149271. * @param scene defines the scene where you want your assets to be loaded
  149272. * @param onSuccess is a callback called when the task is successfully executed
  149273. * @param onError is a callback called if an error occurs
  149274. */
  149275. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149276. }
  149277. /**
  149278. * This class can be used to easily import assets into a scene
  149279. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  149280. */
  149281. export class AssetsManager {
  149282. private _scene;
  149283. private _isLoading;
  149284. protected _tasks: AbstractAssetTask[];
  149285. protected _waitingTasksCount: number;
  149286. protected _totalTasksCount: number;
  149287. /**
  149288. * Callback called when all tasks are processed
  149289. */
  149290. onFinish: (tasks: AbstractAssetTask[]) => void;
  149291. /**
  149292. * Callback called when a task is successful
  149293. */
  149294. onTaskSuccess: (task: AbstractAssetTask) => void;
  149295. /**
  149296. * Callback called when a task had an error
  149297. */
  149298. onTaskError: (task: AbstractAssetTask) => void;
  149299. /**
  149300. * Callback called when a task is done (whatever the result is)
  149301. */
  149302. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  149303. /**
  149304. * Observable called when all tasks are processed
  149305. */
  149306. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  149307. /**
  149308. * Observable called when a task had an error
  149309. */
  149310. onTaskErrorObservable: Observable<AbstractAssetTask>;
  149311. /**
  149312. * Observable called when all tasks were executed
  149313. */
  149314. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  149315. /**
  149316. * Observable called when a task is done (whatever the result is)
  149317. */
  149318. onProgressObservable: Observable<IAssetsProgressEvent>;
  149319. /**
  149320. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  149321. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  149322. */
  149323. useDefaultLoadingScreen: boolean;
  149324. /**
  149325. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  149326. * when all assets have been downloaded.
  149327. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  149328. */
  149329. autoHideLoadingUI: boolean;
  149330. /**
  149331. * Creates a new AssetsManager
  149332. * @param scene defines the scene to work on
  149333. */
  149334. constructor(scene: Scene);
  149335. /**
  149336. * Add a MeshAssetTask to the list of active tasks
  149337. * @param taskName defines the name of the new task
  149338. * @param meshesNames defines the name of meshes to load
  149339. * @param rootUrl defines the root url to use to locate files
  149340. * @param sceneFilename defines the filename of the scene file
  149341. * @returns a new MeshAssetTask object
  149342. */
  149343. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  149344. /**
  149345. * Add a TextFileAssetTask to the list of active tasks
  149346. * @param taskName defines the name of the new task
  149347. * @param url defines the url of the file to load
  149348. * @returns a new TextFileAssetTask object
  149349. */
  149350. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  149351. /**
  149352. * Add a BinaryFileAssetTask to the list of active tasks
  149353. * @param taskName defines the name of the new task
  149354. * @param url defines the url of the file to load
  149355. * @returns a new BinaryFileAssetTask object
  149356. */
  149357. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  149358. /**
  149359. * Add a ImageAssetTask to the list of active tasks
  149360. * @param taskName defines the name of the new task
  149361. * @param url defines the url of the file to load
  149362. * @returns a new ImageAssetTask object
  149363. */
  149364. addImageTask(taskName: string, url: string): ImageAssetTask;
  149365. /**
  149366. * Add a TextureAssetTask to the list of active tasks
  149367. * @param taskName defines the name of the new task
  149368. * @param url defines the url of the file to load
  149369. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149370. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  149371. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  149372. * @returns a new TextureAssetTask object
  149373. */
  149374. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  149375. /**
  149376. * Add a CubeTextureAssetTask to the list of active tasks
  149377. * @param taskName defines the name of the new task
  149378. * @param url defines the url of the file to load
  149379. * @param extensions defines the extension to use to load the cube map (can be null)
  149380. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149381. * @param files defines the list of files to load (can be null)
  149382. * @returns a new CubeTextureAssetTask object
  149383. */
  149384. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  149385. /**
  149386. *
  149387. * Add a HDRCubeTextureAssetTask to the list of active tasks
  149388. * @param taskName defines the name of the new task
  149389. * @param url defines the url of the file to load
  149390. * @param size defines the size you want for the cubemap (can be null)
  149391. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149392. * @param generateHarmonics defines if you want to automatically generate (true by default)
  149393. * @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)
  149394. * @param reserved Internal use only
  149395. * @returns a new HDRCubeTextureAssetTask object
  149396. */
  149397. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  149398. /**
  149399. *
  149400. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  149401. * @param taskName defines the name of the new task
  149402. * @param url defines the url of the file to load
  149403. * @param size defines the size you want for the cubemap (can be null)
  149404. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149405. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  149406. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  149407. * @returns a new EquiRectangularCubeTextureAssetTask object
  149408. */
  149409. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  149410. /**
  149411. * Remove a task from the assets manager.
  149412. * @param task the task to remove
  149413. */
  149414. removeTask(task: AbstractAssetTask): void;
  149415. private _decreaseWaitingTasksCount;
  149416. private _runTask;
  149417. /**
  149418. * Reset the AssetsManager and remove all tasks
  149419. * @return the current instance of the AssetsManager
  149420. */
  149421. reset(): AssetsManager;
  149422. /**
  149423. * Start the loading process
  149424. * @return the current instance of the AssetsManager
  149425. */
  149426. load(): AssetsManager;
  149427. /**
  149428. * Start the loading process as an async operation
  149429. * @return a promise returning the list of failed tasks
  149430. */
  149431. loadAsync(): Promise<void>;
  149432. }
  149433. }
  149434. declare module BABYLON {
  149435. /**
  149436. * Wrapper class for promise with external resolve and reject.
  149437. */
  149438. export class Deferred<T> {
  149439. /**
  149440. * The promise associated with this deferred object.
  149441. */
  149442. readonly promise: Promise<T>;
  149443. private _resolve;
  149444. private _reject;
  149445. /**
  149446. * The resolve method of the promise associated with this deferred object.
  149447. */
  149448. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  149449. /**
  149450. * The reject method of the promise associated with this deferred object.
  149451. */
  149452. get reject(): (reason?: any) => void;
  149453. /**
  149454. * Constructor for this deferred object.
  149455. */
  149456. constructor();
  149457. }
  149458. }
  149459. declare module BABYLON {
  149460. /**
  149461. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  149462. */
  149463. export class MeshExploder {
  149464. private _centerMesh;
  149465. private _meshes;
  149466. private _meshesOrigins;
  149467. private _toCenterVectors;
  149468. private _scaledDirection;
  149469. private _newPosition;
  149470. private _centerPosition;
  149471. /**
  149472. * Explodes meshes from a center mesh.
  149473. * @param meshes The meshes to explode.
  149474. * @param centerMesh The mesh to be center of explosion.
  149475. */
  149476. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  149477. private _setCenterMesh;
  149478. /**
  149479. * Get class name
  149480. * @returns "MeshExploder"
  149481. */
  149482. getClassName(): string;
  149483. /**
  149484. * "Exploded meshes"
  149485. * @returns Array of meshes with the centerMesh at index 0.
  149486. */
  149487. getMeshes(): Array<Mesh>;
  149488. /**
  149489. * Explodes meshes giving a specific direction
  149490. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  149491. */
  149492. explode(direction?: number): void;
  149493. }
  149494. }
  149495. declare module BABYLON {
  149496. /**
  149497. * Class used to help managing file picking and drag'n'drop
  149498. */
  149499. export class FilesInput {
  149500. /**
  149501. * List of files ready to be loaded
  149502. */
  149503. static get FilesToLoad(): {
  149504. [key: string]: File;
  149505. };
  149506. /**
  149507. * Callback called when a file is processed
  149508. */
  149509. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  149510. private _engine;
  149511. private _currentScene;
  149512. private _sceneLoadedCallback;
  149513. private _progressCallback;
  149514. private _additionalRenderLoopLogicCallback;
  149515. private _textureLoadingCallback;
  149516. private _startingProcessingFilesCallback;
  149517. private _onReloadCallback;
  149518. private _errorCallback;
  149519. private _elementToMonitor;
  149520. private _sceneFileToLoad;
  149521. private _filesToLoad;
  149522. /**
  149523. * Creates a new FilesInput
  149524. * @param engine defines the rendering engine
  149525. * @param scene defines the hosting scene
  149526. * @param sceneLoadedCallback callback called when scene is loaded
  149527. * @param progressCallback callback called to track progress
  149528. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  149529. * @param textureLoadingCallback callback called when a texture is loading
  149530. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  149531. * @param onReloadCallback callback called when a reload is requested
  149532. * @param errorCallback callback call if an error occurs
  149533. */
  149534. 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);
  149535. private _dragEnterHandler;
  149536. private _dragOverHandler;
  149537. private _dropHandler;
  149538. /**
  149539. * Calls this function to listen to drag'n'drop events on a specific DOM element
  149540. * @param elementToMonitor defines the DOM element to track
  149541. */
  149542. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  149543. /**
  149544. * Release all associated resources
  149545. */
  149546. dispose(): void;
  149547. private renderFunction;
  149548. private drag;
  149549. private drop;
  149550. private _traverseFolder;
  149551. private _processFiles;
  149552. /**
  149553. * Load files from a drop event
  149554. * @param event defines the drop event to use as source
  149555. */
  149556. loadFiles(event: any): void;
  149557. private _processReload;
  149558. /**
  149559. * Reload the current scene from the loaded files
  149560. */
  149561. reload(): void;
  149562. }
  149563. }
  149564. declare module BABYLON {
  149565. /**
  149566. * Defines the root class used to create scene optimization to use with SceneOptimizer
  149567. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149568. */
  149569. export class SceneOptimization {
  149570. /**
  149571. * Defines the priority of this optimization (0 by default which means first in the list)
  149572. */
  149573. priority: number;
  149574. /**
  149575. * Gets a string describing the action executed by the current optimization
  149576. * @returns description string
  149577. */
  149578. getDescription(): string;
  149579. /**
  149580. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149581. * @param scene defines the current scene where to apply this optimization
  149582. * @param optimizer defines the current optimizer
  149583. * @returns true if everything that can be done was applied
  149584. */
  149585. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149586. /**
  149587. * Creates the SceneOptimization object
  149588. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149589. * @param desc defines the description associated with the optimization
  149590. */
  149591. constructor(
  149592. /**
  149593. * Defines the priority of this optimization (0 by default which means first in the list)
  149594. */
  149595. priority?: number);
  149596. }
  149597. /**
  149598. * Defines an optimization used to reduce the size of render target textures
  149599. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149600. */
  149601. export class TextureOptimization extends SceneOptimization {
  149602. /**
  149603. * Defines the priority of this optimization (0 by default which means first in the list)
  149604. */
  149605. priority: number;
  149606. /**
  149607. * 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
  149608. */
  149609. maximumSize: number;
  149610. /**
  149611. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149612. */
  149613. step: number;
  149614. /**
  149615. * Gets a string describing the action executed by the current optimization
  149616. * @returns description string
  149617. */
  149618. getDescription(): string;
  149619. /**
  149620. * Creates the TextureOptimization object
  149621. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149622. * @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
  149623. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149624. */
  149625. constructor(
  149626. /**
  149627. * Defines the priority of this optimization (0 by default which means first in the list)
  149628. */
  149629. priority?: number,
  149630. /**
  149631. * 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
  149632. */
  149633. maximumSize?: number,
  149634. /**
  149635. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149636. */
  149637. step?: number);
  149638. /**
  149639. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149640. * @param scene defines the current scene where to apply this optimization
  149641. * @param optimizer defines the current optimizer
  149642. * @returns true if everything that can be done was applied
  149643. */
  149644. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149645. }
  149646. /**
  149647. * Defines an optimization used to increase or decrease the rendering resolution
  149648. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149649. */
  149650. export class HardwareScalingOptimization extends SceneOptimization {
  149651. /**
  149652. * Defines the priority of this optimization (0 by default which means first in the list)
  149653. */
  149654. priority: number;
  149655. /**
  149656. * Defines the maximum scale to use (2 by default)
  149657. */
  149658. maximumScale: number;
  149659. /**
  149660. * Defines the step to use between two passes (0.5 by default)
  149661. */
  149662. step: number;
  149663. private _currentScale;
  149664. private _directionOffset;
  149665. /**
  149666. * Gets a string describing the action executed by the current optimization
  149667. * @return description string
  149668. */
  149669. getDescription(): string;
  149670. /**
  149671. * Creates the HardwareScalingOptimization object
  149672. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149673. * @param maximumScale defines the maximum scale to use (2 by default)
  149674. * @param step defines the step to use between two passes (0.5 by default)
  149675. */
  149676. constructor(
  149677. /**
  149678. * Defines the priority of this optimization (0 by default which means first in the list)
  149679. */
  149680. priority?: number,
  149681. /**
  149682. * Defines the maximum scale to use (2 by default)
  149683. */
  149684. maximumScale?: number,
  149685. /**
  149686. * Defines the step to use between two passes (0.5 by default)
  149687. */
  149688. step?: number);
  149689. /**
  149690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149691. * @param scene defines the current scene where to apply this optimization
  149692. * @param optimizer defines the current optimizer
  149693. * @returns true if everything that can be done was applied
  149694. */
  149695. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149696. }
  149697. /**
  149698. * Defines an optimization used to remove shadows
  149699. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149700. */
  149701. export class ShadowsOptimization extends SceneOptimization {
  149702. /**
  149703. * Gets a string describing the action executed by the current optimization
  149704. * @return description string
  149705. */
  149706. getDescription(): string;
  149707. /**
  149708. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149709. * @param scene defines the current scene where to apply this optimization
  149710. * @param optimizer defines the current optimizer
  149711. * @returns true if everything that can be done was applied
  149712. */
  149713. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149714. }
  149715. /**
  149716. * Defines an optimization used to turn post-processes off
  149717. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149718. */
  149719. export class PostProcessesOptimization extends SceneOptimization {
  149720. /**
  149721. * Gets a string describing the action executed by the current optimization
  149722. * @return description string
  149723. */
  149724. getDescription(): string;
  149725. /**
  149726. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149727. * @param scene defines the current scene where to apply this optimization
  149728. * @param optimizer defines the current optimizer
  149729. * @returns true if everything that can be done was applied
  149730. */
  149731. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149732. }
  149733. /**
  149734. * Defines an optimization used to turn lens flares off
  149735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149736. */
  149737. export class LensFlaresOptimization extends SceneOptimization {
  149738. /**
  149739. * Gets a string describing the action executed by the current optimization
  149740. * @return description string
  149741. */
  149742. getDescription(): string;
  149743. /**
  149744. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149745. * @param scene defines the current scene where to apply this optimization
  149746. * @param optimizer defines the current optimizer
  149747. * @returns true if everything that can be done was applied
  149748. */
  149749. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149750. }
  149751. /**
  149752. * Defines an optimization based on user defined callback.
  149753. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149754. */
  149755. export class CustomOptimization extends SceneOptimization {
  149756. /**
  149757. * Callback called to apply the custom optimization.
  149758. */
  149759. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  149760. /**
  149761. * Callback called to get custom description
  149762. */
  149763. onGetDescription: () => string;
  149764. /**
  149765. * Gets a string describing the action executed by the current optimization
  149766. * @returns description string
  149767. */
  149768. getDescription(): string;
  149769. /**
  149770. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149771. * @param scene defines the current scene where to apply this optimization
  149772. * @param optimizer defines the current optimizer
  149773. * @returns true if everything that can be done was applied
  149774. */
  149775. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149776. }
  149777. /**
  149778. * Defines an optimization used to turn particles off
  149779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149780. */
  149781. export class ParticlesOptimization extends SceneOptimization {
  149782. /**
  149783. * Gets a string describing the action executed by the current optimization
  149784. * @return description string
  149785. */
  149786. getDescription(): string;
  149787. /**
  149788. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149789. * @param scene defines the current scene where to apply this optimization
  149790. * @param optimizer defines the current optimizer
  149791. * @returns true if everything that can be done was applied
  149792. */
  149793. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149794. }
  149795. /**
  149796. * Defines an optimization used to turn render targets off
  149797. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149798. */
  149799. export class RenderTargetsOptimization extends SceneOptimization {
  149800. /**
  149801. * Gets a string describing the action executed by the current optimization
  149802. * @return description string
  149803. */
  149804. getDescription(): string;
  149805. /**
  149806. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149807. * @param scene defines the current scene where to apply this optimization
  149808. * @param optimizer defines the current optimizer
  149809. * @returns true if everything that can be done was applied
  149810. */
  149811. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149812. }
  149813. /**
  149814. * Defines an optimization used to merge meshes with compatible materials
  149815. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149816. */
  149817. export class MergeMeshesOptimization extends SceneOptimization {
  149818. private static _UpdateSelectionTree;
  149819. /**
  149820. * Gets or sets a boolean which defines if optimization octree has to be updated
  149821. */
  149822. static get UpdateSelectionTree(): boolean;
  149823. /**
  149824. * Gets or sets a boolean which defines if optimization octree has to be updated
  149825. */
  149826. static set UpdateSelectionTree(value: boolean);
  149827. /**
  149828. * Gets a string describing the action executed by the current optimization
  149829. * @return description string
  149830. */
  149831. getDescription(): string;
  149832. private _canBeMerged;
  149833. /**
  149834. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149835. * @param scene defines the current scene where to apply this optimization
  149836. * @param optimizer defines the current optimizer
  149837. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  149838. * @returns true if everything that can be done was applied
  149839. */
  149840. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  149841. }
  149842. /**
  149843. * Defines a list of options used by SceneOptimizer
  149844. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149845. */
  149846. export class SceneOptimizerOptions {
  149847. /**
  149848. * Defines the target frame rate to reach (60 by default)
  149849. */
  149850. targetFrameRate: number;
  149851. /**
  149852. * Defines the interval between two checkes (2000ms by default)
  149853. */
  149854. trackerDuration: number;
  149855. /**
  149856. * Gets the list of optimizations to apply
  149857. */
  149858. optimizations: SceneOptimization[];
  149859. /**
  149860. * Creates a new list of options used by SceneOptimizer
  149861. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  149862. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  149863. */
  149864. constructor(
  149865. /**
  149866. * Defines the target frame rate to reach (60 by default)
  149867. */
  149868. targetFrameRate?: number,
  149869. /**
  149870. * Defines the interval between two checkes (2000ms by default)
  149871. */
  149872. trackerDuration?: number);
  149873. /**
  149874. * Add a new optimization
  149875. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  149876. * @returns the current SceneOptimizerOptions
  149877. */
  149878. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  149879. /**
  149880. * Add a new custom optimization
  149881. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  149882. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  149883. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149884. * @returns the current SceneOptimizerOptions
  149885. */
  149886. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  149887. /**
  149888. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  149889. * @param targetFrameRate defines the target frame rate (60 by default)
  149890. * @returns a SceneOptimizerOptions object
  149891. */
  149892. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149893. /**
  149894. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  149895. * @param targetFrameRate defines the target frame rate (60 by default)
  149896. * @returns a SceneOptimizerOptions object
  149897. */
  149898. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149899. /**
  149900. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  149901. * @param targetFrameRate defines the target frame rate (60 by default)
  149902. * @returns a SceneOptimizerOptions object
  149903. */
  149904. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149905. }
  149906. /**
  149907. * Class used to run optimizations in order to reach a target frame rate
  149908. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149909. */
  149910. export class SceneOptimizer implements IDisposable {
  149911. private _isRunning;
  149912. private _options;
  149913. private _scene;
  149914. private _currentPriorityLevel;
  149915. private _targetFrameRate;
  149916. private _trackerDuration;
  149917. private _currentFrameRate;
  149918. private _sceneDisposeObserver;
  149919. private _improvementMode;
  149920. /**
  149921. * Defines an observable called when the optimizer reaches the target frame rate
  149922. */
  149923. onSuccessObservable: Observable<SceneOptimizer>;
  149924. /**
  149925. * Defines an observable called when the optimizer enables an optimization
  149926. */
  149927. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  149928. /**
  149929. * Defines an observable called when the optimizer is not able to reach the target frame rate
  149930. */
  149931. onFailureObservable: Observable<SceneOptimizer>;
  149932. /**
  149933. * Gets a boolean indicating if the optimizer is in improvement mode
  149934. */
  149935. get isInImprovementMode(): boolean;
  149936. /**
  149937. * Gets the current priority level (0 at start)
  149938. */
  149939. get currentPriorityLevel(): number;
  149940. /**
  149941. * Gets the current frame rate checked by the SceneOptimizer
  149942. */
  149943. get currentFrameRate(): number;
  149944. /**
  149945. * Gets or sets the current target frame rate (60 by default)
  149946. */
  149947. get targetFrameRate(): number;
  149948. /**
  149949. * Gets or sets the current target frame rate (60 by default)
  149950. */
  149951. set targetFrameRate(value: number);
  149952. /**
  149953. * Gets or sets the current interval between two checks (every 2000ms by default)
  149954. */
  149955. get trackerDuration(): number;
  149956. /**
  149957. * Gets or sets the current interval between two checks (every 2000ms by default)
  149958. */
  149959. set trackerDuration(value: number);
  149960. /**
  149961. * Gets the list of active optimizations
  149962. */
  149963. get optimizations(): SceneOptimization[];
  149964. /**
  149965. * Creates a new SceneOptimizer
  149966. * @param scene defines the scene to work on
  149967. * @param options defines the options to use with the SceneOptimizer
  149968. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  149969. * @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)
  149970. */
  149971. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  149972. /**
  149973. * Stops the current optimizer
  149974. */
  149975. stop(): void;
  149976. /**
  149977. * Reset the optimizer to initial step (current priority level = 0)
  149978. */
  149979. reset(): void;
  149980. /**
  149981. * Start the optimizer. By default it will try to reach a specific framerate
  149982. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  149983. */
  149984. start(): void;
  149985. private _checkCurrentState;
  149986. /**
  149987. * Release all resources
  149988. */
  149989. dispose(): void;
  149990. /**
  149991. * Helper function to create a SceneOptimizer with one single line of code
  149992. * @param scene defines the scene to work on
  149993. * @param options defines the options to use with the SceneOptimizer
  149994. * @param onSuccess defines a callback to call on success
  149995. * @param onFailure defines a callback to call on failure
  149996. * @returns the new SceneOptimizer object
  149997. */
  149998. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  149999. }
  150000. }
  150001. declare module BABYLON {
  150002. /**
  150003. * Class used to serialize a scene into a string
  150004. */
  150005. export class SceneSerializer {
  150006. /**
  150007. * Clear cache used by a previous serialization
  150008. */
  150009. static ClearCache(): void;
  150010. /**
  150011. * Serialize a scene into a JSON compatible object
  150012. * @param scene defines the scene to serialize
  150013. * @returns a JSON compatible object
  150014. */
  150015. static Serialize(scene: Scene): any;
  150016. /**
  150017. * Serialize a mesh into a JSON compatible object
  150018. * @param toSerialize defines the mesh to serialize
  150019. * @param withParents defines if parents must be serialized as well
  150020. * @param withChildren defines if children must be serialized as well
  150021. * @returns a JSON compatible object
  150022. */
  150023. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  150024. }
  150025. }
  150026. declare module BABYLON {
  150027. /**
  150028. * Class used to host texture specific utilities
  150029. */
  150030. export class TextureTools {
  150031. /**
  150032. * Uses the GPU to create a copy texture rescaled at a given size
  150033. * @param texture Texture to copy from
  150034. * @param width defines the desired width
  150035. * @param height defines the desired height
  150036. * @param useBilinearMode defines if bilinear mode has to be used
  150037. * @return the generated texture
  150038. */
  150039. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  150040. }
  150041. }
  150042. declare module BABYLON {
  150043. /**
  150044. * This represents the different options available for the video capture.
  150045. */
  150046. export interface VideoRecorderOptions {
  150047. /** Defines the mime type of the video. */
  150048. mimeType: string;
  150049. /** Defines the FPS the video should be recorded at. */
  150050. fps: number;
  150051. /** Defines the chunk size for the recording data. */
  150052. recordChunckSize: number;
  150053. /** The audio tracks to attach to the recording. */
  150054. audioTracks?: MediaStreamTrack[];
  150055. }
  150056. /**
  150057. * This can help with recording videos from BabylonJS.
  150058. * This is based on the available WebRTC functionalities of the browser.
  150059. *
  150060. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  150061. */
  150062. export class VideoRecorder {
  150063. private static readonly _defaultOptions;
  150064. /**
  150065. * Returns whether or not the VideoRecorder is available in your browser.
  150066. * @param engine Defines the Babylon Engine.
  150067. * @returns true if supported otherwise false.
  150068. */
  150069. static IsSupported(engine: Engine): boolean;
  150070. private readonly _options;
  150071. private _canvas;
  150072. private _mediaRecorder;
  150073. private _recordedChunks;
  150074. private _fileName;
  150075. private _resolve;
  150076. private _reject;
  150077. /**
  150078. * True when a recording is already in progress.
  150079. */
  150080. get isRecording(): boolean;
  150081. /**
  150082. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  150083. * @param engine Defines the BabylonJS Engine you wish to record.
  150084. * @param options Defines options that can be used to customize the capture.
  150085. */
  150086. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  150087. /**
  150088. * Stops the current recording before the default capture timeout passed in the startRecording function.
  150089. */
  150090. stopRecording(): void;
  150091. /**
  150092. * Starts recording the canvas for a max duration specified in parameters.
  150093. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  150094. * If null no automatic download will start and you can rely on the promise to get the data back.
  150095. * @param maxDuration Defines the maximum recording time in seconds.
  150096. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  150097. * @return A promise callback at the end of the recording with the video data in Blob.
  150098. */
  150099. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  150100. /**
  150101. * Releases internal resources used during the recording.
  150102. */
  150103. dispose(): void;
  150104. private _handleDataAvailable;
  150105. private _handleError;
  150106. private _handleStop;
  150107. }
  150108. }
  150109. declare module BABYLON {
  150110. /**
  150111. * Class containing a set of static utilities functions for screenshots
  150112. */
  150113. export class ScreenshotTools {
  150114. /**
  150115. * Captures a screenshot of the current rendering
  150116. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150117. * @param engine defines the rendering engine
  150118. * @param camera defines the source camera
  150119. * @param size This parameter can be set to a single number or to an object with the
  150120. * following (optional) properties: precision, width, height. If a single number is passed,
  150121. * it will be used for both width and height. If an object is passed, the screenshot size
  150122. * will be derived from the parameters. The precision property is a multiplier allowing
  150123. * rendering at a higher or lower resolution
  150124. * @param successCallback defines the callback receives a single parameter which contains the
  150125. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  150126. * src parameter of an <img> to display it
  150127. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  150128. * Check your browser for supported MIME types
  150129. */
  150130. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  150131. /**
  150132. * Captures a screenshot of the current rendering
  150133. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150134. * @param engine defines the rendering engine
  150135. * @param camera defines the source camera
  150136. * @param size This parameter can be set to a single number or to an object with the
  150137. * following (optional) properties: precision, width, height. If a single number is passed,
  150138. * it will be used for both width and height. If an object is passed, the screenshot size
  150139. * will be derived from the parameters. The precision property is a multiplier allowing
  150140. * rendering at a higher or lower resolution
  150141. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  150142. * Check your browser for supported MIME types
  150143. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  150144. * to the src parameter of an <img> to display it
  150145. */
  150146. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  150147. /**
  150148. * Generates an image screenshot from the specified camera.
  150149. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150150. * @param engine The engine to use for rendering
  150151. * @param camera The camera to use for rendering
  150152. * @param size This parameter can be set to a single number or to an object with the
  150153. * following (optional) properties: precision, width, height. If a single number is passed,
  150154. * it will be used for both width and height. If an object is passed, the screenshot size
  150155. * will be derived from the parameters. The precision property is a multiplier allowing
  150156. * rendering at a higher or lower resolution
  150157. * @param successCallback The callback receives a single parameter which contains the
  150158. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  150159. * src parameter of an <img> to display it
  150160. * @param mimeType The MIME type of the screenshot image (default: image/png).
  150161. * Check your browser for supported MIME types
  150162. * @param samples Texture samples (default: 1)
  150163. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  150164. * @param fileName A name for for the downloaded file.
  150165. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  150166. */
  150167. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  150168. /**
  150169. * Generates an image screenshot from the specified camera.
  150170. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150171. * @param engine The engine to use for rendering
  150172. * @param camera The camera to use for rendering
  150173. * @param size This parameter can be set to a single number or to an object with the
  150174. * following (optional) properties: precision, width, height. If a single number is passed,
  150175. * it will be used for both width and height. If an object is passed, the screenshot size
  150176. * will be derived from the parameters. The precision property is a multiplier allowing
  150177. * rendering at a higher or lower resolution
  150178. * @param mimeType The MIME type of the screenshot image (default: image/png).
  150179. * Check your browser for supported MIME types
  150180. * @param samples Texture samples (default: 1)
  150181. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  150182. * @param fileName A name for for the downloaded file.
  150183. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  150184. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  150185. * to the src parameter of an <img> to display it
  150186. */
  150187. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  150188. /**
  150189. * Gets height and width for screenshot size
  150190. * @private
  150191. */
  150192. private static _getScreenshotSize;
  150193. }
  150194. }
  150195. declare module BABYLON {
  150196. /**
  150197. * Interface for a data buffer
  150198. */
  150199. export interface IDataBuffer {
  150200. /**
  150201. * Reads bytes from the data buffer.
  150202. * @param byteOffset The byte offset to read
  150203. * @param byteLength The byte length to read
  150204. * @returns A promise that resolves when the bytes are read
  150205. */
  150206. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  150207. /**
  150208. * The byte length of the buffer.
  150209. */
  150210. readonly byteLength: number;
  150211. }
  150212. /**
  150213. * Utility class for reading from a data buffer
  150214. */
  150215. export class DataReader {
  150216. /**
  150217. * The data buffer associated with this data reader.
  150218. */
  150219. readonly buffer: IDataBuffer;
  150220. /**
  150221. * The current byte offset from the beginning of the data buffer.
  150222. */
  150223. byteOffset: number;
  150224. private _dataView;
  150225. private _dataByteOffset;
  150226. /**
  150227. * Constructor
  150228. * @param buffer The buffer to read
  150229. */
  150230. constructor(buffer: IDataBuffer);
  150231. /**
  150232. * Loads the given byte length.
  150233. * @param byteLength The byte length to load
  150234. * @returns A promise that resolves when the load is complete
  150235. */
  150236. loadAsync(byteLength: number): Promise<void>;
  150237. /**
  150238. * Read a unsigned 32-bit integer from the currently loaded data range.
  150239. * @returns The 32-bit integer read
  150240. */
  150241. readUint32(): number;
  150242. /**
  150243. * Read a byte array from the currently loaded data range.
  150244. * @param byteLength The byte length to read
  150245. * @returns The byte array read
  150246. */
  150247. readUint8Array(byteLength: number): Uint8Array;
  150248. /**
  150249. * Read a string from the currently loaded data range.
  150250. * @param byteLength The byte length to read
  150251. * @returns The string read
  150252. */
  150253. readString(byteLength: number): string;
  150254. /**
  150255. * Skips the given byte length the currently loaded data range.
  150256. * @param byteLength The byte length to skip
  150257. */
  150258. skipBytes(byteLength: number): void;
  150259. }
  150260. }
  150261. declare module BABYLON {
  150262. /**
  150263. * Class for storing data to local storage if available or in-memory storage otherwise
  150264. */
  150265. export class DataStorage {
  150266. private static _Storage;
  150267. private static _GetStorage;
  150268. /**
  150269. * Reads a string from the data storage
  150270. * @param key The key to read
  150271. * @param defaultValue The value if the key doesn't exist
  150272. * @returns The string value
  150273. */
  150274. static ReadString(key: string, defaultValue: string): string;
  150275. /**
  150276. * Writes a string to the data storage
  150277. * @param key The key to write
  150278. * @param value The value to write
  150279. */
  150280. static WriteString(key: string, value: string): void;
  150281. /**
  150282. * Reads a boolean from the data storage
  150283. * @param key The key to read
  150284. * @param defaultValue The value if the key doesn't exist
  150285. * @returns The boolean value
  150286. */
  150287. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  150288. /**
  150289. * Writes a boolean to the data storage
  150290. * @param key The key to write
  150291. * @param value The value to write
  150292. */
  150293. static WriteBoolean(key: string, value: boolean): void;
  150294. /**
  150295. * Reads a number from the data storage
  150296. * @param key The key to read
  150297. * @param defaultValue The value if the key doesn't exist
  150298. * @returns The number value
  150299. */
  150300. static ReadNumber(key: string, defaultValue: number): number;
  150301. /**
  150302. * Writes a number to the data storage
  150303. * @param key The key to write
  150304. * @param value The value to write
  150305. */
  150306. static WriteNumber(key: string, value: number): void;
  150307. }
  150308. }
  150309. declare module BABYLON {
  150310. /**
  150311. * An interface for all Hit test features
  150312. */
  150313. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  150314. /**
  150315. * Triggered when new babylon (transformed) hit test results are available
  150316. */
  150317. onHitTestResultObservable: Observable<T[]>;
  150318. }
  150319. /**
  150320. * Options used for hit testing
  150321. */
  150322. export interface IWebXRLegacyHitTestOptions {
  150323. /**
  150324. * Only test when user interacted with the scene. Default - hit test every frame
  150325. */
  150326. testOnPointerDownOnly?: boolean;
  150327. /**
  150328. * The node to use to transform the local results to world coordinates
  150329. */
  150330. worldParentNode?: TransformNode;
  150331. }
  150332. /**
  150333. * Interface defining the babylon result of raycasting/hit-test
  150334. */
  150335. export interface IWebXRLegacyHitResult {
  150336. /**
  150337. * Transformation matrix that can be applied to a node that will put it in the hit point location
  150338. */
  150339. transformationMatrix: Matrix;
  150340. /**
  150341. * The native hit test result
  150342. */
  150343. xrHitResult: XRHitResult | XRHitTestResult;
  150344. }
  150345. /**
  150346. * The currently-working hit-test module.
  150347. * Hit test (or Ray-casting) is used to interact with the real world.
  150348. * For further information read here - https://github.com/immersive-web/hit-test
  150349. */
  150350. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  150351. /**
  150352. * options to use when constructing this feature
  150353. */
  150354. readonly options: IWebXRLegacyHitTestOptions;
  150355. private _direction;
  150356. private _mat;
  150357. private _onSelectEnabled;
  150358. private _origin;
  150359. /**
  150360. * The module's name
  150361. */
  150362. static readonly Name: string;
  150363. /**
  150364. * The (Babylon) version of this module.
  150365. * This is an integer representing the implementation version.
  150366. * This number does not correspond to the WebXR specs version
  150367. */
  150368. static readonly Version: number;
  150369. /**
  150370. * Populated with the last native XR Hit Results
  150371. */
  150372. lastNativeXRHitResults: XRHitResult[];
  150373. /**
  150374. * Triggered when new babylon (transformed) hit test results are available
  150375. */
  150376. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  150377. /**
  150378. * Creates a new instance of the (legacy version) hit test feature
  150379. * @param _xrSessionManager an instance of WebXRSessionManager
  150380. * @param options options to use when constructing this feature
  150381. */
  150382. constructor(_xrSessionManager: WebXRSessionManager,
  150383. /**
  150384. * options to use when constructing this feature
  150385. */
  150386. options?: IWebXRLegacyHitTestOptions);
  150387. /**
  150388. * execute a hit test with an XR Ray
  150389. *
  150390. * @param xrSession a native xrSession that will execute this hit test
  150391. * @param xrRay the ray (position and direction) to use for ray-casting
  150392. * @param referenceSpace native XR reference space to use for the hit-test
  150393. * @param filter filter function that will filter the results
  150394. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150395. */
  150396. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  150397. /**
  150398. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  150399. * @param event the (select) event to use to select with
  150400. * @param referenceSpace the reference space to use for this hit test
  150401. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150402. */
  150403. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150404. /**
  150405. * attach this feature
  150406. * Will usually be called by the features manager
  150407. *
  150408. * @returns true if successful.
  150409. */
  150410. attach(): boolean;
  150411. /**
  150412. * detach this feature.
  150413. * Will usually be called by the features manager
  150414. *
  150415. * @returns true if successful.
  150416. */
  150417. detach(): boolean;
  150418. /**
  150419. * Dispose this feature and all of the resources attached
  150420. */
  150421. dispose(): void;
  150422. protected _onXRFrame(frame: XRFrame): void;
  150423. private _onHitTestResults;
  150424. private _onSelect;
  150425. }
  150426. }
  150427. declare module BABYLON {
  150428. /**
  150429. * Options used for hit testing (version 2)
  150430. */
  150431. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  150432. /**
  150433. * Do not create a permanent hit test. Will usually be used when only
  150434. * transient inputs are needed.
  150435. */
  150436. disablePermanentHitTest?: boolean;
  150437. /**
  150438. * Enable transient (for example touch-based) hit test inspections
  150439. */
  150440. enableTransientHitTest?: boolean;
  150441. /**
  150442. * Offset ray for the permanent hit test
  150443. */
  150444. offsetRay?: Vector3;
  150445. /**
  150446. * Offset ray for the transient hit test
  150447. */
  150448. transientOffsetRay?: Vector3;
  150449. /**
  150450. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  150451. */
  150452. useReferenceSpace?: boolean;
  150453. }
  150454. /**
  150455. * Interface defining the babylon result of hit-test
  150456. */
  150457. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  150458. /**
  150459. * The input source that generated this hit test (if transient)
  150460. */
  150461. inputSource?: XRInputSource;
  150462. /**
  150463. * Is this a transient hit test
  150464. */
  150465. isTransient?: boolean;
  150466. /**
  150467. * Position of the hit test result
  150468. */
  150469. position: Vector3;
  150470. /**
  150471. * Rotation of the hit test result
  150472. */
  150473. rotationQuaternion: Quaternion;
  150474. /**
  150475. * The native hit test result
  150476. */
  150477. xrHitResult: XRHitTestResult;
  150478. }
  150479. /**
  150480. * The currently-working hit-test module.
  150481. * Hit test (or Ray-casting) is used to interact with the real world.
  150482. * For further information read here - https://github.com/immersive-web/hit-test
  150483. *
  150484. * Tested on chrome (mobile) 80.
  150485. */
  150486. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  150487. /**
  150488. * options to use when constructing this feature
  150489. */
  150490. readonly options: IWebXRHitTestOptions;
  150491. private _tmpMat;
  150492. private _tmpPos;
  150493. private _tmpQuat;
  150494. private _transientXrHitTestSource;
  150495. private _xrHitTestSource;
  150496. private initHitTestSource;
  150497. /**
  150498. * The module's name
  150499. */
  150500. static readonly Name: string;
  150501. /**
  150502. * The (Babylon) version of this module.
  150503. * This is an integer representing the implementation version.
  150504. * This number does not correspond to the WebXR specs version
  150505. */
  150506. static readonly Version: number;
  150507. /**
  150508. * When set to true, each hit test will have its own position/rotation objects
  150509. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  150510. * the developers will clone them or copy them as they see fit.
  150511. */
  150512. autoCloneTransformation: boolean;
  150513. /**
  150514. * Triggered when new babylon (transformed) hit test results are available
  150515. */
  150516. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  150517. /**
  150518. * Use this to temporarily pause hit test checks.
  150519. */
  150520. paused: boolean;
  150521. /**
  150522. * Creates a new instance of the hit test feature
  150523. * @param _xrSessionManager an instance of WebXRSessionManager
  150524. * @param options options to use when constructing this feature
  150525. */
  150526. constructor(_xrSessionManager: WebXRSessionManager,
  150527. /**
  150528. * options to use when constructing this feature
  150529. */
  150530. options?: IWebXRHitTestOptions);
  150531. /**
  150532. * attach this feature
  150533. * Will usually be called by the features manager
  150534. *
  150535. * @returns true if successful.
  150536. */
  150537. attach(): boolean;
  150538. /**
  150539. * detach this feature.
  150540. * Will usually be called by the features manager
  150541. *
  150542. * @returns true if successful.
  150543. */
  150544. detach(): boolean;
  150545. /**
  150546. * Dispose this feature and all of the resources attached
  150547. */
  150548. dispose(): void;
  150549. protected _onXRFrame(frame: XRFrame): void;
  150550. private _processWebXRHitTestResult;
  150551. }
  150552. }
  150553. declare module BABYLON {
  150554. /**
  150555. * Configuration options of the anchor system
  150556. */
  150557. export interface IWebXRAnchorSystemOptions {
  150558. /**
  150559. * a node that will be used to convert local to world coordinates
  150560. */
  150561. worldParentNode?: TransformNode;
  150562. /**
  150563. * If set to true a reference of the created anchors will be kept until the next session starts
  150564. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  150565. */
  150566. doNotRemoveAnchorsOnSessionEnded?: boolean;
  150567. }
  150568. /**
  150569. * A babylon container for an XR Anchor
  150570. */
  150571. export interface IWebXRAnchor {
  150572. /**
  150573. * A babylon-assigned ID for this anchor
  150574. */
  150575. id: number;
  150576. /**
  150577. * Transformation matrix to apply to an object attached to this anchor
  150578. */
  150579. transformationMatrix: Matrix;
  150580. /**
  150581. * The native anchor object
  150582. */
  150583. xrAnchor: XRAnchor;
  150584. /**
  150585. * if defined, this object will be constantly updated by the anchor's position and rotation
  150586. */
  150587. attachedNode?: TransformNode;
  150588. }
  150589. /**
  150590. * An implementation of the anchor system for WebXR.
  150591. * For further information see https://github.com/immersive-web/anchors/
  150592. */
  150593. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  150594. private _options;
  150595. private _lastFrameDetected;
  150596. private _trackedAnchors;
  150597. private _referenceSpaceForFrameAnchors;
  150598. private _futureAnchors;
  150599. /**
  150600. * The module's name
  150601. */
  150602. static readonly Name: string;
  150603. /**
  150604. * The (Babylon) version of this module.
  150605. * This is an integer representing the implementation version.
  150606. * This number does not correspond to the WebXR specs version
  150607. */
  150608. static readonly Version: number;
  150609. /**
  150610. * Observers registered here will be executed when a new anchor was added to the session
  150611. */
  150612. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  150613. /**
  150614. * Observers registered here will be executed when an anchor was removed from the session
  150615. */
  150616. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  150617. /**
  150618. * Observers registered here will be executed when an existing anchor updates
  150619. * This can execute N times every frame
  150620. */
  150621. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  150622. /**
  150623. * Set the reference space to use for anchor creation, when not using a hit test.
  150624. * Will default to the session's reference space if not defined
  150625. */
  150626. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  150627. /**
  150628. * constructs a new anchor system
  150629. * @param _xrSessionManager an instance of WebXRSessionManager
  150630. * @param _options configuration object for this feature
  150631. */
  150632. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  150633. private _tmpVector;
  150634. private _tmpQuaternion;
  150635. private _populateTmpTransformation;
  150636. /**
  150637. * Create a new anchor point using a hit test result at a specific point in the scene
  150638. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150639. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150640. *
  150641. * @param hitTestResult The hit test result to use for this anchor creation
  150642. * @param position an optional position offset for this anchor
  150643. * @param rotationQuaternion an optional rotation offset for this anchor
  150644. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150645. */
  150646. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  150647. /**
  150648. * Add a new anchor at a specific position and rotation
  150649. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  150650. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  150651. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150652. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150653. *
  150654. * @param position the position in which to add an anchor
  150655. * @param rotationQuaternion an optional rotation for the anchor transformation
  150656. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  150657. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150658. */
  150659. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  150660. /**
  150661. * detach this feature.
  150662. * Will usually be called by the features manager
  150663. *
  150664. * @returns true if successful.
  150665. */
  150666. detach(): boolean;
  150667. /**
  150668. * Dispose this feature and all of the resources attached
  150669. */
  150670. dispose(): void;
  150671. protected _onXRFrame(frame: XRFrame): void;
  150672. /**
  150673. * avoiding using Array.find for global support.
  150674. * @param xrAnchor the plane to find in the array
  150675. */
  150676. private _findIndexInAnchorArray;
  150677. private _updateAnchorWithXRFrame;
  150678. private _createAnchorAtTransformation;
  150679. }
  150680. }
  150681. declare module BABYLON {
  150682. /**
  150683. * Options used in the plane detector module
  150684. */
  150685. export interface IWebXRPlaneDetectorOptions {
  150686. /**
  150687. * The node to use to transform the local results to world coordinates
  150688. */
  150689. worldParentNode?: TransformNode;
  150690. /**
  150691. * If set to true a reference of the created planes will be kept until the next session starts
  150692. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  150693. */
  150694. doNotRemovePlanesOnSessionEnded?: boolean;
  150695. }
  150696. /**
  150697. * A babylon interface for a WebXR plane.
  150698. * A Plane is actually a polygon, built from N points in space
  150699. *
  150700. * Supported in chrome 79, not supported in canary 81 ATM
  150701. */
  150702. export interface IWebXRPlane {
  150703. /**
  150704. * a babylon-assigned ID for this polygon
  150705. */
  150706. id: number;
  150707. /**
  150708. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  150709. */
  150710. polygonDefinition: Array<Vector3>;
  150711. /**
  150712. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  150713. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  150714. */
  150715. transformationMatrix: Matrix;
  150716. /**
  150717. * the native xr-plane object
  150718. */
  150719. xrPlane: XRPlane;
  150720. }
  150721. /**
  150722. * The plane detector is used to detect planes in the real world when in AR
  150723. * For more information see https://github.com/immersive-web/real-world-geometry/
  150724. */
  150725. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  150726. private _options;
  150727. private _detectedPlanes;
  150728. private _enabled;
  150729. private _lastFrameDetected;
  150730. /**
  150731. * The module's name
  150732. */
  150733. static readonly Name: string;
  150734. /**
  150735. * The (Babylon) version of this module.
  150736. * This is an integer representing the implementation version.
  150737. * This number does not correspond to the WebXR specs version
  150738. */
  150739. static readonly Version: number;
  150740. /**
  150741. * Observers registered here will be executed when a new plane was added to the session
  150742. */
  150743. onPlaneAddedObservable: Observable<IWebXRPlane>;
  150744. /**
  150745. * Observers registered here will be executed when a plane is no longer detected in the session
  150746. */
  150747. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  150748. /**
  150749. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  150750. * This can execute N times every frame
  150751. */
  150752. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  150753. /**
  150754. * construct a new Plane Detector
  150755. * @param _xrSessionManager an instance of xr Session manager
  150756. * @param _options configuration to use when constructing this feature
  150757. */
  150758. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  150759. /**
  150760. * detach this feature.
  150761. * Will usually be called by the features manager
  150762. *
  150763. * @returns true if successful.
  150764. */
  150765. detach(): boolean;
  150766. /**
  150767. * Dispose this feature and all of the resources attached
  150768. */
  150769. dispose(): void;
  150770. protected _onXRFrame(frame: XRFrame): void;
  150771. private _init;
  150772. private _updatePlaneWithXRPlane;
  150773. /**
  150774. * avoiding using Array.find for global support.
  150775. * @param xrPlane the plane to find in the array
  150776. */
  150777. private findIndexInPlaneArray;
  150778. }
  150779. }
  150780. declare module BABYLON {
  150781. /**
  150782. * Options interface for the background remover plugin
  150783. */
  150784. export interface IWebXRBackgroundRemoverOptions {
  150785. /**
  150786. * Further background meshes to disable when entering AR
  150787. */
  150788. backgroundMeshes?: AbstractMesh[];
  150789. /**
  150790. * flags to configure the removal of the environment helper.
  150791. * If not set, the entire background will be removed. If set, flags should be set as well.
  150792. */
  150793. environmentHelperRemovalFlags?: {
  150794. /**
  150795. * Should the skybox be removed (default false)
  150796. */
  150797. skyBox?: boolean;
  150798. /**
  150799. * Should the ground be removed (default false)
  150800. */
  150801. ground?: boolean;
  150802. };
  150803. /**
  150804. * don't disable the environment helper
  150805. */
  150806. ignoreEnvironmentHelper?: boolean;
  150807. }
  150808. /**
  150809. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  150810. */
  150811. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  150812. /**
  150813. * read-only options to be used in this module
  150814. */
  150815. readonly options: IWebXRBackgroundRemoverOptions;
  150816. /**
  150817. * The module's name
  150818. */
  150819. static readonly Name: string;
  150820. /**
  150821. * The (Babylon) version of this module.
  150822. * This is an integer representing the implementation version.
  150823. * This number does not correspond to the WebXR specs version
  150824. */
  150825. static readonly Version: number;
  150826. /**
  150827. * registered observers will be triggered when the background state changes
  150828. */
  150829. onBackgroundStateChangedObservable: Observable<boolean>;
  150830. /**
  150831. * constructs a new background remover module
  150832. * @param _xrSessionManager the session manager for this module
  150833. * @param options read-only options to be used in this module
  150834. */
  150835. constructor(_xrSessionManager: WebXRSessionManager,
  150836. /**
  150837. * read-only options to be used in this module
  150838. */
  150839. options?: IWebXRBackgroundRemoverOptions);
  150840. /**
  150841. * attach this feature
  150842. * Will usually be called by the features manager
  150843. *
  150844. * @returns true if successful.
  150845. */
  150846. attach(): boolean;
  150847. /**
  150848. * detach this feature.
  150849. * Will usually be called by the features manager
  150850. *
  150851. * @returns true if successful.
  150852. */
  150853. detach(): boolean;
  150854. /**
  150855. * Dispose this feature and all of the resources attached
  150856. */
  150857. dispose(): void;
  150858. protected _onXRFrame(_xrFrame: XRFrame): void;
  150859. private _setBackgroundState;
  150860. }
  150861. }
  150862. declare module BABYLON {
  150863. /**
  150864. * Options for the controller physics feature
  150865. */
  150866. export class IWebXRControllerPhysicsOptions {
  150867. /**
  150868. * Should the headset get its own impostor
  150869. */
  150870. enableHeadsetImpostor?: boolean;
  150871. /**
  150872. * Optional parameters for the headset impostor
  150873. */
  150874. headsetImpostorParams?: {
  150875. /**
  150876. * The type of impostor to create. Default is sphere
  150877. */
  150878. impostorType: number;
  150879. /**
  150880. * the size of the impostor. Defaults to 10cm
  150881. */
  150882. impostorSize?: number | {
  150883. width: number;
  150884. height: number;
  150885. depth: number;
  150886. };
  150887. /**
  150888. * Friction definitions
  150889. */
  150890. friction?: number;
  150891. /**
  150892. * Restitution
  150893. */
  150894. restitution?: number;
  150895. };
  150896. /**
  150897. * The physics properties of the future impostors
  150898. */
  150899. physicsProperties?: {
  150900. /**
  150901. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  150902. * Note that this requires a physics engine that supports mesh impostors!
  150903. */
  150904. useControllerMesh?: boolean;
  150905. /**
  150906. * The type of impostor to create. Default is sphere
  150907. */
  150908. impostorType?: number;
  150909. /**
  150910. * the size of the impostor. Defaults to 10cm
  150911. */
  150912. impostorSize?: number | {
  150913. width: number;
  150914. height: number;
  150915. depth: number;
  150916. };
  150917. /**
  150918. * Friction definitions
  150919. */
  150920. friction?: number;
  150921. /**
  150922. * Restitution
  150923. */
  150924. restitution?: number;
  150925. };
  150926. /**
  150927. * the xr input to use with this pointer selection
  150928. */
  150929. xrInput: WebXRInput;
  150930. }
  150931. /**
  150932. * Add physics impostor to your webxr controllers,
  150933. * including naive calculation of their linear and angular velocity
  150934. */
  150935. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  150936. private readonly _options;
  150937. private _attachController;
  150938. private _controllers;
  150939. private _debugMode;
  150940. private _delta;
  150941. private _headsetImpostor?;
  150942. private _headsetMesh?;
  150943. private _lastTimestamp;
  150944. private _tmpQuaternion;
  150945. private _tmpVector;
  150946. /**
  150947. * The module's name
  150948. */
  150949. static readonly Name: string;
  150950. /**
  150951. * The (Babylon) version of this module.
  150952. * This is an integer representing the implementation version.
  150953. * This number does not correspond to the webxr specs version
  150954. */
  150955. static readonly Version: number;
  150956. /**
  150957. * Construct a new Controller Physics Feature
  150958. * @param _xrSessionManager the corresponding xr session manager
  150959. * @param _options options to create this feature with
  150960. */
  150961. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  150962. /**
  150963. * @hidden
  150964. * enable debugging - will show console outputs and the impostor mesh
  150965. */
  150966. _enablePhysicsDebug(): void;
  150967. /**
  150968. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  150969. * @param xrController the controller to add
  150970. */
  150971. addController(xrController: WebXRInputSource): void;
  150972. /**
  150973. * attach this feature
  150974. * Will usually be called by the features manager
  150975. *
  150976. * @returns true if successful.
  150977. */
  150978. attach(): boolean;
  150979. /**
  150980. * detach this feature.
  150981. * Will usually be called by the features manager
  150982. *
  150983. * @returns true if successful.
  150984. */
  150985. detach(): boolean;
  150986. /**
  150987. * Get the headset impostor, if enabled
  150988. * @returns the impostor
  150989. */
  150990. getHeadsetImpostor(): PhysicsImpostor | undefined;
  150991. /**
  150992. * Get the physics impostor of a specific controller.
  150993. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  150994. * @param controller the controller or the controller id of which to get the impostor
  150995. * @returns the impostor or null
  150996. */
  150997. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  150998. /**
  150999. * Update the physics properties provided in the constructor
  151000. * @param newProperties the new properties object
  151001. */
  151002. setPhysicsProperties(newProperties: {
  151003. impostorType?: number;
  151004. impostorSize?: number | {
  151005. width: number;
  151006. height: number;
  151007. depth: number;
  151008. };
  151009. friction?: number;
  151010. restitution?: number;
  151011. }): void;
  151012. protected _onXRFrame(_xrFrame: any): void;
  151013. private _detachController;
  151014. }
  151015. }
  151016. declare module BABYLON {
  151017. /**
  151018. * The motion controller class for all microsoft mixed reality controllers
  151019. */
  151020. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  151021. protected readonly _mapping: {
  151022. defaultButton: {
  151023. valueNodeName: string;
  151024. unpressedNodeName: string;
  151025. pressedNodeName: string;
  151026. };
  151027. defaultAxis: {
  151028. valueNodeName: string;
  151029. minNodeName: string;
  151030. maxNodeName: string;
  151031. };
  151032. buttons: {
  151033. "xr-standard-trigger": {
  151034. rootNodeName: string;
  151035. componentProperty: string;
  151036. states: string[];
  151037. };
  151038. "xr-standard-squeeze": {
  151039. rootNodeName: string;
  151040. componentProperty: string;
  151041. states: string[];
  151042. };
  151043. "xr-standard-touchpad": {
  151044. rootNodeName: string;
  151045. labelAnchorNodeName: string;
  151046. touchPointNodeName: string;
  151047. };
  151048. "xr-standard-thumbstick": {
  151049. rootNodeName: string;
  151050. componentProperty: string;
  151051. states: string[];
  151052. };
  151053. };
  151054. axes: {
  151055. "xr-standard-touchpad": {
  151056. "x-axis": {
  151057. rootNodeName: string;
  151058. };
  151059. "y-axis": {
  151060. rootNodeName: string;
  151061. };
  151062. };
  151063. "xr-standard-thumbstick": {
  151064. "x-axis": {
  151065. rootNodeName: string;
  151066. };
  151067. "y-axis": {
  151068. rootNodeName: string;
  151069. };
  151070. };
  151071. };
  151072. };
  151073. /**
  151074. * The base url used to load the left and right controller models
  151075. */
  151076. static MODEL_BASE_URL: string;
  151077. /**
  151078. * The name of the left controller model file
  151079. */
  151080. static MODEL_LEFT_FILENAME: string;
  151081. /**
  151082. * The name of the right controller model file
  151083. */
  151084. static MODEL_RIGHT_FILENAME: string;
  151085. profileId: string;
  151086. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  151087. protected _getFilenameAndPath(): {
  151088. filename: string;
  151089. path: string;
  151090. };
  151091. protected _getModelLoadingConstraints(): boolean;
  151092. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151093. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151094. protected _updateModel(): void;
  151095. }
  151096. }
  151097. declare module BABYLON {
  151098. /**
  151099. * The motion controller class for oculus touch (quest, rift).
  151100. * This class supports legacy mapping as well the standard xr mapping
  151101. */
  151102. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  151103. private _forceLegacyControllers;
  151104. private _modelRootNode;
  151105. /**
  151106. * The base url used to load the left and right controller models
  151107. */
  151108. static MODEL_BASE_URL: string;
  151109. /**
  151110. * The name of the left controller model file
  151111. */
  151112. static MODEL_LEFT_FILENAME: string;
  151113. /**
  151114. * The name of the right controller model file
  151115. */
  151116. static MODEL_RIGHT_FILENAME: string;
  151117. /**
  151118. * Base Url for the Quest controller model.
  151119. */
  151120. static QUEST_MODEL_BASE_URL: string;
  151121. profileId: string;
  151122. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  151123. protected _getFilenameAndPath(): {
  151124. filename: string;
  151125. path: string;
  151126. };
  151127. protected _getModelLoadingConstraints(): boolean;
  151128. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151129. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151130. protected _updateModel(): void;
  151131. /**
  151132. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  151133. * between the touch and touch 2.
  151134. */
  151135. private _isQuest;
  151136. }
  151137. }
  151138. declare module BABYLON {
  151139. /**
  151140. * The motion controller class for the standard HTC-Vive controllers
  151141. */
  151142. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  151143. private _modelRootNode;
  151144. /**
  151145. * The base url used to load the left and right controller models
  151146. */
  151147. static MODEL_BASE_URL: string;
  151148. /**
  151149. * File name for the controller model.
  151150. */
  151151. static MODEL_FILENAME: string;
  151152. profileId: string;
  151153. /**
  151154. * Create a new Vive motion controller object
  151155. * @param scene the scene to use to create this controller
  151156. * @param gamepadObject the corresponding gamepad object
  151157. * @param handedness the handedness of the controller
  151158. */
  151159. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  151160. protected _getFilenameAndPath(): {
  151161. filename: string;
  151162. path: string;
  151163. };
  151164. protected _getModelLoadingConstraints(): boolean;
  151165. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151166. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151167. protected _updateModel(): void;
  151168. }
  151169. }
  151170. declare module BABYLON {
  151171. /**
  151172. * A cursor which tracks a point on a path
  151173. */
  151174. export class PathCursor {
  151175. private path;
  151176. /**
  151177. * Stores path cursor callbacks for when an onchange event is triggered
  151178. */
  151179. private _onchange;
  151180. /**
  151181. * The value of the path cursor
  151182. */
  151183. value: number;
  151184. /**
  151185. * The animation array of the path cursor
  151186. */
  151187. animations: Animation[];
  151188. /**
  151189. * Initializes the path cursor
  151190. * @param path The path to track
  151191. */
  151192. constructor(path: Path2);
  151193. /**
  151194. * Gets the cursor point on the path
  151195. * @returns A point on the path cursor at the cursor location
  151196. */
  151197. getPoint(): Vector3;
  151198. /**
  151199. * Moves the cursor ahead by the step amount
  151200. * @param step The amount to move the cursor forward
  151201. * @returns This path cursor
  151202. */
  151203. moveAhead(step?: number): PathCursor;
  151204. /**
  151205. * Moves the cursor behind by the step amount
  151206. * @param step The amount to move the cursor back
  151207. * @returns This path cursor
  151208. */
  151209. moveBack(step?: number): PathCursor;
  151210. /**
  151211. * Moves the cursor by the step amount
  151212. * If the step amount is greater than one, an exception is thrown
  151213. * @param step The amount to move the cursor
  151214. * @returns This path cursor
  151215. */
  151216. move(step: number): PathCursor;
  151217. /**
  151218. * Ensures that the value is limited between zero and one
  151219. * @returns This path cursor
  151220. */
  151221. private ensureLimits;
  151222. /**
  151223. * Runs onchange callbacks on change (used by the animation engine)
  151224. * @returns This path cursor
  151225. */
  151226. private raiseOnChange;
  151227. /**
  151228. * Executes a function on change
  151229. * @param f A path cursor onchange callback
  151230. * @returns This path cursor
  151231. */
  151232. onchange(f: (cursor: PathCursor) => void): PathCursor;
  151233. }
  151234. }
  151235. declare module BABYLON {
  151236. /** @hidden */
  151237. export var blurPixelShader: {
  151238. name: string;
  151239. shader: string;
  151240. };
  151241. }
  151242. declare module BABYLON {
  151243. /** @hidden */
  151244. export var pointCloudVertexDeclaration: {
  151245. name: string;
  151246. shader: string;
  151247. };
  151248. }
  151249. // Mixins
  151250. interface Window {
  151251. mozIndexedDB: IDBFactory;
  151252. webkitIndexedDB: IDBFactory;
  151253. msIndexedDB: IDBFactory;
  151254. webkitURL: typeof URL;
  151255. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  151256. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  151257. WebGLRenderingContext: WebGLRenderingContext;
  151258. MSGesture: MSGesture;
  151259. CANNON: any;
  151260. AudioContext: AudioContext;
  151261. webkitAudioContext: AudioContext;
  151262. PointerEvent: any;
  151263. Math: Math;
  151264. Uint8Array: Uint8ArrayConstructor;
  151265. Float32Array: Float32ArrayConstructor;
  151266. mozURL: typeof URL;
  151267. msURL: typeof URL;
  151268. VRFrameData: any; // WebVR, from specs 1.1
  151269. DracoDecoderModule: any;
  151270. setImmediate(handler: (...args: any[]) => void): number;
  151271. }
  151272. interface HTMLCanvasElement {
  151273. requestPointerLock(): void;
  151274. msRequestPointerLock?(): void;
  151275. mozRequestPointerLock?(): void;
  151276. webkitRequestPointerLock?(): void;
  151277. /** Track wether a record is in progress */
  151278. isRecording: boolean;
  151279. /** Capture Stream method defined by some browsers */
  151280. captureStream(fps?: number): MediaStream;
  151281. }
  151282. interface CanvasRenderingContext2D {
  151283. msImageSmoothingEnabled: boolean;
  151284. }
  151285. interface MouseEvent {
  151286. mozMovementX: number;
  151287. mozMovementY: number;
  151288. webkitMovementX: number;
  151289. webkitMovementY: number;
  151290. msMovementX: number;
  151291. msMovementY: number;
  151292. }
  151293. interface Navigator {
  151294. mozGetVRDevices: (any: any) => any;
  151295. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151296. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151297. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151298. webkitGetGamepads(): Gamepad[];
  151299. msGetGamepads(): Gamepad[];
  151300. webkitGamepads(): Gamepad[];
  151301. }
  151302. interface HTMLVideoElement {
  151303. mozSrcObject: any;
  151304. }
  151305. interface Math {
  151306. fround(x: number): number;
  151307. imul(a: number, b: number): number;
  151308. }
  151309. interface WebGLRenderingContext {
  151310. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  151311. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  151312. vertexAttribDivisor(index: number, divisor: number): void;
  151313. createVertexArray(): any;
  151314. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  151315. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  151316. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  151317. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  151318. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  151319. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  151320. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  151321. // Queries
  151322. createQuery(): WebGLQuery;
  151323. deleteQuery(query: WebGLQuery): void;
  151324. beginQuery(target: number, query: WebGLQuery): void;
  151325. endQuery(target: number): void;
  151326. getQueryParameter(query: WebGLQuery, pname: number): any;
  151327. getQuery(target: number, pname: number): any;
  151328. MAX_SAMPLES: number;
  151329. RGBA8: number;
  151330. READ_FRAMEBUFFER: number;
  151331. DRAW_FRAMEBUFFER: number;
  151332. UNIFORM_BUFFER: number;
  151333. HALF_FLOAT_OES: number;
  151334. RGBA16F: number;
  151335. RGBA32F: number;
  151336. R32F: number;
  151337. RG32F: number;
  151338. RGB32F: number;
  151339. R16F: number;
  151340. RG16F: number;
  151341. RGB16F: number;
  151342. RED: number;
  151343. RG: number;
  151344. R8: number;
  151345. RG8: number;
  151346. UNSIGNED_INT_24_8: number;
  151347. DEPTH24_STENCIL8: number;
  151348. MIN: number;
  151349. MAX: number;
  151350. /* Multiple Render Targets */
  151351. drawBuffers(buffers: number[]): void;
  151352. readBuffer(src: number): void;
  151353. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  151354. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  151355. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  151356. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  151357. // Occlusion Query
  151358. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  151359. ANY_SAMPLES_PASSED: number;
  151360. QUERY_RESULT_AVAILABLE: number;
  151361. QUERY_RESULT: number;
  151362. }
  151363. interface WebGLProgram {
  151364. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  151365. }
  151366. interface EXT_disjoint_timer_query {
  151367. QUERY_COUNTER_BITS_EXT: number;
  151368. TIME_ELAPSED_EXT: number;
  151369. TIMESTAMP_EXT: number;
  151370. GPU_DISJOINT_EXT: number;
  151371. QUERY_RESULT_EXT: number;
  151372. QUERY_RESULT_AVAILABLE_EXT: number;
  151373. queryCounterEXT(query: WebGLQuery, target: number): void;
  151374. createQueryEXT(): WebGLQuery;
  151375. beginQueryEXT(target: number, query: WebGLQuery): void;
  151376. endQueryEXT(target: number): void;
  151377. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  151378. deleteQueryEXT(query: WebGLQuery): void;
  151379. }
  151380. interface WebGLUniformLocation {
  151381. _currentState: any;
  151382. }
  151383. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  151384. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  151385. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  151386. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151387. interface WebGLRenderingContext {
  151388. readonly RASTERIZER_DISCARD: number;
  151389. readonly DEPTH_COMPONENT24: number;
  151390. readonly TEXTURE_3D: number;
  151391. readonly TEXTURE_2D_ARRAY: number;
  151392. readonly TEXTURE_COMPARE_FUNC: number;
  151393. readonly TEXTURE_COMPARE_MODE: number;
  151394. readonly COMPARE_REF_TO_TEXTURE: number;
  151395. readonly TEXTURE_WRAP_R: number;
  151396. readonly HALF_FLOAT: number;
  151397. readonly RGB8: number;
  151398. readonly RED_INTEGER: number;
  151399. readonly RG_INTEGER: number;
  151400. readonly RGB_INTEGER: number;
  151401. readonly RGBA_INTEGER: number;
  151402. readonly R8_SNORM: number;
  151403. readonly RG8_SNORM: number;
  151404. readonly RGB8_SNORM: number;
  151405. readonly RGBA8_SNORM: number;
  151406. readonly R8I: number;
  151407. readonly RG8I: number;
  151408. readonly RGB8I: number;
  151409. readonly RGBA8I: number;
  151410. readonly R8UI: number;
  151411. readonly RG8UI: number;
  151412. readonly RGB8UI: number;
  151413. readonly RGBA8UI: number;
  151414. readonly R16I: number;
  151415. readonly RG16I: number;
  151416. readonly RGB16I: number;
  151417. readonly RGBA16I: number;
  151418. readonly R16UI: number;
  151419. readonly RG16UI: number;
  151420. readonly RGB16UI: number;
  151421. readonly RGBA16UI: number;
  151422. readonly R32I: number;
  151423. readonly RG32I: number;
  151424. readonly RGB32I: number;
  151425. readonly RGBA32I: number;
  151426. readonly R32UI: number;
  151427. readonly RG32UI: number;
  151428. readonly RGB32UI: number;
  151429. readonly RGBA32UI: number;
  151430. readonly RGB10_A2UI: number;
  151431. readonly R11F_G11F_B10F: number;
  151432. readonly RGB9_E5: number;
  151433. readonly RGB10_A2: number;
  151434. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  151435. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  151436. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  151437. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  151438. readonly DEPTH_COMPONENT32F: number;
  151439. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  151440. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  151441. 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;
  151442. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  151443. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  151444. readonly TRANSFORM_FEEDBACK: number;
  151445. readonly INTERLEAVED_ATTRIBS: number;
  151446. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  151447. createTransformFeedback(): WebGLTransformFeedback;
  151448. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  151449. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  151450. beginTransformFeedback(primitiveMode: number): void;
  151451. endTransformFeedback(): void;
  151452. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  151453. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151454. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151455. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151456. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  151457. }
  151458. interface ImageBitmap {
  151459. readonly width: number;
  151460. readonly height: number;
  151461. close(): void;
  151462. }
  151463. interface WebGLQuery extends WebGLObject {
  151464. }
  151465. declare var WebGLQuery: {
  151466. prototype: WebGLQuery;
  151467. new(): WebGLQuery;
  151468. };
  151469. interface WebGLSampler extends WebGLObject {
  151470. }
  151471. declare var WebGLSampler: {
  151472. prototype: WebGLSampler;
  151473. new(): WebGLSampler;
  151474. };
  151475. interface WebGLSync extends WebGLObject {
  151476. }
  151477. declare var WebGLSync: {
  151478. prototype: WebGLSync;
  151479. new(): WebGLSync;
  151480. };
  151481. interface WebGLTransformFeedback extends WebGLObject {
  151482. }
  151483. declare var WebGLTransformFeedback: {
  151484. prototype: WebGLTransformFeedback;
  151485. new(): WebGLTransformFeedback;
  151486. };
  151487. interface WebGLVertexArrayObject extends WebGLObject {
  151488. }
  151489. declare var WebGLVertexArrayObject: {
  151490. prototype: WebGLVertexArrayObject;
  151491. new(): WebGLVertexArrayObject;
  151492. };
  151493. // Type definitions for WebVR API
  151494. // Project: https://w3c.github.io/webvr/
  151495. // Definitions by: six a <https://github.com/lostfictions>
  151496. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151497. interface VRDisplay extends EventTarget {
  151498. /**
  151499. * Dictionary of capabilities describing the VRDisplay.
  151500. */
  151501. readonly capabilities: VRDisplayCapabilities;
  151502. /**
  151503. * z-depth defining the far plane of the eye view frustum
  151504. * enables mapping of values in the render target depth
  151505. * attachment to scene coordinates. Initially set to 10000.0.
  151506. */
  151507. depthFar: number;
  151508. /**
  151509. * z-depth defining the near plane of the eye view frustum
  151510. * enables mapping of values in the render target depth
  151511. * attachment to scene coordinates. Initially set to 0.01.
  151512. */
  151513. depthNear: number;
  151514. /**
  151515. * An identifier for this distinct VRDisplay. Used as an
  151516. * association point in the Gamepad API.
  151517. */
  151518. readonly displayId: number;
  151519. /**
  151520. * A display name, a user-readable name identifying it.
  151521. */
  151522. readonly displayName: string;
  151523. readonly isConnected: boolean;
  151524. readonly isPresenting: boolean;
  151525. /**
  151526. * If this VRDisplay supports room-scale experiences, the optional
  151527. * stage attribute contains details on the room-scale parameters.
  151528. */
  151529. readonly stageParameters: VRStageParameters | null;
  151530. /**
  151531. * Passing the value returned by `requestAnimationFrame` to
  151532. * `cancelAnimationFrame` will unregister the callback.
  151533. * @param handle Define the hanle of the request to cancel
  151534. */
  151535. cancelAnimationFrame(handle: number): void;
  151536. /**
  151537. * Stops presenting to the VRDisplay.
  151538. * @returns a promise to know when it stopped
  151539. */
  151540. exitPresent(): Promise<void>;
  151541. /**
  151542. * Return the current VREyeParameters for the given eye.
  151543. * @param whichEye Define the eye we want the parameter for
  151544. * @returns the eye parameters
  151545. */
  151546. getEyeParameters(whichEye: string): VREyeParameters;
  151547. /**
  151548. * Populates the passed VRFrameData with the information required to render
  151549. * the current frame.
  151550. * @param frameData Define the data structure to populate
  151551. * @returns true if ok otherwise false
  151552. */
  151553. getFrameData(frameData: VRFrameData): boolean;
  151554. /**
  151555. * Get the layers currently being presented.
  151556. * @returns the list of VR layers
  151557. */
  151558. getLayers(): VRLayer[];
  151559. /**
  151560. * Return a VRPose containing the future predicted pose of the VRDisplay
  151561. * when the current frame will be presented. The value returned will not
  151562. * change until JavaScript has returned control to the browser.
  151563. *
  151564. * The VRPose will contain the position, orientation, velocity,
  151565. * and acceleration of each of these properties.
  151566. * @returns the pose object
  151567. */
  151568. getPose(): VRPose;
  151569. /**
  151570. * Return the current instantaneous pose of the VRDisplay, with no
  151571. * prediction applied.
  151572. * @returns the current instantaneous pose
  151573. */
  151574. getImmediatePose(): VRPose;
  151575. /**
  151576. * The callback passed to `requestAnimationFrame` will be called
  151577. * any time a new frame should be rendered. When the VRDisplay is
  151578. * presenting the callback will be called at the native refresh
  151579. * rate of the HMD. When not presenting this function acts
  151580. * identically to how window.requestAnimationFrame acts. Content should
  151581. * make no assumptions of frame rate or vsync behavior as the HMD runs
  151582. * asynchronously from other displays and at differing refresh rates.
  151583. * @param callback Define the eaction to run next frame
  151584. * @returns the request handle it
  151585. */
  151586. requestAnimationFrame(callback: FrameRequestCallback): number;
  151587. /**
  151588. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  151589. * Repeat calls while already presenting will update the VRLayers being displayed.
  151590. * @param layers Define the list of layer to present
  151591. * @returns a promise to know when the request has been fulfilled
  151592. */
  151593. requestPresent(layers: VRLayer[]): Promise<void>;
  151594. /**
  151595. * Reset the pose for this display, treating its current position and
  151596. * orientation as the "origin/zero" values. VRPose.position,
  151597. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  151598. * updated when calling resetPose(). This should be called in only
  151599. * sitting-space experiences.
  151600. */
  151601. resetPose(): void;
  151602. /**
  151603. * The VRLayer provided to the VRDisplay will be captured and presented
  151604. * in the HMD. Calling this function has the same effect on the source
  151605. * canvas as any other operation that uses its source image, and canvases
  151606. * created without preserveDrawingBuffer set to true will be cleared.
  151607. * @param pose Define the pose to submit
  151608. */
  151609. submitFrame(pose?: VRPose): void;
  151610. }
  151611. declare var VRDisplay: {
  151612. prototype: VRDisplay;
  151613. new(): VRDisplay;
  151614. };
  151615. interface VRLayer {
  151616. leftBounds?: number[] | Float32Array | null;
  151617. rightBounds?: number[] | Float32Array | null;
  151618. source?: HTMLCanvasElement | null;
  151619. }
  151620. interface VRDisplayCapabilities {
  151621. readonly canPresent: boolean;
  151622. readonly hasExternalDisplay: boolean;
  151623. readonly hasOrientation: boolean;
  151624. readonly hasPosition: boolean;
  151625. readonly maxLayers: number;
  151626. }
  151627. interface VREyeParameters {
  151628. /** @deprecated */
  151629. readonly fieldOfView: VRFieldOfView;
  151630. readonly offset: Float32Array;
  151631. readonly renderHeight: number;
  151632. readonly renderWidth: number;
  151633. }
  151634. interface VRFieldOfView {
  151635. readonly downDegrees: number;
  151636. readonly leftDegrees: number;
  151637. readonly rightDegrees: number;
  151638. readonly upDegrees: number;
  151639. }
  151640. interface VRFrameData {
  151641. readonly leftProjectionMatrix: Float32Array;
  151642. readonly leftViewMatrix: Float32Array;
  151643. readonly pose: VRPose;
  151644. readonly rightProjectionMatrix: Float32Array;
  151645. readonly rightViewMatrix: Float32Array;
  151646. readonly timestamp: number;
  151647. }
  151648. interface VRPose {
  151649. readonly angularAcceleration: Float32Array | null;
  151650. readonly angularVelocity: Float32Array | null;
  151651. readonly linearAcceleration: Float32Array | null;
  151652. readonly linearVelocity: Float32Array | null;
  151653. readonly orientation: Float32Array | null;
  151654. readonly position: Float32Array | null;
  151655. readonly timestamp: number;
  151656. }
  151657. interface VRStageParameters {
  151658. sittingToStandingTransform?: Float32Array;
  151659. sizeX?: number;
  151660. sizeY?: number;
  151661. }
  151662. interface Navigator {
  151663. getVRDisplays(): Promise<VRDisplay[]>;
  151664. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  151665. }
  151666. interface Window {
  151667. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  151668. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  151669. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  151670. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151671. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151672. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  151673. }
  151674. interface Gamepad {
  151675. readonly displayId: number;
  151676. }
  151677. type XRSessionMode =
  151678. | "inline"
  151679. | "immersive-vr"
  151680. | "immersive-ar";
  151681. type XRReferenceSpaceType =
  151682. | "viewer"
  151683. | "local"
  151684. | "local-floor"
  151685. | "bounded-floor"
  151686. | "unbounded";
  151687. type XREnvironmentBlendMode =
  151688. | "opaque"
  151689. | "additive"
  151690. | "alpha-blend";
  151691. type XRVisibilityState =
  151692. | "visible"
  151693. | "visible-blurred"
  151694. | "hidden";
  151695. type XRHandedness =
  151696. | "none"
  151697. | "left"
  151698. | "right";
  151699. type XRTargetRayMode =
  151700. | "gaze"
  151701. | "tracked-pointer"
  151702. | "screen";
  151703. type XREye =
  151704. | "none"
  151705. | "left"
  151706. | "right";
  151707. type XREventType =
  151708. | "devicechange"
  151709. | "visibilitychange"
  151710. | "end"
  151711. | "inputsourceschange"
  151712. | "select"
  151713. | "selectstart"
  151714. | "selectend"
  151715. | "squeeze"
  151716. | "squeezestart"
  151717. | "squeezeend"
  151718. | "reset";
  151719. interface XRSpace extends EventTarget {
  151720. }
  151721. interface XRRenderState {
  151722. depthNear?: number;
  151723. depthFar?: number;
  151724. inlineVerticalFieldOfView?: number;
  151725. baseLayer?: XRWebGLLayer;
  151726. }
  151727. interface XRInputSource {
  151728. handedness: XRHandedness;
  151729. targetRayMode: XRTargetRayMode;
  151730. targetRaySpace: XRSpace;
  151731. gripSpace: XRSpace | undefined;
  151732. gamepad: Gamepad | undefined;
  151733. profiles: Array<string>;
  151734. }
  151735. interface XRSessionInit {
  151736. optionalFeatures?: string[];
  151737. requiredFeatures?: string[];
  151738. }
  151739. interface XRSession {
  151740. addEventListener: Function;
  151741. removeEventListener: Function;
  151742. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  151743. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  151744. requestAnimationFrame: Function;
  151745. end(): Promise<void>;
  151746. renderState: XRRenderState;
  151747. inputSources: Array<XRInputSource>;
  151748. // hit test
  151749. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  151750. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  151751. // legacy AR hit test
  151752. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151753. // legacy plane detection
  151754. updateWorldTrackingState(options: {
  151755. planeDetectionState?: { enabled: boolean; }
  151756. }): void;
  151757. }
  151758. interface XRReferenceSpace extends XRSpace {
  151759. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  151760. onreset: any;
  151761. }
  151762. type XRPlaneSet = Set<XRPlane>;
  151763. type XRAnchorSet = Set<XRAnchor>;
  151764. interface XRFrame {
  151765. session: XRSession;
  151766. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  151767. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  151768. // AR
  151769. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  151770. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  151771. // Anchors
  151772. trackedAnchors?: XRAnchorSet;
  151773. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  151774. // Planes
  151775. worldInformation: {
  151776. detectedPlanes?: XRPlaneSet;
  151777. };
  151778. }
  151779. interface XRViewerPose extends XRPose {
  151780. views: Array<XRView>;
  151781. }
  151782. interface XRPose {
  151783. transform: XRRigidTransform;
  151784. emulatedPosition: boolean;
  151785. }
  151786. interface XRWebGLLayerOptions {
  151787. antialias?: boolean;
  151788. depth?: boolean;
  151789. stencil?: boolean;
  151790. alpha?: boolean;
  151791. multiview?: boolean;
  151792. framebufferScaleFactor?: number;
  151793. }
  151794. declare var XRWebGLLayer: {
  151795. prototype: XRWebGLLayer;
  151796. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  151797. };
  151798. interface XRWebGLLayer {
  151799. framebuffer: WebGLFramebuffer;
  151800. framebufferWidth: number;
  151801. framebufferHeight: number;
  151802. getViewport: Function;
  151803. }
  151804. declare class XRRigidTransform {
  151805. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  151806. position: DOMPointReadOnly;
  151807. orientation: DOMPointReadOnly;
  151808. matrix: Float32Array;
  151809. inverse: XRRigidTransform;
  151810. }
  151811. interface XRView {
  151812. eye: XREye;
  151813. projectionMatrix: Float32Array;
  151814. transform: XRRigidTransform;
  151815. }
  151816. interface XRInputSourceChangeEvent {
  151817. session: XRSession;
  151818. removed: Array<XRInputSource>;
  151819. added: Array<XRInputSource>;
  151820. }
  151821. interface XRInputSourceEvent extends Event {
  151822. readonly frame: XRFrame;
  151823. readonly inputSource: XRInputSource;
  151824. }
  151825. // Experimental(er) features
  151826. declare class XRRay {
  151827. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  151828. origin: DOMPointReadOnly;
  151829. direction: DOMPointReadOnly;
  151830. matrix: Float32Array;
  151831. }
  151832. declare enum XRHitTestTrackableType {
  151833. "point",
  151834. "plane"
  151835. }
  151836. interface XRHitResult {
  151837. hitMatrix: Float32Array;
  151838. }
  151839. interface XRTransientInputHitTestResult {
  151840. readonly inputSource: XRInputSource;
  151841. readonly results: Array<XRHitTestResult>;
  151842. }
  151843. interface XRHitTestResult {
  151844. getPose(baseSpace: XRSpace): XRPose | undefined;
  151845. // When anchor system is enabled
  151846. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  151847. }
  151848. interface XRHitTestSource {
  151849. cancel(): void;
  151850. }
  151851. interface XRTransientInputHitTestSource {
  151852. cancel(): void;
  151853. }
  151854. interface XRHitTestOptionsInit {
  151855. space: XRSpace;
  151856. entityTypes?: Array<XRHitTestTrackableType>;
  151857. offsetRay?: XRRay;
  151858. }
  151859. interface XRTransientInputHitTestOptionsInit {
  151860. profile: string;
  151861. entityTypes?: Array<XRHitTestTrackableType>;
  151862. offsetRay?: XRRay;
  151863. }
  151864. interface XRAnchor {
  151865. anchorSpace: XRSpace;
  151866. delete(): void;
  151867. }
  151868. interface XRPlane {
  151869. orientation: "Horizontal" | "Vertical";
  151870. planeSpace: XRSpace;
  151871. polygon: Array<DOMPointReadOnly>;
  151872. lastChangedTime: number;
  151873. }